Commit Graph

147 Commits

Author SHA1 Message Date
Jeevesh Krishna c29b273117
refactored and optimized code (#9292)
* refactored and optimized code

* refactored code

* formatted the code

* undid changes
added comment explaining the deprecated logic

* reformatted using tox -e black

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2023-01-11 19:45:31 +00:00
Jake Lishman b0f3d5cbe8
Remove deprecated methods from QuantumCircuit (#8980)
* Remove deprecated methods from QuantumCircuit

This removes the old `c?u[1-3]` methods from `QuantumCircuit`, along
with the `combine` and `extend` methods.  The numbered-argument `UGate`
alternatives had been deprecated since Terra 0.16, and the simpler forms
of `compose` since 0.17.

The `U1Gate` class, and so on, are left in so the transpiler and
equivalence rules can still support legacy backends with these as basis
gates, but their privileged place as direct methods on `QuantumCircuit`
is removed.

* Fix lint failures

* Remove now-unused private method

* Correct release note

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-11-02 21:14:05 +00:00
Jake Lishman 90f45b4a70
Remove IBM Q example scripts (#8975)
These hadn't been updated for recent Terra practices in quite some time
anyway, and with the general move away from `qiskit.providers.ibmq`, it
really makes no sense to have them in Terra.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-10-21 21:34:55 +00:00
Matthew Treinish ccc371f8ff
Implement multithreaded stochastic swap in rust (#7658)
* Implement multithreaded stochastic swap in rust

This commit is a rewrite of the core swap trials functionality in the
StochasticSwap transpiler pass. Previously this core routine was written
using Cython (see #1789) which had great performance, but that
implementation was single threaded. The core of the stochastic swap
algorithm by it's nature is well suited to be executed in parallel, it
attempts a number of random trials and then picks the best result
from all the trials and uses that for that layer. These trials can
easily be run in parallel as there is no data dependency between the
trials (there are shared inputs but read-only). As the algorithm
generally scales exponentially the speed up from running the trials in
parallel can offset this and improve the scaling of the pass. Running
the pass in parallel was previously tried in #4781 using Python
multiprocessing but the overhead of launching an additional process and
serializing the input arrays for each trial was significantly larger
than the speed gains. To run the algorithm efficiently in parallel
multithreading is needed to leverage shared memory on shared inputs.

This commit rewrites the cython routine using rust. This was done for
two reasons. The first is that rust's safety guarantees make dealing
with and writing parallel code much easier and safer. It's also
multiplatform because the rust language supports native threading
primatives in language. The second is while writing parallel cython
code using open-mp there are limitations with it, mainly on windows. In
practice it was also difficult to write and maintain parallel cython
code as it has very strict requirements on python and c code
interactions. It was much faster and easier to port it to rust and the
performance for each iteration (outside of parallelism) is the same (in
some cases marginally faster) in rust. The implementation here reuses
the data structures that the previous cython implementation introduced
(mainly flattening all the terra objects into 1d or 2d numpy arrays for
efficient access from C).

The speedups from this PR can be significant, calling transpile() on a
400 qubit (with a depth of 10) QV model circuit targetting a 409 heavy
hex coupling map goes from ~200 seconds with the single threaded cython
to ~60 seconds with this PR locally on a 32 core system, When transpiling
a 1000 qubit (also with a depth of 10) QV model circuit targetting a 1081
qubit heavy hex coupling map goes from taking ~6500 seconds to ~720
seconds.

The tradeoff with this PR is for local qiskit-terra development a rust
compiler needs to be installed. This is made trivial using rustup
(https://rustup.rs/), but it is an additional burden and one that we
might not want to make. If so we can look at turning this PR into a
separate repository/package that qiskit-terra can depend on. The
tradeoff here is that we'll be adding friction to the api boundary
between the pass and the core swap trials interface. But, it does ease
the dependency on development for qiskit-terra.

* Sanitize packaging to support future modules

This commit fixes how we package the compiled rust module in
qiskit-terra. As a single rust project only gives us a single compiled
binary output we can't use the same scheme we did previously with cython
with a separate dynamic lib file for each module. This shifts us to
making the rust code build a `qiskit._accelerate` module and in that we
have submodules for everything we need from compiled code. For this PR
there is only one submodule, `stochastic_swap`, so for example the
parallel swap_trials routine can be imported from
`qiskit._accelerate.stochastic_swap.swap_trials`. In the future we can
have additional submodules for other pieces of compiled code in qiskit.
For example, the likely next candidate is the pauli expectation value
cython module, which we'll likely port to rust and also make parallel
(for sufficiently large number of qubits). In that case we'd add a new
submodule for that functionality.

* Adjust random normal distribution to use correct mean

This commit corrects the use of the normal distribution to have the mean
set to 1.0. Previously we were doing this out of band for each value by
adding 1 to the random value which wasn't necessary because we could
just generate it with a mean of 1.0.

* Remove unecessary extra scope from locked read

This commit removes an unecessary extra scope around the locked read for
where we store the best solution. The scope was previously there to
release the lock after we check if there is a solution or not. However
this wasn't actually needed as we can just do the check inline and the
lock will release after the condition block.

* Remove unecessary explicit type from opt_edges variable

* Fix indices typo in NLayout constructor

Co-authored-by: Jake Lishman <jake@binhbar.com>

* Remove explicit lifetime annotation from swap_trials

Previously the swap_trials() function had an explicit lifetime
annotation `'p` which wasn't necessary because the compiler can
determine this on it's own. Normally when dealing with numpy views and a
Python object (i.e. a GIL handle) we need a lifetime annotation to tell
the rust compiler the numpy view and the python gil handle will have the
same lifetime. But since swap_trials doesn't take a gil handle and
operates purely in rust we don't need this lifetime and the rust
compiler can deal with the lifetime of the numpy views on their own.

* Use sum() instead of fold()

* Fix lint and add rust style and lint checks to CI

This commit fixes the python lint failures and also updates the ci
configuration for the lint job to also run rust's style and lint
enforcement.

* Fix returned layout mapping from NLayout

This commit fixes the output list from the `layout_mapping()`
method of `NLayout`. Previously, it incorrectly would return the
wrong indices it should be a list of virtual -> physical to
qubit pairs. This commit corrects this error

Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.com>

* Tweak tox configuration to try and reliably build rust extension

* Make swap_trials parallelization configurable

This commit makes the parallelization of the swap_trials() configurable.
This is dones in two ways, first a new argument parallel_threshold is
added which takes an optional int which is the number of qubits to
switch between a parallel and serial version. The second is that it
takes into account the the state of the QISKIT_IN_PARALLEL environment
variable. This variable is set to TRUE by parallel_map() when we're
running in a multiprocessing context. In those cases also running
stochastic swap in parallel will likely just cause too much load as
we're potentially oversubscribing work to the number of available CPUs.
So, if QISKIT_IN_PARALLEL is set to True we run swap_trials serially.

* Revert "Make swap_trials parallelization configurable"

This reverts commit 57790c84b0. That
commit attempted to sovle some issues in test running, mainly around
multiple parallel dispatch causing exceess load. But in practice it was
broken and caused more issues than it fixed. We'll investigate and add
control for the parallelization in a future commit separately after all
the tests are passing so we have a good baseline.

* Add docs to swap_trials() and remove unecessary num_gates arg

* Fix race condition leading to non-deterministic behavior

Previously, in the case of circuits that had multiple best possible
depth == 1 solutions for a layer, there was a race condition in the fast
exit path between the threads which could lead to a non-deterministic
result even with a fixed seed. The output was always valid, but which
result was dependent on which parallel thread with an ideal solution
finished last and wrote to the locked best result last. This was causing
weird non-deterministic test failures for some tests because of #1794 as
the exact match result would change between runs. This could be a bigger
issue because user expectations are that with a fixed seed set on the
transpiler that the output circuit will be deterministically
reproducible.

To address this is issue this commit trades off some performance to
ensure we're always returning a deterministic result in this case. This
is accomplished by updating/checking if a depth==1 solution has been
found in another trial thread we only act (so either exit early or
update the already found depth == 1 solution) if that solution already
found has a trial number that is less than this thread's trial number.
This does limit the effectiveness of the fast exit, but in practice it
should hopefully not effect the speed too much.

As part of this commit some tests are updated because the new
deterministic behavior is slightly different from the previous results
from the cython serial implementation. I manually verified that the
new output circuits are still valid (it also looks like the quality
of the results in some of those cases improved, but this is strictly
anecdotal and shouldn't be taken as a general trend with this PR).

* Apply suggestions from code review

Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.com>

* Fix compiler errors in previous commit

* Revert accidental commit of parallel reduction in compute_cost

This was only a for local testing to prove it was a bad idea and was
accidently included in the branch. We should not nest the parallel
execution like this.

* Eliminate short circuit for depth == 1 swap_trial() result

This commit eliminates the short circuit fast return in swap_trial()
when another trial thread has found an ideal solution. Trying to do this
in a parallel context is tricky to make deterministic because in cases
of >1 depth == 1 solutions there is an inherent race condition between
the threads for writing out their depth == 1 result to the shared
location. Different strategies were tried to make this reliably
deterministic but there wa still a race condition. Since this was just a
performance optimization to avoid doing unnecessary work this commit
removes this step. Weighing improved performance against repeatability
in the output of the compiler, the reproducible results are more
important. After we've adopted a multithreaded stochastic swap we can
investigate adding this back as a potential future optimization.

* Add missing docstrings

* Add section to contributing on installing form source

* Make rust python classes pickleable

* Add rust compiler install to linux wheel jobs

* Try more tox changes to fix docs builds

* Revert "Eliminate short circuit for depth == 1 swap_trial() result"

This reverts commit c510764a77. The
removal there was premature and we had a fix for the non-determinism in
place, ignoring a typo which was preventing it from working.

Co-Authored-By: Georgios Tsilimigkounakis <45130028+georgios-ts@users.noreply.github.com>

* Fix submodule declaration and module attribute on rust classes

* Fix rust lint

* Fix docs job definition

* Disable multiprocessing parallelism in unit tests

This commit disables the multiprocessing based parallelism when running
unittest jobs in CI. We historically have defaulted the use of
multiprocessing in environments only where the "fork" start method is
available because this has the best performance and has no caveats
around how it is used by users (you don't need an
`if __name__ == "__main__"` guard). However, the use of the "fork"
method isn't always 100% reliable (see
https://bugs.python.org/issue40379), which we saw on Python 3.9 #6188.
In unittest CI (and tox) by default we use stestr which spawns (not using
fork) parallel workers to run tests in parallel. With this PR this means
in unittest we're now running multiple test runner subprocesses, which
are executing parallel dispatched code using multiprocessing's fork
start method, which is executing multithreaded rust code. This three layers
of nesting is fairly reliably hanging as Python's fork doesn't seem to
be able to handle this many layers of nested parallelism. There are 2
ways I've been able to fix this, the first is to change the start method
used by `parallel_map()` to either "spawn" or "forkserver" either of
these does not suffer from random hanging. However, doing this in the
unittest context causes significant overhead and slows down test
executing significantly. The other is to just disable the
multiprocessing which fixes the hanging and doesn't impact runtime
performance signifcantly (and might actually help in CI so we're not
oversubscribing the limited resources.

As I have not been able to reproduce `parallel_map()` hanging in
a standalone context with multithreaded stochastic swap this commit opts
for just disabling multiprocessing in CI and documenting the known issue
in the release notes as this is the simpler solution. It's unlikely that
users will nest parallel processes as it typically hurts performance
(and parallel_map() actively guards against it), we only did it in
testing previously because the tests which relied on it were a small
portion of the test suite (roughly 65 tests) and typically did not have
a significant impact on the total throughput of the test suite.

* Fix typo in azure pipelines config

* Remove unecessary extension compilation for image tests

* Add test script to explicitly verify parallel dispatch

In an earlier commit we disabled the use of parallel dispatch in
parallel_map() to avoid a bug in cpython associated with their fork()
based subprocess launch. Doing this works around the bug which was
reliably triggered by running multiprocessing in parallel subprocesses.
It also has the side benefit of providing a ~2x speed up for test suite
execution in CI. However, this meant we lost our test coverage in CI for
running parallel_map() with actual multiprocessing based parallel
dispatch. To ensure we don't inadvertandtly regress this code path
moving forward this commit adds a dedicated test script which runs a
simple transpilation in parallel and verifies that everything works as
expected with the default parallelism settings.

* Avoid multi-threading when run in a multiprocessing context

This commit adds a switch on running between a single threaded and a
multithreaded variant of the swap_trials loop based on whether the
QISKIT_IN_PARALLEL flag is set. If QISKIT_IN_PARALLEL is set to TRUE
this means the `parallel_map()` function is running in the outer python
context and we're running in multiprocessing already. This means we do
not want to be running in multiple threads generally as that will lead
to potential resource exhaustion by spawn n processes each potentially
running with m threads where `n` is `min(num_phys_cpus, num_tasks)` and
`m` is num_logical_cpus (although only
`min(num_logical_cpus, num_trials)` will be active) which on the typical
system there aren't enough cores to leverage both multiprocessing and
multithreading. However, in case a user does have such an environment
they can set the `QISKIT_FORCE_THREADS` env variable to `TRUE` which
will use threading regardless of the status of `QISKIT_IN_PARALLEL`.

* Apply suggestions from code review

Co-authored-by: Jake Lishman <jake@binhbar.com>

* Minor fixes from review comments

This commits fixes some minor details found during code review. It
expands the section on building from source to explain how to build a
release optimized binary with editable mode, makes the QISKIT_PARALLEL
env variable usage consistent across all jobs, and adds a missing
shebang to the `install_rush.sh` script which is used to install rust in
the manylinux container environment.

* Simplify tox configuration

In earlier commits the tox configuration was changed to try and fix the
docs CI job by going to great effort to try and enforce that
setuptools-rust was installed in all situations, even before it was
actually needed. However, the problem with the docs ci job was unrelated
to the tox configuration and this reverts the configuration to something
that works with more versions of tox and setuptools-rust.

* Add missing pieces of cargo configuration

Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: georgios-ts <45130028+georgios-ts@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-02-28 21:49:54 +00:00
Matthew Treinish 3763e61f16
Bump black version and relax constraint (#7615)
This commit bumps the black version we pin to the latest release,
22.1.0. This release is also the first release not marked as beta and
with that black has introduced a stability policy where no formatting
changes will be introduced on a major version release (which is the
year). [1] With this new policy in place we no longer need to pin to a
single version and can instead constrain the requirement to just the
major version without worrying about a new release breaking ci or local
development. This commit does that and sets the black version
requirement to be any 22.x.y release so that we'll continue to get
bugfixes moving forward without having to manually bump a pinned version.

[1] https://black.readthedocs.io/en/latest/the_black_code_style/index.html#stability-policy
2022-02-03 18:07:22 +00:00
Iulia Zidaru 185df89030
Need to remove max_credits (#7409)
* fix issue #4132 - Need to remove max_credits

* fix issue #4132 - Need to remove max_credits

* deprecate max_credits instead of removing

* deprecate max_credits - add release notes

* fix review comments

* add warning for assamble

* Reword release note

* Remove straggler max_credits

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
2022-01-19 16:51:13 +00:00
Lev Bishop 9e9ad8aa66
Blacken stragglers (#6611)
* Blacken stragglers

* fix tox.ini and azure-pipelines.yml

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2021-06-21 21:49:31 +00:00
Julien Gacon 20c5e15284
Deprecate QuantumCircuit.u1/2/3 (#5083)
* fix first round of deprecation warnings

* fix more deprecation warnings

* add U/P to ast_to_dag

* update examples

* update circuit library

* update controlled gates and UC

* circlib

* Apply suggestions from code review

Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>

* more deprecations

* update deprecation warnings with sx-p decomps

* update test_parameters

* update test_barrier_before_final_meas

* example in qiskit/transpiler/__init__

* update test_assembler

* test_circuit_to_instruction

* dagcircuit.test_compose

* test_dagcircuit & dependency

* qi.test_synthesis

* qi operators/states

* test_basis_translator

* test_collect_2q_blocks

* commutative analysis & cancellation

* transpiler.test_consolidate_blocks

* transpiler.test_cx_direction

* transpiler.test_decompose

* transpiler.test_kak_over_optimization

* transpiler.test_optimize_1q_gates

* test_passmanager & preset_passmanagers

* transpiler.test_remove_diagonal_gates_before_measure

* transpiler.test_stochastic_swap

* transpiler.test_unroller

* visualization tests

* randomized.test_synthesis

* scheduler.test_basic_scheduler

* pulse.test_builder

* qft examples

* transpiler/graysynth

* fix qubit broadcast in U2

* fix lint

* typo: circular->cyclic

* fix lint

* fix lint from merge

* rm deprecated call to u3

* Update qiskit/circuit/quantumcircuit.py

Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>

* Update qiskit/circuit/quantumcircuit.py

Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>

* apply suggestions from code review

* make U a base gate

* update tests to U as base gate

* temporarily run tutorials on aqua master

* wrong linenumber in todo

* remove comment of old decomposition

* add reno

* consistent use of pi symbol in warnings

* update test to not use deprecated names

* fix messed up ff merge

* no clue where that » went

Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
Co-authored-by: Kevin Krsulich <kevin.krsulich@ibm.com>
2020-10-14 23:00:52 +00:00
Lev Bishop 779fa14d44
Remove coding: utf-8 per PEP 3120 (#4914)
utf-8 has been the default since PEP 3120.
https://www.python.org/dev/peps/pep-3120/

Non trivial edits are to Makefile and verify_headers.py
2020-08-12 08:29:16 -04:00
Romilly Cocking 9e51e5229e
Select real providers that offer at least two qubits, as required by this example. (Armonk does not!) (#4511)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2020-05-28 17:42:10 +00:00
Luciano Bello c05182a101
lint in the example files (#4363)
Co-authored-by: Jay Gambetta <jay.gambetta@us.ibm.com>
2020-05-04 13:44:43 +00:00
Paul Nation 3275cae1d8
Update to new NumPy RNG (#4297)
fixes #4273

We used RandomState a lot, but that is now legacy code. This moves us to np.random.default_rng:

https://numpy.org/doc/stable/reference/random/generator.html?highlight=default_rng#numpy.random.default_rng

that makes use of PCG64:

https://numpy.org/doc/stable/reference/random/bit_generators/pcg64.html#numpy.random.PCG64

Besides removing legacy code, this is also 4x faster at initializing the generators.

* move to new rng

* more updates

* update to new rng

* fix issue after merging conflicts

* fix additional merge issue

* update

* update numpy versions

* missed one

* generators in docs

* swear I fixed this earlier

* we using very old scipy

* Fix rebase spots

Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: Jay Gambetta <jay.gambetta@us.ibm.com>
2020-04-30 06:35:38 -04:00
Julien Gacon 4bd91fef28
Stop monkeypatching standard gates and move them to circuit/library/standard_gates (#4035)
* begin move to qiskit.circuit.gates

* move more gates

* move all standard gates

* prepare SQU for moving

not sure where to put it yet though

* Move description of gates to new location

Co-authored-by: Ali Javadi-Abhari <ali.javadi@ibm.com>

* move new gates to  circuit/gates, fix lint

* new gates: dcx, iswap, rzx

* fix test

somehow cannot have * before u=None in SQUGate, otherwise the test_extensions_standard.test_to_matrix test fails due to a wrong num of args

* return type is actually instructionset

* fix tests

* use circuit.gates in qiskit/ but keep old location in test

* update extensions import to import form circ/gates

* move equivalence lib to circuit/gates

* move to library/standard_gates + kevin's comments

* fix cyclic import and RST

* rename leftover locations

* add reno

* fix cases missed in merge

* Update qiskit/circuit/quantumcircuit.py

Co-Authored-By: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>

* trailing whitespace

* fix barrier import

* allow gate import from qiskit.circuit

* fix rxx, ryy, rzz docs (#4275)

Co-authored-by: Ali Javadi-Abhari <ali.javadi@ibm.com>

* fix left comments: circuit/gates to circuit/library

* allow standard gate imports from circuit.library

this also includes the instructions barrier, measure and reset

* remove accidentally added file

* add #4218

Co-authored-by: Luciano Bello <luciano.bello@ibm.com>

* add #4294

Co-authored-by: Luciano Bello <luciano.bello@ibm.com>

* import from new location

* binding a submodule to name need py > 3.6

the circular dependency + name binding `import qiskit.circuit.library.standard_gates a gates` is only supported from python 3.7+

Co-authored-by: Ali Javadi-Abhari <ali.javadi@ibm.com>
Co-authored-by: Erick Winston <ewinston@us.ibm.com>
Co-authored-by: Luciano Bello <luciano.bello@ibm.com>
Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2020-04-28 10:39:53 -04:00
Ali Javadi-Abhari 6eab4d7620
fix no ibmq.backends() (#3456) 2019-11-12 14:40:54 -05:00
Diego M. Rodríguez a3ae434326 Convert CRLF file to LF (#3295)
A small (3) number of files in the repo had their line endings as CRLF. This PR is the result of running dos2unix on them, mostly for having an homogeneous line ending for all the text files in the repository (in particular to avoid some nuisances when working outside git: tarballs, github release files, etc).
2019-10-22 13:42:33 -04:00
Diego M. Rodríguez 0d591b9180 Update examples for IBMQProvider 0.3 and api v2 (#2843)
* Update examples to IBMQ Provider 0.3

* Update hello_quantum example

* Update test_all_ibmq_examples

* Fix qft example
2019-07-22 10:22:58 -04:00
Luciano 00ba08f742 StochasticSwap on physical circuit (#2598)
* change the API

* https://github.com/Qiskit/qiskit-terra/issues/2584#issuecomment-500032736

* regenerate

* unused import

* use trivial layout and simplify signatures

Co-authored-by: Ali Javadi-Abhari <ali.javadi@ibm.com>

* fix tests

* style

* fix stochastic swap example
2019-06-21 14:56:43 -04:00
Matthew Treinish f5dd2e2753
Add tests that run example python scripts (#2559)
* Add tests that run example python scripts

This commit adds a new test module that will execute all the example
scripts to verify they still work as we make changes. However, a number
of example scripts rely on using the ibmq service which is an optional
component now. To make filtering the example scripts between those which
don't need ibmq from those that need ibmq this also moves all the ibmq
examples into a self contained subdir in examples/python. Those examples
which require ibmq are run conditionally as online_tests. For example
scripts which were running on both local simulators and ibmq these are
split into 2 files one for just simulation and the other in ibmq that
uses the ibmq backends.

Fixes #970

* Fix whitespace in ghz

* Fix whitespace in qft

* Fix lint

* bit0 should not be a tuple

* Decode subprocess stdout and stderr

* Mark online tests as slow, since they run on devices

* Pivot to use subtest instead of ddt

* Update ibmq example based on rebase changes

* Add skips for windows/appveyor

The text drawer isn't working correctly on windows/appveyor. Until that
unrelated issue is fixed it will block this. So this commit adds a skip
on windows envs until issue #2616 is fixed.

* Remove outdated comment
2019-06-17 14:56:42 -04:00
Anna Phan bdd38e692c Fixed bug in input_state function in qft python example. (#2585) 2019-06-10 10:26:43 +02:00
Ali Javadi-Abhari 7af9434d5d remove try/except in examples (#2557) 2019-06-03 09:49:37 -04:00
Jay Gambetta 3a5780b0fe
Examples updated to use simplified inputs (#2548)
* Adding examples

* Fixing examples

* Small fixes
2019-06-01 17:29:58 -04:00
Diego M. Rodríguez c1dd679693 Add license header to several modules (#2428)
* examples/python
* qiskit/tools/qi
* test/python/validation
2019-05-15 13:20:09 -04:00
Matthew Treinish 7053ee238f Add example for stochastic swap and use to verify wheels (#2251)
* Add example for stochastic swap and use to verify wheels

This commit adds a new example to the examples directory for running the
stochastic swap pass. This is then used by the wheel build automation
to verify the built wheel works as expected. The compiled code (and
complexity in the wheel build) is for the stochastic swap pass so
verifying it functions when installed from the built wheel is important.

* Test wheel build with new script

Comment out branch logic and wheel upload to verify the wheel build this
is just for testing and will be reverted before the PR merges.

* Remove prints from example

* Revert "Test wheel build with new script"

This reverts commit f5edc1c777.
2019-05-01 17:40:16 -04:00
Ali Javadi-Abhari 7e63af9823 Examples update (#2256)
* Adding the level1

* fixing examples

* level_2

* Bug fix

* Fixing

* make level 2 example richer
2019-04-30 16:59:58 -04:00
Paul Nation 97cf677137
Copyrights (#2249)
* 2017 cps

* 2018 cps

* 2019 cps
2019-04-30 10:36:47 -04:00
Jay Gambetta b39827ad26 Compiler api (#2244) 2019-04-29 22:43:48 -04:00
Maddy Tod 56ee4ca815 Tidy up examples (#2191)
* Fixed teleport example

* Tidied up 3 other examples

* Tidied up some print statements
2019-04-24 14:18:12 -04:00
Jay Gambetta 89ceb1917b Compiler Redo (#1856)
* Compiler redo

* Compiler redo

* More changes

* Linting

* Linting

* Update qiskit/compiler/synthesizer.py

Co-Authored-By: jaygambetta <jay.gambetta@us.ibm.com>

* Update qiskit/compiler/assembler.py

Co-Authored-By: jaygambetta <jay.gambetta@us.ibm.com>

* Update qiskit/compiler/assembler.py

Co-Authored-By: jaygambetta <jay.gambetta@us.ibm.com>

* Update qiskit/runner_wrapper.py

Co-Authored-By: jaygambetta <jay.gambetta@us.ibm.com>

* Renaming for ali

* Cleaning up

* Listing. And doc

* Making compile work with pass manager.

* Style fixes

* Moving around

* Limiting and passing

* naming

* Doctoring

* rename assemble() to assemble_circuits(), update warning messages

* add a changelog

* add qobj_header as an arg to execute() as well

* move schema to models folder like other qiskit components

* add tests for assembler

* qiskit.compiler.transpile -> qiskit.compiler.transpiler

* update teleport example

* update rippleadd example

* fix misleading try-except statements in the examples

* update level 1 example to be transpile then assemble

* bring run_config arg to second position in assemble_circuits()

* remove compile from tests and a bunch of pylint ignores
2019-03-11 01:16:26 -04:00
Yunong Shi ded732e2f3 New commutation passes (#1500)
* Passes implemented and test cases added

* example added

* add support to u1,u2,u3, and rz,rx,ry

* fix support for 1 qubit gates

* fix test cases

* update example

* update code to master, some linting

* changelog

* test is just testing analysis, rename and clean

* add license to files

* more linting fixes

* fix commutation detecction issue with 2 cnots s on same 2 wires

* fixed a bug that misidentify the commutation relations between two alternating CNOTs

* Linting and fixing test

* final lint style
2018-12-19 00:13:31 -05:00
Salvador de la Puente González 43fc166980 Renaming qiskit.backends to qiskit.providers (#1531)
* Renaming qiskit.backends to qiskit.providers

* Replacing routes in the building files.
2018-12-17 18:11:40 -05:00
Jay Gambetta abd94d6e7a
examples update (#1514)
* Ghz

* Qft

* Removing results

* Finish examples
2018-12-16 12:13:29 -05:00
Luciano 3de24f4fa2 add_passes -> append (#1508) 2018-12-15 21:26:44 -05:00
Salvador de la Puente González 1f56ac49f0 Renaming Simulators ot BasicAer to highlight the fact that they are not full-featured (#1494)
* Renaming Simulators ot BasicSimulators to highlight the fact that they are not full-featured.

* change BasicSimulators to BasicAer
2018-12-14 13:00:23 -05:00
Salvador de la Puente González cad469f5e1 Split `qiskit.backend.aer` simulators into Python built-in simulators and C++ legacy simulators (#1484)
* Repackaging qiskit.backends.aer to qiskit.backends.builtinsimulators

* Moving C++ simulators to legacysimulators package

* Fixing qiskit/__init__.py to support extensible backends

* Fixing tests

* Removing traces of aer name inside the backends package.

* Remove traces of aer from qiskit

* Updating CHANGELOG

* Adding deprecation warning

* Replacing aer with legacysimulators in the build system
2018-12-13 19:14:07 -05:00
Jay Gambetta f38d392c05 Renaming QISKit to Qiskit (#1382)
* Renaming QISKit to Qiskit

* Update qiskit/_qiskiterror.py

Co-Authored-By: jaygambetta <jay.gambetta@us.ibm.com>

* Add backwards compat exception class to __init__

This adds the backwards compatible exception class back to __init__ which is likely the point people are importing from.

* Update _instruction.py

* Update _dagcircuit.py

* Update _dagcircuit.py
2018-12-01 21:44:46 -05:00
Jay Gambetta 946aca4a11
Renaming get_data to data (#1362) 2018-11-28 12:48:27 -05:00
Ali Javadi-Abhari 5e50f68488 fix middle measurements moving to the end (#1337) 2018-11-26 19:24:33 -05:00
Jay Gambetta 6a3cbae3a4 Fixing examples with new features (#1292)
* Fixing examples with new features

* Fixing print

* Update
2018-11-19 09:51:48 -05:00
Jay Gambetta 9afb9502e9 load qasm exampe (#1294)
* Test

* Loading a circuit from file
2018-11-19 03:30:40 -05:00
Jay Gambetta 9d6f39eadf
Circuit order and register (#1284)
* Fixed order convention and some random bugs in order
2018-11-18 15:48:51 -05:00
Jay Gambetta 14838089ba Split compile (#1134)
* Removing old wrapper commands

* Linting

* Update _wrapper.py

* First merge

* Adding changelog

* Fixing the test

* Passing test

* adding linting

* Linting

* Documentation

* Renaming compile in transpiler

* Renaming

* Adding lint fix

* Update _circuit_visualization.py
2018-10-28 16:38:56 -04:00
Lee James O'Riordan 7e2204c7f0 Correcting typos throughout project (#1139)
* Correcting typos in comments, variable names, and documentation.
2018-10-26 16:25:36 -04:00
Salvador de la Puente González 017e4566bb
This PR introduces a new transpilier architecture to support advance functionality. (#1060)
The main goal of Qiskit Terra's transpiler is to provide an extensible infrastructure of pluggable passes that allows flexibility in customizing the compilation pipeline through the creation and combination of new passes. Includes:

    Pass manager.
    Dependency control.
    Pass scheduling.
    Control Flow modules.

More information can be found on the README.md file inside qiskit/transpiler.
2018-10-09 15:17:16 +02:00
Jay Gambetta d0af0c01d3 Readme (#1018)
* starting reademe

* adding readme
2018-10-03 14:04:55 -04:00
Ali Javadi 16204f5c47 update tests and examples 2018-10-02 10:28:01 -04:00
Ali Javadi-Abhari 42f1b2ddba expand qobj types for previous version too (#987)
* expand qobj types for previous version too

* nit fix in example

* lint
2018-10-01 09:59:24 +02:00
Jay Gambetta 7fbc259256 Examples (#977)
* fixing the contributing

* adding more to the contrbuting

* more updates to contributing

* more addtions

* more addtions

* more addtions

* more addtions

* more addtions

* fixing up first example

* linting

* adding to the discription

* renaming terra not core

* doc and start of level 1

* doc updates

* killing the compile

* killing the compile

* small updates

* using + load + hello quantum

* ghz +initialize + qft removed optimize as pass manager does this

* small changes

* small changes

* update DeprecationWarning messages in _wrapper.py
2018-09-30 23:07:51 -04:00
Ali Javadi e58d7dedd1 update examples and tests 2018-09-20 15:00:06 -04:00
Salvador de la Puente González 3eb9e00599 Replace properties in jobs and backends with methods. 2018-09-04 20:11:34 +02:00
Ali Javadi-Abhari 909728c61d Update examples for v0.5 (#672)
* remove quantum program from examples

* update changelog
2018-07-25 11:08:58 +02:00