Commit Graph

6331 Commits

Author SHA1 Message Date
Pradeep Krishnamurthy f960d05ab6
set T2 with the correct value in ConfigurableFakeBackend (#8117)
* set T2 with the correct value in ConfigurableFakeBackend

* minor clean up and add to release notes

* Reword release note

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-06-06 14:58:28 +00:00
Matthew Treinish 43e4a72c9c
Add function to easily generate preset pass managers (#8125)
* Add function to easily generate preset pass managers

This commit adds a new function, generate_preset_pass_managers(), which
is used to quickly generate the preset pass manager for manual
interaction. Prior to this new function there were lower level functions
which are used to generate the individual pass manager objects for each
optimization level but they are hidden behind an abstraction object,
PassManagerConfig which is the only input. This makes it harder to work
with because the user has to manually remember to generate the config
object prior to creating the pass manager. Similarly this new function
simplifies the creation of preset pass managers by having a single entry
point instead of 4 for each optimization level.

* Add target override support if manually specified

If a user manually specifies a Target object to use as the compilation
target we still need to generate the old data structures to trigger
some passes to run. We also want the properties of the target to
supersede those in a specified backend if it's manually specified. This
commit corrects the handling of this so the manually specified target is
the source of truth when specified.

* Deduplicate shared argument list

* Expand test coverage

* Fix cyclic import issues

* Apply suggestions from code review

Co-authored-by: Julien Gacon <gaconju@gmail.com>

Co-authored-by: Julien Gacon <gaconju@gmail.com>
2022-06-03 08:31:14 +02:00
chetmurthy 37045b57ec
Fix double matrix computation in numpy eigensolver (#8131)
* minor bug: to_spmatrix was called twice on some paths

Just reuse first result.

* black fixups
2022-06-02 20:19:28 +00:00
Ikko Hamamura df54ae26d6
Enhance Primitives' interface (#8065)
* Enhance Primitives' interface

* use QuantumCircuit.name instead of id

* fix lint

* rename *_indices

* use __new__ instead of __init_subclass__

* refactoring

* Apply suggestions from code review

Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>

* Reflect review comments

* add args and kwargs

* add releasenote

* Apply suggestions from code review

Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>

* Update qiskit/primitives/base_sampler.py

Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>

* Remove broadcasting and optional

* Update qiskit/primitives/base_estimator.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* fix type hint as Iterable

* add comments

* add tests for deprecated arguments

* add validation about max index

* fix typo

* refactoring

* use id instead of name

* Add example with passing objects

* Apply suggestions from code review

Co-authored-by: Junye Huang <h.jun.ye@gmail.com>
Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>

* Update qiskit/primitives/base_estimator.py

Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>

* Update qiskit/primitives/base_estimator.py

Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>

* releasenote

* rm dup and add comments

Co-authored-by: Rathish Cholarajan <rathishc24@gmail.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Junye Huang <h.jun.ye@gmail.com>
2022-06-02 14:07:37 +02:00
Niko Savola b8cb9573b5
Clearer output format params in `QuantumCircuit.draw` (#8120)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-30 14:54:14 +00:00
dependabot[bot] 081d8d700b
Bump indexmap from 1.8.1 to 1.8.2 (#8118)
Bumps [indexmap](https://github.com/bluss/indexmap) from 1.8.1 to 1.8.2.
- [Release notes](https://github.com/bluss/indexmap/releases)
- [Changelog](https://github.com/bluss/indexmap/blob/1.8.2/RELEASES.rst)
- [Commits](https://github.com/bluss/indexmap/compare/1.8.1...1.8.2)

---
updated-dependencies:
- dependency-name: indexmap
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-30 12:41:51 +00:00
Jack J. Woehr 56b0de6822
Fix grammar in `Backend` documentation (#8113)
* very minor grammar and syntax cleanup in comment to `def run`.

* another grammar change

* and one last change!
2022-05-30 11:04:10 +00:00
Matthew Treinish e508729400
Make python-constraint optional (#7733)
* Make python-constraint optional

Since #7213 we no longer have been using the CSPLayout pass by default
in the preset passmanagers or transpile(). This is because it has been
superseded by the VF2Layout pass which is now used everywhere. While we
will keep the CSPLayout pass around for the forseeable future there is
no need to install python-constraint by default anymore since it's only
user is the CSPLayout pass, which isn't going to be commonly used
anymore now that it's not used in the default compilation path anymore.
This commit removes the python-constraint library from the requirements
list and makes it an optional dependency.

Fixes #7726

* Add docstring for HAS_CONSTRAINT

* Add private module to avoid module level optional import

This commit splits the custom solver class definition out into a
separate private module that is not imported until runtime. This enables
us to avoid a module level import for python-constraint meaning we only
try to import if something is actually using CSPLayout.

* Fix rebase issue

* Fix lint

* Fix typo in release note

Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>

* Alphabetize optionals list

Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
2022-05-26 19:20:51 +00:00
Matthew Treinish e76af2058f
Add string representation for PassManagerConfig (#8085)
* Add string representation for PassManagerConfig

This commit adds a new string representation to the PassManagerConfig
class. When str() is run on a PassManagerConfig object it will return a
string listing the values for all of the attributes in the class.

* Adjust tab indent and add tests

This commit ensure that all entries under the pass manager config have a
single tab indent and also adds a test to verify the output.
2022-05-26 15:34:03 +00:00
Doğukan Tuna 4982c69ecc
(fix): deprecate qiskit-aqua version loading after deprecation of aqua (#8094)
Co-authored-by: Doğukan Tuna <5399244-sotapr@users.noreply.gitlab.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-25 22:02:20 +00:00
Luciano Bello be187757ff
Remove erroneous LaTeX alignment character (#8106)
* amp alignment in a single line results in "Misplaced &"

* Restore punctuation

Co-authored-by: Jake Lishman <jake@binhbar.com>
2022-05-25 13:02:48 +00:00
Luciano Bello d2e3340adb
Checks if DiagonalGate has modulus 1 (#8098)
* Checks if DiagonalGate has modulus 1 - Fixes #3842

Co-authored-by: ewinston <ewinston@users.noreply.github.com>
Co-authored-by: hhyap <hhyap@users.noreply.github.com>

* reno

* Fix release-note typo

Co-authored-by: ewinston <ewinston@users.noreply.github.com>
Co-authored-by: hhyap <hhyap@users.noreply.github.com>
Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-23 11:51:58 +00:00
Takashi Imamichi 8360c9b048
Fix performance regression of BasePauli._to_list (#8088) 2022-05-23 09:52:24 +00:00
Takashi Imamichi 794db4792e
Performance improvement of `SparsePauliOp.__init__` (#7830)
* Improve performance of `SparsePauliOp.__init__`

* add `_count_y` utility function (w/ default dtype=np.uint8)
* optimize the phase computation part of `SparsePauliOp.__init__`

* fix add of uint8 and int64

* use np.min_scale_type

* fix axis

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-19 01:45:52 +00:00
Alexander Ivrii cbc801e010
Small speedup to construct DagDependency: gates over disjoint sets of qubits commute (and no matrix multiplication is necessary) (#8078)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-17 21:54:53 +00:00
Jintao YU b898359192
Improve reverse_bits to support registerless bits (#7423)
* Improve reverse_bits to support registerless bits

* Change the algorithm of reverse_bits

* Reimplement reverse_bits with reversed bits

Also add more test cases.

* Simplify bit lookups

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
2022-05-17 15:11:18 +00:00
Jake Lishman 0041b6ff26
Reduce Rust MSRV to 1.56 (#8077)
Commit 84cfd5c1 recently used a `&[char; 2]` as the type in the
constructor of the `std::Pattern` trait, which is a feature of Rust
unstable, and only available in newer versions of Rust.  We've not fixed
an absolute minimum supported Rust version, but have generally tried to
keep things building with at least the last six months' releases.
2022-05-17 11:49:54 +00:00
Kevin J. Sung 35c0c90c22
Change XXPlusYYGate convention (#7949)
* change XXPlusYYGate convention

* add release note

* Fix Sphinx link

Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-17 00:02:30 +00:00
Hristo Georgiev da9ae54587
Enable proper iteration over `Statevector` (#8062)
* Enable proper iteration over Statevector

* Add Statevector.__len__ and add a release note

* Simplify release note

* Update test_statevctor_iter

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-16 22:39:06 +00:00
Matthew Treinish 84cfd5c1aa
Add a marginal_distribution function (#8026)
* Add a marginal_distribution function

This commit adds a new function marginal_distribution which performs
marginalization similar to the existing marginal_counts() function. This
new function however differs in a few key ways. Most importantly the order
of the bit indices is significant for the purpose of permuting the bits
while marginalizing, while marginal_counts() doesn't do this.
Additionally, this function only works with dictionaries and not Result
objects and is written in Rust for performance. While the purposed of
this function is mostly identical to marginal_counts(), because making
the bit indices order significant is a breaking change this was done as
a separate function to avoid that. Once this new function is released
we can look at deprecated and eventually removing the existing
marginal_counts() function.

Fixes #6230

* Fix typos in python function

* Handle missing indices

In case a bit string has stripped leading zeros this commit adds
handling to treat a missing index from the bit string as a '0'.

* Apply suggestions from code review

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

* Remove unecessary rust index

* Update test

Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-16 21:32:00 +00:00
Jim Garrison 4d459c8c47
Remove mention of IBM Q account URL from README (#7827)
While this function accepts a URL, it is not essential for basic
use, and it is not clear from the IBM Q account what URL should
be used.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-16 19:16:51 +00:00
dependabot[bot] d53d17c452
Bump rayon from 1.5.2 to 1.5.3 (#8067)
Bumps [rayon](https://github.com/rayon-rs/rayon) from 1.5.2 to 1.5.3.
- [Release notes](https://github.com/rayon-rs/rayon/releases)
- [Changelog](https://github.com/rayon-rs/rayon/blob/master/RELEASES.md)
- [Commits](https://github.com/rayon-rs/rayon/compare/v1.5.2...v1.5.3)

---
updated-dependencies:
- dependency-name: rayon
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-16 17:34:29 +00:00
nrhawkins 230c0224a3
Explicitly state that coupling map forms a directed graph (#8064)
* fixed issue Explicitly state that coupling map forms a directed graph #7987

* Add missing full stop

Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-16 15:54:17 +00:00
dependabot[bot] 9be2d3b9d1
Bump pyo3 from 0.16.4 to 0.16.5 (#8066)
Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.16.4 to 0.16.5.
- [Release notes](https://github.com/pyo3/pyo3/releases)
- [Changelog](https://github.com/PyO3/pyo3/blob/main/CHANGELOG.md)
- [Commits](https://github.com/pyo3/pyo3/compare/v0.16.4...v0.16.5)

---
updated-dependencies:
- dependency-name: pyo3
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-16 14:15:40 +00:00
Matthew Treinish 2d01b4dfe6
Avoid UnitarySynthesis plugin discovery overhead with no method set (#8059)
* Avoid UnitarySynthesis plugin discovery overhead with no method set

This commit tweaks the logic around loading plugins in the
UnitarySynthesis transpiler pass. Previously we would unconditionally
perform plugin discovery in all cases even if no custom plugin was
specified. This added some overhead the first time we initialize a
UnitarySynthesis pass object to do the initial discovery, import, and
initialization of any installed plugins. While typically this is fast
(locally just with the 2 plugins including in terra this takes ~.04
seconds) it does depend on the performance of all the installed plugins.
However, this overhead is not necessary if there is not a custom
synthesis method requested by a user. If the default method is being
used we can just directly instatiate the plugin and avoid the discovery
process. This commit changes the UnitarySynthesis pass to only run
discovery if the method argument is set to something other than
"default".

* Fix lint failure
2022-05-13 04:48:40 +00:00
Jake Lishman 4410a9b087
Fix SabreSwap with classically conditioned gates (#8041)
* Fix SabreSwap with classically conditioned gates

The calculation of the expected number of predecessors for a gate to
be considered "resolved" in `SabreSwap` was not accounting for wires
stemming from classical conditions.  The tracking of the _actual_ number
of predecessor requirements satisfied did correctly account for this, so
in certain circumstances the actual count could jump from "too low" to
"too high" without passing through "just right", and the gate would
never get added to the circuit.

* Use `successors` to calculate required predecessors

This unifies the calculation of what is considered a required
predecessor by using the same `SabreSwap._successors` function for both
aspects of the comparison: counting the required predecessors and
counting the actual number of applied predecessors.  This simplifies the
logic, since now an update in one place is sufficient, and the wires are
read directly from the DAG, rather than using assumptions about the
nodes.

* Fix incorrect import

* Fix decremented typo

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-12 18:35:04 +00:00
Naoki Kanazawa 829f2324c8
Fix RZX builder rescaled amplitude (#8031)
* Fix RZX builder rescale amplitude bug

* Update releasenotes/notes/fix-rzx-builder-pulse-amp-ba5c876ddea17c41.yaml

Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-11 21:30:45 +00:00
Jake Lishman 9374449d69
Fix marginal_counts on memory with non-zero indices (#8047)
The marginalisation could previously return the empty string instead of
`"0"` if the given indices were too high for a given memory slot,
causing a later error in binary-to-hex conversion.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-11 13:40:31 +00:00
Matthew Treinish b2ddaeb873
Document modifications to the release process (#8042)
* Document modifications to the release process

This commit updates the CONTRIBUTING.md file to more clearly document
the current release process. Previously for the release cycle
documentation we just had a mechanical list of the steps done by the
core team and what the automation does but it didn't really contain any
details on the aspects of how contributions with releasing. This commit
updates this section to better describe the different phases of a
release and the expectations and order of operations a contributor will
need to know around releasing.

* Update CONTRIBUTING.md

Co-authored-by: Lev Bishop <18673315+levbishop@users.noreply.github.com>

* Update CONTRIBUTING.md

Co-authored-by: Lev Bishop <18673315+levbishop@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-11 11:21:55 +00:00
Daniel J. Egger c8ad6cf725
Follow-up on routing commuting 2q gates (#7979)
* * Renamed directory.

* * Typo.

* * Commuting2qBlocks name

* * logical -> virtual.

* * from_line in the example.

* * Reno name fix.

* * Reno rewording.

* * removed unnecessary line in example.

* * Black.

* * Started designing test on non-line graph.

* * Added test on a T device.

* * Renamed Communting2qBlocks to Commuting2qBlock

* * Made test robust to arbitraryness of commuting gate order.
* Added test.

* * Added test and black.

* * Fix missing gate test exception refactor.

* * Bug fix with test.

* * Removed SwapStrategy from the passes init.

* * black
2022-05-11 01:57:18 +00:00
Kevin J. Sung 7726d47045
Use round instead of ceil for GaussianSquare pulse duration in RZXCalibrationBuilder (#7995)
* round duration instead of ceil

* update test

* add test

* add release note

* Update releasenotes/notes/pulse-round-a014390e414c79c8.yaml

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
2022-05-10 16:56:48 +00:00
Daiki Murata ec9d693166
Alias BaseOperator.__mul__ to BaseOperator._multiply in quantum_info (#8007)
* add left multiplication

* add tests

* add releasenote

* fix incorrectly mixed module

* change method of __mul__

* fix lint

* Reword release note

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Co-authored-by: Ikko Hamamura <ikkoham@users.noreply.github.com>
2022-05-09 01:55:17 +00:00
Junye Huang cffbb84934
Fix fake backend v2 dtm unit (#8019)
* convert dtm from nanoseconds to seconds

* Handle dtm not defined in configuration

* Add test for checking backend v2 dtm less than 1e-6

* add release note

* new line in release note

* Update qiskit/test/mock/fake_backend.py

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-04 21:05:18 +00:00
Matthew Treinish 62670dadcb
Deduplicate and unify VF2 layout passes (#7991)
* Deduplicate and unify VF2 layout passes

In #7862 we recently added a new vf2 post layout pass which is designed
to run after routing to improve the layout once we know there is at
least one isomorphic subgraph in the coupling graph for the interactions
in the circuit. In that PR we still ran vf2 post layout even if vf2
layout pass found a match. That's because the heuristic scoring of
layouts used for the vf2 layout and vf2 post layout passes were
different. Originally this difference was due to the the vf2 post
layout pass being intedended to run after the optimization loop where we
could guarantee the gates were in the target and exactly score the error
for each potential layout. But since the vf2 post layout was updated to
score a layout based on the gate counts for each qubit and the average
1q and 2q instruction error rates we can leverage this better heuristic
scoring in the vf2 layout pass. This commit updates the vf2 layout pass
to use the same heuristic and deduplicates some of the code between the
passes at the same time. Additionally, since the scoring heuristics are
the same the preset pass managers are updated to only run vf2 post
layout if vf2 layout didn't find a match. If vf2 layout finds a match
it's going to be the same as what vf2 post layout finds so there is no
need to run the vf2 post layout pass anymore.

* Update apply post layout condition comments

* Remove old layout score function

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-04 19:23:22 +00:00
Matthew Treinish f1f078ba66
Remove hard time limit from vf2 passes in preset passmanagers (#8021)
* Remove hard time limit from vf2 passes in preset passmanagers

This commit removes the hard time limit from the preset passmanager. We
were previously setting two limits on the pass a call_limit parameter,
which is used to set the limit of internal state visits the vf2
implementation in retworkx will attempt before giving up, and a time
limit which sets a hard wall time limit that is checked after each
mapping to ensure we don't spend more than a specific amount of time on
trying to find an optimal mapping. As subgraph isomorphism is
NP-complete we could spend a very large amount of time trying to find
the next isomorphic mapping and both these limits were set to avoid a
situation where we spend hours in optimization level 1 trying to find a
better layout. However, as we've seen in #8017 setting a hard time limit
limits the level of reproducibility on the output of the transpiler. It
means that setting a fixed seed is no longer sufficient to exactly
reproduce the output as it's also partially a function of the
performance of the local system we're running on. If the local
environment is slower we might get different results because we've hit
the hard time limit.

To address this, this commit removes the hard time limit so that we only
rely on the call limit parameter on the preset pass manager. While this
parameter is a bit more opaque in how it should be used because it
requires an understanding of how the VF2 algorithm works (and is
implemented in retworkx) it should be sufficient to avoid the runaway
execution problem but also means the limits are determinitisically
applied. This should improve the reproducability of the transpiler because
the pass will always try exactly up until a given point regardless of
how fast the local environment is.

For people manually instatiating the pass they can still rely on the
hard time limit parameter if they want it, but for the preset pass
managers and the transpile() function we no longer set this.

Fixes #8017

* Add release note

* Fix tense

Co-authored-by: Jake Lishman <jake@binhbar.com>
2022-05-04 18:10:22 +00:00
Matthew Treinish e7fdcc8eac
Support target and basis gates in Unroll3qOrMore transpiler pass (#7997)
* Support target and basis gates in Unroll3qOrMore transpiler pass

This commit adds two new constructor arguments to the Unroll3qOrMore
transpiler pass, target and basis_gates, which are used to specify a
backend target and basis gate list respectively. If these are specified
the pass will not decompose any multiqubit operations present in the
circuit if they are in the target or basis_gates list.

Fixes #5518
Related to #7812
Part of #7113

* Update releasenotes/notes/unroll3q-target-bf57cc4365808862.yaml

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>

* Fix lint

* Fix release-note typo

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>
Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-04 13:45:06 +00:00
Matthew Treinish 9cf198cc4e
Add missing delay instruction to fake backends (#8003)
* Add missing delay instruction to fake backends

This commit adds the delay instruction to the target for fake backends
based on BackendV2. With BackendV2 and the Target delay isn't assumed to
be present on every backend and it has to be explictly listed. This
commit fixes this so that the compiler is aware that delay is a valid
operation (without any additional constraints) on the BackendV2 based
fake backends.

* Add qubits to Delay target entry

If any instructions available in a target are ideal, with no qubits or
properties set, the target class assumes the backend is ideal (like in
the case of an ideal simulator where are all instructions are globally
defined and have no error or duration). To avoid this we need to define
the Delay instruction on all qubits explicitly. This commit makes this
change to ensure the target for backends still shows the qubits and
properties for the other operations. However, in adding an instruction
with no properties defined a bug in the plot gate error map function was
uncovered where it errored because it assumes all instructions have
properties defined, this was fixed at the same time.

* Add release note

* Update releasenotes/notes/delay-fake-backends-3f68c074e85d531f.yaml

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-03 23:01:31 +00:00
Alejandro Montanez 1f052bef64
Remove BasicAer shot limit (#7801)
* Fixing issue #7634

At this point, there is an arbitrary number for the maximum shots in the BasicAer simulator "65536". The solution proposed @kevinsung is to work with zero as the default value of max_shots. This solves the problem with the evaluation of max_shots in the assemble function "_parse_common_args" in qiskit/compiler/assembler.py.

* Update backend.py

* Update backend.py

* Update backend.py

* adding test

correcting some errors about where to add the test.

* Create remove-basicaer-shot-limit-b7cd4e6f6739885c.yaml

* Update releasenotes/notes/remove-basicaer-shot-limit-b7cd4e6f6739885c.yaml

Co-authored-by: Kevin J. Sung <kevinjefferysung@gmail.com>

* Remove test of shot limit

The test previously just ran `BasicAer` with two million shots on the
transpiled circuit to see if it encountered a limit.  This is simple
enough functionality (and unlikely enough to be broken accidentally)
that it can do without a test - the previous one took about 8 seconds,
which is a long time for testing a toggle.

Co-authored-by: Kevin J. Sung <kevinjefferysung@gmail.com>
Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
2022-05-03 17:48:43 +00:00
Edwin Navarro d692bb74a6
Remove DAGNode deprecations (#7902)
* Remove DAGNode deprecations

* Remove name from DAGNode

* Remove unused import

* Add release note and put name getter and setter back

* Fix name setter and getter

* Remove DAGNode name getter and setter

* Update releasenotes/notes/remove-dagnode-deprecations-30703a2156d52b8a.yaml

Co-authored-by: Kevin Krsulich <kevin@krsulich.net>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-03 09:39:29 +00:00
Jim Garrison a3188f588a
Pass through `RAYON_NUM_THREADS` env var in `tox.ini` (#8011)
* `passenv` `RAYON_NUM_THREADS` in `tox.ini`

This allows setting the number of rayon threads used by tox by
passing through `RAYON_NUM_THREADS`, so that the user is not
required to also specify `TOX_TESTENV_PASSENV=RAYON_NUM_THREADS`.

* Update tox.ini

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

* Remove duplicate `OMP_`

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-03 01:04:53 +00:00
Jim Garrison 53db524a7e
Fix typo: [qasi -> quasi]-probability (#8012) 2022-05-02 20:35:15 +00:00
Matthew Treinish 49f39e3a6c
Fix instruction durations in transpile() with BackendV2 (#8001)
* Fix instruction durations in transpile() with BackendV2

When running transpile() with BackendV2 based backends the instruction
durations property from the backend would not be processed correctly
resulting in the absence of the default durations for instructions
supported on the target backend. This commit fixes this by correctly
handling BackendV2 based backends and using those instruction durations
by default for transpile().

* Update test/python/compiler/test_transpiler.py

Co-authored-by: Kevin Hartman <kevin@hart.mn>

Co-authored-by: Kevin Hartman <kevin@hart.mn>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-05-02 15:12:32 +00:00
dependabot[bot] 7505b1dc6c
Bump num-complex from 0.4.0 to 0.4.1 (#8008)
Bumps [num-complex](https://github.com/rust-num/num-complex) from 0.4.0 to 0.4.1.
- [Release notes](https://github.com/rust-num/num-complex/releases)
- [Changelog](https://github.com/rust-num/num-complex/blob/master/RELEASES.md)
- [Commits](https://github.com/rust-num/num-complex/compare/num-complex-0.4.0...num-complex-0.4.1)

---
updated-dependencies:
- dependency-name: num-complex
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-05-02 12:48:05 +00:00
Kevin Hartman ce4f94db6d
Fix `dt` units in test util function `convert_to_target` (#8000)
* Multilpy dt value by conversion factor when reading from conf file.

* Add simple test and release note.

* Update releasenotes/notes/fix-target-dt-4d306f1e9b07f819.yaml

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
2022-04-29 22:14:38 +00:00
Kevin Hartman 04807a13a7
Tweak probabilities in random equiv test. (#7992)
Previously, Hypothesis spent most of the test cycles adding
registers rather than useful instructions, and would in
fact skip running the equivalence test rule altogether,
so we'd pretty much expect testing to pass no matter
what.

This commit limits the number of classical and quantum
registers to 3 each (arbitrary) to increase the chances
of gate generation and invocation of the equivalence
transpilation rule.

The number of examples has also been increased from 25
to 200, which should vastly improve the coverage of
this test, at the expense of a longer runtime.
2022-04-27 22:34:20 +00:00
dlasecki 18b5a048ea
Trotterization-based Quantum Real Time Evolution (#7411)
* Introduced time evolution classes and interfaces.

* Migrated trotterization as trotterization builder.

* Implemented enum for trotterization mode; fixed imports.

* Implemented trotter_qrte.py with unit tests.

* trotter_qrte.py repetitions added.

* Code refactoring.

* Code refactoring.

* Gradient object introduced in a signature.

* Draft of trotter_qrte.py gradient with unit tests.

* trotter_qrte.py improvements; unit tests extended.

* trotter_qrte.py improvements; unit tests extended.

* Trotter test fix.

* Fixed float and complex handling.

* qrte with product formula

* Removed irrelevant files.

* Removed irrelevant files.

* Extended docs.

* Removed outdated unit tests.

* Removed outdated files.

* Code refactoring, docs extended.

* Code refactoring.

* Updated unit tests.

* Code refactoring, extended docs and typehints.

* Reno added.

* Extended checks and unit tests.

* Code refactoring.

* Code refactoring.

* fix problem with test

* Docs extended.

* Added support for PauliOp, code refactoring.

* Implemented general Quantum Time Evolution Framework interfaces.

* Updated docs.

* Reno added.

* Improved reno.

* Code refactoring.

* Update qiskit/algorithms/time_evolution/evolution_base.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Code refactoring.

* Introduced evolution problem classes.

* Code refactoring.

* Apply suggestions from code review

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Added unit tests.

* Lint fixed.

* Code refactoring

* Code refactoring

* Code refactoring

* Code refactoring

* Code refactoring

* Code refactoring

* Code review changes.

* Removed gradient code for now.

* Code review refactoring.

* Removed gradient code for now.

* Evolving observable removed. Evaluating observables added.

* Code refactoring.

* Improved naming.

* Improved folder structure; filled evolvers init file.

* Added Evolvers to algorithms init file.

* Fixed missing imports.

* Code refactoring

* Fixed cyclic imports.

* Extracted ListOrDict.

* Code refactoring.

* Code refactoring.

* Fixed release note.

* Fixed inheritance order.

* Updated code to the latest time evolution interface.

* Code refactoring.

* Code refactoring.

* Code refactoring.

* Fixed cyclic imports.

* Fixed pylint.

* Name fix.

* Import fix.

* Lint fix.

* Lint fix.

* Code refactoring.

* Extracted and refactored aux_ops_evaluator.py

* Code refactoring

* Implemented unit test.

* Extended unit test.

* Date fixed.

* Reno added.

* Switched to bound ansatz.

* Fix reno.

* Added docs.

* Refactored unit test.

* Lint fixed.

* Code review edits.

* Added unit test cases for dicts.

* Fixed reno reference.

* Improved unit test.

* Added quantum instance support.

* Added support for aux_ops and unit test.

* Fixed input object to eval_observables.

* Fixed quantum_state types and conversion.

* Fixed quantum_state types and conversion.

* Fixed types and docs.

* Code refactoring.

* Lint fix.

* Code refactoring.

* Reno update.

* Code refactoring.

* Implemented some CR feedback.

* evolution_problem.py fix

* Removed trotter_ops_validator.py for now, extended unit tests, code refactoring.

* Updated names of the algorithm.

* Added support for QuantumCircuit input. Code refactoring.

* Improved error handling in evolution_problem.py and unit tests added.

* Code refactoring.

* Cyclic import fix

* Refactored evolution_problem.py

* Refactored test_trotter_qrte.py

* Removed global tolerance.

* CI fix.

* Code review fixes.

* Code refactoring.

* Prepared qasm unit test.

* Removing state eval.

* Refactored and updated tests.

* Added qasm test for aux ops.

* Added param binding test.

* Added missing setters.

* Updated unit tests.

* Improved folder structure.

* Updated interfaces.

* Fix lint.

* Removed legacy (soon) BaseBackend.

* Updated copyright years.

* Added example to reno.

* Fixed reno.

* Removed BaseOperator.

* Code refactoring.

* Imports fix.

* Delayed parameters checks.

* Update qiskit/algorithms/evolvers/evolution_problem.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Code refactoring.

* Update qiskit/algorithms/evolvers/evolution_problem.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Update qiskit/algorithms/evolvers/trotterization/trotter_qrte.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Update qiskit/algorithms/evolvers/trotterization/trotter_qrte.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Update qiskit/algorithms/evolvers/trotterization/trotter_qrte.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Update qiskit/algorithms/evolvers/trotterization/trotter_qrte.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Update qiskit/algorithms/evolvers/trotterization/trotter_qrte.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Update qiskit/algorithms/evolvers/trotterization/trotter_qrte.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Update qiskit/algorithms/evolvers/trotterization/trotter_qrte.py

Co-authored-by: Julien Gacon <gaconju@gmail.com>

* Expectation might be None

Co-authored-by: acv@zurich.ibm.com <acv@zurich.ibm.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
2022-04-27 08:26:14 +00:00
Matthew Treinish 7e83de6d80
Add VF2PostLayout pass (#7862)
* Add VF2PostLayout pass

This commit adds a new transpiler VF2PostLayout and adds a new
phase/model to the preset transpiler pipeline post-layout/qubit
selection. The idea is based on the mapomatic project [1] which
took the code from the existing VF2Layout pass to find an isomorphic
subgraph in the coupling graph after transpilation which had better
noise characteristics than those initial selected as part of the initial
layout phase. Doing post transpile qubit selection provides the pass
more information because we can assume that the circuit's operations are
in the target basis and that there is at least 1 subgraph already in the
coupling graph because we've gone through routing. This enables us to
look at the specific error rates for each instruction and weigh the sum
of error rates for the mapped circuit on each potential qubit mapping to
find the best performing set of qubits for a given circuit. Initial
layout doesn't have access to this information because at the beginning
of the circuit we aren't necessarily going to find a perfect mapping and
we're not guaranteed to be in the target basis. So running post layout
may yield quality improvements even if we found an initial perfect
layout using VF2Layout.

While this new pass is very similar to VF2Layout pass as it builds an
interaction graph representing the 2q interactions in the circuit and
uses retworkx's vf2_mapping() function to find all isomorphic subgraphs
in the coupling graph it behaves diffferently. This is a separate pass
because it performs the search a bit differently. First the interaction
graphs are annotated with the gate counts on each qubit and edge which
is used to completely apply a heuristic score to the circuit and secondly
in the case of a target we verify the nodes and edges are feasible in the
subgraph isomorphism check since a target can have operations defined on
a subset of bits. Additionally the scoring heursitic checks the
sum of the error rates for each gate on the mapped qubits.

The preset pass managers are updated to use this new pass at the end of
the transpile and apply a layout if a solution is found.

[1] https://github.com/Qiskit-Partners/mapomatic

* Fix matching callback function

The matching callback function had a typo so it was always returning
True on edge comparisons even if the target coupling graph edge was not
a superset of the local gates in the interaction graph. This commit
fixes the oversight so such cases are correctly rejected as a viable
subgraph isomorphic graph.

* Fix lint

* Add back removed ancillas to layout

If we find a a better layout using post layout and there are ancillas in
the original layout those would previously be lost. This commit fixes
this by detecting when we're missing qubits in the new layout and adding
the ancillas on unused qubits in the coupling graph.

* Move VF2PostLayout before scheduling

Applying a new layout after we schedule a circuit would invalidate
that scheduling. This commit moves the post layout pass to run prior
to scheduling in the preset passmanagers.

* Fix docs

* Drop max_trials and rely solely on time

* Fix ancilla handling

* Restore original virtual bits and registers

This commit modifies the ApplyLayout pass to enable slightly altered
behavior when applying a post layout ontop of a circuit that's already
had a layout applied. Previously we overwrote the layout and apply
layout just blindly applied the layout, this caused us to lose the
original bit and register context as that only exists as metadata
in the property set's layout field. To ensure we preserve the mapping
from the initial virtual bits through our second round of layout apply
layout is modified to handle doing this mapping for us by passing the
new layout separately as a new field in the property set.

* Only run post layout if no manual layout options are set

If initial_layout or layout_method are set in transpile() do not run
post layout as this will produce unexpected results for users. If you're
manually specifying a layout method that should be what is used only and
we shouldn't do any other reordering to try and optimize beyond what the
user requested.

* Only run VF2PostLayout if there are connectivity constraints in the target

* Adjust cost function to no be a sum of error rates

* Update tests that check exact layout

After introducing VF2PostLayout the output layout of the circuit is
potentially different depending on the noise characteristics of the
target backend. This was causing test failures on tests that were
explicitly checking for an exact layout output from transpile. This
commit updates the expected layouts in those tests to match the new
behavior of the transpiler. Most of these tests were actually already
using VF2Layout to find a perfect layout, but with vf2layout the
transpiler is finding an alternative layout post optimization which has
better noise characteristics for the circuit being run.

* Fix lint

* Fix typo in target node/edge match function

This commit fixes a typo in the node/edge match function used in
matching a subgraph to a target over valid operation names. Previously
the reverse condition check was incorrectly checking that the target
operations on a 2q edge were a subset of the circuit operations when it
should have been checking the reverse condition. This commit fixes this
oversight.

* Add release notes

* Add tests

* Update release notes

* Fix typos in release notes

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

* Add strict_direction flag to pass

This commit adds a new flag, strict_direction, which can be used to do
an isomorphic match on undirected graphs and use an avg 1q and 2q error
rate for each qubit for scoring.

* Move VF2PostLayout to right after routing in preset passmanagers

This commit moves the VF2PostLayout run to right after the routing phase
in the preset passmanagers. This lets us set the strict_direction flag
to False which expands the search space to ignore 2q gate
directionality which will potentially find better mappings.

* Updated expected test layout for v2 failing test case

* Fix doc issues

Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-26 23:45:55 +00:00
Harshit Gupta 74e0711906
Improve scaling and performance of `Optimize1qSimpleCommutation` (#7913)
* change adjoining_run logic

* change insert to append and remove assertion

* use deque to optimize deletion

* remove copy and change condition

* add deque for commuted
2022-04-26 17:21:31 +00:00
ewinston 48306bda79
add Quantum Shannon Decomposition (#7907)
* pass tests, lint

* black

* Update qiskit/quantum_info/synthesis/qsd.py

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

* add some documentation

* modify ucry with cz gates

* add release notes. remove unimplmented keyword option.

* remove opt_a2

* remove uneeded import

* add reference to paper

* make demultiplex private.

* remove QuantumShannonDecomposer class.

* Update qiskit/quantum_info/synthesis/qsd.py

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

* Update qiskit/quantum_info/synthesis/qsd.py

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

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: Ali Javadi-Abhari <ajavadia@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-26 00:59:06 +00:00
Jake Lishman 27ef0d6c7e
Update randomised transpiler-equivalence test strategies (#7980)
This commit updates the strategies used to do the randomised testing of
transpiler equivalence, having three main effects:

1. The "pre-transpilation" circuit is now run on an Aer backend without
   any transpilation at all, making the test truer to its name.
   Previously `execute` was used which secretly performs a transpilation
   internally.  This was accompanied by a small change to the set of
   gates, to ensure only those that are directly supported by Aer are
   used.

2. The strategies used for drawing gates are simplified into (mostly) a
   single rule that draws a gate from a set, and populates it.  This is
   just tidying up - it unifies the logic for drawing a gate into one
   strategy rather than several.

3. The tests are updated to avoid using deprecated behaviour (e.g.
   back-referencing a register from a bit) or features (e.g. various old
   gate classes, and the old Aer `qasm_simulator`).

Point 1 in this list is also a fix to recent randomised testing
failures; since the tests were updated in ff4ee1b to call `backend.run`
directly (rather than `execute`) in the second run of each circuit,
when Hypothesis was drawing `None` as the backend in conjunction with a
gate Aer didn't know how to simulate (e.g. `CRZGate`), Aer would raise
an exception.  Previously this behaviour was hidden by the internal call
to `transpile` inherent in `execute`, and was a logic error in the test
suite, rather than in Terra.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-25 18:00:58 +00:00