Commit Graph

6331 Commits

Author SHA1 Message Date
ewinston 4211b5bcb0
Support control flow in Unroller transpiler pass (#7768)
* create two tests and 1st modification of unroller

* if_else test, parameter test

* black

* linting

* change shallow copy of control flow ops to not copy body

* add special copy

* add `replace_blocks` method

* minor commit

* linting

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-25 15:00:00 +00:00
Jake Lishman 446af33983
Fix order of input and gate declarations in QASM 3 exporter (#7972)
The current reference grammar requires that inputs and outputs are
defined before any gate declarations, so previously exported OpenQASM 3
programmes could fail to parse with the reference implementation.  It is
likely that the ordering is an arbitrary restriction and can be removed
from the grammar, but for the time being, we ought to match what is
written.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-24 17:30:55 +00:00
Slavikmew bde2e03602
Fix bug in TridiagonalToeplitz.eigs_bounds() method (#7968)
* Fix a bug in TridiagonalToeplitz.eigs_bounds() method, which has been
causing a returning of wrong eigenvalues bounds in some cases with negative
eigenvalues

* fix codestyle for passing CI + add reno description

Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-22 14:05:08 +00:00
Daiki Murata 6aacabd991
Alias BaseOperator.__matmul__ to BaseOperator.dot (#7919)
* overloading @

* rewrite tests

* add note

* add release note

* update release note

* Revert "rewrite tests"

This reverts commit 3cf3b6b40b.

* add test to "test_dot"

* reset incorrect change

* add test

Co-authored-by: Ikko Hamamura <ikkoham@users.noreply.github.com>
2022-04-22 00:56:58 +00:00
Jake Lishman 4f2fd2d55c
Fix sdist build and deployment (#7973) 2022-04-21 22:20:26 +00:00
Jake Lishman fefeacce65
Add delay handling to QASM 3 exporter (#7942)
This simply adds the additional special-case needed to handle the
built-in delay instructions for OpenQASM 3.  We have to take care when
dealing with `ps`, which is a supported unit by Terra but not by OQ3.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-21 19:06:36 +00:00
Jake Lishman f414273faf
Fix potential infinite loop in SabreSwap (#7970)
* Fix potential infinite loop in SabreSwap

This adds a "release valve" mechanism to `SabreSwap`, so that it will
always eventually make forwards progress and terminate the run.  Before
this commit, it was possible for certain pathological circuits
(see `looping_circuit` in `test/python/transpiler/test_sabre_swap.py`
for an example) to get stuck in a stable local minimum of the
'lookahead' or 'decay' heuristics (no matter the weightings).

The release mechanism is done with very small per-loop overhead for the
vastly more common good paths; we simply count how many iterations we
have been through since we made progress, and the minimum weight in the
coupling map to be overcome to make progress again.  Once the
number of iterations without progress exceeds some value, we backtrack
(inefficiently, because this is the bad path) to the last time we made
progress, and forcibly insert swaps to bring the nearest gate together.
We then continue like normal.

There are also a few minor optimisations in this commit that prevent
recalculating sets that we already know; `extended_set` is fixed by
knowledge of the `front_layer` if the DAG isn't (meaningfully) changed,
so there's no need to recalculate it on each loop.

* Reduce depth of greedy swap insertion

* Add link in release note

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

* Remove extra keyword argument in SabreSwap constructor

The `max_iterations_without_progress` value was originally exposed to
users via the constructor.  It was added because I thought I'd need a
way to force the backtracking algorithm to occur to test the behaviour.
When I wrote the tests, I ended up using Aer to find the keys, which is
sufficiently fast that we can verify validity using the regular infinite
loop circuit, and the argument is unnecessary.  It was highly unlikely
to actually be useful in real applications, so it does not need to be
added.

* Remove useless return from _add_greedy_swaps

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
2022-04-21 16:00:56 +00:00
Jake Lishman dde6126e8d
Deprecate old paths for module-availability testers (#7954)
The canonical location for all of these is `qiskit.utils.optionals`,
along with all the other import testers.  Historically these objects
were available from `qiskit.visualization` just because they were reused
in several places within that module, and now a few downstream packages
have begun importing from there.  The alternate path was made available
in Terra 0.20.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-20 22:49:19 +00:00
Daniel J. Egger eb60d95d29
Add swap strategies transpiler pass (#7813)
* * This pull requests adds the swap strategies, i.e. a class of layerized swap gates,
  and the corresponding transpiler passes to apply them on block of pauli evolution
  gates where all gates in the Pauli evolution op commute.

* * Module init doc.

* polish docs

* * renamed CheckCommutingEvolutions to FindCommutingPauliEvolutions

* * Removed sparse pauli op check.

* * use ddt in tests

* * Too short line test.

* * Added repr test.

* * Added comment on copy

* * Fix test

* Update qiskit/transpiler/passes/routing/swap_strategies/evolution_commutation_analysis.py

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>

* Apply suggestions from code review

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>

* Update qiskit/transpiler/passes/routing/swap_strategies/swap_strategy_router.py

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>

* Update qiskit/transpiler/passes/routing/swap_strategies/swap_strategy_router.py

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>

* * Refactored missing_couplings

* * Removed composed_permutation.

* * First part of refactor.

* * First version that works.

* * Black.

* * Make test more robust.

* * Test exclude.

* * Black and docs.

* * Lint

* * Updated reno.

* * Use copy empty like.

* * PR -> module in docstring.

* * Renammed Commuting2QBlocks to Commuting2qBlocks

* * Remove Commuting2qBlocks from the module init

* * Enforce no clbit in Commuting2qBlocks.

* * Made pauli to edge more robust.

* * Made single_qubit_terms_only more robust.

* * Removed unneeded check on coefficient.

* * remove str usage in _decompose_to_2q

* * Removed list conversion in Commuting2qBlocks

* * Renamed missed_edges to missing_couplings

* * Removed LineSwapStrategy in favour of a class method.

* * Added inplace argment to apply_swap_layer.

* * Made the distance matrix an array.

* * Fix list comprehension.

* * Removed __instruction_type__

* * Changed input swap strategies to tuple.

* * Removed _get_nodes_to_decompose

* * Fix typo

* * Made _position_in_cmap O(1).

* * removed register in _check_edges.

* * Removed register in _make_op_layers.

* * Docs, lint, and black.

* * Docs.

* * Updated reno.

* * Make sure a layer does not apply swaps on more than one qubit.

* * Changed circuit initialization in swap_decompose.

* * black

* * Small test fix.

* Update releasenotes/notes/swap-strategies-3ab013ca60f02b36.yaml

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

* Update qiskit/transpiler/passes/routing/swap_strategies/commuting_2q_block.py

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

* Update qiskit/transpiler/passes/routing/swap_strategies/commuting_2q_block.py

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

* * from_line and typing.

* * Added SwapStrategyRouter and SwapStrategy to the __init__'s

* * Renamed SwapStrategyRouter to Commuting2qGateRouter

* * Renamed file

* * SwapStrategy docstring.

* black

* * Docs

* Update qiskit/transpiler/passes/routing/swap_strategies/swap_strategy.py

Co-authored-by: Luciano Bello <bel@zurich.ibm.com>

* * Added a test with a ccx gate.

* * Fix docs

* * Black

* * fix typo in test.

* * ccx test fix.

* * dag.qubits, *dag.qregs.values() fix

* * Second layout fix.

* * Removed reaches_full_connectivity

* * Simplified the way missing coupling are computed.

* * Revereted the dag.qubits suggestion

* * Added conditions on registers.

* Skip instantiation errors in `test_to_matrix_op`

We don't generally care if the gate fails to instantiate in this
particular test; that's caught by other stuff, and this test is just for
gates that have "regular" free parameters.

* Fix cyclic imports

* Skip on TypeError in other test

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Luciano Bello <bel@zurich.ibm.com>
Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
2022-04-20 14:14:52 +00:00
Kevin Hartman b2f0964f2c
Add uniformly controlled rotations to docs. (#7960)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-20 02:23:06 +00:00
Matthew Treinish ad4283eefa
Remove legacy providers interface (#7886)
* Remove legacy providers interface

This commit removes the legacy providers interface from terra. This
includes the BaseBackend, BaseJob, BaseProvider abstract classes and
everything that inherits from them in the tree. These classes were
deprecated as part of qiskit-terra 0.18.0 and have been supersceded by
the versioned provider interface and all providers should have migrated
by now to these new supported interface. This also means we no longer
support the qobj execution path and QuantumCircuit and Schedule objects
are used directly everywhere for running. In the future we can look at
deprecating and removing the assemble() function and qobj class in the
future as nothing in tree is using them directly. But before we can
deprecate these the IBM provider and aer will need to have native
implementations.

* Drop handling for incorrect backend.version in BaseBackend

Now that BaseBackend is no longer in qiskit we don't need to special
handle the case where backend.version is not the interface version
(since it was a method in BaseBackend). This commit drops the handling
for this and uses the interface for the versioned interface as it was
originally intended.

* Fix lint

* Fix typo causing test failures

The tests were failing because one of the default values for getting the
backend version attribute was None instead of 0 causing a type error
when an integer was expected. This was not caught previously because the
BaseBackend handling checked for non integer versions and converted
those to 0. However, now without BaseBackend we need to be more explicit
and use an integer for the backend interface version.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-19 23:46:29 +00:00
Jake Lishman 6138ac5f1d
Swap old networkx usage to retworkx (#7958)
Since NetworkX 2.8, calling `networkx.adjacency_matrix` issues a
FutureWarning that causes the documentation build to fail.  There's no
reason for us to be using `networkx` since we have `retworkx` now.
2022-04-19 22:29:19 +00:00
Jake Lishman 38f3705d5f
Make SabreSwap account for clbits in predecessors (#7952)
* Make SabreSwap account for clbits in predecessors

Previously, SabreSwap only checked that it was valid to add a gate back
to the DAG by ensuring that all its qubit predecessors had already been
added to the DAG.  It did not check for clbit successors.  This meant
that measurements and (potentially, unverified) classically conditioned
gates could be re-ordered out from the correct topological ordering.

The most notable effect of this was that measurements writing to the
same bit could be re-ordered, changing the output of the circuit.

See gh-7950 for more detail.

* Add reno

* Fix lint

* Trim fat in SabreSwap._successors

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

* Fix _successors method

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
2022-04-19 19:57:41 +00:00
Kevin J. Sung 5012ee1964
Fix XXPlusYYGate documentation (#7918)
* fix XX+YY gate doc

* fix doc and add test of exponential formula

* lint test

* add note that gate definition will change in next Qiskit version

* fix qubit order

* Add issue release note

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
2022-04-19 17:58:47 +00:00
Luciano Bello aee0dc4d53
Add some explanation and example to circuit library documentation (#7354)
* Add some explanation and example to circuit library

* remove BooleanExpression

* missing gates

* standard and directives

* title mod

* generalized gates

* boolean logic circuits

* Basis Change Circuits and Arithmetic Circuits

* section Amplitude Functions is duplicated. (maybe a bad merge in #5142?)

* N-local and feature map

* dup entry

* Template circuits

* ups

* line too long

* address https://github.com/Qiskit/qiskit-terra/pull/7354#discussion_r792019550

* addressing https://github.com/Qiskit/qiskit-terra/pull/7354#discussion_r792020166

* addressing https://github.com/Qiskit/qiskit-terra/pull/7354#discussion_r792047022

* Update qiskit/circuit/library/__init__.py

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

* import to address https://github.com/Qiskit/qiskit-terra/pull/7354#discussion_r792049584

* Update qiskit/circuit/library/__init__.py

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

* Update qiskit/circuit/library/__init__.py

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

* addressing https://github.com/Qiskit/qiskit-terra/pull/7354#discussion_r792078771

* Update qiskit/circuit/library/__init__.py

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

* Update qiskit/circuit/library/__init__.py

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

* Update qiskit/circuit/library/__init__.py

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

* Update qiskit/circuit/library/__init__.py

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

* Update qiskit/circuit/library/__init__.py

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

* Apply suggestions from code review

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

* directives

* pretty colors

* undo changes in standard_gates/__init__.py

* operations

* Update qiskit/circuit/library/__init__.py

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

* Update qiskit/circuit/library/__init__.py

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

* Apply suggestions from code review

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

* Apply suggestions from code review

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

* example

* Update qiskit/circuit/library/__init__.py

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

* Fix Sphinx errors

* Fix duplicate definitions and indentation

* Fix typo

Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: Matthew Treinish <mtreinish@kortar.org>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-19 15:02:26 +00:00
Matthew Treinish 57f16ab61a
Store simulator Backend in FakeBackend instance (#7912)
* Initialize simulator at FakeBackend inititialization

This commit updates the FakeBackend and FakeBackendV2 classes
(FakeLegacyBackend is being removed in #7886) to only build a noise
model from the stored properties one. This is done by initializing the
internal simulator object only once at storing it as an instance
attribute. The noise model is then constructed once at object
initialization and used to update the backend at the same time.

Fixes #7500
Fixes #7911

* Lazy load simulator backend objects and properties

This commit fixes another regression introduced in the previous commit
around the import and __init__ performance of fake backends. By parsing
the properties payload and creating a noise model we significantly
slowed down the initialization of fake backend objects. This commit
fixes this by ensuring we are lazy loading the noise model and simulator
object creation as well as not parsing the properties (or defaults)
payloads until we actually need them.

* Use qubit properties in target for backendv2

* Filter all noise model warnings

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-19 01:39:41 +00:00
Matthew Treinish a4edc11877
Update docstrings for renamed scheduling passes (#7884)
* Update docstrings for renamed scheduling passes

In #7835 we renamed the passes used in the new scheduler pass workflow
to differentiate them from the existing legacy scheduling pass workflow
(which we restored pending a future deprecation in that PR). However,
while we updated the docstring for the legacy path to update them to
point to the new passes, we neglected to update the docstrings for the
renamed classes to reflect the new names. The examples in the docstrings
still worked because of the old passes, but it wasn't showing an example
of how to use the new workflow anymore. This commit corrects this
oversight so that they actually explain how to use them.

* Add scheduling section to top level transpiler doc

* Update reference

* Fix lint

* Fix typos

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

* Apply suggestions from code review

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

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>
Co-authored-by: Kevin Hartman <kevin@hart.mn>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-19 00:09:42 +00:00
upsideon ef997f9ba2
Ensuring instruction labels are strings when provided to the Instruction constructor. (#7671)
* Fixes #7667 by ensuring that instruction labels are strings when provided to the Instruction constructor.

* Optimizing speed of instruction label type checking.

* Switching to an equality rather than reference check for instruction labels.

* Adding a release note for label type checking on creation.

* Use Sphinx cross-ref in release note

* Fix release note

* Add ctrl_state to non-parameter kwargs

Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
2022-04-18 22:59:18 +00:00
Kevin Hartman ff4ee1bb72
Improve transpiler coverage of randomized equivalence test (#7945)
* Improve transpiler coverage of randomized equivalence test.

Chooses layout, routing, and scheduling methods to use when invoking
transpile. This way, preset pass manager behavior with designated
transpilation method combinations is covered.

To support scheduling method coverage, a filter list is introduced to
exclude any fake backends that do not provide the necessary information
for instruction scheduling (i.e. gate durations).

Secondarily, this test is now configurable via enviroment variables,
the intention of which is to ultimately make it easy for transpiler passes
living outside of Terra to run equivalence tests in their own CI pipelines
to ensure proper Terra integration. For now, this has limited utility,
since neither layout, routing, nor scheduling methods can be used with
`transpile` unless Terra already knows about them. In the near future,
[qiskit-toqm](https://github.com/qiskit-toqm/qiskit-toqm) is a planned
integration for Terra, but will be excluded from Terra's randomized
equivalence test CI pipeline since it lives externally. To provide
coverage, it'll use its own CI pipeline to invoke this test with
environment variables that exercise it sufficiently. This should be even
more useful in the future, should the transpiler support a more
plugin-oriented architecture.

The following changes have been made to support the above:

The hypothesis profile can now be changed via the built-in
hypothesis environment variable, HYPOTHESIS_PROFILE. Note that the
named profile must first be registered through some means
(e.g. conftest.py). See the following for details:
https://hypothesis.readthedocs.io/en/latest/settings.html#settings-profiles

This test can now be optionally configured (e.g. by CI) via the
following env vars:

QISKIT_RANDOMIZED_TEST_LAYOUT_METHODS

  A space-delimited list of layout method names from which the
  randomizer should pick the layout method. Defaults to all
  available built-in methods if unspecified.

QISKIT_RANDOMIZED_TEST_ROUTING_METHODS

  A space-delimited list of routing method names from which the
  randomizer should pick the routing method. Defaults to all
  available built-in methods if unspecified.

QISKIT_RANDOMIZED_TEST_SCHEDULING_METHODS

  A space-delimited list of scheduling method names from which the
  randomizer should pick the scheduling method. Defaults to all
  available built-in methods if unspecified.

QISKIT_RANDOMIZED_TEST_BACKEND_NEEDS_DURATIONS

  A boolean value (e.g. "true", "Y", etc.) which, when true, forces
  the randomizer to pick a backend which fully supports scheduling
  (i.e. has fully specified duration info). Defaults to False.

QISKIT_RANDOMIZED_TEST_ALLOW_BARRIERS

  A boolean value (e.g. "true", "Y", etc.) which, when false,
  prevents the randomizer from emitting barrier instructions.
  Defaults to True.

* Address review comments.

* Address additional review comments.
2022-04-18 20:21:35 +00:00
Luciano Bello ff421fdbae
Grover class crosslinks note to tutorials and textbook (#7924)
* Grover: A note crosslinking to textbook and tutorials

* Grover: A note crosslinking to textbook and tutorials

* Update qiskit/algorithms/amplitude_amplifiers/grover.py

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

* link

* link

* Update qiskit/algorithms/amplitude_amplifiers/grover.py

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

* Fix formatting

Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
Co-authored-by: Jake Lishman <jake.lishman@ibm.com>
2022-04-18 16:02:29 +00:00
Jake Lishman 618e0ea8b3
Revert "Workaround Aer bug with subnormal floats in randomised tests (#7719)" (#7946)
Since Aer 0.10.4 is now released with corrected handling of subnormal
floating-point numbers when compiled with gcc, this commit is no longer
necessary.

This reverts commit 77219b5c7b.
2022-04-16 01:30:28 +00:00
dependabot[bot] 1c5ed4726c
Bump pyo3 from 0.16.3 to 0.16.4 (#7943)
Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.16.3 to 0.16.4.
- [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.3...v0.16.4)

---
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-04-15 14:02:46 +00:00
Matthew Treinish 46accafbfe
Set sphinx-build --keep-going by default (#7940)
* Set sphinx-build --keep-going by default

For sphinx builds we set the -W flag to treat warnings as errors. This
however, has the unfortunate side-effect of exiting the sphinx build
on the first warning and in the typical documentation debugging
workflow multiple iterations are required to debug all the issues. This
commit adds the --keep-going sphinx-build flag [1] to the default build
options. The --keep-going flag will still treat warnings as errors, but
not exit the build early. This should hopefully improve the
debuggability of the documentation as we'll get a complete picture of
what's wrong with a build instead of having to deal with it one warning
at a time.

[1] https://www.sphinx-doc.org/en/master/man/sphinx-build.html#cmdoption-sphinx-build-keep-going

* Add -T for full tracebacks to docs build

* Set options on tutorials builds too

* Revert tutorials changes

The tutorials are actually throwing warnings which are an upstream issue
in the qiskit-tutorials repo. Before we can start running with -W on the
tutorials job we need to do it on the qiskit-tutorials repo first before
we can apply it here. This commit reverts the job configuration change
for the tutorials job until that happens.
2022-04-15 01:28:43 +00:00
Matthew Treinish 2f182f6830
Fix QPY deserialization of UCRX, UCRY, and UCRZ gates (#7933)
This commit fixes the deserialization of the UCRX, UCRY, and UCRZ gates.
These gates aren't constructed in the standard way as other gate objects
where the parameters are passed directly as args to the class
constructor. Instead they behave the same as Initialize and the params
are passed as a list to the constructor to make a new gate object. This
commit fixes the handling in deserialization to treat these gates the
same as Initialize so that it can be properly deserialized by
qpy.load().

Fixes #7847

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-14 18:54:54 +00:00
Matthew Treinish 36a3d9620b
Update qiskit_bot regex for rust file change trigger (#7929)
* Update qiskit_bot regex for rust file change trigger

This commit updates the regex path trigger used for qiskit-bot's
reviewer notification for changes to rust source files. The intent of
the regex was to match any path ending with .rs which indicates it was a
rust source file. However, the regex was overly broad and would match
any file that had rs in it as was recently found in #7924. [1] This
commit fixes this by making the regex more specific, it also adds an or
condition to trigger on changes to Cargo files in the root of the repo
which are the build configs for the rust code.

[1] https://github.com/Qiskit/qiskit-terra/pull/7924#issuecomment-1096900294

* Add notification trigger for visualizations

In code review enavarro51 asked to be added to the notification list
for changes to the visualization (excluding the pulse drawers). This
commit adds a new notification regex key to do this and will notify him
on PRs that touch these files.

* Add missing @

Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-14 17:07:19 +00:00
Naoki Kanazawa b074d7a942
fix amplitude limit test (#7931)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-14 16:08:00 +00:00
Matthew Treinish 4463ac33c6
Fix dag visualization for DAGCircuits without registers (#7923)
* Fix dag visualization for DAGCircuits without registers

This commit fixes the handling of generating visualizations for
DAGCircuit objects that have standalone bit objects. Previously, the
dag_drawer() function was assuming every bit in the dag was a member of
a register. In the case of circuits with standalone bits this is not the
case and would result in a KeyError being raised when the register was
attempted to be used to generate a string label for the node or edge
in the visualization. This fixes this by still using registers if
present, but in the absence of a register it fallsback to using it's
absolute index in the dag to generate a similar label. For example, the
4th qubit will have the label "q[4]" in the output visualization.

Fixes #7915

* Adjust default label from q[0] to q_0

This commit changes the default fallback label when no register match is
found to be of the form q_0, where 0 is the qubit index. This was done
to avoid potential confusion with a register named q which might be in
the circuit and not the first element in the qubits list.

* Add release note

* Add test

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-14 15:01:43 +00:00
dependabot[bot] 0e61992920
Bump rayon from 1.5.1 to 1.5.2 (#7936)
Bumps [rayon](https://github.com/rayon-rs/rayon) from 1.5.1 to 1.5.2.
- [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/commits)

---
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>
2022-04-14 12:36:07 +00:00
Jake Lishman fd46fd154f
Overhaul Azure Pipelines configuration (#7698)
* Overhaul Azure Pipelines configuration

This restructures our monolithic `azure-pipelines.yml` file into a
modular setup that separates the logic of specifying "what to run" from
"how to run".  For example, the different processes for running the
Python tests on Linux, Mac and Windows are separated out into three
template files, which are then called by the "branch push" and "PR sync"
pipeline files in a few different stages.  This is also to centralise
the logic for "how to run"; previously, it was duplicated in a few
different stages.

There are also major changes to content of "what to run".

    Branch push:
        This now only runs a single Linux test, just as a sanity check.
        Previously it ran the full PR CI suite, including lint, docs,
        tutorials, and the entire Python testing matrix.  This was
        unnecessary, as the branch protection rules and PR merge
        strategy ensured that the code must already have been up-to-date
        and passed the PR CI before it could be pushed to the branch, so
        was simply burning CI resources for no benefit.  To the best of
        my knowledge, the branch-push CI had never caught a bug.

    PR sync:
        This remains split into two stages, but now only the oldest and
        newest Python versions are tested, rather than the entire
        matrix.  It is exceedingly rare (I'm not sure it's ever
        happened) that a commit breaks an intermediate Python version
        _only_, so instead we add a new "nightly" CI run to test the
        full matrix, which should be sufficient to catch these.  The
        "preliminary" stage is reduced to lint, docs and a single test
        run; about half of PR commits cause a CI failure, and over 90%
        of these would be caught by the new structure.  The second stage
        contains the tutorials and the rest of the
        `{oldest,newest},{windows,mac,linux}` matrix.  This is to reduce
        total CI load, with the intent that failing runs should almost
        universally fail just as quickly as they did before.

    Nightly:
        Entirely new.  This is tests of the full matrix of Python
        versions and OSes for the `main` and `stable` branches, if a
        given branch was updated since the last run.  It should be very
        unlikely that this run catches errors.

    Tag push:
        The deployment process is unchanged, just refactored into a
        format for easier management.

* Refactor split pipelines into single entry point

This maintains the same logical splits as the previous commit, but
rather than using four separate pipeline files, it uses template
conditional compilation to put them in a single large file.  This lets
us keep continuity with our current Azure setup, and lets us easily
share a series of configuration variables (including a general YAML
object) between the different stages.

This commit swaps from using a `strategy: matrix` in the test jobs, in
favour of using templated loops over the variables from the main
`azure-pipelines.yml` file.  This is because passing strings like
`"3.10"` contained within YAML arrays from one template file to another
appears to trigger some sort of implicit conversion somewhere, and
`"3.10"` can be interpreted as `3.1`.

* Leave comment on nightly testing failure

* Reinstate autocancel

* Quote string parameters

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

* Split long environment variable

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

* Add more comments on YAML syntax

* Add option to install from sdist in Linux tests

Co-authored-by: Kevin Hartman <kevin@hart.mn>
2022-04-13 19:45:37 +00:00
Jim Garrison d9a6f0bb42
Allow `shots` to be a `numpy.int64` (#7824)
* Allow `shots` to be a `numpy.int64`

I've noticed that the Aer backends, all work properly if the `shots`
count is passed as a `numpy.int64`, but the BasicAer and hardware
backends both fail in this case.  The simplest way to make it work
on all backends is by making this change in terra, inspired by #4591.

* Allow shots to be either an int or a numpy.integer, explicitly

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-13 14:43:03 +00:00
Matthew Treinish a735680f69
Deprecate networkx converter methods for DAGCircuit (#7927)
* Deprecate networkx converter methods for DAGCircuit

This commit deprecates the to_networkx and from_networkx converter
methods for DAGCircuit and DAGDependency. These methods were originally
added around the time we moved to use retworkx as our graph library to
build internal graph objects. Since that time our dependence on retworkx
has grown and retworkx has also matured. At this point the support for
the converter functions isn't really there and as recent issues have
shown it's a lossy conversion. Moving forward we don't need to support
this code path anymore and it will also remove our optional dependency
on networkx.

* Add release note

* Remove multi_graph attribute from DAGDependency

* Drop intersphinx config as it's not needed now

* Fix missing comma

Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-12 21:50:59 +00:00
Naoki Kanazawa 8e45a3bb95
Bug fix for DRAG pulse beta validation (#7925)
* fix DRAG pulse validation bug

* avoid wrong backend cache
2022-04-12 19:43:55 +00:00
Tobias Kehrer c90c176382
Correcting documentation of Drag/LiftedDrag (Qiskit#7659) (#7856)
* Correct documentation of Drag/LiftedDrag

As discussed in qiskit-terra issue #7659, the definition of the LiftedDrag pulse was not consistent with its implementation in qiskit.pulse.library.continuous.py.
One error is fixed by this PR.
A remaining problem is the explicit definition of the sampler strategy. This should be fixed after/with the update of parametric pulses, qiskit-terra issue  #7821.

* Implement review update of #7856

- Removal of f'(x)
- Added definition of g'(x)
- Typos corrected 'gaussian' -> 'Gaussian'
- Link to `qiskit.pulse.library.Gaussian` added

* Fixing linting errors #7856

Fixed the linting errors (line too long) in lines 353, 356, and 358 of qiskit/pulse/library/parametric_pulses.py.

* Replace URL link to Gaussian

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

* Removal of trailing whitespace in line 357

Moved link to Gaussian via :class: from line 358 to 357.

Co-authored-by: Naoki Kanazawa <nkanazawa1989@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-12 04:44:05 +00:00
Luciano Bello 5371cd23eb
remove ENHANCEMENT_REQUEST template (#7917) 2022-04-12 00:08:59 +00:00
Anthony-Gandon d8b4fdc10f
Add support for non-hermitian operators in AerPauliExpectation (#7857)
* Added support for non-hermitian operators in AerPauliExpectation

Fixes #415

QEOM creates a dictionary of operators to evaluate on the groundstate.
When using the noisy simulators (qasm_simulator or aer_simulator), one
could either use PauliExpectation (with noise) or AerPauliExpectation
(without noise). PauliExpectation works with non-hermitian operators
but internal methods of AerPauliExpectation raised an Error.
This is a workaround to this limitation.
Note that using include_custom=True on qasm allows the VQE to use a
local AerPauliExpectation without using the "expectation" input.
This does not apply to QEOM and one should explicitly define the
"expectation" input of the VQE for it to apply globally.

* Added support for non-hermitian operators in AerPauliExpectation

Fixes #415

QEOM creates a dictionary of operators to evaluate on the groundstate.
When using the noisy simulators (qasm_simulator or aer_simulator), one
could either use PauliExpectation (with noise) or AerPauliExpectation
(without noise). PauliExpectation works with non-hermitian operators
but internal methods of AerPauliExpectation raised an Error.
This is a workaround to this limitation.
Note that using include_custom=True on qasm allows the VQE to use a
local AerPauliExpectation without using the "expectation" input.
This does not apply to QEOM and one should explicitly define the
"expectation" input of the VQE for it to apply globally.

* Add a test case for non-hermitian operators.

* Add a test case for non-hermitian operators.

* Add a test case for non-hermitian operators.

* Update test/python/opflow/test_aer_pauli_expectation.py

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

* Update aer_pauli_expectation.py

Use a generator instead of list

* Update qiskit/opflow/expectations/aer_pauli_expectation.py

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

* Update releasenotes/notes/add-support-non-hermitian-op-aerpauliexpectation-653d8e16de4eca07.yaml

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

* Add a test case for PauliOp

* Change the test cases from using ~StateFn() to using StateFn(, is_measurement=True)

* Fix the formatting

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-08 13:12:40 +00:00
Julien Gacon 10624ae294
Add interfaces for a general Quantum Time Evolution Framework (#7858)
* Revert "Revert "Implemented general Quantum Time Evolution Framework interfaces. (#7669)" (#7845)"

This reverts commit 1b6c1b30f8.

Co-authored-by: dlasecki <dal@zurich.ibm.com>

* remove Evolver base class

* Don't import list or dict from MES

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

* fix import order

Co-authored-by: dlasecki <dal@zurich.ibm.com>
Co-authored-by: Steve Wood <40241007+woodsp-ibm@users.noreply.github.com>
2022-04-07 15:36:54 +00:00
Julien Gacon e3c4e76957
Fix small typos and improve consistency in primitive docs (#7897)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-07 09:48:59 +02:00
Ikko Hamamura 60fdd33b26
Fix init_observable for Pauli (#7898)
* Fix init_observable for Pauli

* add releasenote
2022-04-06 15:19:55 +00:00
smturro2 23acf363e5
Example for creating quantum circuit from unitary matrix (#7893)
* Example for creating a quantum circuit from unitary matrix

* Apply suggestions from code review

* Apply suggestions from code review

Changes we made to the example descriptions and class/method descriptions

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

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-06 09:47:43 +00:00
Matthew Treinish b510d6a65d
Add qiskit-bot notification config (#7811)
* Add qiskit-bot notification config

This commit adds a local config file for qiskit-bot. Qiskit-bot
recently added a feature that enables a configurable first
comment/notification (see https://github.com/Qiskit/qiskit-bot/pull/18).
This feature works by adding a local in-repo configuration file that
lists regex keys that match the paths modified in a PR when it is
opened. If the paths match any of the regexes the listed users are
mentioned in the comment the bot leaves. For this commit I picked an
initial selection of users to notify we can easily modify this and add
any user (whether they're a core team member, codeowner, or just an
individual contributor), the bot will simply parrot whatever we put in
this config on comments when the PR matches the regex.

* Correct Julien's username

* Update qiskit_bot.yaml

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

* Fix typo

Co-authored-by: Jake Lishman <jake@binhbar.com>
Co-authored-by: Julien Gacon <gaconju@gmail.com>
2022-04-05 23:03:47 +00:00
dependabot[bot] 0e46791d7b
Bump pyo3 from 0.16.2 to 0.16.3 (#7890)
Bumps [pyo3](https://github.com/pyo3/pyo3) from 0.16.2 to 0.16.3.
- [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.2...v0.16.3)

---
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-04-05 10:14:16 +00:00
Matthew Treinish 6192bfd529
Fix return type from schedule() with a list of one entry (#7885)
This commit fixes the return type when calling schedule() with a list of
a single entry. Previously this would return a single Schedule object
instead of the expected list return. A similar issue was already fixed
in transpile() in #5298 but schedule still had the incorrect behavior.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-04 23:46:02 +00:00
Matthew Treinish d430e4d259
Fix plot_error_map with BackendProperties set or BackendV2 (#7880)
* Fix plot_error_map

In #7814 we updated the plot_error_map() error to be more general and
also work with BackendV2 instead of assuming it's a BaseBackend or
BackendV1 backend. However, as part of that refactor 2 errors were
accidently introduced preventing the function from being used. First in
the BackendV2 path we were incorrectly handling the backend name to use
for the plot title. Secondly, in the BaseBackend/BackendV1 path the
readout error array loop was incorrectly constructed resulting in the
array being larger than expected causing an error. This commit fixes
both conditions so that we can correctly plot the result.

Fixes #7879

* Add tests for plot_error_map

This commit adds test coverage for plot_error_map. The reason the issues
around this function slipped in was a complete lack of test coverage.
This adds some basic tests with both the BackendV1 and BackendV2 test
paths to ensure we have some coverage for the function.

* Add release note
2022-04-04 20:54:44 +00:00
Anthony-Gandon a296ca009b
Fix of eval_observables() when quantum_circuit is a StateFn. (#7863)
* Fix the eval_observables() when quantum_state is StateFn.

StateFn(StateFn()) actually returns an OperatorStateFn.
This caused an issue that was not checked by the
test cases test_aux_ops_evaluator.py.

The associated test case was added.

* Add the associated releasenote

* Update releasenotes/notes/fix-aux-ops-evaluator-83ce1606d1ad19b3.yaml

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

* Fix sphinx identifier

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-04 15:57:42 +00:00
Jake Lishman 528740f1a5
Add regression tests of single-bit conditions in QuantumCircuit.compose (#7806)
Recent work in #7653 had introduced a bug where a private method
`DAGCircuit._map_condition` would fail on single-bit conditionals.  This
method is used by `QuantumCircuit.compose`, and our CI should have
caught the issue before merge.  This commit introduces regression tests
to prevent this from happening again.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-04 13:51:54 +00:00
saktar-unr 2e64b98e6d
Improve parenthesis in circuit library equations (#7872)
* Improving Parenthesis Fixing Issue #7800

* Fixing CRX and CU1 gate documentation
2022-04-04 11:13:33 +02:00
Rathish Cholarajan cf2b948f16
Fix potential copy/paste error in doc string (#7851)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-01 20:48:50 +00:00
Renier Morales 51d11396b0
Fix hard-coded sleep in run_circuits (#7793)
* Fix hard-coded sleep in run_circuits

Fixes #7792

Since all the places where the `_safe_get_job_status` happen in
a context where the intended wait/sleep time is available, we can
add the argument with the value to remove the hard-coded 5 seconds.

* run black

* add reno fix note

* grammar

* revising note accuracy

* Update releasenotes/notes/fix-hard-coded-sleep-run-circuits-a1588164e61d5336.yaml

Co-authored-by: Julien Gacon <gaconju@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-01 16:36:15 +00:00
Kevin Hartman 0de4f7d47b
Fix a few 0.20 release note typos. (#7853)
Co-authored-by: Julien Gacon <jul@zurich.ibm.com>

Co-authored-by: Julien Gacon <jul@zurich.ibm.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-01 04:10:00 +00:00
Christopher J. Wood 9c91b6e58e
Fixes Clifford, Pauli, CNOTDihedral to handle Delay (#7850)
* Fixes Clifford,Pauli,CNOTDihedreal to handle Delay

Fixes the Clifford, Pauli and CNOTDihedreal operator classes to handle conversion of circuits containing Delay instructions. These instructions are ignored (treated as identity) when converting to operators.

* black

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
2022-04-01 02:12:31 +00:00