The 0.14.0 release includes several new features and bug fixes. The biggest change for this release is the introduction of a quantum circuit library in
qiskit.circuit.library, containing some circuit families of interest.
The circuit library gives users access to a rich set of well-studied circuit families, instances of which can be used as benchmarks, as building blocks in building more complex circuits, or as a tool to explore quantum computational advantage over classical. The contents of this library will continue to grow and mature.
The initial release of the circuit library contains:
standard_gates: these are fixed-width gates commonly used as primitive building blocks, consisting of 1, 2, and 3 qubit gates. For example the
CSWAPGate. The old location of these gates under
generalized_gates: these are families that can generalize to arbitrarily many qubits, for example a
GMS(Global Molmer-Sorensen gate).
boolean_logic: circuits that transform basis states according to simple Boolean logic functions, such as
arithmetic: a set of circuits for doing classical arithmetic such as
basis_changes: circuits such as the quantum Fourier transform,
QFT, that mathematically apply basis changes.
n_local: patterns to easily create large circuits with rotation and entanglement layers, such as
TwoLocalwhich uses single-qubit rotations and two-qubit entanglements.
data_preparation: circuits that take classical input data and encode it in a quantum state that is difficult to simulate, e.g.
- Other circuits that have proven interesting in the literature, such as
To allow easier use of these circuits as building blocks, we have introduced a
compose() method of
qiskit.circuit.QuantumCircuit for composition of circuits either with other circuits (by welding them at the ends and optionally permuting wires) or with other simpler gates:
>>> lhs.compose(rhs, qubits=[3, 2], inplace=True)
┌───┐ ┌─────┐ ┌───┐ lqr_1_0: ───┤ H ├─── rqr_0: ──■──┤ Tdg ├ lqr_1_0: ───┤ H ├─────────────── ├───┤ ┌─┴─┐└─────┘ ├───┤ lqr_1_1: ───┤ X ├─── rqr_1: ┤ X ├─────── lqr_1_1: ───┤ X ├─────────────── ┌──┴───┴──┐ └───┘ ┌──┴───┴──┐┌───┐ lqr_1_2: ┤ U1(0.1) ├ + = lqr_1_2: ┤ U1(0.1) ├┤ X ├─────── └─────────┘ └─────────┘└─┬─┘┌─────┐ lqr_2_0: ─────■───── lqr_2_0: ─────■───────■──┤ Tdg ├ ┌─┴─┐ ┌─┴─┐ └─────┘ lqr_2_1: ───┤ X ├─── lqr_2_1: ───┤ X ├─────────────── └───┘ └───┘ lcr_0: 0 ═══════════ lcr_0: 0 ═══════════════════════ lcr_1: 0 ═══════════ lcr_1: 0 ═══════════════════════
With this, Qiskit’s circuits no longer assume an implicit initial state of , and will not be drawn with this initial state. The all-zero initial state is still assumed on a backend when a circuit is executed.
compose()method has been added to
qiskit.circuit.QuantumCircuit. It allows composition of two quantum circuits without having to turn one into a gate or instruction. It also allows permutations of qubits/clbits at the point of composition, as well as optional inplace modification. It can also be used in place of
append(), as it allows composing instructions and operators onto the circuit as well.
qiskit.circuit.library.Diagonalcircuits have been added to the circuit library. These circuits implement diagonal quantum operators (consisting of non-zero elements only on the diagonal). They are more efficiently simulated by the Aer simulator than dense matrices.
qiskit.pulse.reschedule.compress_pulses()performs an optimization pass to reduce the usage of waveform memory in hardware by replacing multiple identical instances of a pulse in a pulse schedule with a single pulse. For example:
from qiskit.pulse import reschedule schedules =  for _ in range(2): schedule = Schedule() drive_channel = DriveChannel(0) schedule += Play(SamplePulse([0.0, 0.1]), drive_channel) schedule += Play(SamplePulse([0.0, 0.1]), drive_channel) schedules.append(schedule) compressed_schedules = reschedule.compress_pulses(schedules)
Two new methods have been added to the
qiskit.providers.models.PulseBackendConfigurationfor interacting with channels.
get_channel_qubits()to get a list of all qubits operated by the given channel and
get_qubit_channel()to get a list of channels operating on the given qubit.
qiskit.circuit.QuantumCircuit.hamiltonian()methods are introduced, representing Hamiltonian evolution of the circuit wavefunction by a user-specified Hermitian Operator and evolution time. The evolution time can be a
Parameter, allowing the creation of parameterized UCCSD or QAOA-style circuits which compile to
timeparameters are provided. The Unitary of a
HamiltonianGatewith Hamiltonian Operator
Hand time parameter
The circuit library module
qiskit.circuit.librarynow provides a new boolean logic AND circuit,
qiskit.circuit.library.AND, and OR circuit,
qiskit.circuit.library.OR, which implement the respective operations on a variable number of provided qubits.
New fake backends are added under
qiskit.test.mock. These include mocked versions of
ibmq_athens. As with 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.
BackendPropertiescan now also be passed in as a
datetimeobject. Previously only a string in ISO8601 format was accepted.
The methods on the
qiskit.circuit.QuantumCircuitclass for adding gates (for example
h()) which were previously added dynamically at run time to the class definition have been refactored to be statically defined methods of the class. This means that static analyzer (such as IDEs) can now read these methods.
A new package, python-dateutil (opens in a new tab), is now required and has been added to the requirements list. It is being used to parse datetime strings received from external providers in
The marshmallow schema classes in
qiskit.providers.modelshave been removed since they are no longer used by the BackendObjects.
The output of the
to_dict()method for the classes in
qiskit.providers.modelsis no longer in a format for direct JSON serialization. Depending on the content contained in instances of these class there may be numpy arrays and/or complex numbers in the fields of the dict. If you’re JSON serializing the output of the to_dict methods you should ensure your JSON encoder can handle numpy arrays and complex numbers. This includes:
qiskit.dagcircuit.DAGCircuit.compose()method now takes a list of qubits/clbits that specify the positional order of bits to compose onto. The dictionary-based method of mapping using the
edge_mapargument is deprecated and will be removed in a future release.
combine_into_edge_map()method for the
qiskit.transpiler.Layoutclass has been deprecated and will be removed in a future release. Instead, the new method
reorder_bits()should be used to reorder a list of virtual qubits according to the layout object.
qiskit.pulse.ControlChannelobject in via the parameter
control()has been deprecated and will be removed in a future release. The
ControlChannelobjects are now generated from the backend configuration
channelsattribute which has the information of all channels and the qubits they operate on. Now, the method
control()is expected to take the parameter
qubitsof the form
(control_qubit, target_qubit)and type
tuple, and returns a list of control channels.
qiskit.circuit.QuantumCircuitare deprecated and will be removed in a future release. Instead you should use the circuit library boolean logic classes
qiskit.circuit.library.ORand then append those objects to your class. For example:
from qiskit import QuantumCircuit from qiskit.circuit.library import AND qc = QuantumCircuit(2) qc.h(0) qc.cx(0, 1) qc_and = AND(2) qc.compose(qc_and, inplace=True)
qiskit.extensions.standardmodule is deprecated and will be removed in a future release. The gate classes in that module have been moved to
mirror()methods, as well as the
QuantumCircuit.datasetter would generate an invalid circuit when used on a parameterized circuit instance. This has been resolved and these methods should now work with a parameterized circuit. Fixes #4235 (opens in a new tab)
Previously when creating a controlled version of a standard qiskit gate if a
ctrl_statewas specified a generic
ControlledGateobject would be returned whereas without it a standard qiskit controlled gate would be returned if it was defined. This PR allows standard qiskit controlled gates to understand
Additionally, this PR fixes what might be considered a bug where setting the
ctrl_stateof an already controlled gate would assume the specified state applied to the full control width instead of the control qubits being added. For instance,:
circ = QuantumCircuit(2) circ.h(0) circ.x(1) gate = circ.to_gate() cgate = gate.control(1) c3gate = cgate.control(2, ctrl_state=0)
ctrl_stateto all three control qubits instead of just the two control qubits being added.
qiskit.circuit.Instruction.is_parameterized()method had previously returned
Instructioninstance which had a
qiskit.circuit.Parameterin any element of its
paramsarray, even if that
Parameterhad been fully bound. This has been corrected so that
Falsewhen the instruction is fully bound.
qiskit.circuit.ParameterExpression.subs()had not correctly detected some cases where substituting parameters would result in a two distinct
Parametersobjects in an expression with the same name. This has been corrected so a
CircuitErrorwill be raised in these cases.
Improve performance of
qiskit.quantum_info.DensityMatrixfor low-qubit circuit simulations by optimizing the class
__init__methods. Fixes #4281 (opens in a new tab)
qiskit.compiler.transpile()now correctly handles when the parameter
basis_gatesis set to
None. This will allow any gate in the output tranpiled circuit, including gates added by the transpilation process. Note that using this parameter may have some unintended consequences during optimization. Some transpiler passes depend on having a
basis_gatesset. For example,
qiskit.transpiler.passes.Optimize1qGatesonly optimizes the chains of u1, u2, and u3 gates and without
basis_gatesit is unable to unroll gates that otherwise could be optimized:
from qiskit import * q = QuantumRegister(1, name='q') circuit = QuantumCircuit(q) circuit.h(q) circuit.u1(0.1, q) circuit.u2(0.1, 0.2, q) circuit.h(q) circuit.u3(0.1, 0.2, 0.3, q) result = transpile(circuit, basis_gates=None, optimization_level=3) result.draw()
┌───┐┌─────────────┐┌───┐┌─────────────────┐ q_0: ┤ H ├┤ U2(0.1,0.3) ├┤ H ├┤ U3(0.1,0.2,0.3) ├ └───┘└─────────────┘└───┘└─────────────────┘
The objects in
qiskit.providers.modelswhich were previously constructed using the marshmallow library have been refactored to not depend on marshmallow. This includes:
These should be drop-in replacements without any noticeable change but specifics inherited from marshmallow may not work. Please file issues for any incompatibilities found.
The Qiskit Aqua 0.7.0 release introduces a lot of new functionality along with an improved integration with
qiskit.circuit.QuantumCircuit objects. The central contributions are the Qiskit’s optimization module, a complete refactor on Operators, using circuits as native input for the algorithms and removal of the declarative JSON API.
qiskit.optimization` module now offers functionality for modeling and solving quadratic programs. It provides various near-term quantum and conventional algorithms, such as the
MinimumEigenOptimizer (covering e.g.
CplexOptimizer, as well as a set of converters to translate between different problem representations, such as
QuadraticProgramToQubo. See the changelog (opens in a new tab) for a list of the added features.
The operator logic provided in
qiskit.aqua.operators` was completely refactored and is now a full set of tools for constructing physically-intuitive quantum computations. It contains state functions, operators and measurements and internally relies on Terra’s Operator objects. Computing expectation values and evolutions was heavily simplified and objects like the
ExpectationFactory produce the suitable, most efficient expectation algorithm based on the Operator input type. See the changelog (opens in a new tab) for a overview of the added functionality.
Algorithms commonly use parameterized circuits as input, for example the VQE, VQC or QSVM. Previously, these inputs had to be of type
FeatureMap which were wrapping the circuit object. Now circuits are natively supported in these algorithms, which means any individually constructed
QuantumCircuit can be passed to these algorithms. In combination with the release of the circuit library which offers a wide collection of circuit families, it is now easy to construct elaborate circuits as algorithm input.
The ability of running algorithms using dictionaries as parameters as well as using the Aqua interfaces GUI has been removed.
- A new exception,
qiskit.providers.ibmq.IBMQBackendJobLimitError, is now raised if a job could not be submitted because the limit on active jobs has been reached.
qiskit.providers.ibmq.managed.ManagedJobSeteach has two new methods
update_tags. They are used to change the name and tags of a job or a job set, respectively.
qiskit.providers.ibmq.IBMQFactory.enable_account()now accept optional parameters
project, which allow specifying a default provider to save to disk or use, respectively.
time_per_stepnow return date time information as a
datetimeobject in local time instead of UTC. Similarly, the parameters
qiskit.providers.ibmq.IBMQBackend.jobs()can now be specified in local time.
qiskit.providers.ibmq.job.QueueInfo.format()method now uses a custom
datetimeto string formatter, and the package arrow (opens in a new tab) is no longer required and has been removed from the requirements list.
qiskit.providers.ibmq.job.IBMQJobare deprecated and will be removed in the next release.
- Fixed an issue where
nest_asyncio.apply()may raise an exception if there is no asyncio loop due to threading.
- Fixed bug with statevector and unitary simulators running a number of (parallel) shots equal to the number of CPU threads instead of only running a single shot.
- Fixes the “diagonal” qobj gate instructions being applied incorrectly in the density matrix Qasm Simulator method.
- Fixes bug where conditional gates were not being applied correctly on the density matrix simulation method.
- Fix bug in CZ gate and Z gate for “density_matrix_gpu” and “density_matrix_thrust” QasmSimulator methods.
- Fixes issue where memory requirements of simulation were not being checked on the QasmSimulator when using a non-automatic simulation method.
- Fixed a memory leak that effected the GPU simulator methods
qiskit.provider.ibmq.IBMQBackend.jobs()will now return the correct list of
IBMQJobobjects when the
statuskwarg is set to
'RUNNING'. Fixes #523 (opens in a new tab)
- The package metadata has been updated to properly reflect the dependency on
qiskit-terra>= 0.14.0. This dependency was implicitly added as part of the 0.7.0 release but was not reflected in the package requirements so it was previously possible to install
qiskit-ibmq-providerwith a version of
qiskit-terrawhich was too old. Fixes #677 (opens in a new tab)
circuit_to_instructionconverters had previously automatically included the generated gate or instruction in the active
SessionEquivalenceLibrary. These converters now accept an optional
equivalence_librarykeyword argument to specify if and where the converted instances should be registered. The default behavior is not to register the converted instance.
- Implementations of the multi-controlled X Gate (
MCXVChain) have had their
nameproperties changed to more accurately describe their implementation (
mcx_vchainrespectively.) Previously, these gates shared the name
mcx` with ``MCXGate, which caused these gates to be incorrectly transpiled and simulated.
ControlledGateinstances with a set
ctrl_statewere in some cases not being evaluated as equal, even if the compared gates were equivalent. This has been resolved.
- Fixed the SI unit conversion for
SetFrequencyinstruction should be in Hz on the frontend and has to be converted to GHz when
SetFrequencyis converted to
- Open controls were implemented by modifying a gate's definition. However, when the gate already exists in the basis, this definition is not used, which yields incorrect circuits sent to a backend. This modifies the unroller to output the definition if it encounters a controlled gate with open controls.
VQE expectation computation with Aer qasm_simulator now defaults to a computation that has the expected shot noise behavior.
- cvxpy (opens in a new tab) is now in the requirements list as a dependency for qiskit-aqua. It is used for the quadratic program solver which is used as part of the
cvxoptwas an optional dependency that needed to be installed to use this functionality. This is no longer required as cvxpy will be installed with qiskit-aqua.
- For state tomography run as part of
qiskit.aqua.algorithms.HHLwith a QASM backend the tomography fitter function
qiskit.ignis.verification.StateTomographyFitter.fit()now gets called explicitly with the method set to
lstsqto always use the least-squares fitting. Previously it would opportunistically try to use the
cvxpywere installed. But, the
cvxfitter depends on a specifically configured
cvxpyinstallation with an SDP solver installed as part of
cvxpywhich is not always present in an environment with
- The VQE expectation computation using qiskit-aer’s
qiskit.providers.aer.extensions.SnapshotExpectationValueinstruction is not enabled by default anymore. This was changed to be the default in 0.7.0 because it is significantly faster, but it led to unexpected ideal results without shot noise (see #1013 (opens in a new tab) for more details). The default has now changed back to match user expectations. Using the faster expectation computation is now opt-in by setting the new
- A new kwarg
include_customhas been added to the constructor for
qiskit.aqua.algorithms.VQEand it’s subclasses (mainly
qiskit.aqua.algorithms.QAOA). When set to true and the
expectationkwarg is set to
None(the default) this will enable the use of VQE expectation computation with Aer’s
qiskit.providers.aer.extensions.SnapshotExpectationValueinstruction. The special Aer snapshot based computation is much faster but with the ideal output similar to state vector simulator.
qiskit.ignis.verification.TomographyFitter.fit()method has improved detection logic for the default fitter. Previously, the
cvxfitter method was used whenever cvxpy (opens in a new tab) was installed. However, it was possible to install cvxpy without an SDP solver that would work for the
cvxfitter method. This logic has been reworked so that the
cvxfitter method is only used if
cvxpyis installed and an SDP solver is present that can be used. Otherwise, the
lstsqfitter is used.
- Fixes an edge case in
qiskit.ignis.mitigation.measurement.fitters.MeasurementFitter.apply()for input that has invalid or incorrect state labels that don’t match the calibration circuit. Previously, this would not error and just return an empty result. Instead now this case is correctly caught and a
QiskitErrorexception is raised when using incorrect labels.
- The cvxpy (opens in a new tab) dependency which is required for the svm classifier has been removed from the requirements list and made an optional dependency. This is because installing cvxpy is not seamless in every environment and often requires a compiler be installed to run. To use the svm classifier now you’ll need to install cvxpy by either running
pip install cvxpy<1.1.0or to install it with aqua running
pip install qiskit-aqua[cvx].
composemethod of the
QuantumCircuit.combinewhich has been changed to use
QuantumCircuit.compose. Using combine leads to the problem that composing an operator with a
CircuitOpbased on a named register does not chain the operators but stacks them. E.g. composing
Z ^ 2with a circuit based on a 2-qubit named register yielded a 4-qubit operator instead of a 2-qubit operator.
MatrixOp.to_instructionmethod previously returned an operator and not an instruction. This method has been updated to return an Instruction. Note that this only works if the operator primitive is unitary, otherwise an error is raised upon the construction of the instruction.
__hash__method of the
PauliOpclass used the
id()method which prevents set comparisons to work as expected since they rely on hash tables and identical objects used to not have identical hashes. Now, the implementation uses a hash of the string representation inline with the implementation in the
- A new requirement scikit-learn (opens in a new tab) has been added to the requirements list. This dependency was added in the 0.3.0 release but wasn’t properly exposed as a dependency in that release. This would lead to an
qiskit.ignis.measurement.discriminator.iq_discriminatorsmodule was imported. This is now correctly listed as a dependency so that
scikit-learnwill be installed with qiskit-ignis.
- Fixes an issue in qiskit-ignis 0.3.2 which would raise an
qiskit.ignis.verification.tomography.fitters.process_fitterwas imported without