Release Notes¶
Version History¶
This table tracks the meta-package versions and the version of each Qiskit element installed:
Qiskit Metapackage Version |
qiskit-terra |
qiskit-aer |
qiskit-ignis |
qiskit-ibmq-provider |
qiskit-aqua |
Release Date |
---|---|---|---|---|---|---|
0.36.2 |
0.20.2 |
0.10.4 |
0.7.1 |
0.19.1 |
2022-05-18 |
|
0.36.1 |
0.20.1 |
0.10.4 |
0.7.0 |
0.19.1 |
2022-04-21 |
|
0.36.0 |
0.20.0 |
0.10.4 |
0.7.0 |
0.19.0 |
2022-04-06 |
|
0.35.0 |
0.20.0 |
0.10.3 |
0.7.0 |
0.18.3 |
2022-03-31 |
|
0.34.2 |
0.19.2 |
0.10.3 |
0.7.0 |
0.18.3 |
2022-02-09 |
|
0.34.1 |
0.19.1 |
0.10.2 |
0.7.0 |
0.18.3 |
2022-01-05 |
|
0.34.0 |
0.19.1 |
0.10.1 |
0.7.0 |
0.18.3 |
2021-12-20 |
|
0.33.1 |
0.19.1 |
0.9.1 |
0.7.0 |
0.18.2 |
2021-12-10 |
|
0.33.0 |
0.19.0 |
0.9.1 |
0.7.0 |
0.18.1 |
2021-12-06 |
|
0.32.1 |
0.18.3 |
0.9.1 |
0.6.0 |
0.18.1 |
0.9.5 |
2021-11-22 |
0.32.0 |
0.18.3 |
0.9.1 |
0.6.0 |
0.18.0 |
0.9.5 |
2021-11-10 |
0.31.0 |
0.18.3 |
0.9.1 |
0.6.0 |
0.17.0 |
0.9.5 |
2021-10-12 |
0.30.1 |
0.18.3 |
0.9.0 |
0.6.0 |
0.16.0 |
0.9.5 |
2021-09-29 |
0.30.0 |
0.18.2 |
0.9.0 |
0.6.0 |
0.16.0 |
0.9.5 |
2021-09-16 |
0.29.1 |
0.18.2 |
0.8.2 |
0.6.0 |
0.16.0 |
0.9.5 |
2021-09-10 |
0.29.0 |
0.18.1 |
0.8.2 |
0.6.0 |
0.16.0 |
0.9.4 |
2021-08-02 |
0.28.0 |
0.18.0 |
0.8.2 |
0.6.0 |
0.15.0 |
0.9.4 |
2021-07-13 |
0.27.0 |
0.17.4 |
0.8.2 |
0.6.0 |
0.14.0 |
0.9.2 |
2021-06-15 |
0.26.2 |
0.17.4 |
0.8.2 |
0.6.0 |
0.13.1 |
0.9.1 |
2021-05-19 |
0.26.1 |
0.17.4 |
0.8.2 |
0.6.0 |
0.13.1 |
0.9.1 |
2021-05-18 |
0.26.0 |
0.17.3 |
0.8.2 |
0.6.0 |
0.13.1 |
0.9.1 |
2021-05-11 |
0.25.4 |
0.17.2 |
0.8.2 |
0.6.0 |
0.12.3 |
0.9.1 |
2021-05-05 |
0.25.3 |
0.17.1 |
0.8.2 |
0.6.0 |
0.12.3 |
0.9.1 |
2021-04-29 |
0.25.2 |
0.17.1 |
0.8.1 |
0.6.0 |
0.12.3 |
0.9.1 |
2021-04-21 |
0.25.1 |
0.17.1 |
0.8.1 |
0.6.0 |
0.12.2 |
0.9.1 |
2021-04-15 |
0.25.0 |
0.17.0 |
0.8.0 |
0.6.0 |
0.12.2 |
0.9.0 |
2021-04-02 |
0.24.1 |
0.16.4 |
0.7.6 |
0.5.2 |
0.12.2 |
0.8.2 |
2021-03-24 |
0.24.0 |
0.16.4 |
0.7.6 |
0.5.2 |
0.12.1 |
0.8.2 |
2021-03-04 |
0.23.6 |
0.16.4 |
0.7.5 |
0.5.2 |
0.11.1 |
0.8.2 |
2021-02-18 |
0.23.5 |
0.16.4 |
0.7.4 |
0.5.2 |
0.11.1 |
0.8.2 |
2021-02-08 |
0.23.4 |
0.16.3 |
0.7.3 |
0.5.1 |
0.11.1 |
0.8.1 |
2021-01-28 |
0.23.3 |
0.16.2 |
0.7.3 |
0.5.1 |
0.11.1 |
0.8.1 |
2021-01-26 |
0.23.2 |
0.16.1 |
0.7.2 |
0.5.1 |
0.11.1 |
0.8.1 |
2020-12-15 |
0.23.1 |
0.16.1 |
0.7.1 |
0.5.1 |
0.11.1 |
0.8.1 |
2020-11-12 |
0.23.0 |
0.16.0 |
0.7.0 |
0.5.0 |
0.11.0 |
0.8.0 |
2020-10-16 |
0.22.0 |
0.15.2 |
0.6.1 |
0.4.0 |
0.10.0 |
0.7.5 |
2020-10-05 |
0.21.0 |
0.15.2 |
0.6.1 |
0.4.0 |
0.9.0 |
0.7.5 |
2020-09-16 |
0.20.1 |
0.15.2 |
0.6.1 |
0.4.0 |
0.8.0 |
0.7.5 |
2020-09-08 |
0.20.0 |
0.15.1 |
0.6.1 |
0.4.0 |
0.8.0 |
0.7.5 |
2020-08-10 |
0.19.6 |
0.14.2 |
0.5.2 |
0.3.3 |
0.7.2 |
0.7.3 |
2020-06-25 |
0.19.5 |
0.14.2 |
0.5.2 |
0.3.2 |
0.7.2 |
0.7.3 |
2020-06-19 |
0.19.4 |
0.14.2 |
0.5.2 |
0.3.0 |
0.7.2 |
0.7.2 |
2020-06-16 |
0.19.3 |
0.14.1 |
0.5.2 |
0.3.0 |
0.7.2 |
0.7.1 |
2020-06-02 |
0.19.2 |
0.14.1 |
0.5.1 |
0.3.0 |
0.7.1 |
0.7.1 |
2020-05-14 |
0.19.1 |
0.14.1 |
0.5.1 |
0.3.0 |
0.7.0 |
0.7.0 |
2020-05-01 |
0.19.0 |
0.14.0 |
0.5.1 |
0.3.0 |
0.7.0 |
0.7.0 |
2020-04-30 |
0.18.3 |
0.13.0 |
0.5.1 |
0.3.0 |
0.6.1 |
0.6.6 |
2020-04-24 |
0.18.2 |
0.13.0 |
0.5.0 |
0.3.0 |
0.6.1 |
0.6.6 |
2020-04-23 |
0.18.1 |
0.13.0 |
0.5.0 |
0.3.0 |
0.6.0 |
0.6.6 |
2020-04-20 |
0.18.0 |
0.13.0 |
0.5.0 |
0.3.0 |
0.6.0 |
0.6.5 |
2020-04-09 |
0.17.0 |
0.12.0 |
0.4.1 |
0.2.0 |
0.6.0 |
0.6.5 |
2020-04-01 |
0.16.2 |
0.12.0 |
0.4.1 |
0.2.0 |
0.5.0 |
0.6.5 |
2020-03-20 |
0.16.1 |
0.12.0 |
0.4.1 |
0.2.0 |
0.5.0 |
0.6.4 |
2020-03-05 |
0.16.0 |
0.12.0 |
0.4.0 |
0.2.0 |
0.5.0 |
0.6.4 |
2020-02-27 |
0.15.0 |
0.12.0 |
0.4.0 |
0.2.0 |
0.4.6 |
0.6.4 |
2020-02-06 |
0.14.1 |
0.11.1 |
0.3.4 |
0.2.0 |
0.4.5 |
0.6.2 |
2020-01-07 |
0.14.0 |
0.11.0 |
0.3.4 |
0.2.0 |
0.4.4 |
0.6.1 |
2019-12-10 |
0.13.0 |
0.10.0 |
0.3.2 |
0.2.0 |
0.3.3 |
0.6.1 |
2019-10-17 |
0.12.2 |
0.9.1 |
0.3.0 |
0.2.0 |
0.3.3 |
0.6.0 |
2019-10-11 |
0.12.1 |
0.9.0 |
0.3.0 |
0.2.0 |
0.3.3 |
0.6.0 |
2019-09-30 |
0.12.0 |
0.9.0 |
0.3.0 |
0.2.0 |
0.3.2 |
0.6.0 |
2019-08-22 |
0.11.2 |
0.8.2 |
0.2.3 |
0.1.1 |
0.3.2 |
0.5.5 |
2019-08-20 |
0.11.1 |
0.8.2 |
0.2.3 |
0.1.1 |
0.3.1 |
0.5.3 |
2019-07-24 |
0.11.0 |
0.8.2 |
0.2.3 |
0.1.1 |
0.3.0 |
0.5.2 |
2019-07-15 |
0.10.5 |
0.8.2 |
0.2.1 |
0.1.1 |
0.2.2 |
0.5.2 |
2019-06-27 |
0.10.4 |
0.8.2 |
0.2.1 |
0.1.1 |
0.2.2 |
0.5.1 |
2019-06-17 |
0.10.3 |
0.8.1 |
0.2.1 |
0.1.1 |
0.2.2 |
0.5.1 |
2019-05-29 |
0.10.2 |
0.8.0 |
0.2.1 |
0.1.1 |
0.2.2 |
0.5.1 |
2019-05-24 |
0.10.1 |
0.8.0 |
0.2.0 |
0.1.1 |
0.2.2 |
0.5.0 |
2019-05-07 |
0.10.0 |
0.8.0 |
0.2.0 |
0.1.1 |
0.2.1 |
0.5.0 |
2019-05-06 |
0.9.0 |
0.8.0 |
0.2.0 |
0.1.1 |
0.1.1 |
0.5.0 |
2019-05-02 |
0.8.1 |
0.7.2 |
0.1.1 |
0.1.0 |
2019-05-01 |
||
0.8.0 |
0.7.1 |
0.1.1 |
0.1.0 |
2019-03-05 |
||
0.7.3 |
>=0.7,<0.8 |
>=0.1,<0.2 |
2019-02-19 |
|||
0.7.2 |
>=0.7,<0.8 |
>=0.1,<0.2 |
2019-01-22 |
|||
0.7.1 |
>=0.7,<0.8 |
>=0.1,<0.2 |
2019-01-17 |
|||
0.7.0 |
>=0.7,<0.8 |
>=0.1,<0.2 |
2018-12-14 |
Note
For the 0.7.0
, 0.7.1
, and 0.7.2
meta-package releases the
Gestion des versions de Qiskit policy was not formalized yet.
Notable Changes¶
Qiskit 0.36.2¶
Terra 0.20.2¶
Prelude¶
Qiskit Terra 0.20.2 is a bugfix release, addressing some minor issues identified since the last patch release.
Bug Fixes¶
Fixed an issue with
BackendV2
-based fake backend classes from theqiskit.providers.fake_provider
module such asFakeMontrealV2
, where the values for thedtm
anddt
attributes and the associated attributeTarget.dt
would not be properly converted to seconds. This would cause issues when using these fake backends with scheduling. See #8018.
marginal_counts()
will now succeed when asked to marginalize memory with anindices
parameter containing non-zero elements. Previously, shots whose hexadecimal result representation was sufficiently small could raise aValueError
. See #8044.
The OpenQASM 3 exporter (
qiskit.qasm3
) will now outputinput
oroutput
declarations before gate declarations. This is more consistent with the current reference ANTLR grammar from the OpenQASM 3 team. See #7964.
Fixed a bug in the
RZXCalibrationBuilder
transpiler pass where the scaled cross-resonance pulse amplitude could appear to be parametrized even after assignment. This could cause the pulse visualization tools to use the parametrized format instead of the expected numeric one. See #8031.
Fixed an issue with the
transpile()
function when run with aBackendV2
-based backend and setting thescheduling_method
keyword argument. Previously, the function would not correctly process the default durations of the instructions supported by the backend which would lead to an error.
Fixed a bug in the
RZXCalibrationBuilder
transpiler pass that was causing pulses to sometimes be constructed with incorrect durations. See #7994.
The
SabreSwap
transpiler pass, used intranspile()
whenrouting_method="sabre"
is set, will no longer sporadically drop classically conditioned gates and their successors from circuits during the routing phase of transpilation. See #8040.
Statevector
will now allow direct iteration through its values (such asfor coefficient in statevector
) and correctly report its length underlen
. Previously it would try and and access out-of-bounds data and raise aQiskitError
. See #8039.
Aer 0.10.4¶
No change
Ignis 0.7.1¶
Prelude¶
This is a bugfix release that primarily fixes a packaging issue that was
causing the docs/
directory, which contains the source files used to
build the qiskit-ignis documentation, to get included in the Python package.
IBM Q Provider 0.19.1¶
No change
Qiskit 0.36.1¶
Terra 0.20.1¶
Prelude¶
Qiskit Terra 0.20.1 is a bugfix release resolving issues identified in release 0.20.0.
Known Issues¶
QPY deserialization with the
qpy.load()
function of a directly instantiatedUCPauliRotGate
object in a circuit will fail because the rotation axis argument to the class isn’t stored in a standard place. To workaround this you can instead use the subclasses:UCRXGate
,UCRYGate
, orUCRZGate
(based on whether you’re using a rotation axis of"X"
,"Y"
, or"Z"
respectively) which embeds the rotation axis in the class constructor and will work correctly in QPY.
Since its original introduction in Qiskit Terra 0.20,
XXPlusYYGate
has used a negative angle convention compared to all other rotation gates. In Qiskit Terra 0.21, this will be corrected to be consistent with the other rotation gates. This does not affect any other rotation gates, norXXMinusYYGate
.
Bug Fixes¶
Fixed
Clifford
,Pauli
andCNOTDihedral
operator initialization from compatible circuits that containDelay
instructions. These instructions are treated as identities when converting to operators.
Fixed an issue where the
eval_observables()
function would raise an error if itsquantum_state
argument was of typeStateFn
.eval_observables
now correctly supports all input types denoted by its type hints.
Fixed an issue with the visualization function
dag_drawer()
and methodDAGCircuit.draw()
where previously the drawer would fail when attempting to generate a visualization for aDAGCircuit
object that contained aQubit
orClbit
which wasn’t part of aQuantumRegister
orClassicalRegister
. Fixed #7915.
Fixed parameter validation for class
Drag
. Previously, it was not sensitive to large beta values with negative signs, which may have resulted in waveform samples with a maximum value exceeding the amplitude limit of 1.0.
The
QuantumInstance
class used by many algorithms (likeVQE
) was hard-coding the value for a sleep while it looped waiting for the job status to be updated. It now respects the configured sleep value as set per thewait
attribute in the initializer ofQuantumInstance
.
Fixed an issue with the
schedule
function where callers specifying alist
ofQuantumCircuit
objects with a single entry would incorrectly be returned a singleSchedule
object instead of alist
.
Fixed an issue with the
plot_error_map
visualization function which prevented it from working when run with a backend that had readout error defined in the provided backend’sBackendProperties
or when running with aBackendV2
backend. Fixed #7879.
Fixed a bug that could result in exponential runtime and nontermination when a
Pauli
instance is given to methodinit_observables()
.
Fixed
SabreSwap
, and by extensiontranspile()
withoptimization_level=3
, occasionally re-ordering measurements invalidly. Previously, if two measurements wrote to the same classical bit,SabreSwap
could (depending on the coupling map) re-order them to produce a non-equivalent circuit. This behaviour was stochastic, so may not have appeared reliably. Fixed #7950
The
SabreSwap
transpiler pass, and by extensionSabreLayout
andtranspile()
atoptimization_level=3
, now has an escape mechanism to guarantee that it can never get stuck in an infinite loop. Certain inputs previously could, with a great amount of bad luck, get stuck in a stable local minimum of the search space and the pass would never make further progress. It will now force a series of swaps that allow the routing to continue if it detects it has not made progress recently. Fixed #7707.
Fixed an issue with QPY deserialization via the
qpy.load()
function of theUCRXGate
,UCRYGate
, andUCRZGate
classes. Previously, a QPY file that contained any of these gates would error when trying to load the file. Fixed #7847.
Aer 0.10.4¶
No change
Ignis 0.7.0¶
No change
IBM Q Provider 0.19.1¶
0.19.1¶
Bug Fixes¶
PR #1129 updates
least_busy()
method to no longer support BaseBackend as a valid input or output type since it has been long deprecated in qiskit-terra and has recently been removed.
Qiskit 0.36.0¶
Terra 0.20.0¶
No change
Aer 0.10.4¶
Upgrade Notes¶
Qiskit Aer is no longer compiled with unsafe floating-point optimisations. While most of the effects should have been localised to Qiskit Aer, some aspects of subnormal handling may previously have been leaked into user code by the library incorrectly setting the « flush to zero » mode. This will not happen any more.
Bug Fixes¶
Fix cache blocking transpiler to recognize superop to be cache blocked. This is fix for issue 1479 <https://github.com/Qiskit/qiskit-aer/issues/1479> now density_matrix with noise models can be parallelized. New test, test_noise.TestNoise.test_kraus_gate_noise_on_QFT_cache_blocking is added to verify this issue. Also this fix include fix for issue 1483 <https://github.com/Qiskit/qiskit-aer/issues/1483> discovered by adding new test case. This fixes measure over chunks for statevector.
Fixes a bug in
NoiseModel.from_backend()
that raised an error when T2 value greater than 2 * T1 was supplied by the backend. After this fix, it becomes to truncate T2 value up to 2 * T1 and issue a user warning if truncates. The bug was introduced at #1391 and, before that,NoiseModel.from_backend()
had truncated the T2 value up to 2 * T1 silently.See Issue 1464 for details.
device=Thrust was very slow for small number of qubits because OpenMP threading was always applied. This fix applies OpenMP threads as same as device=CPU by using statevector_parallel_threshold.
Qiskit Aer will no longer set the floating-point mode to « flush to zero » when loaded. Downstream users may previously have seen warnings from Numpy such as:
The value of the smallest subnormal for <class “numpy.float64”> type is zero.
These will now no longer be emitted, and the floating-point handling will be correct.
Fixed a potential issue with running simulations on circuits that have the
QuantumCircuit.metadata
attribute set. Themetadata
attribute can be any python dictionary and previously qiskit-aer would attempt to JSON serialize the contents of the attribute to process it with the rest of the rest of the circuit input, even if the contents were not JSON serializable. This no longer occurs as theQuantumCircuit.metadata
attribute is not used to run the simulation so now the contents are no serialized and instead are directly attached to theqiskit.result.Result
object without attempting to JSON serialize the contents. Fixed #1435
Ignis 0.7.0¶
No change
IBM Q Provider 0.19.0¶
0.19.0¶
New Features¶
The qiskit-ibmq-provider package now supports IBM Quantum LiveData features. These features allow users to observe the real-time behavior of IBM Quantum backends while executing jobs. Specifically, the provider now includes a new tab in the backend Jupyter-related widget and supports the execution of jobs (via
qiskit.providers.ibmq.IBMQBackend.run()
method) with the live_data_enabled=True parameter in allowed IBM Quantum backends.You can now specify a different logging level in the
options
keyword when submitting a Qiskit Runtime job with theqiskit.providers.ibmq.runtime.IBMRuntimeService.run()
method.
Upgrade Notes¶
Python 3.6 support has been dropped since it has reached end of life in Dec 2021.
qiskit.providers.ibmq.random, the random number service which was used to access the CQC randomness extractor is no longer supported and has been removed.
Deprecation Notes¶
The
image
keyword in theqiskit.providers.ibmq.runtime.IBMRuntimeService.run()
method is deprecated. You should instead specify the image to use in theoptions
keyword.
Bug Fixes¶
Fixes issue #190. Now
qiskit.providers.ibmq.runtime.RuntimeEncoder
andqiskit.providers.ibmq.runtime.RuntimeDecoder
have been updated to handle instances of the Instruction class.Fixes issue #74 where numpy ndarrays with object types could not be serialized.
qiskit.providers.ibmq.runtime.RuntimeEncoder
andqiskit.providers.ibmq.runtime.RuntimeDecoder
have been updated to handle these ndarrays.
Qiskit 0.35.0¶
Terra 0.20.0¶
Prelude¶
The Qiskit Terra 0.20.0 release highlights are:
The introduction of multithreaded modules written in Rust to accelerate the performance of certain portions of Qiskit Terra and improve scaling with larger numbers of qubits. However, when building Qiskit from source a Rust compiler is now required.
More native support for working with a
Target
in the transpiler. Several passes now support working directly with aTarget
object which makes the transpiler robust in the types of backends it can target.The introduction of the
qiskit.primitives
module. These APIs provide different abstraction levels for computing outputs of interest fromQuantumCircuit
and using backends. For example, theBaseEstimator
defines an abstract interface for estimating an expectation value of an observable. This can then be used to construct higher level algorithms and applications that are built using the estimation of expectation values without having to worry about the implementation of computing the expectation value. This decoupling allows the implementation to improve in speed and quality while adhering to the defined abstract interface. Likewise, theBaseSampler
computes quasi-probability distributions from circuit measurements. Other primitives will be introduced in the future.
This release no longer has support for Python 3.6. With this release, Python 3.7 through Python 3.10 are required.
New Features¶
Added a new constructor method for the
Operator
class,Operator.from_circuit()
for creating a newOperator
object from aQuantumCircuit
. While this was possible normally using the default constructor, theOperator.from_circuit()
method provides additional options to adjust how the operator is created. Primarily this lets you permute the qubit order based on a setLayout
. For, example:from qiskit.circuit import QuantumCircuit from qiskit import transpile from qiskit.transpiler import CouplingMap from qiskit.quantum_info import Operator circuit = QuantumCircuit(3) circuit.h(0) circuit.cx(0, 1) circuit.cx(1, 2) cmap = CouplingMap.from_line(3) out_circuit = transpile(circuit, initial_layout=[2, 1, 0], coupling_map=cmap) operator = Operator.from_circuit(out_circuit)
the
operator
variable will have the qubits permuted based on the layout so that it is identical to what is returned byOperator(circuit)
before transpilation.
Added a new method
DAGCircuit.copy_empty_like()
to theDAGCircuit
class. This method is used to create a new copy of an existingDAGCircuit
object with the same structure but empty of any instructions. This method is the same as the private method_copy_circuit_metadata()
, but instead is now part of the public API of the class.
The fake backend and fake provider classes which were previously available in
qiskit.test.mock
are now also accessible in a new module:qiskit.providers.fake_provider
. This new module supersedes the previous moduleqiskit.test.mock
which will be deprecated in Qiskit 0.21.0.
Added a new gate class,
LinearFunction
, that efficiently encodes a linear function (i.e. a function that can be represented by a sequence ofCXGate
andSwapGate
gates).
Added a new transpiler pass
CollectLinearFunctions
that collects blocks of consecutiveCXGate
andSwapGate
gates in a circuit, and replaces each block with aLinearFunction
gate.
Added a new transpiler pass
LinearFunctionsSynthesis
that synthesizes anyLinearFunction
gates in using the Patel-Markov-Hayes algorithm. When combined with theCollectLinearFunctions
transpiler pass this enables to collect blocks of consecutiveCXGate
andSwapGate
gates in a circuit, and re-synthesize them using the Patel-Markov-Hayes algorithm.
Added a new transpiler pass
LinearFunctionsToPermutations
that replaces aLinearFunction
gate by aPermutation
circuit whenever possible.
FlowController
classes (such asConditionalController
) can now be nested inside aPassManager
instance when using thePassManager.append()
method. This enables the use of nested logic to control the execution of passes in thePassManager
. For example:from qiskit.transpiler import ConditionalController, PassManager from qiskit.transpiler.passes import ( BasisTranslator, GatesInBasis, Optimize1qGatesDecomposition, FixedPoint, Depth ) from qiskit.circuit.equivalence_library import SessionEquivalenceLibrary as sel pm = PassManager() def opt_control(property_set): return not property_set["depth_fixed_point"] def unroll_condition(property_set): return not property_set["all_gates_in_basis"] depth_check = [Depth(), FixedPoint("depth")] opt = [Optimize1qGatesDecomposition(['rx', 'ry', 'rz', 'rxx'])] unroll = [BasisTranslator(sel, ['rx', 'ry', 'rz', 'rxx'])] unroll_check = [GatesInBasis(['rx', 'ry', 'rz', 'rxx'])] flow_unroll = [ConditionalController(unroll, condition=unroll_condition)] pm.append(depth_check + opt + unroll_check + flow_unroll, do_while=opt_control)
The
pm
PassManager
object will only execute theBasisTranslator
pass (in theunroll
step) in each loop iteration if theunroll_condition
is met.
The constructors for the
ZFeatureMap
andZZFeatureMap
classes have a new keyword argumentparameter_prefix
. This new argument is used to set the prefix of parameters of the data encoding circuit. For example:from qiskit.circuit.library import ZFeatureMap feature_map = ZFeatureMap(feature_dimension=4, parameter_prefix="my_prefix") feature_map.decompose().draw('mpl')
the generated
ZFeatureMap
circuit has prefixed all its internal parameters with the prefix"my_prefix"
.
The
TemplateOptimization
transpiler pass can now work withGate
objects that haveParameterExpression
parameters. An illustrative example of usingParameter
s withTemplateOptimization
is the following:from qiskit import QuantumCircuit, transpile, schedule from qiskit.circuit import Parameter from qiskit.transpiler import PassManager from qiskit.transpiler.passes import TemplateOptimization # New contributions to the template optimization from qiskit.transpiler.passes.calibration import RZXCalibrationBuilder, rzx_templates from qiskit.test.mock import FakeCasablanca backend = FakeCasablanca() phi = Parameter('φ') qc = QuantumCircuit(2) qc.cx(0,1) qc.p(2*phi, 1) qc.cx(0,1) print('Original circuit:') print(qc) pass_ = TemplateOptimization(**rzx_templates.rzx_templates(['zz2'])) qc_cz = PassManager(pass_).run(qc) print('ZX based circuit:') print(qc_cz) # Add the calibrations pass_ = RZXCalibrationBuilder(backend) cal_qc = PassManager(pass_).run(qc_cz.bind_parameters({phi: 0.12})) # Transpile to the backend basis gates cal_qct = transpile(cal_qc, backend) qct = transpile(qc.bind_parameters({phi: 0.12}), backend) # Compare the schedule durations print('Duration of schedule with the calibration:') print(schedule(cal_qct, backend).duration) print('Duration of standard with two CNOT gates:') print(schedule(qct, backend).duration)
outputs
Original circuit: q_0: ──■──────────────■── ┌─┴─┐┌────────┐┌─┴─┐ q_1: ┤ X ├┤ P(2*φ) ├┤ X ├ └───┘└────────┘└───┘ ZX based circuit: ┌─────────────┐ » q_0: ────────────────────────────────────┤0 ├────────────» ┌──────────┐┌──────────┐┌──────────┐│ Rzx(2.0*φ) │┌──────────┐» q_1: ┤ Rz(-π/2) ├┤ Rx(-π/2) ├┤ Rz(-π/2) ├┤1 ├┤ Rx(-2*φ) ├» └──────────┘└──────────┘└──────────┘└─────────────┘└──────────┘» « «q_0: ──────────────────────────────────────────────── « ┌──────────┐┌──────────┐┌──────────┐┌──────────┐ «q_1: ┤ Rz(-π/2) ├┤ Rx(-π/2) ├┤ Rz(-π/2) ├┤ P(2.0*φ) ├ « └──────────┘└──────────┘└──────────┘└──────────┘ Duration of schedule with the calibration: 1600 Duration of standard with two CNOT gates: 6848
The
DAGOpNode
,DAGInNode
andDAGOutNode
classes now define a custom__repr__
method which outputs a representation. Per the Python documentation the output is a string representation that is roughly equivalent to the Python string used to create an equivalent object.
The performance of the
SparsePauliOp.simplify()
method has greatly improved by replacing the use ofnumpy.unique
to compute unique elements of an array by a new similar function implemented in Rust that doesn’t pre-sort the array.
Added a new method
equiv()
to theSparsePauliOp
class for testing the equivalence of aSparsePauliOp
with anotherSparsePauliOp
object. Unlike the==
operator which compares operators element-wise,equiv()
compares whether two operators are equivalent or not. For example:op = SparsePauliOp.from_list([("X", 1), ("Y", 1)]) op2 = SparsePauliOp.from_list([("X", 1), ("Y", 1), ("Z", 0)]) op3 = SparsePauliOp.from_list([("Y", 1), ("X", 1)]) print(op == op2) # False print(op == op3) # False print(op.equiv(op2)) # True print(op.equiv(op3)) # True
Added new fake backend classes from snapshots of the IBM Quantum systems based on the
BackendV2
interface and provided aTarget
for each backend.BackendV2
based versions of all the existing backends are added except for three old backendsFakeRueschlikon
,FakeTenerife
andFakeTokyo
as they do not have snapshots files available which are required for creating a new fake backend class based onBackendV2
.These new V2 fake backends will enable testing and development of new features introduced by
BackendV2
andTarget
such as improving the transpiler.
Added a new gate class
XXMinusYYGate
to the circuit library (qiskit.circuit.library
) for the XX-YY interaction. This gate can be used to implement the bSwap gate and its powers. It also arises in the simulation of superconducting fermionic models.
Added new gate class,
XXPlusYYGate
, to the circuit library (qiskit.circuit.library
). This gate is a 2-qubit parameterized XX+YY interaction, also known as an XY gate, and is based on the gate described in https://arxiv.org/abs/1912.04424.
The
FakeBogota
,FakeManila
,FakeRome
, andFakeSantiago
fake backends which can be found in theqiskit.providers.fake_provider
module can now be used as backends in Pulse experiments as they now include aPulseDefaults
created from a snapshot of the equivalent IBM Quantum machine’s properties.
The
ConsolidateBlocks
pass has a new keyword argument on its constructor,target
. This argument is used to specify aTarget
object representing the compilation target for the pass. If it is specified it supersedes thebasis_gates
kwarg. If a target is specified, the pass will respect the gates and qubits for the instructions defined in theTarget
when deciding which gates to consolidate into a unitary.
The
Target
class has a new method,instruction_supported()
which is used to query the target to see if an instruction (the combination of an operation and the qubit(s) it is executed on) is supported on the backend modelled by theTarget
.
Added a new kwarg,
metadata_serializer
, to theqpy.dump()
function for specifying a customJSONEncoder
subclass for use when serializing theQuantumCircuit.metadata
attribute and a dual kwargmetadata_deserializer
to theqpy.load()
function for specifying aJSONDecoder
subclass. By default thedump()
andload()
functions will attempt to JSON serialize and deserialize with the stdlib default json encoder and decoder. SinceQuantumCircuit.metadata
can contain any Python dictionary, even those with contents not JSON serializable by the default encoder, will lead to circuits that can’t be serialized. The newmetadata_serializer
argument fordump()
enables users to specify a customJSONEncoder
that will be used with the internaljson.dump()
call for serializing theQuantumCircuit.metadata
dictionary. This can then be paired with the newmetadata_deserializer
argument of theqpy.load()
function to decode those custom JSON encodings. Ifmetadata_serializer
is specified ondump()
butmetadata_deserializer
is not specified onload()
calls the QPY will be loaded, but the circuit metadata may not be reconstructed fully.For example if you wanted to define a custom serialization for metadata and then load it you can do something like:
from qiskit.qpy import dump, load from qiskit.circuit import QuantumCircuit, Parameter import json import io class CustomObject: """Custom string container object.""" def __init__(self, string): self.string = string def __eq__(self, other): return self.string == other.string class CustomSerializer(json.JSONEncoder): """Custom json encoder to handle CustomObject.""" def default(self, o): if isinstance(o, CustomObject): return {"__type__": "Custom", "value": o.string} return json.JSONEncoder.default(self, o) class CustomDeserializer(json.JSONDecoder): """Custom json decoder to handle CustomObject.""" def __init__(self, *args, **kwargs): super().__init__(*args, object_hook=self.object_hook, **kwargs) def object_hook(self, o): """Hook to override default decoder.""" if "__type__" in o: obj_type = o["__type__"] if obj_type == "Custom": return CustomObject(o["value"]) return o theta = Parameter("theta") qc = QuantumCircuit(2, global_phase=theta) qc.h(0) qc.cx(0, 1) qc.measure_all() circuits = [qc, qc.copy()] circuits[0].metadata = {"key": CustomObject("Circuit 1")} circuits[1].metadata = {"key": CustomObject("Circuit 2")} with io.BytesIO() as qpy_buf: dump(circuits, qpy_buf, metadata_serializer=CustomSerializer) qpy_buf.seek(0) new_circuits = load(qpy_buf, metadata_deserializer=CustomDeserializer)
The
DenseLayout
pass has a new keyword argument on its constructor,target
. This argument is used to specify aTarget
object representing the compilation target for the pass. If it is specified it supersedes the other arguments on the constructor,coupling_map
andbackend_prop
.
The
Target
class has a new method,operation_names_for_qargs()
. This method is used to get the operation names (i.e. lookup key in the target) for the operations on a givenqargs
tuple.
A new pass
DynamicalDecouplingPadding
has been added to theqiskit.transpiler.passes
module. This new pass supersedes the existingDynamicalDecoupling
pass to work with the new scheduling workflow in the transpiler. It is a subclass of theBasePadding
pass and depends on having scheduling and alignment analysis passes run prior to it in aPassManager
. This new pass can take apulse_alignment
argument which represents a hardware constraint for waveform start timing. The spacing between gates comprising a dynamical decoupling sequence is now adjusted to satisfy this constraint so that the circuit can be executed on hardware with the constraint. This value is usually found inBackendConfiguration.timing_constraints
. Additionally the pass also has anextra_slack_distribution
option has been to control how to distribute the extra slack when the duration of the created dynamical decoupling sequence is shorter than the idle time of your circuit that you want to fill with the sequence. This defaults tomiddle
which is identical to conventional behavior. The new strategysplit_edges
evenly divide the extra slack into the beginning and end of the sequence, rather than adding it to the interval in the middle of the sequence. This might result in better noise cancellation especially whenpulse_alignment
> 1.
The
Z2Symmetries
class now exposes the threshold tolerances used to chop small real and imaginary parts of coefficients. With this one can control how the coefficients of the tapered operator are simplified. For example:from qiskit.opflow import Z2Symmetries from qiskit.quantum_info import Pauli z2_symmetries = Z2Symmetries( symmetries=[Pauli("IIZI"), Pauli("IZIZ"), Pauli("ZIII")], sq_paulis=[Pauli("IIXI"), Pauli("IIIX"), Pauli("XIII")], sq_list=[1, 0, 3], tapering_values=[1, -1, -1], tol=1e-10, )
By default, coefficients are chopped with a tolerance of
tol=1e-14
.
Added a
chop()
method to theSparsePauliOp
class that truncates real and imaginary parts of coefficients individually. This is different from theSparsePauliOp.simplify()
method which removes a coefficient only if the absolute value is close to 0. For example:>>> from qiskit.quantum_info import SparsePauliOp >>> op = SparsePauliOp(["X", "Y", "Z"], coeffs=[1+1e-17j, 1e-17+1j, 1e-17]) >>> op.simplify() SparsePauliOp(['X', 'Y'], coeffs=[1.e+00+1.e-17j, 1.e-17+1.e+00j]) >>> op.chop() SparsePauliOp(['X', 'Y'], coeffs=[1.+0.j, 0.+1.j])
Note that the chop method does not accumulate the coefficents of the same Paulis, e.g.
>>> op = SparsePauliOp(["X", "X"], coeffs=[1+1e-17j, 1e-17+1j) >>> op.chop() SparsePauliOp(['X', 'X'], coeffs=[1.+0.j, 0.+1.j])
Added a new kwarg,
target
, to the constructor for theGatesInBasis
transpiler pass. This new argument can be used to optionally specify aTarget
object that represents the backend. When set thisTarget
will be used for determining whether aDAGCircuit
contains gates outside the basis set and thebasis_gates
argument will not be used.
Added partial support for running on ppc64le and s390x Linux platforms. This release will start publishing pre-compiled binaries for ppc64le and s390x Linux platforms on all Python versions. However, unlike other supported platforms not all of Qiskit’s upstream dependencies support these platforms yet. So a C/C++ compiler may be required to build and install these dependencies and a simple
pip install qiskit-terra
with just a working Python environment will not be sufficient to install Qiskit. Additionally, these same constraints prevent us from testing the pre-compiled wheels before publishing them, so the same guarantees around platform support that exist for the other platforms don’t apply here.
The
Gradient
andQFI
classes can now calculate the imaginary part of expectation value gradients. When using a different measurement basis, i.e.-Y
instead ofZ
, we can measure the imaginary part of gradients The measurement basis can be set with theaux_meas_op
argument.For the gradients,
aux_meas_op = Z
computes0.5Re[(⟨ψ(ω)|)O(θ)|dωψ(ω)〉]
andaux_meas_op = -Y
computes0.5Im[(⟨ψ(ω)|)O(θ)|dωψ(ω)〉]
. For the QFIs,aux_meas_op = Z
computes4Re[(dω⟨<ψ(ω)|)(dω|ψ(ω)〉)]
andaux_meas_op = -Y
computes4Im[(dω⟨<ψ(ω)|)(dω|ψ(ω)〉)]
. For example:from qiskit import QuantumRegister, QuantumCircuit from qiskit.opflow import CircuitStateFn, Y from qiskit.opflow.gradients.circuit_gradients import LinComb from qiskit.circuit import Parameter a = Parameter("a") b = Parameter("b") params = [a, b] q = QuantumRegister(1) qc = QuantumCircuit(q) qc.h(q) qc.rz(params[0], q[0]) qc.rx(params[1], q[0]) op = CircuitStateFn(primitive=qc, coeff=1.0) aux_meas_op = -Y prob_grad = LinComb(aux_meas_op=aux_meas_op).convert(operator=op, params=params)
The
InstructionDurations
class now has support for working with parameters of an instruction. Each entry in anInstructionDurations
object now consists of a tuple of(inst_name, qubits, duration, parameters, unit)
. This enables anInstructionDurations
to define durations for an instruction given a certain parameter value to account for different durations with different parameter values on an instruction that takes a numeric parameter.
Added a new value for the
style
keyword argument on the circuit drawer functioncircuit_drawer()
andQuantumCircuit.draw()
method,iqx_dark
. Whenstyle
is set toiqx_dark
with thempl
drawer backend, the output visualization will use a color scheme similar to the the dark mode color scheme used by the IBM Quantum composer. For example:from qiskit.circuit import QuantumCircuit from matplotlib.pyplot import show circuit = QuantumCircuit(2) circuit.h(0) circuit.cx(0, 1) circuit.p(0.2, 1) circuit.draw("mpl", style="iqx-dark")
Several lazy dependency checkers have been added to the new module
qiskit.utils.optionals
, which can be used to query if certain Qiskit functionality is available. For example, you can ask if Qiskit has detected the presence ofmatplotlib
by askingif qiskit.utils.optionals.HAS_MATPLOTLIB
. These objects only attempt to import their dependencies when they are queried, so you can use them in runtime code without affecting import time.
Import time for
qiskit
has been significantly improved, especially for those with many of Qiskit Terra’s optional dependencies installed.
The
marginal_counts()
function now supports marginalizing thememory
field of an inputResult
object. For example, if the inputresult
argument is a qiskitResult
object obtained from a 4-qubit measurement we can marginalize onto the first qubit with:print(result.results[0].data.memory) marginal_result = marginal_counts(result, [0]) print(marginal_result.results[0].data.memory)
The output is:
['0x0', '0x1', '0x2', '0x3', '0x4', '0x5', '0x6', '0x7'] ['0x0', '0x1', '0x0', '0x1', '0x0', '0x1', '0x0', '0x1']
The internals of the
StochasticSwap
algorithm have been reimplemented to be multithreaded and are now written in the Rust programming language instead of Cython. This significantly increases the run time performance of the compiler pass and by extensiontranspile()
when run withoptimization_level
0, 1, and 2. By default the pass will use up to the number of logical CPUs on your local system but you can control the number of threads used by the pass by setting theRAYON_NUM_THREADS
environment variable to an integer value. For example, settingRAYON_NUM_THREADS=4
will run theStochasticSwap
with 4 threads.
A new environment variable
QISKIT_FORCE_THREADS
is available for users to directly control whether potentially multithreaded portions of Qiskit’s code will run in multiple threads. Currently this is only used by theStochasticSwap
transpiler pass but it likely will be used other parts of Qiskit in the future. When this env variable is set toTRUE
any multithreaded code in Qiskit Terra will always use multiple threads regardless of any other runtime conditions that might have otherwise caused the function to use a single threaded variant. For example, inStochasticSwap
if the pass is being run as part of atranspile()
call with > 1 circuit that is being executed in parallel withmultiprocessing
viaparallel_map()
theStochasticSwap
will not use multiple threads to avoid potentially oversubscribing CPU resources. However, if you’d like to use multiple threads in the pass along with multiple processes you can setQISKIT_FORCE_THREADS=TRUE
.
New fake backend classes are available under
qiskit.providers.fake_provider
. These include mocked versions ofibm_cairo
,ibm_hanoi
,ibmq_kolkata
,ibm_nairobi
, andibm_washington
. As with the other fake backends, these include snapshots of calibration and error data taken from the real system, and can be used for local testing, compilation and simulation.
Introduced a new class
StatePreparation
. This class allows users to prepare a desired state in the same fashion asInitialize
without the reset being automatically applied.For example, to prepare a qubit in the state \((|0\rangle - |1\rangle) / \sqrt{2}\):
import numpy as np from qiskit import QuantumCircuit circuit = QuantumCircuit(1) circuit.prepare_state([1/np.sqrt(2), -1/np.sqrt(2)], 0) circuit.draw()
The output is as:
┌─────────────────────────────────────┐ q_0: ┤ State Preparation(0.70711,-0.70711) ├ └─────────────────────────────────────┘
The
Optimize1qGates
transpiler pass now has support for optimizingU1Gate
,U2Gate
, andPhaseGate
gates with unbound parameters in a circuit. Previously, if these gates had unbound parameters the pass would not use them. For example:from qiskit import QuantumCircuit from qiskit.circuit import Parameter from qiskit.transpiler import PassManager from qiskit.transpiler.passes import Optimize1qGates, Unroller phi = Parameter('φ') alpha = Parameter('α') qc = QuantumCircuit(1) qc.u1(2*phi, 0) qc.u1(alpha, 0) qc.u1(0.1, 0) qc.u1(0.2, 0) pm = PassManager([Unroller(['u1', 'cx']), Optimize1qGates()]) nqc = pm.run(qc)
will be combined to the circuit with only one single-qubit gate:
qc = QuantumCircuit(1) qc.u1(2*phi + alpha + 0.3, 0)
The methods
Pauli.evolve()
andPauliList.evolve()
now have a new keyword argument,frame
, which is used to perform an evolution of a Pauli by a Clifford. Ifframe='h'
(default) then it does the Heisenberg picture evolution of a Pauli by a Clifford (\(P' = C^\dagger P C\)), and ifframe='s'
then it does the Schrödinger picture evolution of a Pauli by a Clifford (\(P' = C P C^\dagger\)). The latter option yields a faster calculation, and is also useful in certain cases. This new option makes the calculation of the greedy Clifford decomposition method indecompose_clifford
significantly faster.
Added a new module to Qiskit:
qiskit.primitives
. The primitives module is where APIs are defined which provide different abstractions around computing certain common functions fromQuantumCircuit
which abstracts away the details of the underlying execution on aBackend
. This enables higher level algorithms and applications to concentrate on performing the computation and not need to worry about the execution and processing of results and have a standardized interface for common computations. For example, estimating an expectation value of a quantum circuit and observable can be performed by any class implementing theBaseEstimator
class and consumed in a standardized manner regardless of the underlying implementation. Applications can then be written using the primitive interface directly.To start the module contains two types of primitives, the
Sampler
(seeBaseSampler
for the abstract class definition) andEstimator
(seeBaseEstimator
for the abstract class definition). Reference implementations are included in theqiskit.primitives
module and are built using theqiskit.quantum_info
module which perform ideal simulation of primitive operation. The expectation is that provider packages will offer their own implementations of these interfaces for providers which can efficiently implement the protocol natively (typically using a classical runtime). Additionally, in the future for providers which do not offer a native implementation of the primitives a method will be provided which will enable constructing primitive objects from aBackend
.
Added a new module,
qiskit.qpy
, which contains the functionality previously exposed inqiskit.circuit.qpy_serialization
. The public functions previously exposed atqiskit.circuit.qpy_serialization
,dump()
andload()
are now available from this new module (although they are still accessible fromqiskit.circuit.qpy_serialization
but this will be deprecated in a future release). This new module was added in the interest of the future direction of the QPY file format, which in future versions will support representingpulse
Schedule
andScheduleBlock
objects in addition to theQuantumCircuit
objects it supports today.
Added a new attribute,
qubit_properties
to theTarget
class. This attribute contains a list ofQubitProperties
objects for each qubit in the target. For example:target.qubit_properties[2]
will contain the
QubitProperties
for qubit number 2 in the target.For
BackendV2
authors, if you were previously definingQubitProperties
directly on yourBackendV2
implementation by overridingBackendV2.qubit_properties()
this will still work fine. However, if you do move the definition to the underlyingTarget
object and remove the specializedBackendV2.qubit_properties()
implementation which will enable using qubit properties in the transpiler and also maintain API compatibility with your previous implementation.
Added a new function,
qiskit.algorithms.eval_observables()
, which is used to evaluate observables given a boundQuantumCircuit
. It originates from a private method,_eval_aux_ops()
, of theqiskit.algorithms.VQE
class but the neweval_observables()
function is now more general so that it can be used in other algorithms, for example time evolution algorithms.
The basis search strategy in
BasisTranslator
transpiler pass has been modified into a variant of Dijkstra search which greatly improves the runtime performance of the pass when attempting to target an unreachable basis.
The
DenseLayout
transpiler pass is now multithreaded, which greatly improves the runtime performance of the pass. By default, it will use the number of logical CPUs on your local system, but you can control the number of threads used by the pass by setting theRAYON_NUM_THREADS
environment variable to an integer value. For example, settingRAYON_NUM_THREADS=4
will run theDenseLayout
pass with 4 threads.
The internal computations of
Statevector.expectation_value()
andDensityMatrix.expectation_value()
methods have been reimplemented in the Rust programming language. This new implementation is multithreaded and by default for aStatevector
orDensityMatrix
>= 19 qubits will spawn a thread pool with the number of logical CPUs available on the local system. You can you can control the number of threads used by setting theRAYON_NUM_THREADS
environment variable to an integer value. For example, settingRAYON_NUM_THREADS=4
will only use 4 threads in the thread pool.
Added a new
SparsePauliOp.from_sparse_list()
constructor that takes an iterable, where the elements represent Pauli terms that are themselves sparse, so that"XIIIIIIIIIIIIIIIX"
can now be written as("XX", [0, 16])
. For example, the operator\[H = X_0 Z_3 + 2 Y_1 Y_4\]can now be constructed as
op = SparsePauliOp.from_sparse_list([("XZ", [0, 3], 1), ("YY", [1, 4], 2)], num_qubits=5) # or equivalently, as previously op = SparsePauliOp.from_list([("IZIIX", 1), ("YIIYI", 2)])
This facilitates the construction of very sparse operators on many qubits, as is often the case for Ising Hamiltonians.
The
UnitarySynthesis
transpiler pass has a new keyword argument on its constructor,target
. This can be used to optionally specify aTarget
object which represents the compilation target for the pass. When it’s specified it will supersede the values set forbasis_gates
,coupling_map
, andbackend_props
.
The
UnitarySynthesisPlugin
abstract plugin class has a new optional attribute implementations can add,supports_target
. If a plugin has this attribute set toTrue
aTarget
object will be passed in theoptions
payload under thetarget
field. The expectation is that thisTarget
object will be used in place ofcoupling_map
,gate_lengths
,basis_gates
, andgate_errors
.
Introduced a new transpiler pass workflow for building
PassManager
objects for schedulingQuantumCircuit
objects in the transpiler. In the new workflow scheduling and alignment passes are allAnalysisPass
objects that only update the property set of the pass manager, specifically new property set itemnode_start_time
, which holds the absolute start time of each opnode. A separateTransformationPass
such asPadDelay
is subsequently used to apply scheduling to the DAG. This new workflow is both more efficient and can correct for additional timing constraints exposed by a backend.Previously, the pass chain would have been implemented as
scheduling -> alignment
which were both transform passes thus there were multipleDAGCircuit
instances recreated during each pass. In addition, scheduling occured in each pass to obtain instruction start time. Now the required pass chain becomesscheduling -> alignment -> padding
where theDAGCircuit
update only occurs at the end with thepadding
pass.For those who are creating custom
PassManager
objects that involve circuit scheduling you will need to adjust yourPassManager
to insert one of theBasePadding
passes (currently eitherPadDelay
orPadDynamicalDecoupling
can be used) at the end of the scheduling pass chain. Without the padding pass the scheduling passes will not be reflected in the output circuit of therun()
method of your customPassManager
.For example, if you were previously building your
PassManager
with something like:from qiskit.transpiler import PassManager from qiskit.transpiler.passes import TimeUnitConversion, ALAPSchedule, ValidatePulseGates, AlignMeasures pm = PassManager() scheduling = [ ALAPSchedule(instruction_durations), PadDelay()), ValidatePulseGates(granularity=timing_constraints.granularity, min_length=timing_constraints.min_length), AlignMeasures(alignment=timing_constraints.acquire_alignment), ] pm.append(scheduling)
you can instead use:
from qiskit.transpiler import PassManager from qiskit.transpiler.passes import TimeUnitConversion, ALAPScheduleAnalysis, ValidatePulseGates, AlignMeasures, PadDelay pm = PassManager() scheduling = [ ALAPScheduleAnalysis(instruction_durations), PadDelay()), ConstrainedReschedule(acquire_alignment=timing_constraints.acquire_alignment, pulse_alignment=timing_constraints.pulse_alignment), ValidatePulseGates(granularity=timing_constraints.granularity, min_length=timing_constraints.min_length), PadDelay() ] pm.append(scheduling)
which will both be more efficient and also align instructions based on any hardware constraints.
Added a new transpiler pass
ConstrainedReschedule
pass. TheConstrainedReschedule
pass considers both hardware alignment constraints that can be definied in aBackendConfiguration
object,pulse_alignment
andacquire_alignment
. This new class supersedes the previosuly existingAlignMeasures
as it performs the same alignment (via the property set) for measurement instructions in addition to general instruction alignment. By setting theacquire_alignment
constraint argument for theConstrainedReschedule
pass it is a drop-in replacement ofAlignMeasures
when paired with a newBasePadding
pass.
Added two new transpiler passes
ALAPScheduleAnalysis
andASAPScheduleAnalysis
which superscede theALAPSchedule
andASAPSchedule
as part of the reworked transpiler workflow for schedling. The new passes perform the same scheduling but in the property set and relying on aBasePadding
pass to adjust the circuit based on all the scheduling alignment analysis.The standard behavior of these passes also aligns timing ordering with the topological ordering of the DAG nodes. This change may affect the scheduling outcome if it includes conditional operations, or simultaneously measuring two qubits with the same classical register (edge-case). To reproduce conventional behavior, set
clbit_write_latency
identical to the measurement instruction length.For example, consider scheduling an input circuit like:
┌───┐┌─┐ q_0: ┤ X ├┤M├────────────── └───┘└╥┘ ┌───┐ q_1: ──────╫────┤ X ├────── ║ └─╥─┘ ┌─┐ q_2: ──────╫──────╫─────┤M├ ║ ┌────╨────┐└╥┘ c: 1/══════╩═╡ c_0=0x1 ╞═╩═ 0 └─────────┘ 0
from qiskit import QuantumCircuit from qiskit.transpiler import InstructionDurations, PassManager from qiskit.transpiler.passes import ALAPScheduleAnalysis, PadDelay, SetIOLatency from qiskit.visualization.timeline import draw circuit = QuantumCircuit(3, 1) circuit.x(0) circuit.measure(0, 0) circuit.x(1).c_if(0, 1) circuit.measure(2, 0) durations = InstructionDurations([("x", None, 160), ("measure", None, 800)]) pm = PassManager( [ SetIOLatency(clbit_write_latency=800, conditional_latency=0), ALAPScheduleAnalysis(durations), PadDelay(), ] ) draw(pm.run(circuit))
As you can see in the timeline view, the measurement on
q_2
starts before the conditional X gate on theq_1
, which seems to be opposite to the topological ordering of the node. This is also expected behavior because clbit write-access happens at the end edge of the measure instruction, and the read-access of the conditional gate happens the begin edge of the instruction. Thus topological ordering is preserved on the timeslot of the classical register, which is not captured by the timeline view. However, this assumes a paticular microarchitecture design, and the circuit is not necessary scheduled like this.By using the default configuration of passes, the circuit is schedule like below.
from qiskit import QuantumCircuit from qiskit.transpiler import InstructionDurations, PassManager from qiskit.transpiler.passes import ALAPScheduleAnalysis, PadDelay from qiskit.visualization.timeline import draw circuit = QuantumCircuit(3, 1) circuit.x(0) circuit.measure(0, 0) circuit.x(1).c_if(0, 1) circuit.measure(2, 0) durations = InstructionDurations([("x", None, 160), ("measure", None, 800)]) pm = PassManager([ALAPScheduleAnalysis(durations), PadDelay()]) draw(pm.run(circuit))
Note that clbit is locked throughout the measurement instruction interval. This behavior is designed based on the Qiskit Pulse, in which the acquire instruction takes
AcquireChannel
andMemorySlot
which are not allowed to overlap with other instructions, i.e. simultaneous memory access from the different instructions is prohibited. This also always aligns the timing ordering with the topological node ordering.
Added a new transpiler pass
PadDynamicalDecoupling
which supersedes theDynamicalDecoupling
pass as part of the reworked transpiler workflow for scheduling. This new pass will insert dynamical decoupling sequences into the circuit per any scheduling and alignment analysis that occured in earlier passes.
The
plot_gate_map()
visualization function and the functions built on top of it,plot_error_map()
andplot_circuit_layout()
, have a new keyword argument,qubit_coordinates
. This argument takes a sequence of 2D coordinates to use for plotting each qubit in the backend being visualized. If specified this sequence must have a length equal to the number of qubits on the backend and it will be used instead of the default behavior.
The
plot_gate_map()
visualization function and the functions built on top of it,plot_error_map()
andplot_circuit_layout()
, now are able to plot any backend not just those with the number of qubits equal to one of the IBM backends. This relies on the retworkxspring_layout()
function to generate the layout for the visualization. If the default layout doesn’t work with a backend’s particular coupling graph you can use thequbit_coordinates
function to set a custom layout.
The
plot_gate_map()
visualization function and the functions built on top of it,plot_error_map()
andplot_circuit_layout()
, are now able to function with aBackendV2
based backend. Previously, these functions only worked withBaseBackend
orBackendV1
based backends.
Added a new transpiler pass,
SetIOLatency
. This pass takes two argumentsclbit_write_latency
andconditional_latency
to define the I/O latency for classical bits and classical conditions on a backend. This pass will then define these values on the pass manager’s property set to enable subsequent scheduling and alignment passes to correct for these latencies and provide a more presice scheduling output of a dynamic circuit.
A new transpiler pass
PadDelay
has been added. This pass fills idle time on the qubit wires withDelay
instructions. This pass is part of the new workflow for scheduling passes in the transpiler and depends on a scheduling analysis pass (such asALAPScheduleAnalysis
orASAPScheduleAnalysis
) and any alignment passes (such asConstrainedReschedule
) to be run prior toPadDelay
.
The
VF2Layout
transpiler pass has a new keyword argument,target
which is used to provide aTarget
object for the pass. When specified, theTarget
will be used by the pass for all information about the target device. If it is specified, thetarget
option will take priority over thecoupling_map
andproperties
arguments.
Allow callables as optimizers in
VQE
andQAOA
. Now, the optimizer can either be one of Qiskit’s optimizers, such asSPSA
or a callable with the following signature:from qiskit.algorithms.optimizers import OptimizerResult def my_optimizer(fun, x0, jac=None, bounds=None) -> OptimizerResult: # Args: # fun (callable): the function to minimize # x0 (np.ndarray): the initial point for the optimization # jac (callable, optional): the gradient of the objective function # bounds (list, optional): a list of tuples specifying the parameter bounds result = OptimizerResult() result.x = # optimal parameters result.fun = # optimal function value return result
The above signature also allows to directly pass any SciPy minimizer, for instance as
from functools import partial from scipy.optimize import minimize optimizer = partial(minimize, method="L-BFGS-B")
Known Issues¶
When running
parallel_map()
(which is done internally by performance sensitive functions such astranspile()
andassemble()
) in a subprocess launched outside ofparallel_map()
, it is possible that the parallel dispatch performed insideparallel_map()
will hang and never return. This is due to upstream issues in CPython around the default method to launch subprocesses on Linux and macOS with Python 3.7 (see https://bugs.python.org/issue40379 for more details). If you encounter this, you have two options: you can either remove the nested parallel processes, as callingparallel_map()
from a main process should work fine; or you can manually call the CPython standard librarymultiprocessing
module to perform similar parallel dispatch from a subprocess, but use the"spawn"
or"forkserver"
launch methods to avoid the potential to have things get stuck and never return.
Upgrade Notes¶
The classes
Qubit
,Clbit
andAncillaQubit
now have the__slots__
attribute. This is to reduce their memory usage. As a side effect, they can no longer have arbitrary data attached as attributes to them. This is very unlikely to have any effect on downstream code other than performance benefits.
The core dependency
retworkx
had its version requirement bumped to 0.11.0, up from 0.10.1. This improves the performance of transpilation passConsolidateBlocks
.
The minimum supported version of
symengine
is now 0.9.0. This was necessary to improve compatibility with Python’spickle
module which is used internally as part of parallel dispatch withparallel_map()
.
The default value of
QISKIT_PARALLEL
when running with Python 3.9 on Linux is now set toTRUE
. This means when runningparallel_map()
or functions that call it internally, such astranspile()
andassemble()
, the function will be executed in multiple processes and should have better run time performance. This change was made because the issues with reliability of parallel dispatch appear to have been resolved (see #6188 for more details). If you still encounter issues because of this you can disable multiprocessing and revert to the previous default behavior by setting theQISKIT_PARALLEL
environment variable toFALSE
, or setting theparallel
option toFalse
in your user config file (also please file an issue so we can track any issues related to multiprocessing).
The previously deprecated
MSGate
gate class previously found inqiskit.circuit.library
has been removed. It was originally deprecated in the 0.16.0 release. Instead theGMS
class should be used, as this allows you to create an equivalent 2 qubit MS gate in addition to anMSGate
for any number of qubits.
The previously deprecated
mirror()
method of theInstruction
class has been removed. It was originally deprecated in 0.15.0 release. Instead you should useInstruction.reverse_ops()
.
The previously deprecated
num_ancilla_qubits()
method of theqiskit.circuit.library.PiecewiseLinearPauliRotations
andqiskit.circuit.library.WeightedAdder
classes has been removed. It was originally deprecated in the 0.16.0 release. Instead thePiecewiseLinearPauliRotations.num_ancillas()
andWeightedAdder.num_ancillas()
methods should be used.
The previously deprecated
reverse
argument on the constructor for thePolynomialPauliRotations
class has been removed. It was originally deprecated in the 0.15.0 release. Instead you should use theQuantumCircuit.reverse_bits()
method to reverse thePolynomialPauliRotations
circuit if needed.
The previously deprecated
angle
argument on the constructors for theC3SXGate
andC3XGate
gate classes has been removed. It was originally deprecated in the 0.17.0 release. Instead for fractional 3-controlled X gates you can use theC3XGate.power()
method.
Support for using
np.ndarray
objects as part of theparams
attribute of aGate
object has been removed. This has been deprecated since Qiskit Terra 0.16.0 and now will no longer work. Instead one should create a new subclass ofGate
and explicitly allow anp.ndarray
input by overloading thevalidate_parameter()
method.
A new extra
csp-layout-pass
has been added to the install target forpip install qiskit-terra
, and is also included in theall
extra. This has no effect in Qiskit Terra 0.20, but starting from Qiskit Terra 0.21, the dependencies needed only for theCSPLayout
transpiler pass will be downgraded from requirements to optionals, and installed by this extra. You can prepare a package that depends on this pass by setting its requirements (orpip install
command) to targetqiskit-terra[csp-layout-pass]
.
Support for running with Python 3.6 has been removed. To run Qiskit you need a minimum Python version of 3.7.
The
AmplitudeEstimator
now inherits from theABC
class from the Python standard library. This requires any subclass to implement theestimate()
method when previously it wasn’t required. This was done because the original intent of the class was to always be a child class ofABC
, as theestimate()
is required for the operation of anAmplitudeEstimator
object. However, if you were previously defining anAmplitudeEstimator
subclass that didn’t implementestimate()
this will now result in an error.
The error raised by
HoareOptimizer
if the optional dependencyz3
is not available has changed fromTranspilerError
toMissingOptionalLibraryError
(which is both aQiskitError
and anImportError
). This was done to be consistent with the other optional dependencies.
On Linux, the minimum library support has been raised from the manylinux2010 VM to manylinux2014. This mirrors similar changes in Numpy and Scipy. There should be no meaningful effect for most users, unless your system still contains a very old version of
glibc
.
The
marginal_counts()
function when called with aResult
object input, will now marginalize thememory
field of experiment data if it’s set in the inputResult
. Previously, thememory
field in the the input was not marginalized. This change was made because the previous behavior would result in thecounts
field not matching thememory
field aftermarginal_counts()
was called. If the previous behavior is desired it can be restored by settingmarginalize_memory=None
as an argument tomarginal_counts()
which will not marginalize thememory
field.
The
StochasticSwap
transpiler pass may return different results with the same seed value set. This is due to the internal rewrite of the transpiler pass to improve runtime performance. However, this means that if you rantranspile()
withoptimization_level
0, 1 (the default), or 2 with a value set forseed_transpiler
you may get an output with different swap mapping present after upgrading to Qiskit Terra 0.20.0.
To build Qiskit Terra from source a Rust compiler is now needed. This is due to the internal rewrite of the
StochasticSwap
transpiler pass which greatly improves the runtime performance of the transpiler. The rust compiler can easily be installed using rustup, which can be found here: https://rustup.rs/
The
name
attribute of thePauliEvolutionGate
class has been changed to always be"PauliEvolution"
. This change was made to be consistent with other gates in Qiskit and enables other parts of Qiskit to quickly identify when a particular operation in a circuit is aPauliEvolutionGate
. For example, it enables the unrolling to Pauli evolution gates.Previously, the name contained the operators which are evolved, which is now available via the
PauliEvolutionGate.label
attribute. If a circuit with aPauliEvolutionGate
is drawn, the gate will still show the same information, which gates are being evolved.
The previously deprecated methods:
qiskit.algorithms.VQE.get_optimal_cost
qiskit.algorithms.VQE.get_optimal_circuit
qiskit.algorithms.VQE.get_optimal_vector
qiskit.algorithms.VQE.optimal_params
qiskit.algorithms.HamiltonianPhaseEstimationResult.most_likely_phase
qiskit.algorithms.PhaseEstimationResult.most_likely_phase
which were originally deprecated in the Qiskit Terra 0.18.0 release have been removed and will no longer work.
The
qiskit.algorithms.VariationalAlgorithm
class is now defined as an abstract base class (ABC
) which will require classes that inherit from it to define both aVariationalAlgorithm.initial_point
getter and setter method.
The
pass_manager
kwarg for thetranspile()
function has been removed. It was originally deprecated in the 0.13.0 release. The preferred way to transpile a circuit with a customPassManager
object is to use therun()
method of thePassManager
object.
The previously deprecated
ParametrizedSchedule
class has been removed and no longer exists. This class was deprecated as a part of the 0.17.0 release. Instead of using this class you can directly parametrizeSchedule
orScheduleBlock
objects by specifying aParameter
object to the parametric pulse argument.
The module
qiskit.circuit.library.probability_distributions
has been removed and no longer exists as per the deprecation notice from qiskit-terra 0.17.0 (released Apr 1, 2021). The affected classes areUniformDistribution
,NormalDistribution
, andLogNormalDistribution
. They are all moved to the qiskit-finance library, into its circuit library module:qiskit_finance.circuit.library.probability_distributions
.
The previous
qiskit.test.mock.fake_mumbai_v2.FakeMumbaiV2
class has been renamed toFakeMumbaiFractionalCX
to differentiate it from theBackendV2
based fake backend for the IBM Mumbai device,qiskit.test.mock.backends.FakeMumbaiV2
. If you were previously relying on theFakeMumbaiV2
class to get a fake backend that had fractional applications ofCXGate
defined in its target you need to useFakeMumbaiFractionalCX
class as theFakeMumbaiV2
will no longer have those extra gate definitions in itsTarget
.
The resolver used by
QuantumCircuit.append()
(and consequently all methods that add an instruction onto aQuantumCircuit
) to convert bit specifiers has changed to make it faster and more reliable. Certain constructs like:import numpy as np from qiskit import QuantumCircuit qc = QuantumCircuit(1, 1) qc.measure(np.array([0]), np.array([0]))
will now work where they previously would incorrectly raise an error, but certain pathological inputs such as:
from sympy import E, I, pi qc.x(E ** (I * pi))
will now raise errors where they may have occasionally (erroneously) succeeded before. For almost all correct uses, there should be no noticeable change except for a general speed-up.
The semi-public internal method
QuantumCircuit._append()
no longer checks the types of its inputs, and assumes that there are no invalid duplicates in its argument lists. This function is used by certain internal parts of Qiskit and other libraries to build upQuantumCircuit
instances as quickly as possible by skipping the error checking when the data is already known to be correct. In general, users or functions taking in user data should use the publicQuantumCircuit.append()
method, which resolves integer bit specifiers, broadcasts its arguments and checks the inputs for correctness.
Cython is no longer a build dependency of Qiskit Terra and is no longer required to be installed when building Qiskit Terra from source.
The preset passmanagers in
qiskit.transpiler.preset_passmanagers
for all optimization levels 2 and 3 as generated bylevel_2_pass_manager()
andlevel_3_pass_manager()
have been changed to run theVF2Layout
by default prior to the layout pass. TheVF2Layout
pass will quickly check if a perfect layout can be found and supersedes what was previously done for optimization levels 2 and 3 which were using a combination ofTrivialLayout
andCSPLayout
to try and find a perfect layout. This will result in potentially different behavior whentranspile()
is called by default as it removes a default path for all optimization levels >=2 of using a trivial layout (wherecircuit.qubits[0]
is mapped to physical qubit 0,circuit.qubits[1]
is mapped to physical qubit 1, etc) assuming the trivial layout is perfect. If your use case was dependent on the trivial layout you can explictly request it when transpiling by specifyinglayout_method="trivial"
when callingtranspile()
.
The preset pass manager for optimization level 1 (when calling
transpile()
withoptimization_level=1
or when nooptimization_level
argument is set) as generated bylevel_1_pass_manager()
has been changed so thatVF2Layout
is called by default to quickly check if a a perfect layout can be found prior to theDenseLayout
. However, unlike with optimization level 2 and 3 a trivial layout is still attempted prior to runningVF2Layout
and if it’s a perfect mapping the output fromVF2Layout
will be used.
Deprecation Notes¶
The
max_credits
argument toexecute()
, and all of theQobj
configurations (e.g.QasmQobjConfig
andPulseQobjConfig
), is deprecated and will be removed in a future release. The credit system has not been in use on IBM Quantum backends for two years, and the option has no effect. No alternative is necessary. For example, if you were callingexecute()
as:job = execute(qc, backend, shots=4321, max_credits=10)
you can simply omit the
max_credits
argument:job = execute(qc, backend, shots=4321)
Using an odd integer for the
order
argument on the constructor of theSuzukiTrotter
class is deprecated and will no longer work in a future release. The product formulae used by theSuzukiTrotter
are only defined when the order is even as the Suzuki product formulae is symmetric.
The
qregs
,cregs
,layout
, andglobal_phase
kwargs to theMatplotlibDrawer
,TextDrawing
, andQCircuitImage
classes, and thecalibrations
kwarg to theMatplotlibDrawer
class, are now deprecated and will be removed in a subsequent release.
Bug Fixes¶
Fixed an error in the circuit conversion functions
circuit_to_gate()
andcircuit_to_instruction()
(and their associated circuit methodsQuantumCircuit.to_gate()
andQuantumCircuit.to_instruction()
) when acting on a circuit with registerless bits, or bits in more than one register.
Fixed an issue where calling
QuantumCircuit.copy()
on the « body » circuits of a control-flow operation created with the builder interface would raise an error. For example, this was previously an error, but will now return successfully:from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister qreg = QuantumRegister(4) creg = ClassicalRegister(1) circ = QuantumCircuit(qreg, creg) with circ.if_test((creg, 0)): circ.h(0) if_else_instruction, _, _ = circ.data[0] true_body = if_else_instruction.params[0] true_body.copy()
Added a missing entry from the standard session equivalence library between
CXGate
andCPhaseGate
as well as betweenCXGate
andCRZGate
.
Fixed an issue where running the
==
operator between twoSparsePauliOp
objects would raise an error when the two operators had different numbers of coefficients. For example:op = SparsePauliOp.from_list([("X", 1), ("Y", 1)]) op2 = SparsePauliOp.from_list([("X", 1), ("Y", 1), ("Z", 0)]) print(op == op2)
This would previously raise a
ValueError
instead of returningFalse
.
Fixed support in
transpile()
for passing aInstructionScheduleMap
object to the underlyingPassManager
based on theTarget
forBackendV2
based backends. Previously, thetranspile()
function would not do this processing and any transpiler passes which do not support working with aTarget
object yet would not have access to the default pulse calibrations for the instructions from aBackendV2
backend.
The
AmplitudeAmplifier
is now correctly available from the rootqiskit.algorithms
module directly. Previously it was not included in the re-exported classes off the root module and was only accessible fromqiskit.algorithms.amplitude_amplifiers
. Fixed #7751.
Fixed an issue with the
mpl
backend for the circuit drawer functioncircuit_drawer()
and theQuantumCircuit.draw()
method where gates with conditions would not display properly when a sufficient number of gates caused the drawer to fold over to a second row. Fixed: #7752.
Fixed an issue where the
HHL.construct_circuit()
method under certain conditions would not return a correctQuantumCircuit
. Previously, the function had a rounding error in calculating how many qubits were necessary to represent the eigenvalues which would cause an incorrect circuit output.
Fixed an endianness bug in
BaseReadoutMitigator.expectation_value()
when a stringdiagonal
was passed. It will now correctly be interpreted as little endian in the same manner as the rest of Qiskit Terra, instead of big endian.
Fixed an issue with the
quantum_info.partial_trace()
when the function was asked to trace out no subsystems, it will now correctly return theDensityMatrix
of the input state with all dimensions remaining rather than throwing an error. Fixed #7613
Fixed an issue with the
text
backend for the circuit drawer functioncircuit_drawer()
and theQuantumCircuit.draw()
method when gates that use side text, such as theCPhaseGate
andRZZGate
gate classes, with classical conditions set would not display properly. Fixed #7532.
Fixed an issue with the
circuit_drawer()
function anddraw()
method ofQuantumCircuit
. When using thereverse_bits
option with thempl
,latex
, ortext
options, bits without registers did not display in the correct order. Fixed #7303.
Fixed an issue in the
LocalReadoutMitigator.assignment_matrix()
method where it would previously reject an input value for thequbits
argument that wasn’t a trivial sequence of qubits in the form:[0, 1, 2, ..., n-1]
. This has been corrected so that now any list of qubit indices to be measured are accepted by the method.
Fixed an issue in the
StabilizerState.expectation_value()
method’s expectation value calculation, where the output expectation value would be incorrect if the inputPauli
operator for theoper
argument had a non-trivial phase. Fixed #7441.
An opflow expression containing the Pauli identity
opflow.I
no longer produces anIGate
when converted to a circuit. This change fixes a difference in expectation; the identity gate in the circuit indicates a delay however in opflow we expect a mathematical identity – meaning no operation at all.
PauliSumOp
equality tests now handle the case when one of the compared items is a singlePauliOp
. For example,0 * X + I == I
now evaluates to True, whereas it was False prior to this release.
Fixed an issue with the
ALAPSchedule
andASAPSchedule
transpiler passes when working with instructions that had custom pulse calibrations (i.e. pulse gates) set. Previously, the scheduling passes would not use the duration from the custom pulse calibration for thse instructions which would result in the an incorrect scheduling being generated for the circuit. This has been fixed so that now the scheduling passes will use the duration of the custom pulse calibration for any instruction in the circuit which has a custom calibration.
Fixed support for using
ParameterExpression
instruction paramaters in theRZXCalibrationBuilder
transpiler pass. Previously, if an instruction parameter included a boundParameterExpression
the pass would not be able to handle this correctly.
Stopped the parser in
QuantumCircuit.from_qasm_str()
andfrom_qasm_file()
from accepting OpenQASM programs that identified themselves as being from a language version other than 2.0. This parser is only for OpenQASM 2.0; support for imported circuits from OpenQASM 3.0 will be added in an upcoming release.
The OpenQASM 3 exporter,
qasm3.Exporter
, will now escape register and parameter names that clash with reserved OpenQASM 3 keywords by generating a new unique name. Registers and parameters with the same name will no longer have naming clashes in the code output from the OpenQASM 3 exporter. Fixed #7742.
Aer 0.10.3¶
No change
Ignis 0.7.0¶
No change
IBM Q Provider 0.18.3¶
No change
Qiskit 0.34.2¶
Terra 0.19.2¶
Prelude¶
Qiskit Terra 0.19.2 is predominantly a bugfix release, but also now comes with wheels built for Python 3.10 on all major platforms.
New Features¶
Added support for running with Python 3.10. This includes publishing precompiled binaries to PyPI for Python 3.10 on supported platforms.
Upgrade Notes¶
Starting from Python 3.10, Qiskit Terra will have reduced support for 32-bit platforms. These are Linux i686 and 32-bit Windows. These platforms with Python 3.10 are now at Tier 3 instead of Tier 2 support (per the tiers defined in: https://qiskit.org/documentation/getting_started.html#platform-support) This is because the upstream dependencies Numpy and Scipy have dropped support for them. Qiskit will still publish precompiled binaries for these platforms, but we’re unable to test the packages prior to publishing, and you will need a C/C++ compiler so that
pip
can build their dependencies from source. If you’re using one of these platforms, we recommended that you use Python 3.7, 3.8, or 3.9.
Bug Fixes¶
Fixed a bug where the
CVaRMeasurement
attempted to convert aPauliSumOp
to a dense matrix to check whether it were diagonal. For large operators (> 16 qubits) this computation was extremely expensive and raised an error if not explicitly enabled usingqiskit.utils.algorithm_globals.massive = True
. The check is now efficient even for large numbers of qubits.
DAGCircuit.draw()
and the associated functiondag_drawer()
will now show a more useful error message when the provided filename is not valid.
QuantumCircuit.add_register()
will no longer cause duplicateAncillaQubit
references in a circuit when given anAncillaRegister
whose bits are already present.
Fixed conversion of
QuantumCircuit
s with classical conditions on single, registerlessClbit
s toInstruction
s when using thecircuit_to_instruction()
function or theQuantumCircuit.to_instruction()
method. For example, the following will now work:from qiskit.circuit import QuantumCircuit, Qubit, Clbit qc = QuantumCircuit([Qubit(), Clbit()]) qc.h(0).c_if(qc.clbits[0], 0) qc.to_instruction()
Registers will now correctly reject duplicate bits. Fixed #7446.
The
FakeOpenPulse2Q
mock backend now has T2 times and readout errors stored for its qubits. These are arbitrary values, approximately consistent with real backends at the time of its creation.
Fix the qubit order of 2-qubit evolutions in the
PauliEvolutionGate
, if used with a product formula synthesis. For instance, before, the evolution ofIIZ + IZI + IZZ
from qiskit.circuit.library import PauliEvolutionGate from qiskit.opflow import I, Z operator = (I ^ I ^ Z) + (I ^ Z ^ I) + (I ^ Z ^ Z) print(PauliEvolutionGate(operator).definition.decompose())
produced
┌───────┐ q_0: ┤ Rz(2) ├──────── ├───────┤ q_1: ┤ Rz(2) ├─■────── └───────┘ │ZZ(2) q_2: ──────────■──────
whereas now it correctly yields
┌───────┐ q_0: ┤ Rz(2) ├─■────── ├───────┤ │ZZ(2) q_1: ┤ Rz(2) ├─■────── └───────┘ q_2: ─────────────────
Fixed a problem in the
latex
andmpl
circuit drawers when register names with multiple underscores in the name did not display correctly.
Negative numbers in array outputs from the drawers will now appear as decimal numbers instead of fractions with huge numerators and denominators. Like positive numbers, they will still be fractions if the ratio is between small numbers.
Fixed an issue with the
Target.get_non_global_operation_names()
method when running on a target incorrectly raising an exception on targets with ideal global operations. Previously, if this method was called on a target that contained any ideal globally defined operations, where the instruction properties are set toNone
, this method would raise an exception instead of treating that instruction as global.
Fixed an issue with the
transpile()
function where it could fail when being passed aTarget
object directly with thetarget
kwarg.
Fixed an issue with the
transpile()
function where it could fail when thebackend
argument was aBackendV2
or aTarget
via thetarget
kwarg that contained ideal globally defined operations.
Fixed an issue where plotting Bloch spheres could cause an
AttributeError
to be raised in Jupyter or when trying to crop figures down to size with Matplotlib 3.3 or 3.4 (but not 3.5). For example, the following code would previously crash with a message:AttributeError: 'Arrow3D' object has no attribute '_path2d'
but will now succeed with all current supported versions of Matplotlib:
from qiskit.visualization import plot_bloch_vector plot_bloch_vector([0, 1, 0]).savefig("tmp.png", bbox_inches='tight')
Fixed a bug in
PauliSumOp.permute()
where the object on which the method is called was permuted in-place, instead of returning a permuted copy. This bug only occured for permutations that left the number of qubits in the operator unchanged.
Fixed the
PauliEvolutionGate.inverse()
method, which previously computed the inverse by inverting the evolution time. This was only the correct inverse if the operator was evolved exactly. In particular, this led to the inverse of Trotterization-based time evolutions being incorrect.
The
QuantumInstance.execute()
method will no longer mutate its input if it is given a list of circuits.
Fixed QPY serialisation of custom instructions which had an explicit no-op definition. Previously these would be written and subsequently read the same way as if they were opaque gates (with no given definition). They will now correctly round-trip an empty definition. For example, the following will now be correct:
import io from qiskit.circuit import Instruction, QuantumCircuit, qpy_serialization # This instruction is explicitly defined as a one-qubit gate with no # operations. empty = QuantumCircuit(1, name="empty").to_instruction() # This instruction will perform some operations that are only known # by the hardware backend. opaque = Instruction("opaque", 1, 0, []) circuit = QuantumCircuit(2) circuit.append(empty, [0], []) circuit.append(opaque, [1], []) qpy_file = io.BytesIO() qpy_serialization.dump(circuit, qpy_file) qpy_file.seek(0) new_circuit = qpy_serialization.load(qpy_file)[0] # Previously both instructions in `new_circuit` would now be opaque, but # there is now a correct distinction. circuit == new_circuit
Added a missing
BackendV2.provider
attribute to implementations of theBackendV2
abstract class. Previously,BackendV2
backends could be initialized with a provider but that was not accessible to users.
Fixed support for the
QuantumInstance
class when running with aBackendV2
backend. Previously, attempting to use aQuantumInstance
with aBackendV2
would have resulted in an error.
Fixed a bug in
VQE
where the parameters of the ansatz were still explicitly ASCII-sorted by their name if the ansatz was resized. This led to a mismatched order of the optimized values in theoptimal_point
attribute of the result object.In particular, this bug occurred if no ansatz was set by the user and the VQE chose a default with 11 or more free parameters.
Stopped the parser in
QuantumCircuit.from_qasm_str()
andfrom_qasm_file()
from accepting OpenQASM programs that identified themselves as being from a language version other than 2.0. This parser is only for OpenQASM 2.0; support for imported circuits from OpenQASM 3.0 will be added in an upcoming release.
Fixed QPY serialization of
QuantumCircuit
objects that contained control flow instructions. Previously if you attempted to serialize a circuit containingIfElseOp
,WhileLoopOp
, orForLoopOp
the serialization would fail. Fixed #7583.
Fixed QPY serialization of
QuantumCircuit
containing subsets of bits from aQuantumRegister
orClassicalRegister
. Previously if you tried to serialize a circuit like this it would incorrectly treat these bits as standaloneQubit
orClbit
without having a register set. For example, if you try to serialize a circuit like:import io from qiskit import QuantumCircuit, QuantumRegister from qiskit.circuit.qpy_serialization import load, dump qr = QuantumRegister(2) qc = QuantumCircuit([qr[0]]) qc.x(0) with open('file.qpy', 'wb') as fd: dump(qc, fd)
when that circuit is loaded now the registers will be correctly populated fully even though the circuit only contains a subset of the bits from the register.
QFT
will now warn if it is instantiated or built with settings that will cause it to lose precision, rather than raising anOverflowError
. This can happen if the number of qubits is very large (slightly over 1000) without the approximation degree being similarly large. The circuit will now build successfully, but some angles might be indistinguishable from zero, due to limitations in double-precision floating-point numbers.
Aer 0.10.3¶
Prelude¶
Qiskit Aer 0.10.3 is mainly a bugfix release, fixing several bugs that have been discovered since the 0.10.2 release. Howver, this release also introduces support for running with Python 3.10 including precompiled binary wheels on all major platforms. This release also includes precompiled binary wheels for arm64 on macOS.
New Features¶
Added support for running with Python 3.10. This includes publishing precompiled binaries to PyPI for Python 3.10 on supported platforms.
Added support for M1 macOS systems. Precompiled binaries for supported Python versions >=3.8 on arm64 macOS will now be published on PyPI for this and future releases.
Upgrade Notes¶
Qiskit Aer no longer fully supports 32 bit platforms on Python >= 3.10. These are Linux i686 and 32-bit Windows. These platforms with Python 3.10 are now at Tier 3 instead of Tier 2 support (per the tiers defined in: https://qiskit.org/documentation/getting_started.html#platform-support) This is because the upstream dependencies Numpy and Scipy have dropped support for them. Qiskit will still publish precompiled binaries for these platforms, but we’re unable to test the packages prior to publishing, and you will need a C/C++ compiler so that
pip
can build their dependencies from source. If you’re using one of these platforms, we recommended that you use Python 3.7, 3.8, or 3.9.
Bug Fixes¶
Fixes a bug in
RelaxationNoisePass
where instruction durations were always assumed to be in dt time units, regardless of the actual unit of the isntruction. Now unit conversion is correctly handled for all instruction duration units.See #1453 for details.
Fixes an issue with
LocalNoisePass
for noise functions that return aQuantumCircuit
for the noise op. These were appended to the DAG as an opaque circuit instruction that must be unrolled to be simulated. This fix composes them so that the cirucit instructions are added to the new DAG and can be simulated without additional unrolling if all circuit instructions are supported by the simulator.See #1447 for details.
Multi-threaded transpilations to generate diagonal gates will now work correctly if the number of gates of a circuit exceeds
fusion_parallelization_threshold
. Previously, different threads would occasionally fuse the same element into multiple blocks, causing incorrect results.
Fixes a bug with truncation of circuits in parameterized Qobjs. Previously parameters of parameterized QObj could be wrongly resolved if unused qubits of their circuits were truncated, because indices of the parameters were not updated after the instructions on unmeasured qubits were removed.
See #1427 for details.
Ignis 0.7.0¶
No change
IBM Q Provider 0.18.3¶
No change
Qiskit 0.34.1¶
Terra 0.19.1¶
No change
Aer 0.10.2¶
Bug Fixes¶
Fixed simulation of
for
loops where the loop parameter was not used in the body of the loop. For example, previously this code would fail, but will now succeed:import qiskit from qiskit.providers.aer import AerSimulator qc = qiskit.QuantumCircuit(2) with qc.for_loop(range(4)) as i: qc.h(0) qc.cx(0, 1) AerSimulator(method="statevector").run(qc)
Fixes a bug in
QuantumError.to_dict()
where N-qubit circuit instructions where the assembled instruction always applied to qubits[0, ..., N-1]
rather than the instruction qubits. This bug also affected device and fake backend noise models.See Issue 1415 for details.
Ignis 0.7.0¶
No change
IBM Q Provider 0.18.3¶
No change
Qiskit 0.34.0¶
Qiskit 0.34.0 includes a point release of Qiskit Aer: version 0.10.1, which patches performance regressions in version 0.10.0 that were discovered immediately post-release. See below for the release notes for both Qiskit Aer 0.10.0 and 0.10.1.
Terra 0.19.1¶
No change
Aer 0.10.1¶
Prelude¶
The Qiskit Aer 0.10.1 patch fixes performance regressions introduced in Qiskit Aer 0.10.0.
Bug Fixes¶
Fix performance regression in noisy simulations due to large increase in serialization overhead for loading noise models from Python into C++ resulting from unintended nested Python multiprocessing calls. See issue 1407 for details.
Aer 0.10.0¶
Prelude¶
The Qiskit Aer 0.10 release includes several performance and noise model improvements. Some highlights are:
Improved performance for parallel shot GPU and HPC simulations
Support for simulation of circuits containing QASM 3.0 control-flow instructions
Support for relaxation noise on scheduled circuits in backend noise models
Support of user-created transpiler passes for defining custom gate errors and noise models, and inserting them into circuits.
New Features¶
Added support of QASM 3.0 control-flow instructions introduced in Qiskit-Terra 0.19.0. Supported instructions are
ForLoopOp
,WhileLoopOp
,ContinueLoopOp
,BreakLoopOp
,IfElseOp
.
Added a batched-shot simulation optimization for GPU simulations. This optional feature will use available memory on 1 or more GPUs to run multiple simulation shots in parallel for greatly improved performance on multi-shot simulations with noise models and/or intermediate measurements.
This option is enabled by default when using
device="GPU"
and a simulationmethod
of either"statevector"
or"density_matrix"
with theAerSimulator
. It can be disabled by settingbatched_shots_gpu=False
in the simulator options.This optimization is most beneficial for small to medium numbers of qubits where there is sufficient GPU memory to run multiple simulations in parallel. The maximum number of active circuit qubits for enabling this optimization can be configured using the
batch_shots_gpu_max_qubits
simulator option. The default value of this option is 16.
Added the new
max_shot_size
option to a custom executor for running multiple shots of a noisy circuit in parallel.For example configuring
max_shot_size
with a custom executor:backend = AerSimulator( max_shot_size=1, max_job_size=1, executor=custom_executor) job = backend.run(circuits)
will split the shots of a noisy circuit into multiple circuits. After all individual shots have finished executing, the job results are automatically combined into a single
Result
object that is returned byjob.result()
.
Added the
mps_swap_direction
simulator option that allows the user to determine the direction of internal swaps, when they are inserted for a 2-qubit gate. Possible values are"mps_swap_right"
and"mps_swap_left"
. The direction of the swaps may affect performance, depending on the circuit.
Implemented a new measurement sampling optimization for the
"matrix_product_state"
simulation method of theAerSimulator
. Currently this algorithm is used only when all qubits are measured and when the simulatormps_sample_measure_algorithm
simulator option is set to"mps_probabilities"
.
Improved the performance of the measure instruction for the
"matrix_product_state"
simulation method of theAerSimulator
.
Added a
SaveClifford
instruction for saving the state of the stabilizer simulation method as aClifford
object.Note that this instruction is essentially equivalent to the
SaveStabilizer
instruction, however that instruction will return the saved state as aStabilizerState
object instead of aClifford
object.
Added two transpiler passes for inserting instruction-dependent quantum errors into circuits:
The
LocalNoisePass
pass can be used to implement custom parameterized noise models by defining a noise generating function of the formdef fn( inst: Instruction, qubits: Optional[List[int]] = None, ) -> InstructionLike
which returns a noise instruction (eg. a
QuantumError
or other instruction) that can depend on any properties or parameters of the instruction and qubit arguements.This function can be applied to all instructions in a circuit, or a specified subset (See the
LocalNoisePass
documentation for additional details.)The
RelaxationNoisePass
is a special case of theLocalNoisePass
using a predefined noise function that returns a tensor product ofthermal_relaxation_error()
on each qubit in an instruction, dependent on the instruction’s duration and the supplied relaxation time constant parameters of the pass.
The basic device noise model implemented by
NoiseModel.from_backend()
andAerSimulator.from_backend()
has been upgraded to allow adding duration-dependent relaxation errors on circuit delay gates using theRelaxationNoisePass
.To enable this noise when running noisy simulations you must first schedule your circuit to insert scheduled delay instructions as follows:
backend = AerSimulator.from_backend(ibmq_backend) scheduled_circuit = qiskit.transpile( circuit, backend=backend, scheduling_method='asap') result = backend.run(scheduled_circuit).result()
If the circuit is transpiled without being scheduled (and also contains no delay instructions) the noisy simulation will not include the effect of delay relaxation errors. In this case the simulation will be equivalent to the previous qiskit-aer 0.9 simulation where relaxation noise is only added to gate instructions based on their duration as obtained from the backend properties.
The constructor of
QuantumError
now accepts several new types of input asnoise_ops
argument, for example:import numpy as np from qiskit import QuantumCircuit from qiskit.circuit.library import IGate, XGate, Reset from qiskit.quantum_info import Kraus from qiskit.providers.aer.noise import QuantumError # Quantum channels kraus = Kraus([ np.array([[1, 0], [0, np.sqrt(1 - 0.9)]], dtype=complex), np.array([[0, 0], [0, np.sqrt(0.9)]], dtype=complex) ]) print(QuantumError(kraus)) # Construction from a QuantumCircuit qc = QuantumCircuit(2) qc.h(0) qc.cx(0, 1) error = QuantumError(qc) # Construction from a tuple of (Instruction, List[int]), where the list of # integers represents the qubits. error = QuantumError((Reset(), [0])) # Construction from an iterable of objects in the same form as above, but # where each also has an associated probability. error = QuantumError([ ((IGate(), [0]), 0.9), ((XGate(), [0]), 0.1), ]) # A short-hand for the iterable form above, where the qubits are implicit, # and each instruction is over all qubits. error = QuantumError([(IGate(), 0.9), (XGate(), 0.1)])
Note that the original JSON-based input format is deperecated.
Added a utility function
qiskit.providers.aer.utils.transform_noise_model()
for constructing a noise model by applying a supplied function to allQuantumError
s in the noise model.
Added two utility functions
qiskit.providers.aer.utils.transpile_quantum_error()
andqiskit.providers.aer.utils.transpile_noise_model()
for transpiling the circuits contained inQuantumError
, and all errors in aNoiseModel
.
Added the ability to add
QuantumError
objects directly to aQuantumCircuit
without converting to aKraus
instruction.Circuits containing quantum errors can now be run on the
AerSimulator
andQasmSimulator
simulators as an alternative to, or in addition to, building aNoiseModel
for defining noisy circuit instructions.Example:
from qiskit import QuantumCircuit from qiskit.providers.aer import AerSimulator from qiskit.providers.aer.noise import pauli_error error_h = pauli_error([('I', 0.95), ('X', 0.05)]) error_cx = pauli_error([('II', 0.9), ('XX', 0.1)]) qc = QuantumCircuit(3) qc.h(0) qc.append(error_h, [0]) qc.cx(0, 1) qc.append(error_cx, [0, 1]) qc.cx(0, 2) qc.append(error_cx, [0, 2]) qc.measure_all() backend = AerSimulator(method='stabilizer') result = backend.run(qc).result() result.get_counts(0)
Circuits containing quantum errors can also be evaluated using the
quantum_info
quantum channel andDensityMatrix
classes.
Upgrade Notes¶
The return type of several save instructions have been changed to be the corresponding Qiskit Terra classes rather than raw NumPy arrays or dictionaries. The types that have changed are
save_statevector()
now returns as aStatevector
save_density_matrix()
now returns as aDensityMatrix
save_stabilizer()
now returns asStabilizerState
save_unitary()
now returns asOperator
save_superop()
now returns asSuperOp
save_probabilities_dict()
now returns as aProbDistribution
Changed the default value of
standard_gates
toNone
for all functions inqiskit.providers.aer.noise.errors.standard_errors
as those functions are updated so that they use standard gates by default.
When an unsupported argument is supplied to
approximate_quantum_error()
, it will now raise aNoiseError
instead of aRuntimeError
.
Deprecation Notes¶
Using NumPy
ndarray
methods and attributes on the return type ofsave_statevector()
,save_density_matrix()
,save_unitary()
, andsave_superop()
has been deprecated, and will stop working in a future release. These instructions now returnqiskit.quantum_info
classes for their return types. Partial backwards compatability with treating these objects as NumPy arrays is implemented by forwarding methods to the internal array during the deprecation period.
Passing in a
BackendProperties
object for thebackend
argument ofNoiseModel.from_backend()
has been deprecated, as it is incompatible with duration dependent delay noises, and will be removed in a future release. Pass in a Qiskit TerraBackendV1
object instead.
Deprecated the
number_of_qubits
option of theQuantumError
constructor in favor of automatic determination of the dimension.
Deprecated the
standard_gates
option of theQuantumError
constructor in favor of externalizing such basis-change functionality. In many cases, you can transform any error into an error defined only with specific gates usingapproximate_quantum_error()
.
Deprecated the
standard_gates
option of all functions inqiskit.providers.aer.noise.errors.standard_errors
in favor of returning errors in the form of a mixture of standard gates as much as possible by default.
Deprecated all functions in
errorutils
because they are helper functions meant to be used only for implementing functions inqiskit.providers.aer.noise.errors.standard_errors
and they should have been provided as private functions.
Deprecated the
standard_gates
option ofNoiseModel.from_backend()
in favor of externalizing such basis-change functionality.
Deprecated
NoiseModel.from_dict()
to make the noise model independent of Qobj (JSON) format.
Deprecated all public variables, functions and classes in
qiskit.providers.aer.noise.utils.noise_transformation
except forapproximate_quantum_error()
andapproximate_noise_model()
, because they are helper functions meant to be used only for implementing theapproximate_*
functions and they should have been provided as private functions.
Deprecated
remap_noise_model()
since the C++ code now automatically truncates and remaps noise models if it truncates circuits.
Other Notes¶
Changes in the implementation of the function
approximate_quantum_error()
may change the resulting approximate error compared to Qiskit Aer 0.9.
Ignis 0.7.0¶
No change
IBM Q Provider 0.18.3¶
Bug Fixes¶
Fix delivered in #1100 for an issue with JSON encoding and decoding when using
ParameterExpression
s in conjunction with Qiskit Terra 0.19.1 and above. Previously, theParameter
instances reconstructed from the JSON output would have different unique identifiers, causing them to seem unequal to the input. They will now have the correct backing identities.
Qiskit 0.33.1¶
Terra 0.19.1¶
Prelude¶
Qiskit Terra 0.19.1 is a bugfix release, solving some issues in 0.19.0 concerning circuits constructed by the control-flow builder interface, conditional gates and QPY serialisation of newer Terra objects.
Deprecation Notes¶
The loose functions
qiskit.circuit.measure.measure()
andqiskit.circuit.reset.reset()
are deprecated, and will be removed in a future release. Instead, you should access these as methods onQuantumCircuit
:from qiskit import QuantumCircuit circuit = QuantumCircuit(1, 1) # Replace this deprecated form ... from qiskit.circuit.measure import measure measure(circuit, 0, 0) # ... with either of the next two lines: circuit.measure(0, 0) QuantumCircuit.measure(circuit, 0, 0)
Bug Fixes¶
Fixed an error in the circuit conversion functions
circuit_to_gate()
andcircuit_to_instruction()
(and their associated circuit methodsQuantumCircuit.to_gate()
andQuantumCircuit.to_instruction()
) when acting on a circuit with registerless bits, or bits in more than one register. Previously, the number of bits necessary for the created gate or instruction would be calculated incorrectly, often causing an exception during the conversion.
Fixed an issue where calling
QuantumCircuit.copy()
on the « body » circuits of a control-flow operation created with the builder interface would raise an error. For example, this was previously an error, but will now return successfully:from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister qreg = QuantumRegister(4) creg = ClassicalRegister(1) circ = QuantumCircuit(qreg, creg) with circ.if_test((creg, 0)): circ.h(0) if_else_instruction, _, _ = circ.data[0] true_body = if_else_instruction.params[0] true_body.copy()
The control-flow builder interface now supports using
ClassicalRegister
s as conditions in nested control-flow scopes. Previously, doing this would not raise an error immediately, but the internal circuit blocks would not have the correct registers defined, and so later logic that worked with the inner blocks would fail.For example, previously the drawers would fail when trying to draw an inner block conditioned on a classical register, whereas now it will succeed, such as in this example:
from qiskit import QuantumCircuit from qiskit.circuit import QuantumRegister, ClassicalRegister qreg = QuantumRegister(4) creg = ClassicalRegister(1) circ = QuantumCircuit(qreg, creg) with circ.for_loop(range(10)) as a: circ.ry(a, 0) with circ.if_test((creg, 1)): circ.break_loop() print(circ.draw(cregbundle=False)) print(circ.data[0][0].blocks[0].draw(cregbundle=False))
Fixed
qpy_serialization
support for serializingQuantumCircuit
objects that are usingParameterVector
orParameterVectorElement
as parameters. Previously, aParameterVectorElement
parameter was just treated as aParameter
for QPY serialization which meant theParameterVector
context was lost in QPY and the output order ofparameters
could be incorrect.To fix this issue a new QPY format version, version_3, was required. This new format version includes a representation of the
ParameterVectorElement
class which is described in theqpy_serialization
documentation at param_vector.
Fixed the
qpy_serialization
support for serializing aPauliEvolutionGate
object. Previously, thePauliEvolutionGate
was treated as a custom gate for serialization and would be deserialized as aGate
object that had the same definition and name as the originalPauliEvolutionGate
. However, this would lose the original state from thePauliEvolutionGate
. This has been fixed so that starting in this release aPauliEvolutionGate
in the circuit will be preserved 1:1 across QPY serialization now. The only limitation with this is that it does not support customEvolutionSynthesis
classes. Only the classes available fromqiskit.synthesis
can be used with aPauliEvolutionGate
for qpy serialization.To fix this issue a new QPY format version, version_3, was required. This new format version includes a representation of the
PauliEvolutionGate
class which is described in theqpy_serialization
documentation at PAULI_EVOLUTION.
Two loose functions
qiskit.circuit.measure.measure()
andqiskit.circuit.reset.reset()
were accidentally removed without a deprecation period. They have been reinstated, but are marked as deprecated in favour of the methodsQuantumCircuit.measure()
andQuantumCircuit.reset()
, respectively, and will be removed in a future release.
Other Notes¶
The new control-flow builder interface uses various context managers and helper objects to do its work. These should not be considered part of the public API, and are liable to be changed and removed without warning. The usage of the builder interface has stability guarantees, in the sense that the behaviour described by
QuantumCircuit.for_loop()
,while_loop()
andif_test()
for the builder interface are subject to the standard deprecation policies, but the actual objects used to effect this are not. You should not rely on the objects (such asIfContext
orControlFlowBuilderBlock
) existing in their current locations, or having any methods or attributes attached to them.This was not previously clear in the 0.19.0 release. All such objects now have a warning in their documentation strings making this explicit. It is likely in the future that their locations and backing implementations will become quite different.
Aer 0.9.1¶
No change
Ignis 0.7.0¶
No change
IBM Q Provider 0.18.2¶
Bug Fixes¶
Fix delivered in #1065 for the issue where job kept crashing when
Parameter
was passed in circuit metadata.Fix delivered in #1094 for the issue wherein
qiskit.providers.ibmq.runtime.RuntimeEncoder
does an extra decompose() if the circuit being serialized is aBlueprintCircuit
.
Qiskit 0.33.0¶
This release officially marks the end of support for the Qiskit Aqua project
in Qiskit. It was originally deprecated in the 0.25.0 release and as was documented
in that release the qiskit-aqua
package has been removed from the Qiskit
metapackage, which means pip install qiskit
will no
longer include qiskit-aqua
. However, because of limitations in python
packaging we cannot automatically remove a pre-existing install of qiskit-aqua
when upgrading a previous version of Qiskit to this release (or a future release)
with pip install -U qiskit
. If you are upgrading from a previous version it’s
recommended that you manually uninstall Qiskit Aqua with
pip uninstall qiskit-aqua
or install in a fresh python environment.
The application modules that were provided by qiskit-aqua
have been split into
several new packages:
qiskit-optimization
, qiskit-nature
, qiskit-machine-learning
, and
qiskit-finance
. These packages can be installed by themselves (via the
standard pip install command, e.g. pip install qiskit-nature
) or with the
rest of the Qiskit metapackage as optional extras (e.g.
pip install 'qiskit[finance,optimization]'
or pip install 'qiskit[all]'
).
The core algorithms and the operator flow now exist as part of Qiskit Terra at
qiskit.algorithms
and qiskit.opflow
. Depending on your existing
usage of Aqua you should either use the application packages or the new modules
in Qiskit Terra. For more details on how to migrate from Qiskit Aqua you can
refer to the
Aqua Migration Guide.
This release also officially deprecates the Qiskit Ignis project. Accordingly, in a
future release the qiskit-ignis
package will be removed from the Qiskit
metapackage, which means in that future release pip install qiskit
will no
longer include qiskit-ignis
. Qiskit Ignis has been supersceded by the
Qiskit Experiments project and active
development has ceased. While deprecated, critical bug fixes and compatibility fixes will
continue to be made to provide users a sufficient opportunity to migrate off of Ignis. After the
deprecation period (which will be no shorter than 3 months from this release) the project will be
retired and archived. You can refer to the
migration guide for details on how to
switch from Qiskit Ignis to Qiskit Experiments.
Terra 0.19.0¶
Prelude¶
The Qiskit Terra 0.19 release highlights are:
A new version of the abstract Qiskit/hardware interface, in the form of
BackendV2
, which comes with a new data structureTarget
to allow backends to better model their constraints for the transpiler.An extensible plugin interface to the
UnitarySynthesis
transpiler pass, allowing users or other packages to extend Qiskit Terra’s synthesis routines with new methods.Control-flow instructions, for representing
for
andwhile
loops andif
/else
statements inQuantumCircuit
. The simulators in Qiskit Aer will soon be able to work with these new instructions, allowing you to write more dynamic quantum programs.Preliminary support for the evolving OpenQASM 3 specification. You can use the new
qiskit.qasm3
module to serialize yourQuantumCircuit
s into OpenQASM 3, including the new control-flow constructs.
This release marks the end of support for Python 3.6 in Qiskit. This release of Qiskit Terra, and any subsequent bugfix releases in the 0.19.x series, will be the last to work with Python 3.6. Starting from the next minor release (0.20.0) of Qiskit Terra, the minimum required Python version will be 3.7.
As always, there are many more features and fixes in this release as well, which you can read about below.
New Features¶
QuantumCircuit.decompose()
and its corresponding transpiler passDecompose
now optionally accept a parameter containing a collection of gate names. If this parameter is given, then only gates with matching names will be decomposed. This supports Unix-shell-style wildcard matches. For example:qc.decompose(["h", "r[xz]"])
will decompose any
h
,rx
orrz
gates, but leave (for example)x
gates untouched.
Added the
termination_checker
argument to theSPSA
optimizer. This allows the user to implement a custom termination criterion.import numpy as np from qiskit.algorithms.optimizers import SPSA def objective(x): return np.linalg.norm(x) + .04*np.random.rand(1) class TerminationChecker: def __init__(self, N : int): """ Callback to terminate optimization when the average decrease over the last N data points is smaller than the specified tolerance. """ self.N = N self.values = [] def __call__(self, nfev, parameters, value, stepsize, accepted) -> bool: """ Returns: True if the optimization loop should be terminated. """ self.values.append(value) if len(self.values) > self.N: last_values = self.values[-self.N:] pp = np.polyfit(range(self.N), last_values, 1) slope = pp[0] / self.N if slope > 0: return True return False maxiter = 400 spsa = SPSA(maxiter=maxiter, termination_checker=TerminationChecker(10)) parameters, value, niter = spsa.optimize(2, objective, initial_point=np.array([0.5, 0.5]))
Added a new version of the
Backend
interface,BackendV2
. This new version is a large change from the previous version,BackendV1
and changes both the user access pattern for properties of the backend (like number of qubits, etc) and how the backend represents its constraints to the transpiler. The execution of circuits (via therun()
method) remains unchanged. With aBackendV2
backend instead of having a separateconfiguration()
,properties()
, anddefaults()
methods that constructBackendConfiguration
,BackendProperties
, andPulseDefaults
objects respectively, like in theBackendV1
interface, the attributes contained in those output objects are accessible directly as attributes of theBackendV2
object. For example, to get the number of qubits for a backend withBackendV1
you would do:num_qubits = backend.configuration().n_qubits
while with
BackendV2
it is:num_qubits = backend.num_qubits
The other change around this is that the number of attributes exposed in the abstract
BackendV2
class is designed to be a hardware/vendor agnostic set of the required or optional fields that the rest of Qiskit can use today with any backend. Subclasses of the abstractBackendV2
class can add support for additional attributes and methods beyond those defined inBackendV2
, but these will not be supported universally throughout Qiskit.The other critical change that is primarily important for provider authors is how a
BackendV2
exposes the properties of a particular backend to the transpiler. WithBackendV2
this is done via aTarget
object. TheTarget
, which is exposed via thetarget
attribute, is used to represent the set of constraints for running circuits on a particular backend. It contains the subset of information previously exposed by theBackendConfiguration
,BackendProperties
, andPulseDefaults
classes which the transpiler can actively use. When migrating a provider to useBackendV2
(or when creating a new provider package) the construction of backend objects will primarily be around creating aTarget
object for the backend.
Added a new
Target
class to thetranspiler
module. TheTarget
class is designed to represent the constraints of backend to the compiler. TheTarget
class is intended to be used with aBackendV2
backend and is how backends will model their constraints for the transpiler moving forward. It combines the previously distinct fields used for controlling thetranspile()
target device (e.g.basis_gates
,coupling_map
,instruction_durations
, etc) into a single data structure. It also adds additional functionality on top of what was available previously such as representing heterogeneous gate sets, multi-qubit gate connectivity, and tuned variants of the same gates. Currently the transpiler doesn’t factor in all these constraints, but over time it will grow to leverage the extra functionality.
The
Options
class now has optional support for specifying validators. This enablesBackend
authors to optionally specify basic validation on the user supplied values for fields in theOptions
object. For example, if you had anOptions
object defined with:from qiskit.providers.Options options = Options(shots=1024)
you can set a validator on shots for it to be between 1 and 4096 with:
options.set_validator('shots', (1, 4096))
With the validator set any call to the
update_options()
method will check that ifshots
is being updated the proposed new value is within the valid range.
Added a new transpiler analysis pass,
ContainsInstruction
, to theqiskit.transpiler.passes
module. This pass is used to determine if a circuit contains a specific instruction. It takes in a single parameter at initialization, the name of the instruction to check for and set a boolean in the property set whether the circuit contains that instruction or not. For example:from qiskit.transpiler.passes import ContainsInstruction from qiskit.circuit import QuantumCircuit circuit = QuantumCircuit(2) circuit.h(0) circuit.cx(0, 1) circuit.measure_all() property_set = {} # Contains Hadamard contains_h = ContainsInstruction("h") contains_h(circuit, property_set) assert property_set["contains_h"] == True # Not contains SX contains_sx = ContainsInstruction("sx") contains_sx(circuit, property_set) assert property_set["contains_sx"] == False
Added a utility function
qiskit.utils.detach_prefix()
that is a counterpart ofapply_prefix()
. The new function returns a tuple of scaled value and prefix from a given float value. For example, a value1.3e8
will be converted into(130, "M")
that can be used to display a value in the user friendly format, such as130 MHz
.
The values
"gate_error"
and"balanced"
are now available for theobjective
option in the construction of theBIPMapping
object, and"balanced"
is now the default.The
"gate_error"
objective requires passing aBackendProperties
instance in thebackend_prop
kwarg, which contains the 2q-gate gate errors used in the computation of the objectives. The"balanced"
objective will use theBackendProperties
instance if it is given, but otherwise will assume a CX error rate as given in the new parameterdefault_cx_error_rate
. The relative weights of the gate-error and depth components of the balanced objective can be controlled with the newdepth_obj_weight
parameter.
Every attribute of the
VQE
class that is set at the initialization is now accessible with getters and setters. Further, the default values of the VQE attributesansatz
andoptimizer
can be reset by assigningNone
to them:vqe = VQE(my_ansatz, my_optimizer) vqe.ansatz = None # reset to default: RealAmplitudes ansatz vqe.optimizer = None # reset to default: SLSQP optimizer
Added a new method
PauliList.group_qubit_wise_commuting()
that partitions aPauliList
into sets of mutually qubit-wise commutingPauli
operators. For example:from qiskit.quantum_info import PauliList, Pauli pauli_list = PauliList([Pauli("IY"), Pauli("XX"), Pauli("YY"), Pauli("YX")]) pauli_list.group_qubit_wise_commuting()
Added a new coupling-map constructor method
CouplingMap.from_hexagonal_lattice()
for constructing a hexagonal lattice coupling map. For example, to construct a 2x2 hexagonal lattice coupling map:from qiskit.transpiler import CouplingMap cmap = CouplingMap.from_hexagonal_lattice(2, 2) cmap.draw()
New fake backend classes are available under
qiskit.test.mock
. These include mocked versions ofibmq_brooklyn
,ibmq_manila
,ibmq_jakarta
, andibmq_lagos
. As with the other fake backends, these include snapshots of calibration data (i.e.backend.defaults()
) and error data (i.e.backend.properties()
) taken from the real system, and can be used for local testing, compilation and simulation.
Added the
OperatorBase.is_hermitian()
method to check whether the operator is Hermitian or not.NumPyEigensolver
andNumPyMinimumEigensolver
useeigh
oreigsh
to solve the eigenvalue problem when the operator is Hermitian.
Added a new constructor method
PassManagerConfig.from_backend()
. It constructs aPassManagerConfig
object with user options and the configuration of a backend. With this feature, a preset passmanager can be built easier. For example:from qiskit.transpiler.passmanager_config import PassManagerConfig from qiskit.transpiler.preset_passmanagers import level_1_pass_manager from qiskit.test.mock import FakeMelbourne pass_manager = level_1_pass_manager( PassManagerConfig.from_backend(FakeMelbourne(), seed_transpiler=42) )
A new transpiler pass,
PulseGates
, was added, which automatically extracts user-provided calibrations from the instruction schedule map and attaches the gate schedule to the given (transpiled) quantum circuit as a pulse gate.The
PulseGates
transpiler pass is applied to all optimization levels from 0 to 3. No gate implementation is updated unless the end-user explicitly overrides thebackend.defaults().instruction_schedule_map
. This pass saves users from individually callingQuantumCircuit.add_calibration()
for every circuit run on the hardware.To supplement this new pass, a schedule was added to
InstructionScheduleMap
and is implicitly updated with a metadata field"publisher"
. Backend-calibrated gate schedules have a special publisher kind to avoid overriding circuits with calibrations of already known schedules. Usually, end-users don’t need to take care of this metadata as it is applied automatically. You can callInstructionScheduleMap.has_custom_gate()
to check if the map has custom gate calibration.See the below code example to learn how to apply custom gate implementation for all circuits under execution.
from qiskit.test.mock import FakeGuadalupe from qiskit import pulse, circuit, transpile backend = FakeGuadalupe() with pulse.build(backend, name="x") as x_q0: pulse.play(pulse.Constant(160, 0.1), pulse.drive_channel(0)) backend.defaults().instruction_schedule_map.add("x", (0,), x_q0) circs = [] for _ in range(100): circ = circuit.QuantumCircuit(1) circ.sx(0) circ.rz(1.57, 0) circ.x(0) circ.measure_active() circs.append(circ) circs = transpile(circs, backend) circs[0].calibrations # This returns calibration only for x gate
Note that the instruction schedule map is a mutable object. If you override one of the entries and use that backend for other experiments, you may accidentally update the gate definition.
backend = FakeGuadalupe() instmap = backend.defaults().instruction_schedule_map instmap.add("x", (0, ), my_x_gate_schedule) qc = QuantumCircuit(1, 1) qc.x(0) qc.measure(0, 0) qc = transpile(qc, backend) # This backend uses custom X gate
If you want to update the gate definitions of a specific experiment, you need to first deepcopy the instruction schedule map and directly pass it to the transpiler.
Introduced a new option
qubit_subset
to the constructor ofBIPMapping
. The option enables us to specify physical qubits to be used (incoupling_map
of the device) during the mapping in one line:mapped_circ = BIPMapping( coupling_map=CouplingMap([[0, 1], [1, 2], [1, 3], [3, 4]]), qubit_subset=[1, 3, 4] )(circ)
Previously, to do the same thing, we had to supply a reduced
coupling_map
which contains only the qubits to be used, embed the resulting circuit onto the originalcoupling_map
and update theQuantumCircuit._layout
accordingly:reduced_coupling = coupling_map.reduce(qubit_to_use) mapped = BIPMapping(reduced_coupling)(circ) # skip the definition of fill_with_ancilla() # recover circuit on original coupling map layout = Layout({q: qubit_to_use[i] for i, q in enumerate(mapped.qubits)}) for reg in mapped.qregs: layout.add_register(reg) property_set = {"layout": fill_with_ancilla(layout)} recovered = ApplyLayout()(mapped, property_set) # recover layout overall_layout = Layout({v: qubit_to_use[q] for v, q in mapped._layout.get_virtual_bits().items()}) for reg in mapped.qregs: overall_layout.add_register(reg) recovered._layout = fill_with_ancilla(overall_layout)
Added the
ignore_pauli_phase
andcopy
arguments to the constructor ofSparsePauliOp
.ignore_pauli_phase
prevents thephase
attribute of an inputPauliList
from being read, which is more performant if thePauliList
is already known to have all phases as zero in the internal ZX convention.copy
allows users to avoid the copy of the input data when they explicitly setcopy=False
.
Improved performance of the following
SparsePauliOp
operations:simplify()
(see #7122)_add()
(see #7138)from_list()
and__init__()
(see other discussion in #7138).
Added the
SparsePauliOp.sum()
method to add together manySparsePauliOp
s. This method has significantly better performance than adding the instances together in a loop. For example, the previous way to add severalSparsePauliOp
s together would be to do:from qiskit.quantum_info import SparsePauliOp, random_pauli_list sparse_ops = [SparsePauliOp(random_pauli_list(10, 10)) for _ in [None]*1000] total = sparse_ops[0] for op in sparse_ops[1:]: total += op
This can now be done far more efficiently (in both speed and typing!) as:
SparsePauliOp.sum(sparse_ops)
Added an argument
limit_amplitude
to the constructor ofParametricPulse
, which is the base class ofGaussian
,GaussianSquare
,Drag
andConstant
, to allowing disabling the amplitude limit of 1 on a pulse-by-pulse basis. Withlimit_amplitude=False
, individual pulses may have an amplitude exceeding unity without raising aPulseError
. See #6544 for more detail.
Using
QuantumCircuit.draw()
orcircuit_drawer()
with thelatex
drawer will now generate a file in an image format inferred from the filename extension, for example:import qiskit circuit = qiskit.QuantumCircuit(2) circuit.h(0) circuit.cx(0, 1) circuit.draw('latex', filename='./file.jpg')
This will save the circuit drawing in the JPEG format. Previously, the image always be in PNG format. Refer to #6448 for more details.
Now, if it encounters a filename extension which is not supported, for example:
circuit.draw('latex', filename='./file.spooky')
it will raise a
ValueError
to change the filename extension to a supported image format.
Added the parameter
filename
toplot_gate_map()
andplot_coupling_map()
, which allows saving the resulting images to a file.
Introduced an approximate quantum compiler and a corresponding unitary synthesis plugin implementation. The main AQC class is
AQC
for a standalone version that compiles a unitary matrix into an approximate circuit. The plugin may be invoked bytranspile()
when theunitary_synthesis_method
argument is set to'aqc'
. Seeqiskit.transpiler.synthesis.aqc
for full details.
Added a
filter_function
argument toQuantumCircuit.depth()
andQuantumCircuit.size()
in order to analyze circuit operations according to some criteria.For example, to get the number of two-qubit gates, you can do:
circuit.size(lambda x: x[0].num_qubits == 2)
Or to get the depth of T gates acting on the zeroth qubit:
circuit.depth(lambda x: x[0].name == 't' and circuit.qubits[0] in x[1])
Added a new transpiler pass,
CollectMultiQBlocks
, to theqiskit.transpiler.passes
module. This pass is used to collect sequences of uninterrupted gates acting on groups of qubits. It provides a similar function to the existingCollect2qBlocks
pass, but while that pass is designed and optimized to find 2 qubit blocks this new pass will work to find blocks of any size.
There is a builder interface for the new control-flow operations on
QuantumCircuit
, such as the newForLoopOp
,IfElseOp
, andWhileLoopOp
. The interface uses the same circuit methods, i.e.QuantumCircuit.for_loop()
,QuantumCircuit.if_test()
andQuantumCircuit.while_loop()
, which are overloaded so that if thebody
parameter is not given, they return a context manager. Entering one of these context managers pushes a scope into the circuit, and captures all gate calls (and other scopes) and the resources these use, and builds up the relevant operation at the end. For example, you can now do:qc = QuantumCircuit(2, 2) with qc.for_loop(range(5)) as i: qc.rx(i * math.pi / 4, 0)
This will produce a
ForLoopOp
onqc
, which knows that qubit 0 is the only resource used within the loop body. These context managers can be nested, and will correctly determine their widths. You can useQuantumCircuit.break_loop()
andQuantumCircuit.continue_loop()
within a context, and it will expand to be the correct width for its containing loop, even if it is nested in furtherQuantumCircuit.if_test()
blocks.The
if_test()
context manager provides a chained manager which, if desired, can be used to create anelse
block, such as by:qreg = QuantumRegister(2) creg = ClassicalRegister(2) qc = QuantumCircuit(qreg, creg) qc.h(0) qc.cx(0, 1) qc.measure(0, 0) with qc.if_test((creg, 0)) as else_: qc.x(1) with else_: qc.z(1)
The manager will ensure that the
if
andelse
bodies are defined over the same set of resources.
Introduced a new transpiler pass
InverseCancellation
that generalizes theCXCancellation
pass to cancel any self-inverse gates or gate-inverse pairs. It can be used by initializingInverseCancellation
and passing a gate to cancel, for example:from qiskit.transpiler.passes import InverseCancellation from qiskit import QuantumCircuit from qiskit.circuit.library import HGate from qiskit.transpiler import PassManager qc = QuantumCircuit(2, 2) qc.h(0) qc.h(0) pass_ = InverseCancellation([HGate()]) pm = PassManager(pass_) new_circ = pm.run(qc)
The constructor of
RZXCalibrationBuilder
has two new kwargsinstruction_schedule_map
andqubit_channel_mapping
which take aInstructionScheduleMap
and list of channel name lists for each qubit respectively. These new arguments are used to directly specify the information needed from a backend target. They should be used instead of passing aBaseBackend
orBackendV1
object directly to the pass with thebackend
argument.
The
Statevector
s of states comprised only of qubits can now be drawn in LaTeX in ket notation. In ket notation the entries of the statevector are processed such that exact factors like fractions or square roots of two are drawn as such. The particular convention can be chosen by passing theconvention
keyword argument as either"ket"
or"vector"
as appropriate:import math from qiskit.quantum_info import Statevector sv = Statevector([math.sqrt(0.5), 0, 0, -math.sqrt(0.5)]) sv.draw("latex", convention="ket") sv.draw("latex", convention="vector")
Added a new transpiler pass
EchoRZXWeylDecomposition
that allows users to decompose an arbitrary two-qubit gate in terms of echoed RZX-gates by leveraging Cartan’s decomposition. In combination with other transpiler passes, this can be used to transpile arbitrary circuits to RZX-gate-based and pulse-efficient circuits that implement the same unitary.
The
SPSA
andQNSPSA
optimizer classes are now capable of batching as many circuit evaluations as possible for both the iterations and the initial calibrations. This can be leveraged by setting themax_evals_grouped
kwarg on the constructor forVQE
when using eitherSPSA
orQNSPSA
as theoptimizer
parameter. For example:from qiskit.circuit.library import TwoLocal from qiskit.algorithms import VQE from qiskit.algorithms.optimizers import QNSPSA from qiskit.test.mock import FakeMontreal backend = FakeMontreal() ansatz = TwoLocal(2, rotation_blocks=["ry", "rz"], entanglement_blocks="cz") qnspsa = QNSPSA(fidelity, maxiter=5) vqe = VQE( ansatz=ansatz, optimizer=qnspsa, max_evals_grouped=100, quantum_instance=backend, )
This release introduces a decomposition method for two-qubit gates which targets user-defined sets of RZX gates. Transpiler users can enable decomposition for {
RZX(pi/2)
,RZX(pi/4)
, andRZX(pi/6)
} specifically by including'rzx'
in theirbasis_gates
list when callingtranspile()
. Quantum information package users can find the method itself under theXXDecomposer
class.
Added a transpiler pass
Optimize1qGatesSimpleCommutation
, which optimizes a circuit according to a strategy of commuting single-qubit gates around to discover resynthesis opportunities.
Added a
max_job_tries
parameter toQuantumInstance
, to limit the number of times a job will attempt to be executed on a backend. Previously the submission and fetching of results would be attempted infinitely, even if the job was cancelled or errored on the backend. The default is now 50, and the previous behaviour can be achieved by settingmax_job_tries=-1
. Fixes #6872 and #6821.
The
latex
output method for thecircuit_drawer()
function and theQuantumCircuit.draw()
method can now draw circuits that contain gates with single bit condition. This was added for compatibility of latex drawer with the new feature of supporting classical conditioning of gates on single classical bits.
The
"mpl"
output method for thecircuit_drawer()
function and theQuantumCircuit.draw()
method can now draw circuits that contain gates with single bit condition. This was added for compatibility of the"mpl"
drawer with the new feature of supporting classical conditioning of gates on single classical bits.
The
text
output method for thecircuit_drawer()
function and theQuantumCircuit.draw()
method can now draw circuits that contain gates with single bit condition. This was added for compatibility of text drawer with the new feature of supporting classical conditioning of gates on single classical bits.
A new analysis transpiler pass,
GatesInBasis
, was added toqiskit.transpiler.passes
. This pass is used to check if theDAGCircuit
being transpiled has all the gates in the configured basis set or not. It will set the attribute"all_gates_in_basis"
in the property set toTrue
if all the gates in theDAGCircuit
are in the configured basis set orFalse
if they are not. For example:from qiskit.circuit import QuantumCircuit from qiskit.transpiler.passes import GatesInBasis # Instatiate Pass basis_gates = ["cx", "h"] basis_check_pass = GatesInBasis(basis_gates) # Build circuit circuit = QuantumCircuit(2) circuit.h(0) circuit.cx(0, 1) circuit.measure_all() # Run pass on circuit property_set = {} basis_check_pass(circuit, property_set=property_set) assert property_set["all_gates_in_basis"]
Added two new constructor methods,
from_heavy_hex()
andfrom_heavy_square()
, to theCouplingMap
class. These constructor methods are used to create aCouplingMap
that are a heavy hex or heavy square graph as described in Chamberland et al., 2020.For example:
from qiskit.transpiler import CouplingMap cmap = CouplingMap.from_heavy_hex(5) cmap.draw()
from qiskit.transpiler import CouplingMap cmap = CouplingMap.from_heavy_square(5) cmap.draw()
The
HHL
algorithm can now find solutions when its matrix has negative eigenvalues. To enable this, the algorithm now adds an extra qubit to represent the sign of the value, and the helper algorithmExactReciprocal
was updated to process this new information. See #6971 for more details.
Added two new classes,
CompleteMeasFitter
andTensoredMeasFitter
to theqiskit.utils.mitigation
module. These classes are for use only as values for themeasurement_error_mitigation_cls
kwarg of theQuantumInstance
class. The instantiation and usage of these classes (or anything else inqiskit.utils.mitigation
) outside of themeasurement_error_mitigation_cls
kwarg should be treated as an internal private API and not relied upon.
The
ListOp
class inqiskit.opflow
now has acoeffs
attribute, which returns a list of the coefficients of the operator list, with the overall coefficient (ListOp.coeff
) distributed multiplicatively into the list. Note thatListOp
objects may be nested (contained inoplist
of aListOp
object), and in these cases an exception is raised if the coeffs method is called. TheListOp.coeffs
method conveniently duck-types against thecoeffs
property method of the non-nestingPauliSumOp
class.
The
Statevector
class is now subscriptable. User can now retrieve the nth coefficient in aStatevector
by index asstatevec[n]
.
Added the
Statevector.inner
method to calculate inner products ofStatevector
instances. For example:statevec_inner_other = statevec.inner(other)
will return the inner product of
statevec
withother
. Whilestatevec
must be aStatevector
,other
can be anything that can be constructed into aStatevector
, such as a Numpy array.
Added a new parameter,
add_bits
, toQuantumCircuit.measure_all()
. By default it is set toTrue
to maintain the previous behaviour of adding a newClassicalRegister
of the same size as the number of qubits to store the measurements. If set toFalse
, the measurements will be stored in the already existing classical bits. For example, if you created a circuit with existing classical bits like:from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister qr = QuantumRegister(2) cr = ClassicalRegister(2, "meas") circuit = QuantumCircuit(qr, cr)
calling
circuit.measure_all(add_bits=False)
will use the existing classical registercr
as the output target of theMeasurement
objects added to the circuit.
ParameterExpression
now delegates its numeric conversions to the underlying symbolic library, even if there are potentially unbound parameters. This allows conversions of expressions such as:>>> from qiskit.circuit import Parameter >>> x = Parameter('x') >>> float(x - x + 2.3) 2.3
where the underlying expression has a fixed value, but the parameter
x
is not yet bound.
Added an
Optimizer.minimize()
method to all optimizers:Optimizer
and derived classes. This method mimics the signature of SciPy’sminimize()
function and returns anOptimizerResult
.For example
import numpy as np from qiskit.algorithms.optimizers import COBYLA def loss(x): return -(x[0] - 1) ** 2 - (x[1] + 1) ** 3 initial_point = np.array([0, 0]) optimizer = COBYLA() result = optimizer.minimize(loss, initial_point) optimal_parameters = result.x minimum_value = result.fun num_function_evals = result.nfev
Added a
PauliEvolutionGate
to the circuit library (qiskit.circuit.library
) which defines a gate performing time evolution of (sums or sums-of-sums of)Pauli
s. The synthesis of this gate is performed byEvolutionSynthesis
and is decoupled from the gate itself. Currently available synthesis methods are:LieTrotter
: first order TrotterizationSuzukiTrotter
: higher order TrotterizationMatrixExponential
: exact, matrix-based evolution
For example:
from qiskit.circuit import QuantumCircuit from qiskit.circuit.library import PauliEvolutionGate from qiskit.quantum_info import SparsePauliOp from qiskit.synthesis import SuzukiTrotter operator = SparsePauliOp.from_list([ ("XIZ", 0.5), ("ZZX", 0.5), ("IYY", -1) ]) time = 0.12 # evolution time synth = SuzukiTrotter(order=4, reps=2) evo = PauliEvolutionGate(operator, time=time, synthesis=synth) circuit = QuantumCircuit(3) circuit.append(evo, range(3))
A new function
plot_coupling_map()
has been introduced, which extends the functionality of the existing functionplot_gate_map()
, by accepting three parameters:num_qubit
,qubit_coordinates
, andcoupling_map
(instead ofbackend
), to allow an arbitrary qubit coupling map to be plotted.
Qiskit Terra now has initial support for serializing
QuantumCircuit
s to OpenQASM 3:from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister from qiskit import qasm3 qc = QuantumCircuit(2) qc.h(0) qc.cx(0, 1) print(qasm3.dumps(qc))
OPENQASM 3; include "stdgates.inc"; qubit[2] _all_qubits; let q = _all_qubits[0:1]; h q[0]; cx q[0], q[1];
This initial release has limited support for named registers, basic built-in instructions (such as measure, barrier and reset), user-defined gates, user-defined instructions (as subroutines), and the new control-flow constructs also introduced in this release:
from qiskit.circuit import QuantumCircuit, QuantumRegister, ClassicalRegister from qiskit import qasm3 import math composite_circ_qreg = QuantumRegister(2) composite_circ = QuantumCircuit(composite_circ_qreg, name="composite_circ") composite_circ.h(0) composite_circ.x(1) composite_circ.cx(0, 1) composite_circ_gate = composite_circ.to_gate() qr = QuantumRegister(2, "qr") cr = ClassicalRegister(2, "cr") qc = QuantumCircuit(qr, cr) with qc.for_loop(range(4)) as i: qc.rx(i * math.pi / 4, 0) qc.cx(0, 1) qc.barrier() qc.append(composite_circ_gate, [0, 1]) qc.measure([0, 1], [0, 1]) print(qasm3.dumps(qc))
OPENQASM 3; include "stdgates.inc"; gate composite_circ _gate_q_0, _gate_q_1 { h _gate_q_0; x _gate_q_1; cx _gate_q_0, _gate_q_1; } bit[2] cr; qubit[2] _all_qubits; let qr = _all_qubits[0:1]; for _loop_i_0 in [0:3] { rx(pi/4*_loop_i_0) qr[0]; cx qr[0], qr[1]; } barrier qr[0], qr[1]; composite_circ qr[0], qr[1]; cr[0] = measure qr[0]; cr[1] = measure qr[1];
The
QDrift
class was reformulated as a synthesis method forPauliEvolutionGate
, deriving fromTrotterizationBase
.from qiskit.circuit import QuantumCircuit from qiskit.circuit.library import PauliEvolutionGate from qiskit.synthesis import QDrift from qiskit.opflow import X, Y, Z qdrift = QDrift(reps=2) operator = (X ^ 3) + (Y ^ 3) + (Z ^ 3) time = 2.345 # evolution time evolution_gate = PauliEvolutionGate(operator, time, synthesis=qdrift) circuit = QuantumCircuit(3) circuit.append(evolution_gate, range(3))
QPY serialization is now capable of representing
global_phase
attributes of aQuantumCircuit
object that are anint
,Parameter
object, orParameterExpression
object. Previous versions of QPY would only accept aglobal_phase
that was afloat
.This requires the QPY format version_2 which was introduced in this release to represent the additional types.
A new
find_bit()
method has been added to theQuantumCircuit
class, which allows lookups of the index and registers of a providedBit
on the given circuit. The method returns a two-elementnamedtuple
containing 0) the index of theBit
in eitherqubits
(for aQubit
) orclbits
(for aClbit
) and 1) a list of length-2 tuples containing each circuitRegister
which contains theBit
, and the index in thatRegister
at which theBit
can be found.For example:
from qiskit.circuit import QuantumCircuit, QuantumRegister, Qubit reg1 = QuantumRegister(3, 'foo') qubit = Qubit() reg2 = QuantumRegister(2, 'bar') qc = QuantumCircuit(reg1, [qubit], reg2) print(qc.find_bit(reg1[2])) print(qc.find_bit(qubit))
would generate:
BitLocations(index=2, registers=[(QuantumRegister(3, 'foo'), 2)]) BitLocations(index=3, registers=[])
Three new
Instruction
subclasses have been added to support control flow operations in dynamic circuits:WhileLoopOp
,ForLoopOp
, andIfElseOp
. Additionally, two subclasses,BreakLoopOp
, andContinueLoopOp
, have been added to support breaking from and continuing to the next iteration of a loop context, respectively.These can be created as stand-alone
Instruction
s, or appended to an existingQuantumCircuit
instance via their respective methods,QuantumCircuit.while_loop()
,for_loop()
,if_test()
,if_else()
,break_loop()
, andcontinue_loop()
.
Added the
BaseReadoutMitigator
abstract base class for implementing classical measurement error mitigators. These objects are intended for mitigation measurement errors inCounts
objects returned from execution of circuits on backends with measurement errors.Readout mitigator classes have two main methods:
expectation_value()
which computes an mitigated expectation value and standard error of a diagonal operator from a noisyCounts
object.quasi_probabilities()
that computes an error mitigatedQuasiDistribution
, including standard error, from a noisy counts object.
Note that currently the
qiskit.algorithms
module and theQuantumInstance
class still use the legacy mitigators migrated from Qiskit Ignis inqiskit.utils.mitigation
. It is planned to upgrade the module to use the new mitigator classes and deprecate the legacy mitgation code in a future release.
Added the
LocalReadoutMitigator
class for performing measurement readout error mitigation of local measurement errors. Local measuerment errors are those that are described by a tensor-product of single-qubit measurement errors.This class can be initialized with a list of \(N\) single-qubit of measurement error assignment matrices or from a backend using the readout error information in the backend properties.
Mitigation is implemented using local assignment-matrix inversion which has complexity of \(O(2^N)\) for \(N\)-qubit mitigation of
QuasiDistribution
and expectation values.
Added the
CorrelatedReadoutMitigator
class for performing measurement readout error mitigation of correlated measurement errors. This class can be initialized with a single \(2^N \times 2^N\) measurement error assignment matrix that descirbes the error probabilities. Mitigation is implemented via inversion of assigment matrix which has mitigation complexity of \(O(4^N)\) ofQuasiDistribution
and expectation values.
Added a
QuasiDistribution.stddev_upper_bound
attribute and a kwarg to the constructor of theQuasiDistribution
class, which is used for storing standard errors in quasi-probability estimates. This is used byBaseReadoutMitigator
classes to store the standard error in mitigated quasi probabilities.
Added a
shots()
method toqiskit.result.Counts
to return the sum of all outcomes in the counts.
When running the
Grover
algorithm class if the optimal power is known and only a single circuit is run, theAmplificationProblem.is_good_state
callback function is no longer required to be set and the Grover search will return the most likely bitstring. Generally, if the optimal power of the Grover operator is not known, theGrover
algorithm checks different powers (i.e. iterations) and applies theis_good_state
function to check whether a good bitstring has been measured. For example, you are now able to run something like:from qiskit.algorithms import Grover, AmplificationProblem from qiskit.providers.aer import AerSimulator from qiskit.quantum_info import Statevector # Fixed Grover power: 2. grover = Grover(iterations=2, quantum_instance=AerSimulator()) # The ``is_good_state`` argument not required here since Grover search # will be run only once, with a power of 2. problem = AmplificationProblem(Statevector.from_label("111")) # Run Grover search and print the best measurement result = grover.amplify(problem) print(result.top_measurement) # should print 111
Added method
remove_cregs()
to classDAGCircuit
to support classical register removal.
Added method
remove_clbits()
to classDAGCircuit
to support the removal of idle classical bits. Any classical registers referencing a removed bit are also removed.
Added a new method,
replace_block_with_op()
, to theDAGCircuit
class. This method is used to replace a block of nodes in the DAG with a single operation. The canonical example is for theConsolidateBlocks
pass which replaces blocks of nodes with equivalentUnitaryGate
nodes.
Added a new analysis transpiler pass,
Collect1qRuns
, to theqiskit.transpiler.passes
module. This pass is used to find sequences of uninterrupted gates acting on a single qubit. It is similar to theCollect2qBlocks
andCollectMultiQBlocks
but optimized for single qubit runs instead of multiple qubit blocks.
Various transpilation internals now use new features in retworkx 0.10 when operating on the internal circuit representation. This can often result in speedups in calls to
transpile
of around 10-40%, with greater effects at higher optimization levels. See #6302 for more details.
The
UnitarySynthesis
transpiler pass inqiskit.transpiler.passes
has a new kwarg in the constructor,min_qubits
. When specified this can be set to anint
value which is the minimum sizeUnitaryGate
object to run the unitary synthesis on. If aUnitaryGate
in aQuantumCircuit
uses fewer qubits it will be skipped by that instance of the pass.
The
Eigensolver
andMinimumEigensolver
interfaces now support the typeDict[str, Optional[OperatorBase]]
for theaux_operators
parameter in their respectivecompute_eigenvalues()
andcompute_minimum_eigenvalue()
methods. In this case, the auxiliary eigenvalues are also stored in a dictionary under the same keys provided by theaux_operators
dictionary. Keys that correspond to an operator that does not commute with the main operator are dropped.
The
BasisTranslator
,GateDirection
, andCheckGateDirection
transpiler passes have a newtarget
kwarg in their constructors, which can be used to set aTarget
object as the target for the pass. If it is set it will be used instead of thetarget_basis
(in the case of theBasisTranslator
pass) orcoupling_map
(in the case of theGateDirection
andCheckGateDirection
passes) arguments.
Allow two transpiler stages in the
QuantumInstance
, one for parameterized circuits and a second one for bound circuits (i.e. no free parameters) only. If a quantum instance with passes for unbound and bound circuits is passed into aCircuitSampler
, the sampler will attempt to apply the unbound pass once on the parameterized circuit, cache it, and only apply the bound pass for all future evaluations.This enables variational algorithms like the
VQE
to run a custom pass manager for parameterized circuits once and, additionally, another the transpiler again with a different custom pass manager on the bound circuits in each iteration. Being able to run different pass managers is important because not all passes support parameterized circuits (for exampleOptimize1qGatesDecomposition
only works with bound circuit parameters).For example, this feature allows using the pulse-efficient CX decomposition in the VQE, as
from qiskit.algorithms import VQE from qiskit.opflow import Z from qiskit.circuit.library.standard_gates.equivalence_library import StandardEquivalenceLibrary as std_eqlib from qiskit.transpiler import PassManager, PassManagerConfig, CouplingMap from qiskit.transpiler.preset_passmanagers import level_1_pass_manager from qiskit.transpiler.passes import ( Collect2qBlocks, ConsolidateBlocks, Optimize1qGatesDecomposition, RZXCalibrationBuilderNoEcho, UnrollCustomDefinitions, BasisTranslator ) from qiskit.transpiler.passes.optimization.echo_rzx_weyl_decomposition import EchoRZXWeylDecomposition from qiskit.test.mock import FakeBelem from qiskit.utils import QuantumInstance # Replace by a real backend! If not ensure qiskit-aer is installed to simulate the backend backend = FakeBelem() # Build the pass manager for the parameterized circuit rzx_basis = ['rzx', 'rz', 'x', 'sx'] coupling_map = CouplingMap(backend.configuration().coupling_map) config = PassManagerConfig(basis_gates=rzx_basis, coupling_map=coupling_map) pre = level_1_pass_manager(config) # Build a pass manager for the CX decomposition (works only on bound circuits) post = PassManager([ # Consolidate consecutive two-qubit operations. Collect2qBlocks(), ConsolidateBlocks(basis_gates=['rz', 'sx', 'x', 'rxx']), # Rewrite circuit in terms of Weyl-decomposed echoed RZX gates. EchoRZXWeylDecomposition(backend), # Attach scaled CR pulse schedules to the RZX gates. RZXCalibrationBuilderNoEcho(backend), # Simplify single-qubit gates. UnrollCustomDefinitions(std_eqlib, rzx_basis), BasisTranslator(std_eqlib, rzx_basis), Optimize1qGatesDecomposition(rzx_basis), ]) quantum_instance = QuantumInstance(backend, pass_manager=pre, bound_pass_manager=post) vqe = VQE(quantum_instance=quantum_instance) result = vqe.compute_minimum_eigenvalue(Z ^ Z)
Introduced a new unitary synthesis plugin interface which is used to enable using alternative synthesis techniques included in external packages seamlessly with the
UnitarySynthesis
transpiler pass. Users can select a plugin to use when callingtranspile()
by setting theunitary_synthesis_method
kwarg to the plugin’s name. A full list of installed plugins can be found using theqiskit.transpiler.passes.synthesis.plugin.unitary_synthesis_plugin_names()
function. For example, if you installed a package that includes a synthesis plugin namedspecial_synth
you could use it with:from qiskit import transpile transpile(qc, unitary_synthesis_method='special_synth', optimization_level=3)
This will replace all uses of the
UnitarySynthesis
with the method included in the external package that exports thespecial_synth
plugin.The plugin interface is built around setuptools entry points which enable packages external to Qiskit to advertise they include a synthesis plugin. For details on writing a new plugin refer to the
qiskit.transpiler.passes.synthesis.plugin
module documentation.
Added a new transpiler pass,
VF2Layout
. This pass models the layout allocation problem as a subgraph isomorphism problem and uses the VF2 algorithm implementation in retworkx to find a perfect layout (a layout which would not require additional routing) if one exists. The functionality exposed by this new pass is very similar to exisitingCSPLayout
butVF2Layout
is significantly faster.
Known Issues¶
The
"ket"
convention in the"latex"
drawer ofStatevector.draw()
is only valid for states comprising purely of qubits. If you are using states with some spaces of dimension greater than two, you should either passconvention="vector"
, or use a different drawer.
The OpenQASM 3 export capabilities are in a beta state, and some features of Qiskit Terra’s
QuantumCircuit
are not yet supported. In particular, you may see errors if you try to export custom subroutines with classical parameters, and there is no provision yet for exporting pulse-calibrated operations into OpenPulse.
When running the
BasisTranslator
in isolation with thetarget
argument set to aTarget
object, where some single-qubit gates can only apply to non-overlapping sets of qubits, the output circuit might incorrectly include operations on a qubit that are not allowed by theTarget
. For example, if you ran:from qiskit.circuit import QuantumCircuit, Parameter from qiskit.circuit.library import UGate, RZGate, XGate, SXGate, CXGate from qiskit.circuit.equivalence_library import SessionEquivalenceLibrary as sel from qiskit.transpiler import PassManager, Target, InstructionProperties from qiskit.transpiler.passes import BasisTranslator gmap = Target() # U gate in qubit 0. theta = Parameter('theta') phi = Parameter('phi') lam = Parameter('lambda') u_props = { (0,): InstructionProperties(duration=5.23e-8, error=0.00038115), } gmap.add_instruction(UGate(theta, phi, lam), u_props) # Rz gate in qubit 1. phi = Parameter("phi") rz_props = { (1,): InstructionProperties(duration=0.0, error=0), } gmap.add_instruction(RZGate(phi), rz_props) # X gate in qubit 1. x_props = { (1,): InstructionProperties( duration=3.5555555555555554e-08, error=0.00020056469709026198 ), } gmap.add_instruction(XGate(), x_props) # SX gate in qubit 1. sx_props = { (1,): InstructionProperties( duration=3.5555555555555554e-08, error=0.00020056469709026198 ), } gmap.add_instruction(SXGate(), sx_props) cx_props = { (0, 1): InstructionProperties(duration=5.23e-7, error=0.00098115), (1, 0): InstructionProperties(duration=4.52e-7, error=0.00132115), } gmap.add_instruction(CXGate(), cx_props) bt_pass = BasisTranslator(sel, target_basis=None, target=gmap) qc = QuantumCircuit(2) qc.iswap(0, 1) output = bt_pass(qc)
output
will haveRZGate
andSXGate
on qubit 0, even though this is forbidden. To correct this you can normally run the basis translator a second time (i.e.output = bt_pass(output)
in the above example) to correct this. This should not affect the output of running thetranspile()
function and is only an issue if you run the pass by itself.
Upgrade Notes¶
Starting with this version,
from qiskit import *
will not import submodules, but only a selected list of objects. This might break existing code usingfrom qiskit import *
and referring to objects that are not part of the current namespace. As a reminder,import *
is considered bad practice and it should not be used in production code. Qiskit sets__all__
inqiskit/__init__.py
as a way to mitigate the effects of said bad practice. If your code raisesname '<something>' is not defined
, addfrom qiskit import <something>
and try again.
The preset pass managers for optimization levels 0, 1, 2, and 3 which are generated by
level_0_pass_manager()
,level_1_pass_manager()
,level_2_pass_manager()
, andlevel_3_pass_manager()
respectively will no longer unconditionally run theTimeUnitConversion
. Previously, the preset pass managers would always run this pass regardless of the inputs to the transpiler and the circuit. Now this pass will only be run if ascheduling_method
parameter is set or the circuit contains aDelay
instruction and theinstruction_durations
parameter is set. This change was made in the interest of runtime performance as in some cases runningtranspile()
on circuits with a large number of gates and no delays, timing, or scheduling being used theTimeUnitConversion
could be the largest bottleneck in the transpilation.
The default method for
BIPMapping
is nowbalanced
rather thandepth
. This new objective generally achieves a better result, as it factors in both the circuit depth and the gate error.
The
sort_parameters_by_name
of theVQE
class has been removed, following its deprecation in Qiskit Terra 0.18. There is no alternative provided, as the new ordering of parameters is the more natural sort order.
The circuit drawers
QuantumCircuit.draw()
andcircuit_drawer()
with thelatex
option will now save their images in a format determined the file extension (if a file name is provided). Previously, they would always save in PNG format. They now raiseValueError
if the image format is not known. This was done to make it easier to save the image in different formats.
The core dependency
retworkx
had its version requirement bumped to 0.10.1, up from 0.9. This enables several performance improvements across different transpilation passes.
The previously deprecated
condition
kwarg, which was deprecated as part of the 0.15.0 release, has been removed fromDAGCircuit.apply_operation_back()
andDAGCircuit.apply_operation_front()
. Instead set thecondition
attribute on theInstruction
instances being added to theDAGCircuit
usingInstruction.c_if()
.
The
DAGCircuit.extend_back()
method has been removed. It was originally deprecated in the 0.13.0 release. Instead you can use theDAGCircuit.compose()
method which is more general and provides the same functionality.
The
DAGCircuit.compose_back()
method has been removed. It was originally deprecated in the 0.13.0 release. Instead you can use theDAGCircuit.compose()
method which is more general and provides the same functionality.
The
edge_map
kwarg of theDAGCircuit
methodcompose()
has been removed. It was originally deprecated in the 0.14.0 release. The method takes aqubits
andclbits
kwargs to specify the positional order of bits to compose onto instead of using a dictionary mapping thatedge_map
previously provided.
The
DAGCircuit.twoQ_gates()
method has been removed. It was originally deprecated in the 0.13.0 release. Instead,DAGCircuit.two_qubit_ops()
should be used.
The
DAGCircuit.threeQ_or_more_gates()
method has been removed. It was originally deprecated in the 0.13.0 release. Instead,DAGCircuit.multi_qubit_ops()
method should be used.
Named access for the first positional argument for the constructor of the
SingleQubitUnitary
class withu
has been removed. It was originally deprecated in the 0.14.0 release. Instead, the first positional argument can be set using the nameunitary_matrix
(or just set it positionally instead of by name).
Named access for the first positional argument for the
QuantumCircuit
methodsqu
withu
has been removed. It was originally deprecated in the 0.14.0 release. Instead the first positional argument can be set using the nameunitary_matrix
(or just set it positionally instead of by name).
The unused
proc
andnested_scope
kwargs for theqasm()
method of the QASM node classes in theqiskit.qasm.node
module have been removed. They were originally deprecated in the 0.15.0 release.
The unused
proc
andnested_scope
kwargs for thelatex()
method of the QASM node classes in theqiskit.qasm.node
module have been removed. They were originally deprecated in the 0.15.0 release.
The unused
proc
andnested_scope
kwargs for thereal()
method of the QASM node classes in theqiskit.qasm.node
module have been removed. They were originally deprecated in the 0.15.0 release.
The output of
Statevector.draw()
when using"latex"
output is now the new"ket"
convention if plotting a state comprised purely of qubits. This was changed to make reading the output clearer, especially in educational contexts, because it shows the ket labels, and only displays the nonzero elements.
When running
execute()
with aBackendV1
backend the default values for the kwargsshots
,max_credits
,meas_level
,meas_return
andmemory_slot_size
will now be whatever the set default is on the target backend’soptions
attribute. Previously these defaults were set to match the default values when callingexecute()
with a legacyBaseBackend
backend. For example:from qiskit.test.mock import FakeMumbai from qiskit import QuantumCircuit, execute circuit = QuantumCircuit(2) qc.h(0) qc.cx(0, 1) qc.measure_all() backend = FakeMumbai() backend.set_options(shots=4096) execute(qc, backend)
will now run with
4096
shots. While in previous releases it would run with1024
.
The minimum supported version of Matplotlib has been raised from 2.1.0 to 3.3.0. You will now need to have Matplotlib 3.3.0 installed if you’re using Matplotlib-based visualization functions such as the
'mpl'
backend for thecircuit_drawer()
function or theplot_bloch_vector()
function. This was done for two reasons, the first is because recent versions of Matplotlib have deprecated the use of APIs around 3D visualizations that were compatible with older releases and second installing older versions of Matplotlib was becoming increasingly difficult as matplotlib’s upstream dependencies have caused incompatiblities that made testing moving forward more difficult.
The internal use of the random number generator in
random_circuit()
was adjusted, which will change the output from previous versions, even with a fixed seed. This was done to greatly improve the runtime scaling with the number of qubits being used. If you were depending on an identical output from a previous version it is recommended that you useqpy_serialization.dump()
to save the random circuit generated with a previous version and instead of re-generating it with the new release, and instead just useqpy_serialization.load()
to load that saved circuit.
The use of
*
(__mul__
) for thedot()
method and@
(__matmul__
) for thecompose()
method ofBaseOperator
(which is the parent of all the operator classes inqiskit.quantum_info
including classes likeOperator
andPauli
) is no longer supported. The use of these operators were previously deprecated in 0.17.0 release. Instead you should use thedot()
andcompose()
methods directly, or the&
operator (__and__
) can be used forcompose()
. For example, if you were previously using the operator like:from qiskit.quantum_info import random_hermitian op_a = random_hermitian(4) op_b = random_hermitian(4) new_op = op_a @ op_b
this should be changed to be:
from qiskit.quantum_info import random_hermitian op_a = random_hermitian(4) op_b = random_hermitian(4) new_op = op_a.compose(op_b)
or:
new_op = op_a & op_b
Various methods of assigning parameters to operands of pulse program instructions have been removed, having been deprecated in Qiskit Terra 0.17. These include:
the
assign()
method ofpulse.Instruction
.the
assign()
method ofChannel
, which is the base ofAcquireChannel
,SnapshotChannel
,MemorySlot
andRegisterSlot
.the
assign()
andassign_parameters()
methods ofParametricPulse
, which is the base ofpulse.Gaussian
,pulse.GaussianSquare
,pulse.Drag
andpulse.Constant
.
These parameters should be assigned from the pulse program (
pulse.Schedule
andpulse.ScheduleBlock
) rather than operands of the pulse program instruction.
The
flatten()
method ofpulse.Instruction
andqiskit.pulse.Schedule
has been removed and no longer exists as per the deprecation notice from Qiskit Terra 0.17. This transformation is defined as a standalone function inqiskit.pulse.transforms.canonicalization.flatten()
.
qiskit.pulse.interfaces.ScheduleComponent
has been removed and no longer exists as per the deprecation notice from Qiskit Terra 0.15. No alternative class will be provided.
Legacy pulse drawer arguments have been removed from
pulse.Waveform.draw()
,Schedule.draw()
andScheduleBlock.draw()
and no longer exist as per the deprecation notice from Qiskit Terra 0.16. Now these draw methods support only V2 pulse drawer arguments. See method documentations for details.
The
qiskit.pulse.reschedule
module has been removed and this import path no longer exist as per the deprecation notice from Qiskit Terra 0.14. Useqiskit.pulse.transforms
instead.
A protected method
Schedule._children()
has been removed and replaced by a protected instance variable as per the deprecation notice from Qiskit Terra 0.17. This is now provided as a public attributeSchedule.children
.
Timeslot relevant methods and properties have been removed and no longer exist in
ScheduleBlock
as per the deprecation notice from Qiskit Terra 0.17. Since this representation doesn’t have notion of instruction timet0
, the timeslot information will be available after it is transformed to aSchedule
. Corresponding attributes have been provided after this conversion, but they are no longer supported. The following attributes are removed:timeslots
start_time
stop_time
ch_start_time
ch_stop_time
shift
insert
Alignment pulse schedule transforms have been removed and no longer exist as per the deprecation notice from Qiskit Terra 0.17. These transforms are integrated and implemented in the
AlignmentKind
context of the schedule block. The following explicit transform functions are removed:qiskit.pulse.transforms.align_equispaced
qiskit.pulse.transforms.align_func
qiskit.pulse.transforms.align_left
qiskit.pulse.transforms.align_right
qiskit.pulse.transforms.align_sequential
Redundant pulse builder commands have been removed and no longer exist as per the deprecation notice from Qiskit Terra 0.17.
pulse.builder.call_schedule
andpulse.builder.call_circuit
have been integrated intopulse.builder.call()
.
An internal filter override that caused all Qiskit deprecation warnings to be displayed has been removed. This means that the behaviour will now revert to the standard Python behaviour for deprecations; you should only see a
DeprecationWarning
if it was triggered by code in the main script file, interpreter session or Jupyter notebook. The user will no longer be blamed with a warning if internal Qiskit functions call deprecated behaviour. If you write libraries, you should occasionally run with the default warning filters disabled, or have tests which always run with them disabled. See the Python documentation on warnings, and in particular the section on testing for deprecations for more information on how to do this.
Certain warnings used to be only issued once, even if triggered from multiple places. This behaviour has been removed, so it is possible that if you call deprecated functions, you may see more warnings than you did before. You should change any deprecated function calls to the suggested versions, because the deprecated forms will be removed in future Qiskit releases.
The deprecated
qiskit.schemas
module and theqiskit.validation
module which build jsonschema validator from the schemas have been removed. This was deprecated in the 0.17.0 release and has been replaced with a dedicated repository for the IBM Quantum API payload schemas.If you were relying on the schema files previously packaged in
qiskit.schemas
or the validators built on them you should use that repository and create validators from the schema files it contains.
The functions
qiskit.qobj.validate_qobj_against_schema
andqiskit.qobj.common.validator
along with thevalidate
kwarg of the methodsQasmQobj.to_dict()
,PulseQobj.to_dict()
, andQobj.to_dict()
have been removed. These were deprecated in the 0.17.0 release. If you were using these function you will have to manually build jsonschema validation functions forQobj
objects using the jsonschema files from the dedicated repository for the IBM Quantum API payload schemas.
The
fastjsonschema
andjsonschema
packages are no longer in the requirements list for qiskit-terra. The internal use of jsonschema has been removed and they are no longer required to use qiskit-terra.
The exception raised by the
assemble()
function when invalid parameters are passed in for constructing aPulseQobj
have changed from aSchemaValidationError
to aQiskitError
. This was necessary because theSchemaValidationError
class was removed along with the rest of the deprecatedqiskit.schemas
andqiskit.validation
. This also makes it more consistent with other error conditions fromassemble()
which were already raising aQiskitError
.
The default routing pass and layout pass for transpiler optimization level 3 has changed to use
SabreSwap
andSabreLayout
respectively. This was done to improve the quality of the output result, as using the sabre passes produces better results than usingStochasticSwap
andDenseLayout
, which were used as the defaults in prior releases. This change will improve the quality of the results when runningtranspile()
orexecute()
functions with theoptimization_level
kwarg set to3
. While this is generally an improvement, if you need to retain the previous behavior for any reason you can do this by explicitly setting therouting_method="stochastic"
andlayout_method="dense"
when callingtranspile()
withoptimization_level=3
.
The return type of
pauli_basis()
will change fromPauliTable
toPauliList
in a future release of Qiskit Terra. To immediately swap to the new behaviour, pass the keyword argumentpauli_list=True
.
The
name
attribute of theSingleQubitUnitary
gate class has been changed fromunitary
tosqu
. This was necessary to avoid a conflict with theUnitaryGate
class’s name which was alsounitary
since the 2 gates are not the same and don’t have the same implementation (and can’t be used interchangeably).
The minimum version of Symengine required for installing has been increased to 0.8.0. This was necessary to fix some issues with the handling of
numpy.float16
andnumpy.float32
values when runningbind()
to bind parameters in aParameterExpression
.
A new dependency stevedore has been added to the requirements list. This is required by qiskit-terra as it is used to build the unitary synthesis plugin interface.
Deprecation Notes¶
The
gate
attribute and initialization parameter ofqiskit.transpiler.passes.Decompose
is deprecated, and will be removed in a future release. Instead of this single gate, you should pass a list of gate names to the new parametergates_to_decompose
. This was done as the new form allows you to select more than one gate as a decomposition target, which is more flexible, and does not need to re-run the pass several times to decompose a set of gates.
There has been a significant transpiler pass reorganization regarding calibrations. The import paths:
from qiskit.transpiler.passes.scheduling.calibration_creators import RZXCalibrationBuilder from qiskit.transpiler.passes.scheduling.calibration_creators import RZXCalibrationBuilderNoEcho
are deprecated, and will be removed in a future release. The import path:
from qiskit.transpiler.passes.scheduling.rzx_templates import rzx_templates
is also deprecated, and will be removed in a future release. You should use the new import paths:
from qiskit.transpiler.passes import RZXCalibrationBuilder from qiskit.transpiler.passes import RZXCalibrationBuilderNoEcho from qiskit.transpiler.passes.calibration.rzx_templates import rzx_templates
The
DAGNode
class is being deprecated as a standalone class and will be used in the future only as the parent class forDAGOpNode
,DAGInNode
, andDAGOutNode
. As part of this deprecation, the following kwargs and associated attributes inDAGNode
are also being deprecated:type
,op
, andwire
.
For the constructor of the
RZXCalibrationBuilder
passing a backend either as the first positional argument or with the namedbackend
kwarg is deprecated and will no longer work in a future release. Instead aInstructionScheduleMap
should be passed directly to theinstruction_schedule_map
kwarg and a list of channel name lists for each qubit should be passed directly toqubit_channel_mapping
. For example, if you were calling the pass like:from qiskit.transpiler.passes import RZXCalibrationBuilder from qiskit.test.mock import FakeMumbai backend = FakeMumbai() cal_pass = RZXCalibrationBuilder(backend)
instead you should call it like:
from qiskit.transpiler.passes import RZXCalibrationBuilder from qiskit.test.mock import FakeMumbai backend = FakeMumbai() inst_map = backend.defaults().instruction_schedule_map channel_map = self.backend.configuration().qubit_channel_mapping cal_pass = RZXCalibrationBuilder( instruction_schedule_map=inst_map, qubit_channel_mapping=channel_map, )
This change is necessary because as a general rule backend objects are not pickle serializable and it would break when it was used with multiple processes inside of
transpile()
when compiling multiple circuits at once.
The
label
property of classMCMT
and subclassMCMTVChain
has been deprecated and will be removed in a future release. Consequently, thelabel
kwarg on the constructor for both classes is also deprecated, along with thelabel
kwarg of methodMCMT.control()
. Currently, thelabel
property is used to name the controlled target when it is comprised of more than one target qubit, however, this was never intended to be user-specifiable, and can result in an incorrect MCMT gate if the name of a well-known operation is used. After deprecation, thelabel
property will no longer be user-specifiable. However, you can get the generated name of the controlled target viaMCMT.data[0][0].base_gate.name
The
subgraph()
method of theCouplingMap
class is deprecated and will be removed in a future release. Instead thereduce()
method should be used, which does the same thing except it preserves the node list order for the outputCouplingMap
(whilesubgraph()
did not preserve list order).
Creating an instance of
InstructionSet
with thecircuit_cregs
keyword argument is deprecated. In general, these classes never need to be constructed by users (but are used internally), but should you need to, you should pass a callable as theresource_requester
keyword argument. For example:from qiskit.circuit import Clbit, ClassicalRegister, InstructionSet from qiskit.circuit.exceptions import CircuitError def my_requester(bits, registers): bits_set = set(bits) bits_flat = tuple(bits) registers_set = set(registers) def requester(specifier): if isinstance(specifer, Clbit) and specifier in bits_set: return specifier if isinstance(specifer, ClassicalRegster) and specifier in register_set: return specifier if isinstance(specifier, int) and 0 <= specifier < len(bits_flat): return bits_flat[specifier] raise CircuitError(f"Unknown resource: {specifier}") return requester my_bits = [Clbit() for _ in [None]*5] my_registers = [ClassicalRegister(n) for n in range(3)] InstructionSet(resource_requester=my_requester(my_bits, my_registers))
The use of the measurement mitigation classes
qiskit.ignis.mitigation.CompleteMeasFitter
andqiskit.ignis.mitigation.TensoredMeasFitter
fromqiskit-ignis
as values for themeasurement_error_mitigation_cls
kwarg of the constructor for theQuantumInstance
class is deprecated and will be removed in a future release. Instead the equivalent classes fromqiskit.utils.mitigation
,CompleteMeasFitter
andTensoredMeasFitter
should be used. This was necessary as theqiskit-ignis
project is now deprecated and will no longer be supported in the near future. It’s worth noting that unlike the equivalent classes fromqiskit-ignis
the versions fromqiskit.utils.mitigation
are supported only in their use withQuantumInstance
(i.e. as a class not an instance with themeasurement_error_mitigation_cls
kwarg) and not intended for standalone use.
The
Optimizer.optimize()
method for all the optimizers (Optimizer
and derived classes) is now deprecated and will be removed in a future release. Instead, theOptimizer.minimize()
method should be used which mimics the signature of SciPy’sminimize()
function.To replace the current optimize call with minimize you can replace
xopt, fopt, nfev = optimizer.optimize( num_vars, objective_function, gradient_function, variable_bounds, initial_point, )
with
result = optimizer.minimize( fun=objective_function, x0=initial_point, jac=gradient_function, bounds=variable_bounds, ) xopt, fopt, nfev = result.x, result.fun, result.nfev
Importing the
qiskit.util
module will now issue aDeprecationWarning
. Users should instead import all the same functionality fromqiskit.utils
. Theutil
module has been deprecated since Terra 0.17, but previously did not issue a warning. It will be removed in Terra 0.20.
The property
table
is deprecated, and will be removed in a future release. This is becauseSparsePauliOp
has been updated to internally usePauliList
instead ofPauliTable
. This is in order to significantly improve performance. You should now access thePauliList
data by using theSparsePauliOp.paulis
attribute.
Bug Fixes¶
Fixed a bug where many layout methods would ignore 3-or-more qubit gates, resulting in unexpected layout-allocation decisions. The transpiler pass
Unroll3qOrMore
is now being executed before the layout pass in all the preset pass managers whentranspile()
is called. Fixed #7156.
Disassembled circuits now inherit calibrations from assembled
QasmQobj
and experiments. Fixes #5348.
Fixed setting the
ansatz
oroptimizer
attributes of aVQE
instance toNone
resulting in a buggy behavior. See #7093 for details.
Fixed addition of
PauliList
s withqargs
. The method used to raise a runtime error if the operands had different numbers of qubits.
Fixed an issue causing an error when trying to compute a gradient with the
CircuitGradient
class for a gate that was not a supported gate. This bugfix transpiles a given gate to the set of supported gates for a requested gradient method. Fixes #6918.
Removed calibration results when using error mitigation with the
execute()
method ofQuantumInstance
. Fixes #7129.
Fixed a deprecation warning emitted when running
QuantumCircuit.draw()
orcircuit_drawer()
with Sympy 1.9 installed, mentioning the Sympy functionexpr_free_symbols()
. The circuit drawers previously made use of this method when finding instances of symbolic constants.
Fixed an issue where the
ax
kwarg and thefigwidth
option in thestyle
kwarg for thempl
circuit drawer did not scale properly. Users can now pass anax
from a Matplotlib subplot to thempl
circuit drawer and the circuit will be drawn within the boundaries of that subplot. Alternatively, users can set thefigwidth
in inches in thestyle
dict kwarg and the drawing will scale to the width in inches that was set. Fixed #6367.
Fixed an issue with the
circuit_drawer()
function anddraw()
method ofQuantumCircuit
. When displaying ameasure
instruction targeted on a classical bit instead of a register, using thelatex
drawer option, the drawer would fail.
Fixed an issue with the
circuit_drawer()
function anddraw()
method ofQuantumCircuit
. With any of the 3 drawer options,mpl
,latex
, ortext
, if a gate with a classical condition was encountered that was conditioned on a classical bit without a register, the drawer would fail.
Fixed an issue with the
circuit_drawer()
function anddraw()
method ofQuantumCircuit
. With any of the 3 drawer options,mpl
,latex
, ortext
, if a gate with a classical condition was conditioned on the same classical bit as ameasure
and the bit that the measure targeted did not have a register, the drawer would fail.
C3SXGate
now has a correct decomposition and matrix representation. Previously it was equivalent toSdgXGate().control(3)
, rather than the intendedSXGate().control(3)
.
The member
name
ofqiskit.test.mock.utils.ConfigurableFakeBackend
has been changed tobackend_name
. This was done to avoid a conflict with thename()
method inherited from the parent abstractBackendV1
class. This makesConfigurableFakeBackend
compatible with anything expecting aBackendV1
object. However, if you were using thename
attribute directly before you will now need to either call it as a method or access thebackend_name
attribute instead.
Fixed an issue where calling
QuantumCircuit.decompose()
on a circuit containing anInstruction
whosedefinition
attribute was empty would leave the instruction in place, instead of decomposing it into zero operations. For example, with a circuit:from qiskit.circuit import QuantumCircuit empty = QuantumCircuit(1, name="decompose me!") circuit = QuantumCircuit(1) circuit.append(empty.to_gate(), [0])
Previously, calling
circuit.decompose()
would not change the circuit. Now, the decomposition will correct decomposeempty
into zero instructions. See #6997 for more.
Fixed an issue with the
circuit_drawer()
function anddraw()
method ofQuantumCircuit
. When displaying ameasure
instruction containing a classicalcondition
using thempl
orlatex
options, thecondition
information would sometimes overwrite themeasure
display.
Fixed an issue with the
circuit_drawer()
function anddraw()
method ofQuantumCircuit
. Thempl
drawer used hex notation to display thecondition
value, whereas thetext
andlatex
drawers used decimal notation. Now all three drawers use hex notation.
Fixed a bug in the Hoare optimizer transpilation pass where it could attempt to remove a gate twice if it could be separately combined with both its predecessor and its successor to form the identity. Refer to #7271 for more details.
Making an instruction conditional with the standard
InstructionSet.c_if()
method with integer indices is now consistent with the numbering scheme used by theQuantumCircuit
the instructions are part of. Previously, if there were twoClassicalRegister
s with overlappingClbit
s, the numbering would be incorrect. See #7246 for more detail.
Making an instruction conditional with the standard
InstructionSet.c_if()
method will now succeed, even if there are noClassicalRegister
s in the circuit. See #7250 for more detail.
Making an instruction conditional with the standard
InstructionSet.c_if()
method when using aClbit
that is contained in aClassicalRegister
of size one will now correctly create a condition on the bit, not the register. See #7255 for more detail.
Trying to make an instruction conditional with the standard
InstructionSet.c_if()
method will now correctly raise an error if the classical resource is not present in the circuit. See #7255 for more detail.
Fixed a compatibility issue with Matplotlib 3.5, where the Bloch sphere would fail to render if it had any vectors attached, such as by using
plot_bloch_vector
. See #7272 for more detail.
Fixed an issue with the
NLocal.add_layer()
method incorrectly appending layers if theNLocal
object had already been built.
Fixed an issue with pickling
InstructionScheduleMap
object when using Python 3.6. See #6944 for details.
Complex valued pulse parameter assignment with symengine has been fixed. For example,
from qiskit import circuit, pulse import numpy as np amp = circuit.Parameter("amp") phase = circuit.Parameter("phase") with pulse.build() as sched: pulse.play(pulse.Gaussian(160, amp * np.exp(1j * phase), 40), pulse.DriveChannel(0)) sched.assign_parameters({amp: 0.1, phase: 1.57}, inplace=True)
The assigned amplitude has been shown as
ParameterExpression(0.1*exp(1.57*I))
after the use ofsymengine
was introduced in the 0.18.0 release. This is now correctly evaluated and shown as7.96327e-05 + 0.0999999683j
.
Fixed an issue where
QAOA.construct_circuit()
with different operators with same number of qubits would generate the same circuit each time. See #7223 for more detail.
Fixed an issue where
QAOAAnsatz
had an incorrect number of parameters if identities ofPauliSumOp
were given, e.g.,PauliSumOp.from_list([("III", 1)])
. See #7225 for more detail.
Fixed a bug where the
QuantumCircuit.qasm()
method could return OpenQASM 2 instructions with invalid identifiers. The same bug was fixed forUnitaryGate
.
Fixed an issue where trying to display registerless bits would cause a failure of the
mpl
and thelatex
circuit drawers. A leading_
has been removed from the display of registerless bits” numbers in thetext
drawer. Fixed #6732.
For one-bit registers, all of the circuit drawers now display only the register name and no longer show the
0
subscript. Fixed #5784.
Fixed naming collisions of implicit registers in
QuantumCircuit.qasm
when dealing with registerless qubits and clbits. Previously, registerless qubits and clbits were put into correspondingqreg
andcreg
both calledregless
, despite the collision. They will now have separate, deterministically generated names, which will not clash with any user-defined register names in the circuit.
Fixed an issue in scheduling of circuits with clbits operations, e.g. measurements, conditional gates, updating
ASAPSchedule
,ALAPSchedule
, andAlignMeasures
. The updated schedulers assume all clbits I/O operations take no time,measure
writes the measured value to a clbit at the end, andc_if
reads the conditional value in clbit(s) at the beginning. Fixed #7006.
Calling
transpile
on an empty list will now correctly return an empty list without issuing a warning. Fixed #7287.
Fixed an issue in
PiecewiseChebyshev
when the function to be approximated was constant. In these cases, you should now pass the constant directly as thef_x
argument, rather than using a function, such as:from qiskit.circuit.library.arithmetic import PiecewiseChebyshev PiecewiseChebyshev(1.0, degree=3)
See #6707 for more details.
If an
HHL
algorithm instance was constructed without aQuantumInstance
(the default), attempts to use the getter and setter properties to read or set an instance later would fail. The getters and setters now work as expected.
The
QuantumCircuit.qasm()
method now edits the names of copies of the instructions present in the circuit, not the original instructions that live incircuit.data
. Refer to #6952 for more details.
Fixed a bug in
PauliSumOp.permute()
causing the error:QiskitError: 'Pauli string label "" is not valid.'
if the permutation had the same number of Pauli terms. Calling
permute([2, 1, 0])
onX ^ Y ^ Z
no longer raises an error, and now returnsZ ^ Y ^ X
.
Fixed a bug where the parameter bounds for the mixer parameters in the
QAOAAnsatz
were not been set.
Fixed determination of final operations (barriers and measures) in pass
RemoveFinalMeasurements
and in methodremove_final_measurements()
of classQuantumCircuit
which previously considered only nodes immediately preceding an output node.
Fixed determination of final operations in pass
RemoveFinalMeasurements
and in methodremove_final_measurements()
of classQuantumCircuit
which could wrongly consider a barrier to be final, even if other circuit operations followed it.
Fixed multi-bit classical register removal in pass
RemoveFinalMeasurements
and in methodremove_final_measurements()
of classQuantumCircuit
where classical registers were not removed even if other bits were idle, unless a final measure was done into each and every bit. Now, classical registers that become idle as a result of removing final measurements and barriers are always removed. Classical bits are removed if they are referenced only by removed registers or are not referenced at all and became idle due to the removal. This fix also adds proper handling of registers with shared underlying bits.
Fixed an issue with
RemoveFinalMeasurements
which could cause the resultingDAGCircuit
to become invalid. See #7196 for more details.
Fixed an issue with method
remove_final_measurements()
of classQuantumCircuit
that causedQuantumCircuit.clbits
to be incorrect after invocation. Refer to #7089 for details.
When tapering an empty zero operator in
qiskit.opflow
, the code, on detecting it was zero, logged a warning and returned the original operator. Such operators are commonly found in the auxiliary operators, when using Qiskit Nature, and the above behavior causedVQE
to throw an exception as tapered non-zero operators were a different number of qubits from the tapered zero operators (since taper has returned the input operator unchanged). The code will now correctly taper a zero operator such that the number of qubits is reduced as expected and matches to tapered non-zero operators e.g`0*"IIII"`
when we are tapering by 3 qubits will become0*"I"
.
Fixed an issue with the
draw()
method andcircuit_drawer()
function, where a custom style set via the user config file (i.e.settings.conf
) would ignore the set value of thecircuit_mpl_style
field if thestyle
kwarg on the function/method was not set.
Other Notes¶
The string cast for
qiskit.circuit.ParameterExpression
does not have full precision anymore. This removes the trailing 0s when printing parameters that are bound to floats. This has consequences for QASM serialization and the circuit text drawer:>>> from qiskit.circuit import Parameter >>> x = Parameter('x') >>> str(x.bind({x:0.5})) '0.5' # instead of '0.500000000000000'
The
QAOAAnsatz
has been updated to use the parameter symbolγ
for the cost operator andβ
for the mixer operator, as is the standard notation in QAOA literature.
Aer 0.9.1¶
No change
Ignis 0.7.0¶
Prelude¶
This release deprecates the Qiskit Ignis project, it has been supersceded by the Qiskit Experiments project and active development has ceased. While deprecated, critical bug fixes and compatibility fixes will continue to be made to provide users a sufficient opportunity to migrate off of Ignis. After the deprecation period (which will be no shorter than 3 months from this release) the project will be retired and archived.
New Features¶
Updated the accreditation protocol to use fitting routine from https://arxiv.org/abs/2103.06603.
AccreditationFitter
now has methods FullAccreditation (previous protocol) and MeanAccreditation (new protocol). In addtition data entry has been changed to either use the result object AppendResult or a list of strings AppendStrings.qiskit.ignis.verification.QOTPCorrectString()
was also added.
Added the option for the fast analytical generation of syndrome graphs. The
RepetitionCode
now has a new bool argumentbrute
, which allows to still use the brute force method. Helper classRepetitionCodeSyndromeGenerator
added to facilitate this.
The
RepetitionCode
now has keyword argumentsresets
anddelay
. The former determines whether reset gates are inserted after measurement. The latter allows a time (in dt) to be specificed for a delay after each measurement (and reset, if applicable).The
syndrome_measurement()
method ofRepetitionCode
now has keyword argumentsfinal
anddelay
. The former determines whether to add reset gates according to the globalresets
, or to overwrite it with appropriate behavior for the final round of syndrome measurements. The latter allows a time (in dt) to be specificed for a delay after each measurement (and reset, if applicable).
The
RepetitionCode
class now supports encoding with x basis states. This can be used by setting thexbasis
keyword argument when constructing aRepetitionCode
object.
Upgrade Notes¶
The keyword argument
reset
has been removed from the thesyndrome_measurement()
method ofRepetitionCode
. This is replaced by the globalresets
keyword argument for the class as well as the keyword argumentfinal
forsyndrome_measurement
. In cases where one would previously add the final measurement round usingreset=False
to avoid the final reset gates, one should now usefinal=True
.
Remove
ParametrizedSchedule
fromupdate_u_gates()
.ParametrizedSchedule
was deprecated as a part of Qiskit-terra 0.17.0 and will be removed in next release. The function now updates u gates withSchedule
programs involving unassignedParameter
objects.
Deprecation Notes¶
Deprecating methods in
AccreditationFitter
namely bound_variation_distance and single_protocol_run
The Qiskit Ignis project as a whole has been deprecated and the project will be retired and archived in the future. While deprecated only compatibility fixes and fixes for critical bugs will be made to the proejct. Instead of using Qiskit Ignis you should migrate to use Qiskit Experiments instead. You can refer to the migration guide:
Qiskit 0.32.1¶
Terra 0.18.3¶
No change
Aer 0.9.1¶
No change
Ignis 0.6.0¶
No change
Aqua 0.9.5¶
No change
Qiskit 0.32.0¶
Terra 0.18.3¶
No change
Aer 0.9.1¶
No change
Ignis 0.6.0¶
No change
Aqua 0.9.5¶
No change
IBM Q Provider 0.18.0¶
New Features¶
You can now pass
program_id
parameter toqiskit.providers.ibmq.runtime.IBMRuntimeService.jobs()
method to filter jobs by Program ID.You can view the last updated date of a runtime program using
update_date
property.If you are the author of a runtime program, you can now use
qiskit.providers.ibmq.runtime.RuntimeProgram.data
property to retrieve the program data as a string.You can now use the
qiskit.providers.ibmq.runtime.IBMRuntimeService.update_program()
method to update the metadata for a Qiskit Runtime program. Program metadata can be specified using themetadata
parameter or individual parameters, such asname
anddescription
. If the same metadata field is specified in both places, the individual parameter takes precedence.You can now use the
qiskit.providers.ibmq.runtime.IBMRuntimeService.update_program()
method to update the data of an existing runtime program.
Upgrade Notes¶
Runtime programs will no longer have a
version
field.By default,
qiskit.providers.ibmq.runtime.IBMRuntimeService.pprint_programs()
now only prints the summary of each runtime program instead of all of the details. There is a new parameterdetailed
that can be set toTrue
to print all details.limit
andskip
parameters have been added toqiskit.providers.ibmq.runtime.IBMRuntimeService.programs()
andqiskit.providers.ibmq.runtime.IBMRuntimeService.pprint_programs()
.limit
can be used to set the number of runtime programs returned andskip
is the number of programs to skip when retrieving programs.The data parameter to
qiskit.providers.ibmq.runtime.IBMRuntimeService.upload_program()
can now only be of type string. It can be either the program data, or path to the file that contains program data.qiskit.providers.ibmq.runtime.IBMRuntimeService.upload_program()
now takes only two parameters,data
, which is the program passed as a string or the path to the program file and themetadata
, which is passed as a dictionary or path to the metadata JSON file. Inmetadata
thebackend_requirements
,parameters
,return_values
andinterim_results
are now grouped under a specificationsspec
section.parameters
,return_values
andinterim_results
should now be specified as JSON Schema.qiskit.providers.ibmq.AccountProvider.run_circuits()
method now takes a backend_name parameter, which is a string, instead of backend, which is aBackend
object.The default number of
shots
(represents the number of repetitions of each circuit, for sampling) inqiskit.providers.ibmq.IBMQBackend.run()
, has been increased from 1024 to 4000.
Bug Fixes¶
Fixes the issue wherein a runtime job result cannot be retrieved multiple times if the result contains a numpy array.
Qiskit 0.31.0¶
Terra 0.18.3¶
No change
Aer 0.9.1¶
Upgrade Notes¶
optimize_ideal_threshold
andoptimize_noisy_threshold
have been removed from the lists of simulator defaults and the documentation. These have had no effect since Aer 0.5.1, but these references to them had remained accidentally.
Bug Fixes¶
Fixes #1351 where running an empty
QuantumCircuit
with a noise model set would cause the simulator to crash.Fixes #1347 where the behaviour of using the
set_options()
andset_option()
methods of simulator backends could lead to different behavior for some options.Fixes an bug where using a Dask Client executor would cause an error at job submission due to the executor Client not being pickleable.
Fixed an issue with the matrix_product_state simulation method where the accumulation of small rounding errors during measurement of many quits could sometimes cause a segmentation fault.
Fixes an unintended change between qiskit-aer 0.8.0 and 0.9.0 where when running a list of circuits with an invalid circuit using the
automatic
simulation method of theAerSimulator
orQasmSimulator
would raise an exception for an invalid input qobj rather than return partial results for the circuits that were valid.Fixes an issue with the standalone simulator where it would return a IBM Quantum API schema invalid response in the case of an error that prevented the simulation from running.
Fixes #1346 which was a bug in the handling of the
parameter_binds
kwarg of the backendrun()
method that would result in an error if the parameterized circuit was transpiled to a different set of basis gates than the original parameterizations.
Ignis 0.6.0¶
No change
Aqua 0.9.5¶
No change
IBM Q Provider 0.17.0¶
New Features¶
A runtime program’s visibility can now be specified on upload using
is_public
parameter inqiskit.providers.ibmq.runtime.IBMRuntimeService.upload_program()
.You can now specify a parent experiment ID when creating an experiment with
qiskit.providers.ibmq.experiment.IBMExperimentService.create_experiment()
. Experiments can also be filtered by their parent experiment ID inqiskit.providers.ibmq.experiment.IBMExperimentService.experiments()
.Runtime image can now be specified using the image parameter in
qiskit.providers.ibmq.runtime.IBMRuntimeService.run()
. Note that not all accounts are authorized to select a different image.
Upgrade Notes¶
qiskit.providers.ibmq.runtime.RuntimeEncoder
andqiskit.providers.ibmq.runtime.RuntimeDecoder
are updated to support Pythondatetime
, which is not JSON serializable by default.
Bug Fixes¶
Fixes the issue where
qiskit.providers.ibmq.managed.IBMQJobManager.retrieve_job_set()
only retrieves the first 10 jobs in aqiskit.providers.ibmq.managed.ManagedJobSet
.qiskit.providers.ibmq.runtime.RuntimeDecoder
can now restore dictionary integer keys in optimizer settings from a JSON string representation dumped by theqiskit.providers.ibmq.runtime.RuntimeEncoder
.
Qiskit 0.30.1¶
Terra 0.18.3¶
Prelude¶
This bugfix release fixes a few minor issues in 0.18, including a performance
regression in assemble
when dealing with executing
QuantumCircuit
objects on pulse-enabled backends.
Bug Fixes¶
Fixed #7004 where
AttributeError
was raised when executingScheduleBlock
on a pulse backend. These blocks are now correctly treated as pulse jobs, likeSchedule
.Fixed an issue causing an error when binding a complex parameter value to an operator’s coefficient. Casts to
float
inPrimitiveOp
were generalized to casts tocomplex
if necessary, but will remainfloat
if there is no imaginary component. Fixes #6976.Update the 1-qubit gate errors in
plot_error_map
to use the sx gate instead of the u2 gate, consistent with IBMQ backends.
Aer 0.9.0¶
No change
Ignis 0.6.0¶
No change
Aqua 0.9.5¶
No change
IBM Q Provider 0.16.0¶
No change
Qiskit 0.30.0¶
Terra 0.18.2¶
No change
Aer 0.9.0¶
Prelude¶
The 0.9 release includes new backend options for parallel exeuction of large numbers of circuits on a HPC cluster using a Dask distributed, along with other general performance improvements and bug fixes.
New Features¶
Added support for set_matrix_product_state.
Add qiskit library
SXdgGate
andCUGate
to the supported basis gates for the Aer simulator backends. Note that theCUGate
gate is only natively supported for thestatevector
andunitary
methods. For other simulation methods it must be transpiled to the supported basis gates for that method.Adds support for N-qubit Pauli gate (
qiskit.circuit.library.generalized_gates.PauliGate
) to all simulation methods of theAerSimulator
andQasmSimulator
.Adds the ability to set a custom executor and configure job splitting for executing multiple circuits in parallel on a HPC clustor. A custom executor can be set using the
executor
option, and job splitting is configured by using themax_job_size
option.For example configuring a backend and executing using
backend = AerSimulator(max_job_size=1, executor=custom_executor) job = backend.run(circuits)
will split the exection into multiple jobs each containing a single circuit. If job splitting is enabled the
run
method will return aAerJobSet
object containing all the individualAerJob
classes. After all individual jobs finish running the job results are automatically combined into a single Result object that is returned byjob.result()
.Supported executors include those in the Python
concurrent.futures
module (eg.ThreadPoolExecutor
,ProcessPoolExecutor
), and Dask distributed Client executors if the optional dask library is installed. Using a Dask executor allows configuring parallel execution of multiple circuits on HPC clusters. See the Dask executor API Documentation for additional details on using Dask executors for HPC simulation.Adds ability to record logging data for the
matrix_product_state
simulation method to the experiment result metadata by setting the backend optionmps_log_data=True
. The saved data includes the bond dimensions and the discarded value (the sum of the squares of the Schmidt coeffients that were discarded by approximation) after every relevant circuit instruction.The
run()
method for theAerSimulator
,QasmSimulator
,StatevectorSimulator
, andUnitarySimulator
has a new kwarg,parameter_binds
which is used to provide a list of values to use for any unbound parameters in the inbound circuit. For example:from qiskit.circuit import QuantumCircuit, Parameter from qiskit.providers.aer import AerSimulator shots = 1000 backend = AerSimulator() circuit = QuantumCircuit(2) theta = Parameter('theta') circuit.rx(theta, 0) circuit.cx(0, 1) circuit.measure_all() parameter_binds = [{theta: [0, 3.14, 6.28]}] backend.run(circuit, shots=shots, parameter_binds=parameter_binds).result()
will run the input circuit 3 times with the values 0, 3.14, and 6.28 for theta. When running with multiple parameters the length of the value lists must all be the same. When running with multiple circuits, the length of
parameter_binds
must match the number of input circuits (you can use an empty dict,{}
, if there are no binds for a circuit).The
PulseSimulator
can now takeQuantumCircuit
objects on therun()
. Previously, it only would exceptSchedule
objects as input torun()
. When a circuit or list of circuits is passed to the simulator it will callschedule()
to convert the circuits to a schedule before executing the circuit. For example:from qiskit.circuit import QuantumCircuit from qiskit.compiler import transpile from qiskit.test.mock import FakeVigo from qiskit.providers.aer.backends import PulseSimulator backend = PulseSimulator.from_backend(FakeVigo()) circuit = QuantumCircuit(2) circuit.h(0) circuit.cx(0, 1) circuit.measure_all() transpiled_circuit = transpile(circuit, backend) backend.run(circuit)
Known Issues¶
The
SaveExpectationValue
andSaveExpectationValueVariance
have been disabled for the extended_stabilizer method of theQasmSimulator
andAerSimulator
due to returning the incorrect value for certain Pauli operator components. Refer to #1227 <https://github.com/Qiskit/qiskit-aer/issues/1227> for more information and examples.
Upgrade Notes¶
The default basis for the
NoiseModel
class has been changed from["id", "u3", "cx"]
to["id", "rz", "sx", "cx"]
due to the deprecation of theu3
circuit method in qiskit-terra and change of qiskit-ibmq-provider backend basis gates. To use the old basis gates you can initialize a noise model with custom basis gates asNoiseModel(basis_gates=["id", "u3", "cx"])
.Removed the
backend_options
kwarg from therun
methnod of Aer backends that was deprecated in qiskit-aer 0.7. All run options must now be passed as separate kwargs.Removed passing
system_model
as a positional arg for therun
method of thePulseSimulator
.
Deprecation Notes¶
Passing an assembled qobj directly to the
run()
method of the Aer simulator backends has been deprecated in favor of passing transpiled circuits directly asbackend.run(circuits, **run_options)
.All snapshot instructions in
qiskit.providers.aer.extensions
have been deprecated. For replacement use the save instructions from theqiskit.providers.aer.library
module.Adding non-local quantum errors to a
NoiseModel
has been deprecated due to inconsistencies in how this noise is applied to the optimized circuit. Non-local noise should be manually added to a scheduled circuit in Qiskit using a custom transpiler pass before being run on the simulator.Use of the
method
option of theStatevectorSimulator
, andUnitarySimulator
to run a GPU simulation has been deprecated. To run a GPU simulation on a compatible system use the optiondevice='GPU'
instead.
Bug Fixes¶
Fixes performance issue with how the
basis_gates
configuration attribute was set. Previously there were unintended side-effects to the backend class which could cause repeated simulation runtime to incrementally increase. Refer to #1229 <https://github.com/Qiskit/qiskit-aer/issues/1229> for more information and examples.Fixed bug in MPS::apply_kraus. After applying the kraus matrix to the relevant qubits, we should propagate the changes to the neighboring qubits.
Fixes a bug where qiskit-terra assumes that qubits in a multiplexer gate are first the targets and then the controls of the gate while qiskit-aer assumes the opposite order.
Fixes a bug introduced in 0.8.0 where GPU simulations would allocate unneeded host memory in addition to the GPU memory.
Fixes bug where the initialize instruction would disable measurement sampling optimization for the statevector and matrix product state simulation methods even when it was the first circuit instruction or applied to all qubits and hence deterministic.
Fix issue #1196 by using the inner products with the computational basis states to calculate the norm rather than the norm estimation algorithm.
Fixes a bug in the
stabilizer
simulator method of theQasmSimulator
andAerSimulator
where the expectation value for thesave_expectation_value
andsnapshot_expectation_value
could have the wrong sign for certainY
Pauli’s.Fixes bug where the if the required memory is smaller than the system memory the multi-chunk simulation method was enabled and simulation was still started. This case will now throw an insufficient memory exception.
Fixes issue where setting the
shots
option for a backend withset_options(shots=k)
was always running the default number of shots (1024) rather than the specified value.Fixes a bug in how the
AerSimulator
handled the option value formax_parallel_experiments=1
. Previously this was treated the same asmax_parallel_experiments=0
.Fixes bug in the
extended_stabilizer
simulation method where it incorrectly treated qelay gate and multi-qubit Pauli instructions as unsupported.Fixes typo in the
AerSimulator
andQasmSimulator
options for theextended_stabilizer_norm_estimation_repetitions
option.Fixes bug with applying the
unitary
gate in using thematrix_product_state
simulation method which did not correctly support permutations in the ordering of the qubits on which the gate is applied.Fixes an issue where gate fusion could still be enabled for the
matrix_product_state
simulation method even though it is not supported. Now fusion is always disabled for this method.Fixed bug in the
matrix_product_state
simulation method in computing the normalization following truncation of the Schmidt coefficients after performing the SVD.
Other Notes¶
Improves the performance of the measurement sampling algorithm for the
matrix_product_state
simulation method. The new default behaviour is to always sample using the improvedmps_apply_measure
method. Themps_probabilities
sampling method be still used by setting the custom option valuemps_sample_measure_algorithm="mps_probabilities"
.
Ignis 0.6.0¶
No change
Aqua 0.9.5¶
No change
IBM Q Provider 0.16.0¶
No change
Qiskit 0.29.1¶
Terra 0.18.2¶
Bug Fixes¶
Fixed an issue with the
assemble()
function when called with thebackend
kwarg set and theparametric_pulses
kwarg was set to an empty list the output qobj would contain theparametric_pulses
setting from the given backend’sBackendConfiguration
instead of the expected empty list. Fixed #6898The Matplotlib circuit drawer will no longer duplicate drawings when using
ipykernel>=6.0.0
. Fixes #6889.
Aer 0.8.2¶
No change
Ignis 0.6.0¶
No change
Aqua 0.9.5¶
Bug Fixes¶
Fixed a handling error in the Yahoo provider when only one ticker is entered. Added exception error if no ticker is entered. Limit yfinance to >=0.1.62 as previous versions have a JSON decoder error.
IBM Q Provider 0.16.0¶
No change
Qiskit 0.29.0¶
Terra 0.18.1¶
Prelude¶
This bugfix release fixes a few minor issues and regressions in the 0.18.0
release. There is also a minor change to how pip
handles the [all]
extra when installing qiskit-terra
directly, compared to 0.18.0.
Upgrade Notes¶
pip install qiskit-terra[all]
will no longer attempt to install thebip-mapper
extra. This is because the dependencycplex
is not well supported on the range of Python versions and OSes that Terra supports, and a failed extra dependency would fail the entire package resolution. If you are using Python 3.7 or 3.8 and are on Linux-x64 or -ppc64le, macOS-x64 or Windows-x64 you should be able to installqiskit-terra[bip-mapper]
explicitly, if desired, while other combinations of OS, platform architectures and Python versions will likely fail.
Bug Fixes¶
Fixed an issue where the
QuantumInstance
class would potentially try to use theCompleteMeasFitter
class before it was imported resulting in an error. Fixed #6774Fixed the missing Linux aarch64 wheels which were not published for the 0.18.0 release. They should now continue to be built as expected for all future releases.
Fixed an issue with the mock backends located in
qiskit.test.mock
where in some situations (mainly fake backends with storedBackendProperties
running aQuantumCircuit
withqiskit-aer
installed) passing run time options to therun()
method of a fake backend object would not actually be passed to the simulator underlying therun()
method and not have any effect. Fixed #6741Fix a bug in
EvolvedOperatorAnsatz
when the global phase is 0 (such as forQAOAAnsatz
) but was still aParameterExpression
.Fixed an issue with the
settings
attribute ofQNSPSA
, which was missing thefidelity
argument from the output. This is now correctly included in the attribute’s output.Fixed an issue with the
subgraph()
method of theCouplingMap
class where it would incorrectly add nodes to the outputCouplingMap
object when thenodelist
argument contained a non-contiguous list of qubit indices. This has been fixed so regardless of the input indices innodelist
the outputCouplingMap
will only contained the specified nodes reindexed starting at 0. Fixes #6736Previously,
Optimize1qGatesDecomposition
failed to properly optimize one qubit gates that are sufficiently close to the identity matrix. This was fixed so that any gates that differ from the identity by less than 1e-15 are removed.Fixed the generation and loading of QPY files with
qiskit.circuit.qpy_serialization.dump()
andqiskit.circuit.qpy_serialization.load()
forQuantumCircuit
objects that contain instructions with classical conditions on a singleClbit
instead of aClassicalRegister
. While the use of singleClbit
conditions is not yet fully supported, if you were using them in a circuit they are now correctly serialized by QPY.
Aer 0.8.2¶
No change
Ignis 0.6.0¶
No change
Aqua 0.9.4¶
No change
IBM Q Provider 0.16.0¶
New Features¶
A user can now set and retrieve preferences for
qiskit.providers.ibmq.experiment.IBMExperimentService
. Preferences are saved on disk in the$HOME/.qiskit/qiskitrc
file. Currently the only preference option isauto_save
, which tells applications that use this service, such as qiskit-experiments, whether you want changes to be automatically saved. Usage examples:provider.experiment.save_preferences(auto_save=True) # set and save preferences provider.experiment.preferences # return all saved preferences
The methods
qiskit.providers.ibmq.experiment.IBMExperimentService.create_figure()
andqiskit.providers.ibmq.experiment.IBMExperimentService.update_figure()
now accept thesync_upload
keyword. This controls whether or not the figure will be uploaded asynchronously or synchronously to backend storage. By defaultsync_upload
isTrue
for synchronous upload.
Upgrade Notes¶
IBMExperimentService
is updated to work with the newqiskit-experiments
. As a result, the syntax of the experiment service is drastically changed. This change, however, takes the experiment service out of beta mode, and future changes will provide backward compatibility according to Qiskit deprecation policy.qiskit.providers.ibmq.runtime.utils.RuntimeEncoder
now convert a callable object toNone
, since callables are not JSON serializable.qiskit.providers.ibmq.IBMQBackend.run()
no longer accepts validate_qobj as a parameter. If you were relying on this schema validation you should pull the schemas from the Qiskit/ibm-quantum-schemas and directly validate your payloads with that.
Qiskit 0.28.0¶
Terra 0.18.0¶
Prelude¶
This release includes many new features and bug fixes. The highlights of
this release are the introduction of two new transpiler
passes, BIPMapping
and
DynamicalDecoupling
, which when combined
with the new pulse_optimize
kwarg on the
UnitarySynthesis
pass enables recreating
the Quantum Volume 64 results using the techniques
described in: https://arxiv.org/abs/2008.08571. These new transpiler passes
and options and are also generally applicable to optimizing any circuit.
New Features¶
The
measurement_error_mitgation
kwarg for theQuantumInstance
constructor can now be set to theTensoredMeasFitter
class from qiskit-ignis in addition toCompleteMeasFitter
that was already supported. If you useTensoredMeasFitter
you will also be able to set the newmit_pattern
kwarg to specify the qubits on which to useTensoredMeasFitter
You can refer to the documentation formit_pattern
in theTensoredMeasFitter
documentation for the expected format.The decomposition methods for single-qubit gates, specified via the
basis
kwarg, inOneQubitEulerDecomposer
has been expanded to now also include the'ZSXX'
basis, for making use of direct \(X\) gate as well as \(\sqrt{X}\) gate.Added two new passes
AlignMeasures
andValidatePulseGates
to theqiskit.transpiler.passes
module. These passes are a hardware-aware optimization, and a validation routine that are used to manage alignment restrictions on time allocation of instructions for a backend.If a backend has a restriction on the alignment of
Measure
instructions (in terms of quantization in time), theAlignMeasures
pass is used to adjust delays in a scheduled circuit to ensure that anyMeasure
instructions in the circuit are aligned given the constraints of the backend. TheValidatePulseGates
pass is used to check if any custom pulse gates (gates that have a custom pulse definition in thecalibrations
attribute of aQuantumCircuit
object) are valid given an alignment constraint for the target backend.In the built-in
preset_passmangers
used by thetranspile()
function, these passes get automatically triggered if the alignment constraint, either via the dedicatedtiming_constraints
kwarg ontranspile()
or has antiming_constraints
attribute in theBackendConfiguration
object of the backend being targetted.The backends from IBM Quantum Services (accessible via the qiskit-ibmq-provider package) will provide the alignment information in the near future.
For example:
from qiskit import circuit, transpile from qiskit.test.mock import FakeArmonk backend = FakeArmonk() qc = circuit.QuantumCircuit(1, 1) qc.x(0) qc.delay(110, 0, unit="dt") qc.measure(0, 0) qc.draw('mpl')
qct = transpile(qc, backend, scheduling_method='alap', timing_constraints={'acquire_alignment': 16}) qct.draw('mpl')
A new transpiler pass class
qiskit.transpiler.passes.BIPMapping
that tries to find the best layout and routing at once by solving a BIP (binary integer programming) problem as described in arXiv:2106.06446 has been added.The
BIPMapping
pass (named « mapping » to refer to « layout and routing ») represents the mapping problem as a BIP (binary integer programming) problem and relies on CPLEX (cplex
) to solve the BIP problem. The dependent libraries including CPLEX can be installed along with qiskit-terra:pip install qiskit-terra[bip-mapper]
Since the free version of CPLEX can solve only small BIP problems, i.e. mapping of circuits with less than about 5 qubits, the paid version of CPLEX may be needed to map larger circuits.
The BIP mapper scales badly with respect to the number of qubits or gates. For example, it would not work with
coupling_map
beyond 10 qubits because the BIP solver (CPLEX) could not find any solution within the default time limit.Note that, if you want to fix physical qubits to be used in the mapping (e.g. running Quantum Volume (QV) circuits), you need to specify
coupling_map
which contains only the qubits to be used.Here is a minimal example code to build pass manager to transpile a QV circuit:
num_qubits = 4 # QV16 circ = QuantumVolume(num_qubits=num_qubits) backend = ... basis_gates = backend.configuration().basis_gates coupling_map = CouplingMap.from_line(num_qubits) # supply your own coupling map def _not_mapped(property_set): return not property_set["is_swap_mapped"] def _opt_control(property_set): return not property_set["depth_fixed_point"] from qiskit.circuit.equivalence_library import SessionEquivalenceLibrary as sel pm = PassManager() # preparation pm.append([ Unroll3qOrMore(), TrivialLayout(coupling_map), FullAncillaAllocation(coupling_map), EnlargeWithAncilla(), BarrierBeforeFinalMeasurements() ]) # mapping pm.append(BIPMapping(coupling_map)) pm.append(CheckMap(coupling_map)) pm.append(Error(msg="BIP mapper failed to map", action="raise"), condition=_not_mapped) # post optimization pm.append([ Depth(), FixedPoint("depth"), Collect2qBlocks(), ConsolidateBlocks(basis_gates=basis_gates), UnitarySynthesis(basis_gates), Optimize1qGatesDecomposition(basis_gates), CommutativeCancellation(), UnrollCustomDefinitions(sel, basis_gates), BasisTranslator(sel, basis_gates) ], do_while=_opt_control) transpile_circ = pm.run(circ)
A new constructor method
initialize_from()
was added to theSchedule
andScheduleBlock
classes. This method initializes a new empty schedule which takes the attributes from other schedule. For example:sched = Schedule(name='my_sched') new_sched = Schedule.initialize_from(sched) assert sched.name == new_sched.name
A new kwarg,
line_discipline
, has been added to thejob_monitor()
function. This kwarg enables changing the carriage return characters used in thejob_monitor
output. Theline_discipline
kwarg defaults to'\r'
, which is what was in use before.The abstract
Pulse
class (which is the parent class for classes such asWaveform
,Constant
, andGaussian
now has a new kwarg on the constructor,limit_amplitude
, which can be set toFalse
to disable the previously hard coded amplitude limit of1
. This can also be set as a class attribute directly to change the global default for a Pulse class. For example:from qiskit.pulse.library import Waveform # Change the default value of limit_amplitude to False Waveform.limit_amplitude = False wave = Waveform(2.0 * np.exp(1j * 2 * np.pi * np.linspace(0, 1, 1000)))
A new class,
PauliList
, has been added to theqiskit.quantum_info
module. This class is used to efficiently represent a list ofPauli
operators. This new class inherets from the same parent class as the existingPauliTable
(and therefore can be mostly used interchangeably), however it differs from thePauliTable
because theqiskit.quantum_info.PauliList
class can handle Z4 phases.Added a new transpiler pass,
RemoveBarriers
, toqiskit.transpiler.passes
. This pass is used to remove all barriers in a circuit.Add a new optimizer class,
SciPyOptimizer
, to theqiskit.algorithms.optimizers
module. This class is a simple wrapper class of thescipy.optimize.minimize
function (documentation) which enables the use of all optimization solvers and all parameters (e.g. callback) which are supported byscipy.optimize.minimize
. For example:from qiskit.algorithms.optimizers import SciPyOptimizer values = [] def callback(x): values.append(x) optimizer = SciPyOptimizer("BFGS", options={"maxiter": 1000}, callback=callback)
The
HoareOptimizer
pass has been improved so that it can now replace aControlledGate
in a circuit with with the base gate if all the control qubits are in the \(|1\rangle\) state.Added two new methods,
is_successor()
andis_predecessor()
, to theDAGCircuit
class. These functions are used to check if a node is either a successor or predecessor of another node on theDAGCircuit
.A new transpiler pass,
RZXCalibrationBuilderNoEcho
, was added to theqiskit.transpiler.passes
module. This pass is similar to the existingRZXCalibrationBuilder
in that it creates calibrations for anRZXGate(theta)
, howeverRZXCalibrationBuilderNoEcho
does this without inserting the echo pulses in the pulse schedule. This enables exposing the echo in the cross-resonance sequence as gates so that the transpiler can simplify them. TheRZXCalibrationBuilderNoEcho
pass only supports the hardware-native direction of theCXGate
.A new kwarg,
wrap
, has been added to thecompose()
method ofQuantumCircuit
. This enables choosing whether composed circuits should be wrapped into an instruction or not. By default this isFalse
, i.e. no wrapping. For example:from qiskit import QuantumCircuit circuit = QuantumCircuit(2) circuit.h([0, 1]) other = QuantumCircuit(2) other.x([0, 1]) print(circuit.compose(other, wrap=True)) # wrapped print(circuit.compose(other, wrap=False)) # not wrapped
┌───┐┌──────────────┐ q_0: ┤ H ├┤0 ├ ├───┤│ circuit-123 │ q_1: ┤ H ├┤1 ├ └───┘└──────────────┘ ┌───┐┌───┐ q_0: ┤ H ├┤ X ├ ├───┤├───┤ q_1: ┤ H ├┤ X ├ └───┘└───┘
A new attribute,
control_channels
, has been added to thePulseBackendConfiguration
class. This attribute represents the control channels on a backend as a mapping of qubits to a list ofControlChannel
objects.A new kwarg,
epsilon
, has been added to the constructor for theIsometry
class and the correspondingQuantumCircuit
methodisometry()
. This kwarg enables optionally setting the epsilon tolerance used by anIsometry
gate. For example:import numpy as np from qiskit import QuantumRegister, QuantumCircuit tolerance = 1e-8 iso = np.eye(2,2) num_q_output = int(np.log2(iso.shape[0])) num_q_input = int(np.log2(iso.shape[1])) q = QuantumRegister(num_q_output) qc = QuantumCircuit(q) qc.isometry(iso, q[:num_q_input], q[num_q_input:], epsilon=tolerance)
Added a transpiler pass,
DynamicalDecoupling
, toqiskit.transpiler.passes
for inserting dynamical decoupling sequences in idle periods of a circuit (after mapping to physical qubits and scheduling). The pass allows control over the sequence of DD gates, the spacing between them, and the qubits to apply on. For example:from qiskit.circuit import QuantumCircuit from qiskit.circuit.library import XGate from qiskit.transpiler import PassManager, InstructionDurations from qiskit.transpiler.passes import ALAPSchedule, DynamicalDecoupling from qiskit.visualization import timeline_drawer circ = QuantumCircuit(4) circ.h(0) circ.cx(0, 1) circ.cx(1, 2) circ.cx(2, 3) circ.measure_all() durations = InstructionDurations( [("h", 0, 50), ("cx", [0, 1], 700), ("reset", None, 10), ("cx", [1, 2], 200), ("cx", [2, 3], 300), ("x", None, 50), ("measure", None, 1000)] ) dd_sequence = [XGate(), XGate()] pm = PassManager([ALAPSchedule(durations), DynamicalDecoupling(durations, dd_sequence)]) circ_dd = pm.run(circ) timeline_drawer(circ_dd)
The
QuantumCircuit
methodqasm()
has a new kwarg,encoding
, which can be used to optionally set the character encoding of an output QASM file generated by the function. This can be set to any valid codec or alias string from the Python standard library’s codec module.Added a new class,
EvolvedOperatorAnsatz
, to theqiskit.circuit.library
module. This library circuit, which had previously been located in Qiskit Nature , can be used to construct ansatz circuits that consist of time-evolved operators, where the evolution time is a variational parameter. Examples of such ansatz circuits includeUCCSD
class in thechemistry
module of Qiskit Nature or theQAOAAnsatz
class.A new fake backend class is available under
qiskit.test.mock
for theibmq_guadalupe
backend. As with the other fake backends, this includes a snapshot of calibration data (i.e.backend.defaults()
) and error data (i.e.backend.properties()
) taken from the real system, and can be used for local testing, compilation and simulation.A new method
children()
for theSchedule
class has been added. This method is used to return the child schedule components of theSchedule
object as a tuple. It returns nested schedules without flattening. This method is equivalent to the private_children()
method but has a public and stable interface.A new optimizer class,
GradientDescent
, has been added to theqiskit.algorithms.optimizers
module. This optimizer class implements a standard gradient descent optimization algorithm for use with quantum variational algorithms, such asVQE
. For a detailed description and examples on how to use this class, please refer to theGradientDescent
class documentation.A new optimizer class,
QNSPSA
, has been added to theqiskit.algorithms.optimizers
module. This class implements the Quantum Natural SPSA (QN-SPSA) algorithm, a generalization of the 2-SPSA algorithm, and estimates the Quantum Fisher Information Matrix instead of the Hessian to obtain a stochastic estimate of the Quantum Natural Gradient. For examples on how to use this new optimizer refer to theQNSPSA
class documentation.A new kwarg,
second_order
, has been added to the constructor of theSPSA
class in theqiskit.algorithms.optimizers
module. When set toTrue
this enables using second-order SPSA. Second order SPSA, or 2-SPSA, is an extension of the ordinary SPSA algorithm that enables estimating the Hessian alongside the gradient, which is used to precondition the gradient before the parameter update step. As a second-order method, this tries to improve convergence of SPSA. For examples on how to use this option refer to theSPSA
class documentation.When using the
latex
orlatex_source
output mode ofcircuit_drawer()
or thedraw()
ofQuantumCircuit
thestyle
kwarg can now be used just as with thempl
output formatting. However, unlike thempl
output mode only thedisplaytext
field will be used when using thelatex
orlatex_source
output modes (because neither supports color).When using the
mpl
orlatex
output methods for thecircuit_drawer()
function or thedraw()
ofQuantumCircuit
, you can now use math mode formatting for text and set color formatting (mpl
only) by setting thestyle
kwarg as a dict with a user-generated name or label. For example, to add subscripts and to change a gate color:from qiskit import QuantumCircuit from qiskit.circuit.library import HGate qc = QuantumCircuit(3) qc.append(HGate(label='h1'), [0]) qc.append(HGate(label='h2'), [1]) qc.append(HGate(label='h3'), [2]) qc.draw('mpl', style={'displaytext': {'h1': 'H_1', 'h2': 'H_2', 'h3': 'H_3'}, 'displaycolor': {'h2': ('#EEDD00', '#FF0000')}})
Added three new classes,
CDKMRippleCarryAdder
,ClassicalAdder
andDraperQFTAdder
, to theqiskit.circuit.library
module. These new circuit classes are used to perform classical addition of two equally-sized qubit registers. For two registers \(|a\rangle_n\) and \(|b\rangle_n\) on \(n\) qubits, the three new classes perform the operation:\[|a\rangle_n |b\rangle_n \mapsto |a\rangle_n |a + b\rangle_{n + 1}.\]For example:
from qiskit.circuit import QuantumCircuit from qiskit.circuit.library import CDKMRippleCarryAdder from qiskit.quantum_info import Statevector # a encodes |01> = 1 a = QuantumCircuit(2) a.x(0) # b encodes |10> = 2 b = QuantumCircuit(2) b.x(1) # adder on 2-bit numbers adder = CDKMRippleCarryAdder(2) # add the state preparations to the front of the circuit adder.compose(a, [0, 1], inplace=True, front=True) adder.compose(b, [2, 3], inplace=True, front=True) # simulate and get the state of all qubits sv = Statevector(adder) counts = sv.probabilities_dict() state = list(counts.keys())[0] # we only have a single state # skip the input carry (first bit) and the register |a> (last two bits) result = state[1:-2] print(result) # '011' = 3 = 1 + 2
Added two new classes,
RGQFTMultiplier
andHRSCumulativeMultiplier
, to theqiskit.circuit.library
module. These classes are used to perform classical multiplication of two equally-sized qubit registers. For two registers \(|a\rangle_n\) and \(|b\rangle_n\) on \(n\) qubits, the two new classes perform the operation\[|a\rangle_n |b\rangle_n |0\rangle_{2n} \mapsto |a\rangle_n |b\rangle_n |a \cdot b\rangle_{2n}.\]For example:
from qiskit.circuit import QuantumCircuit from qiskit.circuit.library import RGQFTMultiplier from qiskit.quantum_info import Statevector num_state_qubits = 2 # a encodes |11> = 3 a = QuantumCircuit(num_state_qubits) a.x(range(num_state_qubits)) # b encodes |11> = 3 b = QuantumCircuit(num_state_qubits) b.x(range(num_state_qubits)) # multiplier on 2-bit numbers multiplier = RGQFTMultiplier(num_state_qubits) # add the state preparations to the front of the circuit multiplier.compose(a, [0, 1], inplace=True, front=True) multiplier.compose(b, [2, 3], inplace=True, front=True) # simulate and get the state of all qubits sv = Statevector(multiplier) counts = sv.probabilities_dict(decimals=10) state = list(counts.keys())[0] # we only have a single state # skip both input registers result = state[:-2*num_state_qubits] print(result) # '1001' = 9 = 3 * 3
The
Delay
class now can accept aParameterExpression
orParameter
value for theduration
kwarg on its constructor and for itsduration
attribute.For example:
idle_dur = Parameter('t') qc = QuantumCircuit(1, 1) qc.x(0) qc.delay(idle_dur, 0, 'us') qc.measure(0, 0) print(qc) # parameterized delay in us (micro seconds) # assign before transpilation assigned = qc.assign_parameters({idle_dur: 0.1}) print(assigned) # delay in us transpiled = transpile(assigned, some_backend_with_dt) print(transpiled) # delay in dt # assign after transpilation transpiled = transpile(qc, some_backend_with_dt) print(transpiled) # parameterized delay in dt assigned = transpiled.assign_parameters({idle_dur: 0.1}) print(assigned) # delay in dt
A new binary serialization format, QPY, has been introduced. It is designed to be a fast binary serialization format that is backwards compatible (QPY files generated with older versions of Qiskit can be loaded by newer versions of Qiskit) that is native to Qiskit. The QPY serialization tooling is available via the
qiskit.circuit.qpy_serialization
module. For example, to generate a QPY file:from datetime import datetime from qiskit.circuit import QuantumCircuit from qiskit.circuit import qpy_serialization qc = QuantumCircuit( 2, metadata={'created_at': datetime.utcnow().isoformat()} ) qc.h(0) qc.cx(0, 1) qc.measure_all() circuits = [qc] * 5 with open('five_bells.qpy', 'wb') as qpy_file: qpy_serialization.dump(circuits, qpy_file)
Then the five circuits saved in the QPY file can be loaded with:
from qiskit.circuit.qpy_serialization with open('five_bells.qpy', 'rb') as qpy_file: circuits = qpy_serialization.load(qpy_file)
The QPY file format specification is available in the module documentation.
The
TwoQubitBasisDecomposer
class has been updated to perform pulse optimal decompositions for a basis with CX, √X, and virtual Rz gates as described in https://arxiv.org/pdf/2008.08571. Pulse optimal here means that the duration of gates between the CX gates of the decomposition is reduced in exchange for possibly more local gates before or after all the CX gates such that, when composed into a circuit, there is the possibility of single qubit compression with neighboring gates reducing the overall sequence duration.A new keyword argument,
`pulse_optimize
, has been added to the constructor forTwoQubitBasisDecomposer
to control this:None
: Attempt pulse optimal decomposition. If a pulse optimal decomposition is unknown for the basis of the decomposer, drop back to the standard decomposition without warning. This is the default setting.True
: Attempt pulse optimal decomposition. If a pulse optimal decomposition is unknown for the basis of the decomposer, raise QiskitError.False
: Do not attempt pulse optimal decomposition.
For example:
from qiskit.quantum_info import TwoQubitBasisDecomposer from qiskit.circuit.library import CXGate from qiskit.quantum_info import random_unitary unitary_matrix = random_unitary(4) decomposer = TwoQubitBasisDecomposer(CXGate(), euler_basis="ZSX", pulse_optimize=True) circuit = decomposer(unitary_matrix)
The transpiler pass
UnitarySynthesis
located inqiskit.transpiler.passes
has been updated to support performing pulse optimal decomposition. This is done primarily with the thepulse_optimize
keyword argument which was added to the constructor and used to control whether pulse optimal synthesis is performed. The behavior of this kwarg mirrors thepulse_optimize
kwarg in theTwoQubitBasisDecomposer
class’s constructor. Additionally, the constructor has another new keyword argument,synth_gates
, which is used to specify the list of gate names over which synthesis should be attempted. IfNone
andpulse_optimize
isFalse
orNone
, use"unitary"
. If None and pulse_optimize isTrue
, use"unitary"
and"swap"
. Since the direction of the CX gate in the synthesis is arbitrary, another keyword argument,natural_direction
, is added to consider first a coupling map and thenCXGate
durations in choosing for which direction of CX to generate the synthesis.from qiskit.circuit import QuantumCircuit from qiskit.transpiler import PassManager, CouplingMap from qiskit.transpiler.passes import TrivialLayout, UnitarySynthesis from qiskit.test.mock import FakeVigo from qiskit.quantum_info.random import random_unitary backend = FakeVigo() conf = backend.configuration() coupling_map = CouplingMap(conf.coupling_map) triv_layout_pass = TrivialLayout(coupling_map) circ = QuantumCircuit(2) circ.unitary(random_unitary(4), [0, 1]) unisynth_pass = UnitarySynthesis( basis_gates=conf.basis_gates, coupling_map=None, backend_props=backend.properties(), pulse_optimize=True, natural_direction=True, synth_gates=['unitary']) pm = PassManager([triv_layout_pass, unisynth_pass]) optimal_circ = pm.run(circ)
A new basis option,
'XZX'
, was added for thebasis
argumentOneQubitEulerDecomposer
class.Added a new method,
get_instructions()
, was added to theQuantumCircuit
class. This method is used to return allInstruction
objects in the circuit which have aname
that matches the providedname
argument along with its associatedqargs
andcargs
lists ofQubit
andClbit
objects.A new optional extra
all
has been added to the qiskit-terra package. This enables installing all the optional requirements with a single extra, for example:pip install 'qiskit-terra[all]'
, Previously, it was necessary to list all the extras individually to install all the optional dependencies simultaneously.Added two new classes
ProbDistribution
andQuasiDistribution
for dealing with probability distributions and quasiprobability distributions respectively. These objects both are dictionary subclasses that add additional methods for working with probability and quasiprobability distributions.Added a new
settings
property to theOptimizer
abstract base class that all the optimizer classes in theqiskit.algorithms.optimizers
module are based on. This property will return a Python dictionary of the settings for the optimizer that can be used to instantiate another instance of the same optimizer class. For example:from qiskit.algorithms.optimizers import GradientDescent optimizer = GradientDescent(maxiter=10, learning_rate=0.01) settings = optimizer.settings new_optimizer = GradientDescent(**settings)
The
settings
dictionary is also potentially useful for serializing optimizer objects using JSON or another serialization format.A new function,
set_config()
, has been added to theqiskit.user_config
module. This function enables setting values in a user config from the Qiskit API. For example:from qiskit.user_config import set_config set_config("circuit_drawer", "mpl", section="default", file="settings.conf")
which will result in adding a value of
circuit_drawer = mpl
to thedefault
section in thesettings.conf
file.If no
file_path
argument is specified, the currently used path to the user config file (either the value of theQISKIT_SETTINGS
environment variable if set or the default location~/.qiskit/settings.conf
) will be updated. However, changes to the existing config file will not be reflected in the current session since the config file is parsed at import time.Added a new state class,
StabilizerState
, to theqiskit.quantum_info
module. This class represents a stabilizer simulator state using the convention from Aaronson and Gottesman (2004).Two new options,
'value'
and'value_desc'
were added to thesort
kwarg of theqiskit.visualization.plot_histogram()
function. Whensort
is set to either of these options the output visualization will sort the x axis based on the maximum probability for each bitstring. For example:from qiskit.visualization import plot_histogram counts = { '000': 5, '001': 25, '010': 125, '011': 625, '100': 3125, '101': 15625, '110': 78125, '111': 390625, } plot_histogram(counts, sort='value')
Known Issues¶
When running
parallel_map()
(and functions that internally callparallel_map()
such astranspile()
andassemble()
) on Python 3.9 withQISKIT_PARALLEL
set to True in some scenarios it is possible for the program to deadlock and never finish running. To avoid this from happening the default for Python 3.9 was changed to not run in parallel, but ifQISKIT_PARALLEL
is explicitly enabled then this can still occur.
Upgrade Notes¶
The minimum version of the retworkx dependency was increased to version 0.9.0. This was done to use new APIs introduced in that release which improved the performance of some transpiler passes.
The default value for
QISKIT_PARALLEL
on Python 3.9 environments has changed toFalse
, this means that when running on Python 3.9 by default multiprocessing will not be used. This was done to avoid a potential deadlock/hanging issue that can occur when running multiprocessing on Python 3.9 (see the known issues section for more detail). It is still possible to manual enable it by explicitly setting theQISKIT_PARALLEL
environment variable toTRUE
.The existing fake backend classes in
qiskit.test.mock
now strictly implement theBackendV1
interface. This means that if you were manually constructingQasmQobj
orPulseQobj
object for use with therun()
method this will no longer work. Therun()
method only acceptsQuantumCircuit
orSchedule
objects now. This was necessary to enable testing of new backends implemented without qobj which previously did not have any testing inside qiskit terra. If you need to leverage the fake backends withQasmQobj
orPulseQobj
new fake legacy backend objects were added to explicitly test the legacy providers interface. This will be removed after the legacy interface is deprecated and removed. Moving forward new fake backends will only implement theBackendV1
interface and will not add new legacy backend classes for new fake backends.When creating a
Pauli
object with an invalid string label, aQiskitError
is now raised. This is a change from previous releases which would raise anAttributeError
on an invalid string label. This change was made to ensure the error message is more informative and distinct from a genericAttributeError
.The output program representation from the pulse builder (
qiskit.pulse.builder.build()
) has changed from aSchedule
to aScheduleBlock
. This new representation disables some timing related operations such as shift and insert. However, this enables parameterized instruction durations within the builder context. For example:from qiskit import pulse from qiskit.circuit import Parameter dur = Parameter('duration') with pulse.build() as sched: with pulse.align_sequential(): pulse.delay(dur, pulse.DriveChannel(1)) pulse.play(pulse.Gaussian(dur, 0.1, dur/4), pulse.DriveChannel(0)) assigned0 = sched.assign_parameters({dur: 100}) assigned1 = sched.assign_parameters({dur: 200})
You can directly pass the duration-assigned schedules to the assembler (or backend), or you can attach them to your quantum circuit as pulse gates.
The tweedledum library which was previously an optional dependency has been made a requirement. This was done because of the wide use of the
PhaseOracle
(which depends on having tweedledum installed) with several algorithms fromqiskit.algorithms
.The optional extra
full-featured-simulators
which could previously used to installqiskit-aer
with something likepip install qiskit-terra[full-featured-simulators]
has been removed from the qiskit-terra package. If this was being used to installqiskit-aer
withqiskit-terra
instead you should rely on the qiskit metapackage or just install qiskit-terra and qiskit-aer together withpip install qiskit-terra qiskit-aer
.A new requirement symengine has been added for Linux (on x86_64, aarch64, and ppc64le) and macOS users (x86_64 and arm64). It is an optional dependency on Windows (and available on PyPi as a precompiled package for 64bit Windows) and other architectures. If it is installed it provides significantly improved performance for the evaluation of
Parameter
andParameterExpression
objects.All library circuit classes, i.e. all
QuantumCircuit
derived classes inqiskit.circuit.library
, are now wrapped in aInstruction
(orGate
, if they are unitary). For example, importing and drawing theQFT
circuit:before looked like
┌───┐ q_0: ────────────────────■────────■───────┤ H ├─X─ ┌───┐ │ │P(π/2) └───┘ │ q_1: ──────■───────┤ H ├─┼────────■─────────────┼─ ┌───┐ │P(π/2) └───┘ │P(π/4) │ q_2: ┤ H ├─■─────────────■──────────────────────X─ └───┘
and now looks like
┌──────┐ q_0: ┤0 ├ │ │ q_1: ┤1 QFT ├ │ │ q_2: ┤2 ├ └──────┘
To obtain the old circuit, you can call the
decompose()
method on the circuitThis change was primarily made for consistency as before this release some circuit classes in
qiskit.circuit.library
were previously wrapped in anInstruction
orGate
but not all.
Deprecation Notes¶
The class
qiskit.exceptions.QiskitIndexError
is deprecated and will be removed in a future release. This exception was not actively being used by anything in Qiskit, if you were using it you can create a custom exception class to replace it.The kwargs
epsilon
andfactr
for theqiskit.algorithms.optimizers.L_BFGS_B
constructor andfactr
kwarg of theP_BFGS
optimizer class are deprecated and will be removed in a future release. Instead, please use theeps
karg instead ofepsilon
. Thefactr
kwarg is replaced withftol
. The relationship between the two isftol = factr * numpy.finfo(float).eps
. This change was made to be consistent with the usage of thescipy.optimize.minimize
functions'L-BFGS-B'
method. See the:scipy.optimize.minimize(method='L-BFGS-B')
documentation for more information on how these new parameters are used.The legacy providers interface, which consisted of the
qiskit.providers.BaseBackend
,qiskit.providers.BaseJob
, andqiskit.providers.BaseProvider
abstract classes, has been deprecated and will be removed in a future release. Instead you should use the versioned interface, which the current abstract class versions areqiskit.providers.BackendV1
,qiskit.providers.JobV1
, andqiskit.providers.ProviderV1
. The V1 objects are mostly backwards compatible to ease migration from the legacy interface to the versioned one. However, expect future versions of the abstract interfaces to diverge more. You can refer to theqiskit.providers
documentation for more high level details about the versioned interface.The
condition
kwarg to theDAGDepNode
constructor along with the correspondingcondition
attribute of theDAGDepNode
have been deprecated and will be removed in a future release. Instead, you can access thecondition
of aDAGDepNode
if the node is of typeop
, by usingDAGDepNode.op.condition
.The
condition
attribute of theDAGNode
class has been deprecated and will be removed in a future release. Instead, you can access thecondition
of aDAGNode
object if the node is of typeop
, by usingDAGNode.op.condition
.The pulse builder (
qiskit.pulse.builder.build()
) syntaxqiskit.pulse.builder.inline()
is deprecated and will be removed in a future release. Instead of using this context, you can just remove alignment contexts within the inline context.The pulse builder (
qiskit.pulse.builder.build()
) syntaxqiskit.pulse.builder.pad()
is deprecated and will be removed in a future release. This was done because theScheduleBlock
now being returned by the pulse builder doesn’t support the.insert
method (and there is no insert syntax in the builder). The use of timeslot placeholders to block the insertion of other instructions is no longer necessary.
Bug Fixes¶
The
OneQubitEulerDecomposer
andTwoQubitBasisDecomposer
classes for one and two qubit gate synthesis have been improved to tighten up tolerances, improved repeatability and simplification, and fix several global-phase-tracking bugs.Fixed an issue in the assignment of the
name
attribute toGate
generated by multiple calls to theinverse`()
method. Prior to this fix when theinverse`()
was called it would unconditionally append_dg
on each call to inverse. This has been corrected so on a second call ofinverse`()
the_dg
suffix is now removed.Fixes the triviality check conditions of
CZGate
,CRZGate
,CU1Gate
andMCU1Gate
in theHoareOptimizer
pass. Previously, in some cases the optimizer would remove these gates breaking the semantic equivalence of the transformation.Fixed an issue when converting a
ListOp
object ofPauliSumOp
objects usingPauliExpectation
orAerPauliExpectation
. Previously, it would raise a warning about it converting to a Pauli representation which is potentially expensive. This has been fixed by instead of internally converting theListOp
to aSummedOp
ofPauliOp
objects, it now creates aPauliSumOp
which is more efficient. Fixed #6159Fixed an issue with the
NLocal
class in theqiskit.circuit.library
module where it wouldn’t properly raise an exception at object initialization if an invalid type was used for thereps
kwarg which would result in an unexpected runtime error later. ATypeError
will now be properly raised if thereps
kwarg is not anint
value. Fixed #6515Fixed an issue where the
TwoLocal
class in theqiskit.circuit.library
module did not accept numpy integer types (e.g.numpy.int32
,numpy.int64
, etc) as a valid input for theentanglement
kwarg. Fixed #6455When loading an OpenQASM2 file or string with the
from_qasm_file()
orfrom_qasm_str()
constructors for theQuantumCircuit
class, if the OpenQASM2 circuit contains an instruction with the namedelay
this will be mapped to aqiskit.circuit.Delay
instruction. For example:from qiskit import QuantumCircuit qasm = """OPENQASM 2.0; include "qelib1.inc"; opaque delay(time) q; qreg q[1]; delay(172) q[0]; u3(0.1,0.2,0.3) q[0]; """ circuit = QuantumCircuit.from_qasm_str(qasm) circuit.draw()
┌────────────────┐┌─────────────────┐ q: ┤ Delay(172[dt]) ├┤ U3(0.1,0.2,0.3) ├ └────────────────┘└─────────────────┘
Fixed #6510
Fixed an issue with addition between
PauliSumOp
objects that hadParameterExpression
coefficients. Previously this would result in aQiskitError
exception being raised because the addition of theParameterExpression
was not handled correctly. This has been fixed so that addition can be performed betweenPauliSumOp
objects withParameterExpression
coefficients.Fixed an issue with the initialization of the
AmplificationProblem
class. Theis_good_state
kwarg was a required field but incorrectly being treated as optional (and documented as such). This has been fixed and also updated so unless the inputoracle
is aPhaseOracle
object (which provides it’s on evaluation method) the field is required and will raise aTypeError
when constructed withoutis_good_state
.Fixed an issue where adding a control to a
ControlledGate
with open controls would unset the inner open controls. Fixes #5857Fixed an issue with the
convert()
method of thePauliExpectation
class where calling it on an operator that was non-Hermitian would return an incorrect result. Fixed #6307Fixed an issue with the
qiskit.pulse.transforms.inline_subroutines()
function which would previously incorrectly not remove all the nested components when called on nested schedules. Fixed #6321Fixed an issue when passing a partially bound callable created with the Python standard library’s
functools.partial()
function as theschedule
kwarg to theadd()
method of theInstructionScheduleMap
class, which would previously result in an error. Fixed #6278Fixed an issue with the
PiecewiseChebyshev
when setting thebreakpoints
toNone
on an existing object was incorrectly being treated as a breakpoint. This has been corrected so that when it is set toNone
this will switch back to the default behavior of approximating over the full interval. Fixed #6198Fixed an issue with the
num_connected_components()
method ofQuantumCircuit
which was returning the incorrect number of components when the circuit contains two or more gates conditioned on classical registers. Fixed #6477Fixed an issue with the
qiskit.opflow.expectations
module where coefficients of a statefunction were not being multiplied correctly. This also fixed the calculations of Gradients and QFIs when using thePauliExpectation
orAerPauliExpectation
classes. For example, previously:from qiskit.opflow import StateFn, I, One exp = ~StateFn(I) @ (2 * One)
evaluated to
2
forAerPauliExpectation
and to4
for other expectation converters. Since~StateFn(I) @ (2 * One)
is a shorthand notation for~(2 * One) @ I @ (2 * One)
, the now correct coefficient of4
is returned for all expectation converters. Fixed #6497Fixed the bug that caused
to_circuit()
to fail whenPauliOp
had a phase. At the same time, it was made more efficient to usePauliGate
.Fixed an issue where the QASM output generated by the
qasm()
method ofQuantumCircuit
for composite gates such asMCXGate
and its variants (MCXGrayCode
,MCXRecursive
, andMCXVChain
) would be incorrect. Now if aGate
in the circuit is not present inqelib1.inc
, its definition is added to the output QASM string. Fixed #4943 and #3945Fixed an issue with the
circuit_drawer()
function anddraw()
method ofQuantumCircuit
. When using thempl
orlatex
output modes, with thecregbundle
kwarg set toFalse
and thereverse_bits
kwarg set toTrue
, the bits in the classical registers displayed in the same order as whenreverse_bits
was set toFalse
.Fixed an issue when using the
qiskit.extensions.Initialize
instruction which was not correctly setting the global phase of the synthesized definition when constructed. Fixed #5320Fixed an issue where the bit-order in
qiskit.circuit.library.PhaseOracle.evaluate_bitstring()
did not agree with the order of the measured bitstring. This fix also affects the execution of theGrover
algorithm class if the oracle is specified as aPhaseOracle
, which now will now correctly identify the correct bitstring. Fixed #6314Fixes a bug in
Optimize1qGatesDecomposition()
previously causing certain short sequences of gates to erroneously not be rewritten.Fixed an issue in the
qiskit.opflow.gradients.Gradient.gradient_wrapper()
method with the gradient calculation. Previously, if the operator was not diagonal an incorrect result would be returned in some situations. This has been fixed by using an expectation converter to ensure the result is always correct.Fixed an issue with the
circuit_drawer()
function anddraw()
method ofQuantumCircuit
with all output modes where it would incorrectly render a custom instruction that includes classical bits in some circumstances. Fixed #3201, #3202, and #6178Fixed an issue in
circuit_drawer()
and thedraw()
method of theQuantumCircuit
class when using thempl
output mode, controlled-Z Gates were incorrectly drawn as asymmetrical. Fixed #5981Fixed an issue with the
OptimizeSwapBeforeMeasure
transpiler pass where in some situations aSwapGate
that that contained a classical condition would be removed. Fixed #6192Fixed an issue with the phase of the
qiskit.opflow.gradients.QFI
class when theqfi_method
is set tolin_comb_full
which caused the incorrect observable to be evaluated.Fixed an issue with
VQE
algorithm class when run with theL_BFGS_B
orP_BFGS
optimizer classes and gradients are used, the gradient was incorrectly passed as a numpy array instead of the expected list of floats resulting in an error. This has been resolved so you can use gradients withVQE
and theL_BFGS_B
orP_BFGS
optimizers.
Other Notes¶
The deprecation of the
parameters()
method for theInstruction
class has been reversed. This method was originally deprecated in the 0.17.0, but it is still necessary for several applications, including when running calibration experiments. This method will continue to be supported and will not be removed.
Aer 0.8.2¶
No change
Ignis 0.6.0¶
No change
Aqua 0.9.4¶
No change
IBM Q Provider 0.15.0¶
New Features¶
Add support for new method
qiskit.providers.ibmq.runtime.RuntimeJob.error_message()
which will return a string representing the reason if the job failed.The inputs parameter to
qiskit.providers.ibmq.runtime.IBMRuntimeService.run()
method can now be specified as aqiskit.providers.ibmq.runtime.ParameterNamespace
instance which supports auto-complete features. You can useqiskit.providers.ibmq.runtime.RuntimeProgram.parameters()
to retrieve anParameterNamespace
instance.For example:
from qiskit import IBMQ provider = IBMQ.load_account() # Set the "sample-program" program parameters. params = provider.runtime.program(program_id="sample-program").parameters() params.iterations = 2 # Configure backend options options = {'backend_name': 'ibmq_qasm_simulator'} # Execute the circuit using the "circuit-runner" program. job = provider.runtime.run(program_id="sample-program", options=options, inputs=params)
The user can now set the visibility (private/public) of a Qiskit Runtime program using
qiskit.providers.ibmq.runtime.IBMRuntimeService.set_program_visibility()
.An optional boolean parameter pending has been added to
qiskit.providers.ibmq.runtime.IBMRuntimeService.jobs()
and it allows filtering jobs by their status. If pending is not specified all jobs are returned. If pending is set to True, “QUEUED” and “RUNNING” jobs are returned. If pending is set to False, “DONE”, “ERROR” and “CANCELLED” jobs are returned.Add support for the
use_measure_esp
flag in theqiskit.providers.ibmq.IBMQBackend.run()
method. IfTrue
, the backend will use ESP readout for all measurements which are the terminal instruction on that qubit. If used and the backend does not support ESP readout, an error is raised.
Upgrade Notes¶
qiskit.providers.ibmq.runtime.RuntimeProgram.parameters()
is now a method that returns aqiskit.providers.ibmq.runtime.ParameterNamespace
instance, which you can use to fill in runtime program parameter values and pass toqiskit.providers.ibmq.runtime.IBMRuntimeService.run()
.The
open_pulse
flag in backend configuration no longer indicates whether a backend supports pulse-level control. As a result,qiskit.providers.ibmq.IBMQBackend.configuration()
may return aPulseBackendConfiguration
instance even if itsopen_pulse
flag isFalse
.Job share level is no longer supported due to low adoption and the corresponding interface will be removed in a future release. This means you should no longer pass share_level when creating a job or use
qiskit.providers.ibmq.job.IBMQJob.share_level()
method to get a job’s share level.
Deprecation Notes¶
The
id
instruction has been deprecated on IBM hardware backends. Instead, please use thedelay
instruction which implements variable-length delays, specified in units ofdt
. When running a circuit containing anid
instruction, a warning will be raised on job submission and anyid
instructions in the job will be automatically replaced with their equivalentdelay
instruction.
Qiskit 0.27.0¶
Terra 0.17.4¶
No change
Aer 0.8.2¶
No change
Ignis 0.6.0¶
No change
Aqua 0.9.2¶
Bug Fixes¶
Removed version caps from the requirements list to enable installing with newer versions of dependencies.
IBM Q Provider 0.14.0¶
New Features¶
You can now use the
qiskit.providers.ibmq.runtime.RuntimeJob.logs()
method to retrieve job logs. Note that logs are only available after the job finishes.A new backend configuration attribute
input_allowed
now tells you the types of input supported by the backend. Valid input types arejob
, which means circuit jobs, andruntime
, which means Qiskit Runtime.You can also use
input_allowed
in backend filtering. For example:from qiskit import IBMQ provider = IBMQ.load_account() # Get a list of all backends that support runtime. runtime_backends = provider.backends(input_allowed='runtime')
Upgrade Notes¶
qiskit-ibmq-provider
now uses a new packagewebsocket-client
as its websocket client, and packageswebsockets
andnest-asyncio
are no longer required.setup.py
andrequirements.txt
have been updated accordingly.
Bug Fixes¶
Fixes the issue that uses
shots=1
instead of the documented default when noshots
is specified forrun_circuits()
.Fixes the issue wherein a
QiskitBackendNotFoundError
exception is raised when retrieving a runtime job that was submitted using a different provider than the one used for retrieval.Streaming runtime program interim results with proxies is now supported. You can specify the proxies to use when enabling the account as usual, for example:
from qiskit import IBMQ proxies = {'urls': {'https://127.0.0.1:8085'}} provider = IBMQ.enable_account(API_TOKEN, proxies=proxies)
Qiskit 0.26.1¶
Terra 0.17.4¶
Bug Fixes¶
Fixed an issue with the
QuantumInstance
withBackendV1
backends with the`max_experiments
attribute set to a value less than the number of circuits to run. Previously theQuantumInstance
would not correctly split the circuits to run into separate jobs, which has been corrected.
Aer 0.8.2¶
No change
Ignis 0.6.0¶
No change
Aqua 0.9.1¶
No change
IBM Q Provider 0.13.1¶
No change
Qiskit 0.26.0¶
Terra 0.17.3¶
Prelude¶
This release includes 2 new classes,
ProbDistribution
and
QuasiDistribution
, which were needed for
compatibility with the recent qiskit-ibmq-provider release’s beta support
for the
qiskit-runtime.
These were only added for compatibility with that new feature in the
qiskit-ibmq-provider release and the API for these classes is considered
experimental and not considered stable for the 0.17.x release series. The
interface may change when 0.18.0 is released in the future.
Bug Fixes¶
Fixed an issue in
plot_histogram()
function where aValueError
would be raised when the function run on distributions with unequal lengths.
Aer 0.8.2¶
No change
Ignis 0.6.0¶
No change
Aqua 0.9.1¶
No change
IBM Q Provider 0.13.1¶
Prelude¶
This release introduces a new feature Qiskit Runtime Service
.
Qiskit Runtime is a new architecture offered by IBM Quantum that significantly
reduces waiting time during computational iterations. You can execute your
experiments near the quantum hardware, without the interactions of multiple
layers of classical and quantum hardware slowing it down.
Qiskit Runtime allows authorized users to upload their Qiskit quantum programs, which are Python code that takes certain inputs, performs quantum and maybe classical computation, and returns the processing results. The same or other authorized users can then invoke these quantum programs by simply passing in the required input parameters.
Note that Qiskit Runtime is currently in private beta for select account but will be released to the public in the near future.
New Features¶
qiskit.providers.ibmq.experiment.analysis_result.AnalysisResult
now has an additionalverified
attribute which identifies if thequality
has been verified by a human.qiskit.providers.ibmq.experiment.Experiment
now has an additionalnotes
attribute which can be used to set notes on an experiment.This release introduces a new feature
Qiskit Runtime Service
. Qiskit Runtime is a new architecture that significantly reduces waiting time during computational iterations. This new service allows authorized users to upload their Qiskit quantum programs, which are Python code that takes certain inputs, performs quantum and maybe classical computation, and returns the processing results. The same or other authorized users can then invoke these quantum programs by simply passing in the required input parameters.An example of using this new service:
from qiskit import IBMQ provider = IBMQ.load_account() # Print all avaiable programs. provider.runtime.pprint_programs() # Prepare the inputs. See program documentation on input parameters. inputs = {...} options = {"backend_name": provider.backend.ibmq_montreal.name()} job = provider.runtime.run(program_id="runtime-simple", options=options, inputs=inputs) # Check job status. print(f"job status is {job.status()}") # Get job result. result = job.result()
Upgrade Notes¶
The deprecated
Human Bad
,Computer Bad
,Computer Good
andHuman Good
enum values have been removed fromqiskit.providers.ibmq.experiment.constants.ResultQuality
. They are replaced withBad
andGood
values which should be used with theverified
attribute onqiskit.providers.ibmq.experiment.analysis_result.AnalysisResult
:Old Quality
New Quality
Verified
Human Bad
Bad
True
Computer Bad
Bad
False
Computer Good
Good
False
Human Good
Good
True
Furthermore, the
NO_INFORMATION
enum has been renamed toUNKNOWN
.The
qiskit.providers.ibmq.IBMQBackend.defaults()
method now always returns pulse defaults if they are available, regardless whether open pulse is enabled for the provider.
Bug Fixes¶
Fixes the issue wherein passing in a noise model when sending a job to an IBMQ simulator would raise a
TypeError
. Fixes #894
Other Notes¶
The
qiskit.providers.ibmq.experiment.analysis_result.AnalysisResult
fit
attribute is now optional.
Qiskit 0.25.4¶
Terra 0.17.2¶
Prelude¶
This is a bugfix release that fixes several issues from the 0.17.1 release.
Most importantly this release fixes compatibility for the
QuantumInstance
class when running on backends that are
based on the BackendV1
abstract class. This fixes
all the algorithms and applications built on qiskit.algorithms
or
qiskit.opflow
when running on newer backends.
Bug Fixes¶
Fixed an issue with the
BasisTranslator
transpiler pass which in some cases would translate gates already in the target basis. This would potentially result in both longer execution time and less optimal results. Fixed #6085Fixed an issue in the
SPSA
when the optimizer was initialized with a callback function via thecallback
kwarg would potentially cause an error to be raised.Fixed an issue in the
qiskit.quantum_info.Statevector.expectation_value()
andqiskit.quantum_info.DensityMatrix.expectation_value`methods where the ``qargs`()
kwarg was ignored if the operator was aPauli
orSparsePauliOp
operator object. Fixed #6303Fixed an issue in the
qiskit.quantum_info.Pauli.evolve()
method which could have resulted in the incorrect Pauli being returned when evolving by aCZGate
,CYGate
, or aSwapGate
gate.Fixed an issue in the
qiskit.opflow.SparseVectorStateFn.to_dict_fn()
method, which previously had at most one entry for the all zero state due to an index error.Fixed an issue in the
qiskit.opflow.SparseVectorStateFn.equals()
method so that is properly returningTrue
orFalse
instead of a sparse vector comparison of the single elements.Fixes an issue in the
Statevector
andDensityMatrix
probability methodsqiskit.quantum_info.Statevector.probabilities()
,qiskit.quantum_info.Statevector.probabilities_dict()
,qiskit.quantum_info.DensityMatrix.probabilities()
,qiskit.quantum_info.DensityMatrix.probabilities_dict()
where the returned probabilities could have incorrect ordering for certain values of theqargs
kwarg. Fixed #6320Fixed an issue where the
TaperedPauliSumOp
class did not support the multiplication withParameterExpression
object and also did not have a necessaryassign_parameters()
method for working withParameterExpression
objects. Fixed #6127Fixed compatibility for the
QuantumInstance
class when running on backends that are based on theBackendV1
abstract class. Fixed #6280
Aer 0.8.2¶
No change
Ignis 0.6.0¶
No change
Aqua 0.9.1¶
No change
IBM Q Provider 0.12.3¶
No change
Qiskit 0.25.3¶
Terra 0.17.1¶
No change
Aer 0.8.2¶
Known Issues¶
The
SaveExpectationValue
andSaveExpectationValueVariance
have been disabled for the extended_stabilizer method of theQasmSimulator
andAerSimulator
due to returning the incorrect value for certain Pauli operator components. Refer to #1227 <https://github.com/Qiskit/qiskit-aer/issues/1227> for more information and examples.
Bug Fixes¶
Fixes performance issue with how the
basis_gates
configuration attribute was set. Previously there were unintended side-effects to the backend class which could cause repeated simulation runtime to incrementally increase. Refer to #1229 <https://github.com/Qiskit/qiskit-aer/issues/1229> for more information and examples.Fixes a bug with the
"multiplexer"
simulator instruction where the order of target and control qubits was reversed to the order in the Qiskit instruction.Fixes a bug introduced in 0.8.0 where GPU simulations would allocate unneeded host memory in addition to the GPU memory.
Fixes a bug in the
stabilizer
simulator method of theQasmSimulator
andAerSimulator
where the expectation value for thesave_expectation_value
andsnapshot_expectation_value
could have the wrong sign for certainY
Pauli’s.
Ignis 0.6.0¶
No change
Aqua 0.9.1¶
No change
IBM Q Provider 0.12.3¶
No change
Qiskit 0.25.2¶
Terra 0.17.1¶
No change
Aer 0.8.1¶
No change
Ignis 0.6.0¶
No change
Aqua 0.9.1¶
No change
Qiskit 0.25.1¶
Terra 0.17.1¶
Prelude¶
This is a bugfix release that fixes several issues from the 0.17.0 release. Most importantly this release fixes the incorrectly constructed sdist package for the 0.17.0 release which was not actually buildable and was blocking installation on platforms without precompiled binaries available.
Bug Fixes¶
Fixed an issue where the
global_phase
attribute would not be preserved in the outputQuantumCircuit
object when theqiskit.circuit.QuantumCircuit.reverse_bits()
method was called. For example:import math from qiskit import QuantumCircuit qc = QuantumCircuit(3, 2, global_phase=math.pi) qc.h(0) qc.s(1) qc.cx(0, 1) qc.measure(0, 1) qc.x(0) qc.y(1) reversed = qc.reverse_bits() print(reversed.global_phase)
will now correctly print \(\pi\).
Fixed an issue where the transpiler pass
Unroller
didn’t preserve global phase in case of nested instructions with one rule in their definition. Fixed #6134Fixed an issue where the
parameter
attribute of aControlledGate
object built from aUnitaryGate
was not being set to the unitary matrix of theUnitaryGate
object. Previously,control()
was building aControlledGate
with theparameter
attribute set to the controlled version ofUnitaryGate
matrix. This would lead to a modification of theparameter
of the baseUnitaryGate
object and subsequent calls toinverse()
was creating the inverse of a double-controlledUnitaryGate
. Fixed #5750Fixed an issue with the preset pass managers
level_0_pass_manager
andlevel_1_pass_manager
(which corresponds tooptimization_level
0 and 1 fortranspile()
) where in some cases they would produce circuits not in the requested basis.Fix a bug where using
SPSA
with automatic calibration of the learning rate and perturbation (i.e.learning_rate
andperturbation
areNone
in the initializer), stores the calibration for all future optimizations. Instead, the calibration should be done for each new objective function.
Aer 0.8.1¶
Bug Fixes¶
Fixed an issue with use of the
matrix_product_state
method of theAerSimulator
andQasmSimulator
simulators when running a noisy simulation with Kraus errors. Previously, the matrix product state simulation method would not propogate changes to neighboring qubits after applying the Kraus matrix. This has been fixed so the output from the simulation is correct. Fixed #1184 and #1205Fixed an issue where the
qiskit.extensions.Initialize
instruction would disable measurement sampling optimization for thestatevector
andmatrix_product_state
simulation methods of theAerSimulator
andQasmSimulator
simulators, even when it was the first circuit instruction or applied to all qubits and hence deterministic. Fixed #1210Fix an issue with the
SaveStatevector
andSnapshotStatevector
instructions when used with theextended_stabilizer
simulation method of theAerSimulator
andQasmSimulator
simulators where it would return an unnormalized statevector. Fixed #1196The
matrix_product_state
simulation method now has support for it’s previously missing set state instruction,qiskit.providers.aer.library.SetMatrixProductState
, which enables setting the state of a simulation in a circuit.
Ignis 0.6.0¶
No change
Aqua 0.9.1¶
IBM Q Provider 0.12.2¶
No change
Qiskit 0.25.0¶
This release officially deprecates the Qiskit Aqua project. Accordingly, in a
future release the qiskit-aqua
package will be removed from the Qiskit
metapackage, which means in that future release pip install qiskit
will no
longer include qiskit-aqua
. The application modules that are provided by
qiskit-aqua have been split into several new packages:
qiskit-optimization
, qiskit-nature
, qiskit-machine-learning
, and
qiskit-finance
. These packages can be installed by themselves (via the
standard pip install command, e.g. pip install qiskit-nature
) or with the
rest of the Qiskit metapackage as optional extras (e.g.
pip install 'qiskit[finance,optimization]'
or pip install 'qiskit[all]'
The core algorithms and the operator flow now exist as part of qiskit-terra at
qiskit.algorithms
and qiskit.opflow
. Depending on your existing
usage of Aqua you should either use the application packages or the new modules
in Qiskit Terra. For more details on how to migrate from Qiskit Aqua you can
refer to the aqua-migration.
Terra 0.17.0¶
Prelude¶
The Qiskit Terra 0.17.0 includes many new features and bug fixes. The major
new feature for this release is the introduction of the
qiskit.algorithms
and qiskit.opflow
modules which were
migrated and adapted from the qiskit.aqua
project.
New Features¶
The
qiskit.pulse.call()
function can now take aParameter
object along with a parameterized subroutine. This enables assigning different values to theParameter
objects for each subroutine call.For example,
from qiskit.circuit import Parameter from qiskit import pulse amp = Parameter('amp') with pulse.build() as subroutine: pulse.play(pulse.Gaussian(160, amp, 40), DriveChannel(0)) with pulse.build() as main_prog: pulse.call(subroutine, amp=0.1) pulse.call(subroutine, amp=0.3)
The
qiskit.providers.models.QasmBackendConfiguration
has a new fieldprocessor_type
which can optionally be used to provide information about a backend’s processor in the form:{"family": <str>, "revision": <str>, segment: <str>}
. For example:{"family": "Canary", "revision": "1.0", segment: "A"}
.The
qiskit.pulse.Schedule
,qiskit.pulse.Instruction
, andqiskit.pulse.Channel
classes now have aparameter
property which will return anyParameter
objects used in the object and ais_parameterized()
method which will returnTrue
if any parameters are used in the object.For example:
from qiskit.circuit import Parameter from qiskit import pulse shift = Parameter('alpha') schedule = pulse.Schedule() schedule += pulse.SetFrequency(shift, pulse.DriveChannel(0)) assert schedule.is_parameterized() == True print(schedule.parameters)
{Parameter(alpha)}
Added a
PiecewiseChebyshev
to theqiskit.circuit.library
for implementing a piecewise Chebyshev approximation of an input function. For a given function \(f(x)\) and degree \(d\), this class class implements a piecewise polynomial Chebyshev approximation on \(n\) qubits to \(f(x)\) on the given intervals. All the polynomials in the approximation are of degree \(d\).For example:
import numpy as np from qiskit import QuantumCircuit from qiskit.circuit.library.arithmetic.piecewise_chebyshev import PiecewiseChebyshev f_x, degree,