# Release Notes¶

## Version History¶

This table tracks the meta-package versions and the version of each Qiskit element installed:

Table 1 Version History

Qiskit Metapackage Version

qiskit-terra

qiskit-aer

qiskit-ignis

qiskit-ibmq-provider

qiskit-aqua

Release Date

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

참고

For the 0.7.0, 0.7.1, and 0.7.2 meta-package releases the versioning_strategy policy was not formalized yet.

## Notable Changes¶

### 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 the QuantumInstance constructor can now be set to the TensoredMeasFitter class from qiskit-ignis in addition to CompleteMeasFitter that was already supported. If you use TensoredMeasFitter you will also be able to set the new mit_pattern kwarg to specify the qubits on which to use TensoredMeasFitter You can refer to the documentation for mit_pattern in the TensoredMeasFitter documentation for the expected format.

• The decomposition methods for single-qubit gates, specified via the basis kwarg, in OneQubitEulerDecomposer 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 and ValidatePulseGates to the qiskit.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), the AlignMeasures pass is used to adjust delays in a scheduled circuit to ensure that any Measure instructions in the circuit are aligned given the constraints of the backend. The ValidatePulseGates pass is used to check if any custom pulse gates (gates that have a custom pulse definition in the calibrations attribute of a QuantumCircuit object) are valid given an alignment constraint for the target backend.

In the built-in preset_passmangers used by the transpile() function, these passes get automatically triggered if the alignment constraint, either via the dedicated timing_constraints kwarg on transpile() or has an timing_constraints attribute in the BackendConfiguration 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 the Schedule and ScheduleBlock 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 the job_monitor() function. This kwarg enables changing the carriage return characters used in the job_monitor output. The line_discipline kwarg defaults to '\r', which is what was in use before.

• The abstract Pulse class (which is the parent class for classes such as Waveform, Constant, and Gaussian now has a new kwarg on the constructor, limit_amplitude, which can be set to False to disable the previously hard coded amplitude limit of 1. 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 the qiskit.quantum_info module. This class is used to efficiently represent a list of Pauli operators. This new class inherets from the same parent class as the existing PauliTable (and therefore can be mostly used interchangeably), however it differs from the PauliTable because the qiskit.quantum_info.PauliList class can handle Z4 phases.

• Added a new transpiler pass, RemoveBarriers, to qiskit.transpiler.passes. This pass is used to remove all barriers in a circuit.

• Add a new optimizer class, SciPyOptimizer, to the qiskit.algorithms.optimizers module. This class is a simple wrapper class of the scipy.optimize.minimize function (documentation) which enables the use of all optimization solvers and all parameters (e.g. callback) which are supported by scipy.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 a ControlledGate 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() and is_predecessor(), to the DAGCircuit class. These functions are used to check if a node is either a successor or predecessor of another node on the DAGCircuit.

• A new transpiler pass, RZXCalibrationBuilderNoEcho, was added to the qiskit.transpiler.passes module. This pass is similar to the existing RZXCalibrationBuilder in that it creates calibrations for an RZXGate(theta), however RZXCalibrationBuilderNoEcho 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. The RZXCalibrationBuilderNoEcho pass only supports the hardware-native direction of the CXGate.

• A new kwarg, wrap, has been added to the compose() method of QuantumCircuit. This enables choosing whether composed circuits should be wrapped into an instruction or not. By default this is False, 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-91 │
q_1: ┤ H ├┤1            ├
└───┘└─────────────┘
┌───┐┌───┐
q_0: ┤ H ├┤ X ├
├───┤├───┤
q_1: ┤ H ├┤ X ├
└───┘└───┘

• A new attribute, control_channels, has been added to the PulseBackendConfiguration class. This attribute represents the control channels on a backend as a mapping of qubits to a list of ControlChannel objects.

• A new kwarg, epsilon, has been added to the constructor for the Isometry class and the corresponding QuantumCircuit method isometry(). This kwarg enables optionally setting the epsilon tolerance used by an Isometry 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, to qiskit.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 method qasm() 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 the qiskit.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 include UCCSD class in the chemistry module of Qiskit Nature or the QAOAAnsatz class.

• A new fake backend class is available under qiskit.test.mock for the ibmq_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 the Schedule class has been added. This method is used to return the child schedule components of the Schedule 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 the qiskit.algorithms.optimizers module. This optimizer class implements a standard gradient descent optimization algorithm for use with quantum variational algorithms, such as VQE. For a detailed description and examples on how to use this class, please refer to the GradientDescent class documentation.

• A new optimizer class, QNSPSA, has been added to the qiskit.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 the QNSPSA class documentation.

• A new kwarg, second_order, has been added to the constructor of the SPSA class in the qiskit.algorithms.optimizers module. When set to True 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 the SPSA class documentation.

• When using the latex or latex_source output mode of circuit_drawer() or the draw() of QuantumCircuit the style kwarg can now be used just as with the mpl output formatting. However, unlike the mpl output mode only the displaytext field will be used when using the latex or latex_source output modes (because neither supports color).

• When using the mpl or latex output methods for the circuit_drawer() function or the draw() of QuantumCircuit, you can now use math mode formatting for text and set color formatting (mpl only) by setting the style 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 and DraperQFTAdder, to the qiskit.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.quantum_info import Statevector

# a encodes |01> = 1
a = QuantumCircuit(2)
a.x(0)

# b encodes |10> = 2
b = QuantumCircuit(2)
b.x(1)

# add the state preparations to the front of the circuit

# simulate and get the state of all qubits
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 and HRSCumulativeMultiplier, to the qiskit.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 a ParameterExpression or Parameter value for the duration kwarg on its constructor and for its duration 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(
)
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:


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 for TwoQubitBasisDecomposer 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 in qiskit.transpiler.passes has been updated to support performing pulse optimal decomposition. This is done primarily with the the pulse_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 the pulse_optimize kwarg in the TwoQubitBasisDecomposer 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. If None and pulse_optimize is False or None, use "unitary". If None and pulse_optimize is True, 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 then CXGate 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 the basis argument OneQubitEulerDecomposer class.

• Added a new method, get_instructions(), was added to the QuantumCircuit class. This method is used to return all Instruction objects in the circuit which have a name that matches the provided name argument along with its associated qargs and cargs lists of Qubit and Clbit 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 and QuasiDistribution 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 the Optimizer abstract base class that all the optimizer classes in the qiskit.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

settings = optimizer.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 the qiskit.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 the default section in the settings.conf file.

If no file_path argument is specified, the currently used path to the user config file (either the value of the QISKIT_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 the qiskit.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 the sort kwarg of the qiskit.visualization.plot_histogram() function. When sort 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¶
• 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 to False, 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 the QISKIT_PARALLEL environment variable to TRUE.

• The existing fake backend classes in qiskit.test.mock now strictly implement the BackendV1 interface. This means that if you were manually constructing QasmQobj or PulseQobj object for use with the run() method this will no longer work. The run() method only accepts QuantumCircuit or Schedule 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 with QasmQobj or PulseQobj 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 the BackendV1 interface and will not add new legacy backend classes for new fake backends.

• When creating a Pauli object with an invalid string label, a QiskitError is now raised. This is a change from previous releases which would raise an AttributeError on an invalid string label. This change was made to ensure the error message is more informative and distinct from a generic AttributeError.

• The output program representation from the pulse builder (qiskit.pulse.builder.build()) has changed from a Schedule to a ScheduleBlock. 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 from qiskit.algorithms.

• The optional extra full-featured-simulators which could previously used to install qiskit-aer with something like pip install qiskit-terra[full-featured-simulators] has been removed from the qiskit-terra package. If this was being used to install qiskit-aer with qiskit-terra instead you should rely on the qiskit metapackage or just install qiskit-terra and qiskit-aer together with pip 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 and ParameterExpression objects.

• All library circuit classes, i.e. all QuantumCircuit derived classes in qiskit.circuit.library, are now wrapped in a Instruction (or Gate, if they are unitary). For example, importing and drawing the QFT 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 circuit

This change was primarily made for consistency as before this release some circuit classes in qiskit.circuit.library were previously wrapped in an Instruction or Gate but not all.

##### Other Notes¶
• The deprecation of the parameters() method for the Instruction 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.

No change

No change

No change

#### IBM Q Provider 0.15.0¶

##### Deprecation Notes¶
• The id instruction has been deprecated on IBM hardware backends. Instead, please use the delay instruction which implements variable-length delays, specified in units of dt. When running a circuit containing an id instruction, a warning will be raised on job submission and any id instructions in the job will be automatically replaced with their equivalent delay instruction.

### Qiskit 0.27.0¶

No change

No change

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 are job, which means circuit jobs, and runtime, which means Qiskit Runtime.

You can also use input_allowed in backend filtering. For example:

from qiskit import IBMQ

# Get a list of all backends that support runtime.
runtime_backends = provider.backends(input_allowed='runtime')

• qiskit-ibmq-provider now uses a new package websocket-client as its websocket client, and packages websockets and nest-asyncio are no longer required. setup.py and requirements.txt have been updated accordingly.

##### Bug Fixes¶
• Fixes the issue that uses shots=1 instead of the documented default when no shots is specified for run_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)


No change

No change

No change

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 a ValueError would be raised when the function run on distributions with unequal lengths.

No change

No change

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 additional verified attribute which identifies if the quality has been verified by a human.

• qiskit.providers.ibmq.experiment.Experiment now has an additional notes 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

# 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()

• The deprecated Human Bad, Computer Bad, Computer Good and Human Good enum values have been removed from qiskit.providers.ibmq.experiment.constants.ResultQuality. They are replaced with Bad and Good values which should be used with the verified attribute on qiskit.providers.ibmq.experiment.analysis_result.AnalysisResult:

Old Quality

New Quality

Verified

True

False

Computer Good

Good

False

Human Good

Good

True

Furthermore, the NO_INFORMATION enum has been renamed to UNKNOWN.

• 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.

No change

No change

No change

No change

### Qiskit 0.25.3¶

No change

#### Aer 0.8.2¶

##### 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 the QasmSimulator and AerSimulator where the expectation value for the save_expectation_value and snapshot_expectation_value could have the wrong sign for certain Y Pauli’s.

No change

No change

No change

### Qiskit 0.25.2¶

No change

No change

No change

No change

#### IBM Q Provider 0.12.3¶

##### Other Notes¶
• The qiskit.providers.ibmq.experiment.analysis_result.AnalysisResult fit attribute is now optional.

### 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.

No change

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 Qiskit 아쿠아 마이그레이션 가이드.

#### 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 a Parameter object along with a parameterized subroutine. This enables assigning different values to the Parameter 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 field processor_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, and qiskit.pulse.Channel classes now have a parameter property which will return any Parameter objects used in the object and a is_parameterized() method which will return True 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 the qiskit.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, breakpoints, num_state_qubits = lambda x: np.arcsin(1 / x), 2, [2, 4], 2
pw_approximation = PiecewiseChebyshev(f_x, degree, breakpoints, num_state_qubits)
pw_approximation._build()
qc = QuantumCircuit(pw_approximation.num_qubits)
qc.h(list(range(num_state_qubits)))
qc.append(pw_approximation.to_instruction(), qc.qubits)
qc.draw(output='mpl')

• The BackendProperties class now has a readout_length() method, which returns the readout length [sec] of the given qubit.

• A new class, ScheduleBlock, has been added to the qiskit.pulse module. This class provides a new representation of a pulse program. This representation is best suited for the pulse builder syntax and is based on relative instruction ordering.

This representation takes alignment_context instead of specifying starting time t0 for each instruction. The start time of instruction is implicitly allocated with the specified transformation and relative position of instructions.

The ScheduleBlock allows for lazy instruction scheduling, meaning we can assign arbitrary parameters to the duration of instructions.

For example:

from qiskit.pulse import ScheduleBlock, DriveChannel, Gaussian
from qiskit.pulse.instructions import Play, Call
from qiskit.pulse.transforms import AlignRight
from qiskit.circuit import Parameter

dur = Parameter('rabi_duration')

block = ScheduleBlock(alignment_context=AlignRight())
block += Play(Gaussian(dur, 0.1, dur/4), DriveChannel(0))
block += Call(measure_sched)  # subroutine defined elsewhere


this code defines an experiment scanning a Gaussian pulse’s duration followed by a measurement measure_sched, i.e. a Rabi experiment. You can reuse the block object for every scanned duration by assigning a target duration value.

• Added a new function array_to_latex() to the qiskit.visualization module that can be used to represent and visualize vectors and matrices with LaTeX.

from qiskit.visualization import array_to_latex
from numpy import sqrt, exp, pi
mat = [[0, exp(pi*.75j)],
[1/sqrt(8), 0.875]]
array_to_latex(mat)

$\begin{split}\begin{bmatrix} 0 & \tfrac{1}{\sqrt{2}}(-1 + i) \\ \tfrac{1}{\sqrt{8}} & \tfrac{7}{8} \\ \end{bmatrix} \end{split}$
• The Statevector and DensityMatrix classes now have draw() methods which allow objects to be drawn as either text matrices, IPython Latex objects, Latex source, Q-spheres, Bloch spheres and Hinton plots. By default the output type is the equivalent output from __repr__ but this default can be changed in a user config file by setting the state_drawer option. For example:

from qiskit.quantum_info import DensityMatrix
dm = DensityMatrix.from_label('r0')
dm.draw('latex')

$\begin{split}\begin{bmatrix} \tfrac{1}{2} & 0 & -\tfrac{1}{2}i & 0 \\ 0 & 0 & 0 & 0 \\ \tfrac{1}{2}i & 0 & \tfrac{1}{2} & 0 \\ 0 & 0 & 0 & 0 \\ \end{bmatrix} \end{split}$
from qiskit.quantum_info import Statevector
sv = Statevector.from_label('+r')
sv.draw('qsphere')


Additionally, the draw() method is now used for the ipython display of these classes, so if you change the default output type in a user config file then when a Statevector or a DensityMatrix object are displayed in a jupyter notebook that output type will be used for the object.

• Pulse qiskit.pulse.Instruction objects and parametric pulse objects (eg Gaussian now support using Parameter and ParameterExpression objects for the duration parameter. For example:

from qiskit.circuit import Parameter
from qiskit.pulse import Gaussian

dur = Parameter('x_pulse_duration')
double_dur = dur * 2
rx_pulse = Gaussian(dur, 0.1, dur/4)
double_rx_pulse = Gaussian(double_dir, 0.1, dur/4)


Note that while we can create an instruction with a parameterized duration adding an instruction with unbound parameter duration to a schedule is supported only by the newly introduced representation ScheduleBlock. See the known issues release notes section for more details.

• The run() method for the QasmSimulatorPy, StatevectorSimulatorPy, and UnitarySimulatorPy backends now takes a QuantumCircuit (or a list of QuantumCircuit objects) as its input. The previous QasmQobj object is still supported for now, but will be deprecated in a future release.

For an example of how to use this see:

from qiskit import transpile, QuantumCircuit

from qiskit.providers.basicaer import BasicAer

backend = BasicAer.get_backend('qasm_simulator')

circuit = QuantumCircuit(2)
circuit.h(0)
circuit.cx(0, 1)
circuit.measure_all()

tqc = transpile(circuit, backend)
result = backend.run(tqc, shots=4096).result()

• The CommutativeCancellation transpiler pass has a new optional kwarg on the constructor basis_gates, which takes the a list of the names of basis gates for the target backend. When specified the pass will only use gates in the basis_gates kwarg. Previously, the pass would automatically replace consecutive gates which commute with ZGate with the U1Gate unconditionally. The basis_gates kwarg enables you to specify which z-rotation gates are present in the target basis to avoid this.

• The constructors of the Bit class and subclasses, Qubit, Clbit, and AncillaQubit, have been updated such that their two parameters, register and index are now optional. This enables the creation of bit objects that are independent of a register.

• A new class, BooleanExpression, has been added to the qiskit.circuit.classicalfunction module. This class allows for creating an oracle from a Python boolean expression. For example:

from qiskit.circuit import BooleanExpression, QuantumCircuit

expression = BooleanExpression('~x & (y | z)')
circuit = QuantumCircuit(4)
circuit.append(expression, [0, 1, 2, 3])
circuit.draw('mpl')

circuit.decompose().draw('mpl')


The BooleanExpression also includes a method, from_dimacs_file(), which allows loading formulas described in the DIMACS-CNF format. For example:

from qiskit.circuit import BooleanExpression, QuantumCircuit

boolean_exp = BooleanExpression.from_dimacs_file("simple_v3_c2.cnf")
circuit = QuantumCircuit(boolean_exp.num_qubits)
circuit.append(boolean_exp, range(boolean_exp.num_qubits))
circuit.draw('text')

     ┌───────────────────┐
q_0: ┤0                  ├
│                   │
q_1: ┤1                  ├
│  SIMPLE_V3_C2.CNF │
q_2: ┤2                  ├
│                   │
q_3: ┤3                  ├
└───────────────────┘

circuit.decompose().draw('text')

q_0: ──o────o────────────
│    │
q_1: ──■────o────■───────
│    │    │
q_2: ──■────┼────o────■──
┌─┴─┐┌─┴─┐┌─┴─┐┌─┴─┐
q_3: ┤ X ├┤ X ├┤ X ├┤ X ├
└───┘└───┘└───┘└───┘

• Added a new class, PhaseOracle, has been added to the qiskit.circuit.library module. This class enables the construction of phase oracle circuits from Python boolean expressions.

from qiskit.circuit.library.phase_oracle import PhaseOracle

oracle = PhaseOracle('x1 & x2 & (not x3)')
oracle.draw('mpl')


These phase oracles can be used as part of a larger algorithm, for example with qiskit.algorithms.AmplificationProblem:

from qiskit.algorithms import AmplificationProblem, Grover
from qiskit import BasicAer

backend = BasicAer.get_backend('qasm_simulator')

problem = AmplificationProblem(oracle, is_good_state=oracle.evaluate_bitstring)
grover = Grover(quantum_instance=backend)
result = grover.amplify(problem)
result.top_measurement

'011'


The PhaseOracle class also includes a from_dimacs_file() method which enables constructing a phase oracle from a file describing a formula in the DIMACS-CNF format.

from qiskit.circuit.library.phase_oracle import PhaseOracle

oracle = PhaseOracle.from_dimacs_file("simple_v3_c2.cnf")
oracle.draw('text')

state_0: ─o───────o──────────────
│ ┌───┐ │ ┌───┐
state_1: ─■─┤ X ├─■─┤ X ├─■──────
│ └───┘   └───┘ │ ┌───┐
state_2: ─■───────────────o─┤ Z ├
└───┘

• All transpiler passes (ie any instances of BasePass) are now directly callable. Calling a pass provides a convenient interface for running the pass on a QuantumCircuit object.

For example, running a single transformation pass, such as BasisTranslator, can be done with:

from qiskit import QuantumCircuit
from qiskit.transpiler.passes import BasisTranslator
from qiskit.circuit.equivalence_library import SessionEquivalenceLibrary as sel

circuit = QuantumCircuit(1)
circuit.h(0)

pass_instance = BasisTranslator(sel, ['rx', 'rz', 'cx'])
result = pass_instance(circuit)
result.draw(output='mpl')


When running an analysis pass, a property set (as dict or as PropertySet) needs to be added as a parameter and it might be modified “in-place”. For example:

from qiskit import QuantumCircuit
from qiskit.transpiler.passes import Depth

circuit = QuantumCircuit(1)
circuit.h(0)

property_set = {}
pass_instance = Depth()
pass_instance(circuit, property_set)
print(property_set)

{'depth': 1}

• The QasmQobjConfig class now has an optional kwarg for meas_level and meas_return. These fields can be used to enable generating QasmQobj job payloads that support meas_level=1 (kerneled data) for circuit jobs (previously this was only exposed for PulseQobj objects). The assemble() function has been updated to set this field for QasmQobj objects it generates.

• A new tensor() method has been added to the QuantumCircuit class. This method enables tensoring another circuit with an existing circuit. This method works analogously to qiskit.quantum_info.Operator.tensor() and is consistent with the little-endian convention of Qiskit.

For example:

from qiskit import QuantumCircuit
top = QuantumCircuit(1)
top.x(0);
bottom = QuantumCircuit(2)
bottom.cry(0.2, 0, 1);
bottom.tensor(top).draw(output='mpl')

• The qiskit.circuit.QuantumCircuit class now supports arbitrary free form metadata with the metadata attribute. A user (or program built on top of QuantumCircuit) can attach metadata to a circuit for use in tracking the circuit. For example:

from qiskit.circuit import QuantumCircuit



or:

from qiskit.circuit import QuantumCircuit

qc = QuantumCircuit(2)


This metadata will not be used for influencing the execution of the circuit but is just used for tracking the circuit for the lifetime of the object. The metadata attribute will persist between any circuit transforms including transpile() and assemble(). The expectation is for providers to associate the metadata in the result it returns, so that users can filter results based on circuit metadata the same way they can currently do with QuantumCircuit.name.

• Add a new operator class CNOTDihedral has been added to the qiskit.quantum_info module. This class is used to represent the CNOT-Dihedral group, which is generated by the quantum gates CXGate, TGate, and XGate.

• Adds a & (__and__) binary operator to BaseOperator subclasses (eg qiskit.quantum_info.Operator) in the qiskit.quantum_info module. This is shorthand to call the classes compose() method (ie A & B == A.compose(B)).

For example:

import qiskit.quantum_info as qi

qi.Pauli('X') & qi.Pauli('Y')

• Adds a & (__and__) binary operator to qiskit.quantum_info.Statevector and qiskit.quantum_info.DensityMatrix classes. This is shorthand to call the classes evolve() method (ie psi & U == psi.evolve(U)).

For example:

import qiskit.quantum_info as qi

qi.Statevector.from_label('0') & qi.Pauli('X')

• A new a new 2-qubit gate, ECRGate, the echo cross-resonance (ECR), has been added to the qiskit.circuit.library module along with a corresponding method, ecr() for the QuantumCircuit class. The ECR gate is two $$CR(\frac{π}{4})$$ pulses with an XGate between them for the echo. This gate is locally equivalent to a CXGate (can convert to a CNOT with local pre- or post-rotation). It is the native gate on current IBM hardware and compiling to it allows the pre-/post-rotations to be merged into the rest of the circuit.

• A new kwarg approximation_degree has been added to the transpile() function for enabling approximate compilation. Valid values range from 0 to 1, and higher means less approximation. This is a heuristic dial to experiment with circuit approximations. The concrete interpretation of this number is left to each pass, which may use it to perform some approximate version of the pass. Specific examples include the UnitarySynthesis pass or the or translators to discrete gate sets. If a pass does not support this option, it implies exact transformation.

• Two new transpiler passess, GateDirection and qiskit.transpiler.passes.CheckGateDirection, were added to the qiskit.transpiler.passes module. These new passes are inteded to be more general replacements for CXDirection and CheckCXDirection (which are both now deprecated, see the deprecation notes for more details) that perform the same function but work with other gates beside just CXGate.

• When running on Windows, parallel execution with the parallel_map() function can now be enabled (it is still disabled by default). To do this you can either set parallel = True in a user config file, or set the QISKIT_PARALLEL environment variable to TRUE (this will also effect transpile() and assemble() which both use parallel_map() internally). It is important to note that when enabling parallelism on Windows there are limitations around how Python launches processes for Windows, see the Known Issues section below for more details on the limitations with parallel execution on Windows.

• A new function, hellinger_distance(), for computing the Hellinger distance between two counts distributions has been added to the qiskit.quantum_info module.

• The decompose_clifford() function in the qiskit.quantum_info module (which gets used internally by the qiskit.quantum_info.Clifford.to_circuit() method) has a new kwarg method which enables selecting the synthesis method used by either setting it to 'AG' or 'greedy'. By default for more than three qubits it is set to 'greedy' which uses a non-optimal greedy compilation routine for Clifford elements synthesis, by Bravyi et. al., which typically yields better CX cost compared to the previously used Aaronson-Gottesman method (for more than two qubits). You can use the method kwarg to revert to the previous default Aaronson-Gottesman method by setting method='AG'.

• The Initialize class in the qiskit.extensions module can now be constructed using an integer. The ‘1’ bits of the integer will insert a Reset and an XGate into the circuit for the corresponding qubit. This will be done using the standard little-endian convention is qiskit, ie the rightmost bit of the integer will set qubit 0. For example, setting the parameter in Initialize equal to 5 will set qubits 0 and 2 to value 1.

from qiskit.extensions import Initialize

initialize = Initialize(13)
initialize.definition.draw('mpl')

• The Initialize class in the qiskit.extensions module now supports constructing directly from a Pauli label (analogous to the qiskit.quantum_info.Statevector.from_label() method). The Pauli label refer to basis states of the Pauli eigenstates Z, X, Y. These labels use Qiskit’s standard little-endian notation, for example a label of '01' would initialize qubit 0 to $$|1\rangle$$ and qubit 1 to $$|0\rangle$$.

from qiskit.extensions import Initialize

initialize = Initialize("10+-lr")
initialize.definition.draw('mpl')

• The kwarg, template_list, for the constructor of the qiskit.transpiler.passes.TemplateOptimization transpiler pass now supports taking in a list of both QuantumCircuit and DAGDependency objects. Previously, only QuantumCircuit were accepted (which were internally converted to DAGDependency objects) in the input list.

• A new transpiler pass, qiskit.transpiler.passes.RZXCalibrationBuilder, capable of generating calibrations and adding them to a quantum circuit has been introduced. This pass takes calibrated CXGate objects and creates the calibrations for qiskit.circuit.library.RZXGate objects with an arbitrary rotation angle. The schedules are created by stretching and compressing the GaussianSquare pulses of the echoed-cross resonance gates.

• New template circuits for using qiskit.circuit.library.RZXGate are added to the qiskit.circuit.library module (eg rzx_yz). This enables pairing the TemplateOptimization pass with the qiskit.transpiler.passes.RZXCalibrationBuilder pass to automatically find and replace gate sequences, such as CNOT - P(theta) - CNOT, with more efficent circuits based on qiskit.circuit.library.RZXGate with a calibration.

• The matplotlib output type for the circuit_drawer() and the draw() method for the QuantumCircuit class now supports configuration files for setting the visualization style. In previous releases, there was basic functionality that allowed users to pass in a style kwarg that took in a dict to customize the colors and other display features of the mpl drawer. This has now been expanded so that these dictionaries can be loaded from JSON files directly without needing to pass a dictionary. This enables users to create new style files and use that style for visualizations by passing the style filename as a string to the style kwarg.

To leverage this feature you must set the circuit_mpl_style_path option in a user config file. This option should be set to the path you want qiskit to search for style JSON files. If specifying multiple path entries they should be separated by :. For example, setting circuit_mpl_style_path = ~/.qiskit:~/user_styles in a user config file will look for JSON files in both ~/.qiskit and ~/user_styles.

• A new kwarg, format_marginal has been added to the function marginal_counts() which when set to True formats the counts output according to the cregs in the circuit and missing indices are represented with a _. For example:

from qiskit import QuantumCircuit, execute, BasicAer, result
from qiskit.result.utils import marginal_counts
qc = QuantumCircuit(5, 5)
qc.x(0)
qc.measure(0, 0)

result = execute(qc, BasicAer.get_backend('qasm_simulator')).result()
print(marginal_counts(result.get_counts(), [0, 2, 4], format_marginal=True))

{'0_0_1': 1024}

• Improved the performance of qiskit.quantum_info.Statevector.expectation_value() and qiskit.quantum_info.DensityMatrix.expectation_value() when the argument operator is a Pauli or SparsePauliOp operator.

• The user config file has 2 new configuration options, num_processes and parallel, which are used to control the default behavior of parallel_map(). The parallel option is a boolean that is used to dictate whether parallel_map() will run in multiple processes or not. If it set to False calls to parallel_map() will be executed serially, while setting it to True will enable parallel execution. The num_processes option takes an integer which sets how many CPUs to use when executing in parallel. By default it will use the number of CPU cores on a system.

• There are 2 new environment variables, QISKIT_PARALLEL and QISKIT_NUM_PROCS, that can be used to control the default behavior of parallel_map(). The QISKIT_PARALLEL option can be set to the TRUE (any capitalization) to set the default to run in multiple processes when parallel_map() is called. If it is set to any other value parallel_map() will be executed serially. QISKIT_NUM_PROCS takes an integer (for example QISKIT_NUM_PROCS=5) which will be used as the default number of processes to run with. Both of these will take precedence over the equivalent option set in the user config file.

• A new method, gradient(), has been added to the ParameterExpression class. This method is used to evaluate the gradient of a ParameterExpression object.

• The __eq__ method (ie what is called when the == operator is used) for the ParameterExpression now allows for the comparison with a numeric value. Previously, it was only possible to compare two instances of ParameterExpression with ==. For example:

from qiskit.circuit import Parameter

x = Parameter("x")
y = x + 2
y = y.assign(x, -1)

assert y == 1

• The PauliFeatureMap class in the qiskit.circuit.library module now supports adjusting the rotational factor, $$\alpha$$, by either setting using the kwarg alpha on the constructor or setting the alpha attribute after creation. Previously this value was fixed at 2.0. Adjusting this attribute allows for better control of decision boundaries and provides additional flexibility handling the input features without needing to explicitly scale them in the data set.

• A new Gate class, PauliGate, has been added the qiskit.circuit.library module and corresponding method, pauli(), was added to the QuantumCircuit class. This new gate class enables applying several individual pauli gates to different qubits at the simultaneously. This is primarily useful for simulators which can use this new gate to more efficiently implement multiple simultaneous Pauli gates.

• Improve the qiskit.quantum_info.Pauli operator. This class now represents and element from the full N-qubit Pauli group including complex coefficients. It now supports the Operator API methods including compose(), dot(), tensor() etc, where compose and dot are defined with respect to the full Pauli group.

This class also allows conversion to and from the string representation of Pauli’s for convenience.

For example

from qiskit.quantum_info import Pauli

P1 = Pauli('XYZ')
P2 = Pauli('YZX')
P1.dot(P2)

Pauli('-iZXY')


Pauli’s can also be directly appended to QuantumCircuit objects

from qiskit import QuantumCircuit
from qiskit.quantum_info import Pauli

circ = QuantumCircuit(3)
circ.append(Pauli('XYZ'), [0, 1, 2])
circ.draw(output='mpl')


Additional methods allow computing when two Pauli’s commute (using the commutes() method) or anticommute (using the anticommutes() method), and computing the Pauli resulting from Clifford conjugation $$P^\prime = C.P.C^\dagger$$ using the evolve() method.

See the API documentation of the Pauli class for additional information.

• A new function, random_pauli(), for generating a random element of the N-qubit Pauli group has been added to the qiskit.quantum_info module.

• A new class, PiecewisePolynomialPauliRotations, has been added to the qiskit.circuit.library module. This circuit library element is used for mapping a piecewise polynomial function, $$f(x)$$, which is defined through breakpoints and coefficients, on qubit amplitudes. The breakpoints $$(x_0, ..., x_J)$$ are a subset of $$[0, 2^n-1]$$, where $$n$$ is the number of state qubits. The corresponding coefficients $$[a_{j,1},...,a_{j,d}]$$, where $$d$$ is the highest degree among all polynomials. Then $$f(x)$$ is defined as:

$\begin{split}f(x) = \begin{cases} 0, x < x_0 \\ \sum_{i=0}^{i=d}a_{j,i} x^i, x_j \leq x < x_{j+1} \end{cases}\end{split}$

where we implicitly assume $$x_{J+1} = 2^n$$. And the mapping applied to the amplitudes is given by

$F|x\rangle |0\rangle = \cos(p_j(x))|x\rangle |0\rangle + \sin(p_j(x))|x\rangle |1\rangle$

This mapping is based on controlled Pauli Y-rotations and constructed using the PolynomialPauliRotations.

• A new module qiskit.algorithms has been introduced. This module contains functionality equivalent to what has previously been provided by the qiskit.aqua.algorithms module (which is now deprecated) and provides the building blocks for constructing quantum algorithms. For details on migrating from qiskit-aqua to this new module please refer to the migration guide Qiskit 아쿠아 마이그레이션 가이드

• A new module qiskit.opflow has been introduced. This module contains functionality equivalent to what has previously been provided by the qiskit.aqua.operators module (which is now deprecated) and provides the operators and state functions which are used to build quantum algorithms. For details on migrating from qiskit-aqua to this new module please refer to the migration guide Qiskit 아쿠아 마이그레이션 가이드

• This is the first release that includes precompiled binary wheels for the for Linux aarch64 systems. If you are running a manylinux2014 compatible aarch64 Linux system there are now precompiled wheels available on PyPI, you are no longer required to build from source to install qiskit-terra.

• The qiskit.quantum_info.process_fidelity() function is now able to be used with a non-unitary target channel. In this case the returned value is equivalent to the qiskit.quantum_info.state_fidelity() of the normalized qiskit.quantum_info.Choi matrices for the channels.

Note that the qiskit.quantum_info.average_gate_fidelity() and qiskit.quantum_info.gate_error() functions still require the target channel to be unitary and will raise an exception if it is not.

• Added a new pulse builder function, qiskit.pulse.macro(). This enables normal Python functions to be decorated as macros. This enables pulse builder functions to be used within the decorated function. The builder macro can then be called from within a pulse building context, enabling code reuse.

For Example:

from qiskit import pulse

@pulse.macro
def measure(qubit: int):
pulse.play(pulse.GaussianSquare(16384, 256, 15872),
pulse.MeasureChannel(qubit))
mem_slot = pulse.MemorySlot(0)
pulse.acquire(16384, pulse.AcquireChannel(0), mem_slot)
return mem_slot

with pulse.build(backend=backend) as sched:
mem_slot = measure(0)
print(f"Qubit measured into {mem_slot}")

sched.draw()

• A new class, PauliTwoDesign, was added to the qiskit.circuit.library which implements a particular form of a 2-design circuit from https://arxiv.org/pdf/1803.11173.pdf For instance, this circuit can look like:

from qiskit.circuit.library import PauliTwoDesign
circuit = PauliTwoDesign(4, reps=2, seed=5, insert_barriers=True)
circuit.decompose().draw(output='mpl')

• A new pulse drawer qiskit.visualization.pulse_v2.draw() (which is aliased as qiskit.visualization.pulse_drawer_v2) is now available. This new pulse drawer supports multiple new features not present in the original pulse drawer (pulse_drawer()).

• Truncation of long pulse instructions.

• Visualization of parametric pulses.

• New stylesheets IQXStandard, IQXSimple, IQXDebugging.

• Visualization of system info (channel frequency, etc…) by specifying qiskit.providers.Backend objects for visualization.

• Specifying axis objects for plotting to allow further extension of generated plots, i.e., for publication manipulations.

New stylesheets can take callback functions that dynamically modify the apperance of the output image, for example, reassembling a collection of channels, showing details of instructions, updating appearance of pulse envelopes, etc… You can create custom callback functions and feed them into a stylesheet instance to modify the figure appearance without modifying the drawer code. See pulse drawer module docstrings for details.

Note that file saving is now delegated to Matplotlib. To save image files, you need to call savefig method with returned Figure object.

• Adds a reverse_qargs() method to the qiskit.quantum_info.Statevector and qiskit.quantum_info.DensityMatrix classes. This method reverses the order of subsystems in the states and is equivalent to the qiskit.circuit.QuantumCircuit.reverse_bits() method for N-qubit states. For example:

from qiskit.circuit.library import QFT
from qiskit.quantum_info import Statevector

circ = QFT(3)

state1 = Statevector.from_instruction(circ)
state2 = Statevector.from_instruction(circ.reverse_bits())

state1.reverse_qargs() == state2

True

• Adds a reverse_qargs() method to the qiskit.quantum_info.Operator class. This method reverses the order of subsystems in the operator and is equivalent to the qiskit.circuit.QuantumCircuit.reverse_bits() method for N-qubit operators. For example:

from qiskit.circuit.library import QFT
from qiskit.quantum_info import Operator

circ = QFT(3)

op1 = Operator(circ)
op2 = Operator(circ.reverse_bits())

op1.reverse_qargs() == op2

True

• The latex output method for the qiskit.visualization.circuit_drawer() function and the draw() method now will use a user defined label on gates in the output visualization. For example:

import math

from qiskit.circuit import QuantumCircuit

qc = QuantumCircuit(2)
qc.h(0)
qc.rx(math.pi/2, 0, label='My Special Rotation')

qc.draw(output='latex')

• The routing_method kwarg for the transpile() function now accepts a new option, 'none'. When routing_method='none' no routing pass will be run as part of the transpilation. If the circuit does not fit coupling map a TranspilerError exception will be raised.

• A new gate class, RVGate, was added to the qiskit.circuit.library module along with the corresponding QuantumCircuit method rv(). The RVGate is a general rotation gate, similar to the UGate, but instead of specifying Euler angles the three components of a rotation vector are specified where the direction of the vector specifies the rotation axis and the magnitude specifies the rotation angle about the axis in radians. For example:

import math

import np

from qiskit.circuit import QuantumCircuit

qc = QuantumCircuit(1)
theta = math.pi / 5
phi = math.pi / 3
# RGate axis:
axis = np.array([math.cos(phi), math.sin(phi)])
rotation_vector = theta * axis
qc.rv(*rotation_vector, 0)

• Unbound Parameter objects used in a QuantumCircuit object will now be sorted by name. This will take effect for the parameters returned by the parameters attribute. Additionally, the qiskit.circuit.QuantumCircuit.bind_parameters() and qiskit.circuit.QuantumCircuit.assign_parameters() methods can now take in a list of a values which will bind/assign them to the parameters in name-sorted order. Previously these methods would only take a dictionary of parameters and values. For example:

from qiskit.circuit import QuantumCircuit, Parameter

circuit = QuantumCircuit(1)
circuit.rx(Parameter('x'), 0)
circuit.ry(Parameter('y'), 0)

print(circuit.parameters)

bound = circuit.bind_parameters([1, 2])
bound.draw(output='mpl')

ParameterView([Parameter(x), Parameter(y)])

• The constructors for the qiskit.quantum_info.Statevector and qiskit.quantum_info.DensityMatrix classes can now take a QuantumCircuit object in to build a Statevector and DensityMatrix object from that circuit, assuming that the qubits are initialized in $$|0\rangle$$. For example:

from qiskit import QuantumCircuit
from qiskit.quantum_info import Statevector

qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)

statevector = Statevector(qc)
statevector.draw(output='latex')

$\begin{split}\begin{bmatrix} \tfrac{1}{\sqrt{2}} & 0 & 0 & \tfrac{1}{\sqrt{2}} \\ \end{bmatrix} \end{split}$
• New fake backend classes are available under qiskit.test.mock. These included mocked versions of ibmq_casablanca, ibmq_sydney, ibmq_mumbai, ibmq_lima, ibmq_belem, ibmq_quito. 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.

##### Known Issues¶
• Attempting to add an qiskit.pulse.Instruction object with a parameterized duration (ie the value of duration is an unbound Parameter or ParameterExpression object) to a qiskit.pulse.Schedule is not supported. Attempting to do so will result in UnassignedDurationError PulseError being raised. This is a limitation of how the Instruction overlap constraints are evaluated currently. This is supported by ScheduleBlock, in which the overlap constraints are evaluated just before the execution.

• On Windows systems when parallel execution is enabled for parallel_map() parallelism may not work when called from a script running outside of a if __name__ == '__main__': block. This is due to how Python launches parallel processes on Windows. If a RuntimeError or AttributeError are raised by scripts that call parallel_map() (including using functions that use parallel_map() internally like transpile()) with Windows and parallelism enabled you can try embedding the script calls inside if __name__ == '__main__': to workaround the issue. For example:

from qiskit import QuantumCircuit, QiskitError
from qiskit import execute, Aer

qc1 = QuantumCircuit(2, 2)
qc1.h(0)
qc1.cx(0, 1)
qc1.measure([0,1], [0,1])
# making another circuit: superpositions
qc2 = QuantumCircuit(2, 2)
qc2.h([0,1])
qc2.measure([0,1], [0,1])
execute([qc1, qc2], Aer.get_backend('qasm_simulator'))


should be changed to:

from qiskit import QuantumCircuit, QiskitError
from qiskit import execute, Aer

def main():
qc1 = QuantumCircuit(2, 2)
qc1.h(0)
qc1.cx(0, 1)
qc1.measure([0,1], [0,1])
# making another circuit: superpositions
qc2 = QuantumCircuit(2, 2)
qc2.h([0,1])
qc2.measure([0,1], [0,1])
execute([qc1, qc2], Aer.get_backend('qasm_simulator'))

if __name__ == '__main__':
main()


if any errors are encountered with parallelism on Windows.

• The preset pass managers level_1_pass_manager, level_2_pass_manager, and level_3_pass_manager (which are used for optimization_level 1, 2, and 3 in the transpile() and execute() functions) now unconditionally use the Optimize1qGatesDecomposition pass for 1 qubit gate optimization. Previously, these pass managers would use the Optimize1qGates pass if the basis gates contained u1, u2, or u3. If you want to still use the old Optimize1qGates you will need to construct a custom PassManager with the pass.

• Following transpilation of a parameterized QuantumCircuit, the global_phase attribute of output circuit may no longer be returned in a simplified form, if the global phase is a ParameterExpression.

For example:

qc = QuantumCircuit(1)
theta = Parameter('theta')

qc.rz(theta, 0)
qc.rz(-theta, 0)

print(transpile(qc, basis_gates=['p']).global_phase)


previously returned 0, but will now return -0.5*theta + 0.5*theta. This change was necessary was to avoid a large runtime performance penalty as simplifying symbolic expressions can be quite slow, especially if there are many ParameterExpression objects in a circuit.

• The BasicAerJob job objects returned from BasicAer backends are now synchronous instances of JobV1. This means that calls to the run() will block until the simulation finishes executing. If you want to restore the previous async behavior you’ll need to wrap the run() with something that will run in a seperate thread or process like futures.ThreadPoolExecutor or futures.ProcessPoolExecutor.

• The allow_sample_measuring option for the BasicAer simulator QasmSimulatorPy has changed from a default of False to True. This was done to better reflect the actual default behavior of the simulator, which would use sample measuring if the input circuit supported it (even if it was not enabled). If you are running a circuit that doesn’t support sample measurement (ie it has Reset operations or if there are operations after a measurement on a qubit) you should make sure to explicitly set this option to False when you call run().

• The CommutativeCancellation transpiler pass is now aware of the target basis gates, which means it will only use gates in the specified basis. Previously, the pass would unconditionally replace consecutive gates which commute with ZGate with the U1Gate. However, now that the pass is basis aware and has a kwarg, basis_gates, for specifying the target basis there is a potential change in behavior if the kwarg is not set. When the basis_gates kwarg is not used and there are no variable z-rotation gates in the circuit then no commutative cancellation will occur.

• Register (which is the parent class for QuantumRegister and ClassicalRegister and Bit (which is the parent class for Qubit and Clbit) objects are now immutable. In previous releases it was possible to adjust the value of a size or name attributes of a Register object and the index or register attributes of a Bit object after it was initially created. However this would lead to unsound behavior that would corrupt container structure that rely on a hash (such as a dict) since these attributes are treated as immutable properties of a register or bit (see #4705 for more details). To avoid this unsound behavior this attributes of a Register and Bit are no longer settable after initial creation. If you were previously adjusting the objects at runtime you will now need to create a new Register or Bit object with the new values.

• The DAGCircuit.__eq__ method (which is used by the == operator), which is used to check structural equality of DAGCircuit and QuantumCircuit instances, will now include the global_phase and calibrations attributes in the fields checked for equality. This means that circuits which would have evaluated as equal in prior releases may not anymore if the global_phase or calibrations differ between the circuits. For example, in previous releases this would return True:

import math

from qiskit import QuantumCircuit

qc1 = QuantumCircuit(1)
qc1.x(0)

qc2 = QuantumCircuit(1, global_phase=math.pi)
qc2.x(0)

print(qc2 == qc1)


However, now because the global_phase attribute of the circuits differ this will now return False.

• The previously deprecated qubits() and clbits() methods on the DAGCircuit class, which were deprecated in the 0.15.0 Terra release, have been removed. Instead you should use the qubits and clbits attributes of the DAGCircuit class. For example, if you were running:

from qiskit.dagcircuit import DAGCircuit

dag = DAGCircuit()
qubits = dag.qubits()


That would be replaced by:

from qiskit.dagcircuit import DAGCircuit

dag = DAGCircuit()
qubits = dag.qubits

• The PulseDefaults returned by the fake pulse backends qiskit.test.mock.FakeOpenPulse2Q and qiskit.test.mock.FakeOpenPulse3Q have been updated to have more realistic pulse sequence definitions. If you are using these fake backend classes you may need to update your usage because of these changes.

• The default synthesis method used by decompose_clifford() function in the quantum_info module (which gets used internally by the qiskit.quantum_info.Clifford.to_circuit() method) for more than 3 qubits now uses a non-optimal greedy compilation routine for Clifford elements synthesis, by Bravyi et. al., which typically yields better CX cost compared to the old default. If you need to revert to the previous Aaronson-Gottesman method this can be done by setting method='AG'.

• The previously deprecated module qiskit.visualization.interactive, which was deprecated in the 0.15.0 release, has now been removed. Instead you should use the matplotlib based visualizations:

Removed Interactive function

Equivalent matplotlib function

iplot_bloch_multivector

qiskit.visualization.plot_bloch_multivector()

iplot_state_city

qiskit.visualization.plot_state_city()

iplot_state_qsphere

qiskit.visualization.plot_state_qsphere()

iplot_state_hinton

qiskit.visualization.plot_state_hinton()

iplot_histogram

qiskit.visualization.plot_histogram()

iplot_state_paulivec

qiskit.visualization.plot_state_paulivec()

• The qiskit.Aer and qiskit.IBMQ top level attributes are now lazy loaded. This means that the objects will now always exist and warnings will no longer be raised on import if qiskit-aer or qiskit-ibmq-provider are not installed (or can’t be found by Python). If you were checking for the presence of qiskit-aer or qiskit-ibmq-provider using these module attributes and explicitly comparing to None or looking for the absence of the attribute this no longer will work because they are always defined as an object now. In other words running something like:

try:
from qiskit import Aer
except ImportError:
print("Aer not available")

or::

try:
from qiskit import IBMQ
except ImportError:
print("IBMQ not available")


will no longer work. Instead to determine if those providers are present you can either explicitly use qiskit.providers.aer.Aer and qiskit.providers.ibmq.IBMQ:

try:
from qiskit.providers.aer import Aer
except ImportError:
print("Aer not available")

try:
from qiskit.providers.ibmq import IBMQ
except ImportError:
print("IBMQ not available")


or check bool(qiskit.Aer) and bool(qiskit.IBMQ) instead, for example:

import qiskit

if not qiskit.Aer:
print("Aer not available")
if not qiskit.IBMQ:
print("IBMQ not available")


This change was necessary to avoid potential import cycle issues between the qiskit packages and also to improve the import time when Aer or IBMQ are not being used.

• The user config file option suppress_packaging_warnings option in the user config file and the QISKIT_SUPPRESS_PACKAGING_WARNINGS environment variable no longer has any effect and will be silently ignored. The warnings this option controlled have been removed and will no longer be emitted at import time from the qiskit module.

• The previously deprecated condition kwarg for qiskit.dagcircuit.DAGNode constructor has been removed. It was deprecated in the 0.15.0 release. Instead you should now be setting the classical condition on the Instruction object passed into the DAGNode constructor when creating a new op node.

• When creating a new Register (which is the parent class for QuantumRegister and ClassicalRegister) or QuantumCircuit object with a number of bits (eg QuantumCircuit(2)), it is now required that number of bits are specified as an integer or another type which is castable to unambiguous integers(e.g. 2.0). Non-integer values will now raise an error as the intent in those cases was unclear (you can’t have fractional bits). For more information on why this was changed refer to: #4855

• networkx is no longer a requirement for qiskit-terra. All the networkx usage inside qiskit-terra has been removed with the exception of 3 methods:

If you are using any of these methods you will need to manually install networkx in your environment to continue using them.

• By default on macOS with Python >=3.8 parallel_map() will no longer run in multiple processes. This is a change from previous releases where the default behavior was that parallel_map() would launch multiple processes. This change was made because with newer versions of macOS with Python 3.8 and 3.9 multiprocessing is either unreliable or adds significant overhead because of the change in Python 3.8 to launch new processes with spawn instead of fork. To re-enable parallel execution on macOS with Python >= 3.8 you can use the user config file parallel option or set the environment variable QISKIT_PARALLEL to True.

• The previously deprecated kwarg callback on the constructor for the PassManager class has been removed. This kwarg has been deprecated since the 0.13.0 release (April, 9th 2020). Instead you can pass the callback kwarg to the qiskit.transpiler.PassManager.run() method directly. For example, if you were using:

from qiskit.circuit.random import random_circuit
from qiskit.transpiler import PassManager

qc = random_circuit(2, 2)

def callback(**kwargs)
print(kwargs['pass_'])

pm = PassManager(callback=callback)
pm.run(qc)


this can be replaced with:

from qiskit.circuit.random import random_circuit
from qiskit.transpiler import PassManager

qc = random_circuit(2, 2)

def callback(**kwargs)
print(kwargs['pass_'])

pm = PassManager()
pm.run(qc, callback=callback)

• It is now no longer possible to instantiate a base channel without a prefix, such as qiskit.pulse.Channel or qiskit.pulse.PulseChannel. These classes are designed to classify types of different user facing channel classes, such as qiskit.pulse.DriveChannel, but do not have a definition as a target resource. If you were previously directly instantiating either qiskit.pulse.Channel or qiskit.pulse.PulseChannel, this is no longer allowed. Please use the appropriate subclass.

• When the require_cp and/or require_tp kwargs of qiskit.quantum_info.process_fidelity(), qiskit.quantum_info.average_gate_fidelity(), qiskit.quantum_info.gate_error() are True, they will now only log a warning rather than the previous behavior of raising a QiskitError exception if the input channel is non-CP or non-TP respectively.

• The QFT class in the qiskit.circuit.library module now computes the Fourier transform using a little-endian representation of tensors, i.e. the state $$|1\rangle$$ maps to $$|0\rangle - |1\rangle + |2\rangle - ..$$ assuming the computational basis correspond to little-endian bit ordering of the integers. $$|0\rangle = |000\rangle, |1\rangle = |001\rangle$$, etc. This was done to make it more consistent with the rest of Qiskit, which uses a little-endian convention for bit order. If you were depending on the previous bit order you can use the reverse_bits() method to revert to the previous behavior. For example:

from qiskit.circuit.library import QFT

qft = QFT(5).reverse_bits()

• The qiskit.__qiskit_version__ module attribute was previously a dict will now return a custom read-only Mapping object that checks the version of qiskit elements at runtime instead of at import time. This was done to speed up the import path of qiskit and eliminate a possible import cycle by only importing the element packages at runtime if the version is needed from the package. This should be fully compatible with the dict previously return and for most normal use cases there will be no difference. However, if some applications were relying on either mutating the contents or explicitly type checking it may require updates to adapt to this change.

• The qiskit.execute module has been renamed to qiskit.execute_function. This was necessary to avoid a potentical name conflict between the execute() function which is re-exported as qiskit.execute. qiskit.execute the function in some situations could conflict with qiskit.execute the module which would lead to a cryptic error because Python was treating qiskit.execute as the module when the intent was to the function or vice versa. The module rename was necessary to avoid this conflict. If you’re importing qiskit.execute to get the module (typical usage was from qiskit.execute import execute) you will need to update this to use qiskit.execute_function instead. qiskit.execute will now always resolve to the function.

• The qiskit.compiler.transpile, qiskit.compiler.assemble, qiskit.compiler.schedule, and qiskit.compiler.sequence modules have been renamed to qiskit.compiler.transpiler, qiskit.compiler.assembler, qiskit.compiler.scheduler, and qiskit.compiler.sequence respectively. This was necessary to avoid a potentical name conflict between the modules and the re-exported function paths qiskit.compiler.transpile(), qiskit.compiler.assemble(), qiskit.compiler.schedule(), and qiskit.compiler.sequence(). In some situations this name conflict between the module path and re-exported function path would lead to a cryptic error because Python was treating an import as the module when the intent was to use the function or vice versa. The module rename was necessary to avoid this conflict. If you were using the imports to get the modules before (typical usage would be likefrom qiskit.compiler.transpile import transpile) you will need to update this to use the new module paths. qiskit.compiler.transpile(), qiskit.compiler.assemble(), qiskit.compiler.schedule(), and qiskit.compiler.sequence() will now always resolve to the functions.

• The qiskit.quantum_info.Quaternion class was moved from the qiskit.quantum_info.operator submodule to the qiskit.quantum_info.synthesis submodule to better reflect it’s purpose. No change is required if you were importing it from the root qiskit.quantum_info module, but if you were importing from qiskit.quantum_info.operator you will need to update your import path.

• Removed the QuantumCircuit.mcmt method, which has been deprecated since the Qiskit Terra 0.14.0 release in April 2020. Instead of using the method, please use the MCMT class instead to construct a multi-control multi-target gate and use the qiskit.circuit.QuantumCircuit.append() or qiskit.circuit.QuantumCircuit.compose() to add it to a circuit.

For example, you can replace:

circuit.mcmt(ZGate(), [0, 1, 2], [3, 4])


with:

from qiskit.circuit.library import MCMT
mcmt = MCMT(ZGate(), 3, 2)
circuit.compose(mcmt, range(5))

• Removed the QuantumCircuit.diag_gate method which has been deprecated since the Qiskit Terra 0.14.0 release in April 2020. Instead, use the diagonal() method of QuantumCircuit.

• Removed the QuantumCircuit.ucy method which has been deprecated since the Qiskit Terra 0.14.0 release in April 2020. Instead, use the ucry() method of QuantumCircuit.

• The previously deprecated mirror() method for qiskit.circuit.QuantumCircuit has been removed. It was deprecated in the 0.15.0 release. The qiskit.circuit.QuantumCircuit.reverse_ops() method should be used instead since mirroring could be confused with swapping the output qubits of the circuit. The reverse_ops() method only reverses the order of gates that are applied instead of mirroring.

• The previously deprecated support passing a float (for the scale kwarg as the first positional argument to the qiskit.circuit.QuantumCircuit.draw() has been removed. It was deprecated in the 0.12.0 release. The first positional argument to the qiskit.circuit.QuantumCircuit.draw() method is now the output kwarg which does not accept a float. Instead you should be using scale as a named kwarg instead of using it positionally.

For example, if you were previously calling draw with:

from qiskit import QuantumCircuit

qc = QuantumCircuit(2)
qc.draw(0.75, output='mpl')


this would now need to be:

from qiskit import QuantumCircuit

qc = QuantumCircuit(2)
qc.draw(output='mpl', scale=0.75)


or:

qc.draw('mpl', scale=0.75)

• Features of Qiskit Pulse (qiskit.pulse) which were deprecated in the 0.15.0 release (August, 2020) have been removed. The full set of changes are:

Module

Old

New

qiskit.pulse.library

SamplePulse

Waveform

qiskit.pulse.library

ConstantPulse

Constant

(module rename)

pulse.pulse_lib Module

qiskit.pulse.library

Class

Old method

New method

ParametricPulse

get_sample_pulse

get_waveform

Instruction

command

N/A. Commands and Instructions have been unified. Use operands() to get information about the instruction data.

Acquire

acquires, mem_slots, reg_slots

acquire(), mem_slot(), reg_slot(). (The Acquire instruction no longer broadcasts across multiple qubits.)

• The dictionary previously held on DAGCircuit edges has been removed. Instead, edges now hold the Bit instance which had previously been included in the dictionary as its 'wire' field. Note that the NetworkX graph returned by to_networkx() will still have a dictionary for its edge attributes, but the 'name' field will no longer be populated.

• The parameters attribute of the QuantumCircuit class no longer is returning a set. Instead it returns a ParameterView object which implements all the methods that set offers (albeit deprecated). This was done to support a model that preserves name-sorted parameters. It should be fully compatible with any previous usage of the set returned by the parameters attribute, except for where explicit type checking of a set was done.

• When running transpile() on a QuantumCircuit with delay() instructions, the units will be converted to dt if the value of dt (sample time) is known to transpile(), either explicitly via the dt kwarg or via the BackendConfiguration for a Backend object passed in via the backend kwarg.

• The interpretation of meas_map (which is an attribute of a PulseBackendConfiguration object or as the corresponding meas_map kwarg on the schedule(), assemble(), sequence(), or execute() functions) has been updated to better match the true constraints of the hardware. The format of this data is a list of lists, where the items in the inner list are integers specifying qubit labels. For instance:

[[A, B, C], [D, E, F, G]]


Previously, the meas_map constraint was interpreted such that if one qubit was acquired (e.g. A), then all other qubits sharing a subgroup with that qubit (B and C) would have to be acquired at the same time and for the same duration. This constraint has been relaxed. One acquisition does not require more acquisitions. (If A is acquired, B and C do not need to be acquired.) Instead, qubits in the same measurement group cannot be acquired in a partially overlapping way – think of the meas_map as specifying a shared acquisition resource (If we acquire A from t=1000 to t=2000, we cannot acquire B starting from 1000<t<2000). For example:

# Good
meas_map = [[0, 1]]
# Acquire a subset of [0, 1]
sched = pulse.Schedule()
sched = sched.append(pulse.Acquire(10, acq_q0))

# Acquire 0 and 1 together (same start time, same duration)
sched = pulse.Schedule()
sched = sched.append(pulse.Acquire(10, acq_q0))
sched = sched.append(pulse.Acquire(10, acq_q1))

# Acquire 0 and 1 disjointly
sched = pulse.Schedule()
sched = sched.append(pulse.Acquire(10, acq_q0))
sched = sched.append(pulse.Acquire(10, acq_q1)) << 10

# Acquisitions overlap, but 0 and 1 aren't in the same measurement
# grouping
meas_map = [[0], [1]]
sched = pulse.Schedule()
sched = sched.append(pulse.Acquire(10, acq_q0))
sched = sched.append(pulse.Acquire(10, acq_q1)) << 1

# Bad: 0 and 1 are in the same grouping, but acquisitions
# partially overlap
meas_map = [[0, 1]]
sched = pulse.Schedule()
sched = sched.append(pulse.Acquire(10, acq_q0))
sched = sched.append(pulse.Acquire(10, acq_q1)) << 1

##### Deprecation Notes¶
• Two new arguments have been added to qiskit.dagcircuit.DAGNode.semantic_eq(), bit_indices1 and bit_indices2, which are expected to map the Bit instances in each DAGNode to their index in qubits or clbits list of their respective DAGCircuit. During the deprecation period, these arguments are optional and when not specified the mappings will be automatically constructed based on the register and index properties of each Bit instance. However, in a future release, they will be required arguments and the mapping will need to be supplied by the user.

• The pulse builder functions:

• qiskit.pulse.call_circuit()

• qiskit.pulse.call_schedule()

are deprecated and will be removed in a future release. These functions are unified into qiskit.pulse.call() which should be used instead.

• The qiskit.pulse.Schedule method qiskit.pulse.Schedule.flatten() method is deprecated and will be removed in a future release. Instead you can use the qiskit.pulse.transforms.flatten() function which will perform the same operation.

• The assign_parameters() for the following classes:

• qiskit.pulse.library.Pulse,

and all their subclasses is now deprecated and will be removed in a future release. This functionality has been subsumed ScheduleBlock which is the future direction for constructing parameterized pulse programs.

• The parameters attribute for the following clasess:

is deprecated and will be removed in a future release. This functionality has been subsumed ScheduleBlock which is the future direction for constructing parameterized pulse programs.

• Python 3.6 support has been deprecated and will be removed in a future release. When support is removed you will need to upgrade the Python version you’re using to Python 3.7 or above.

• Two QuantumCircuit methods combine() and extend() along with their corresponding Python operators + and += are deprecated and will be removed in a future release. Instead the QuantumCircuit method compose() should be used. The compose() method allows more flexibility in composing two circuits that do not have matching registers. It does not, however, automatically add qubits/clbits unlike the deprecated methods. To add a circuit on new qubits/clbits, the qiskit.circuit.QuantumCircuit.tensor() method can be used. For example:

from qiskit.circuit import QuantumRegister, QuantumCircuit

a = QuantumRegister(2, 'a')
circuit_a = QuantumCircuit(a)
circuit_a.cx(0, 1)

b = QuantumRegister(2, 'b')
circuit_b = QuantumCircuit(b)
circuit_b.cz(0, 1)

# same as circuit_a + circuit_b (or combine)

# same as circuit_a + circuit_a (or combine)

# same as circuit_a += circuit_b (or extend)
circuit_a = circuit_b.tensor(circuit_a)

# same as circuit_a += circuit_a (or extend)
circuit_a.compose(circuit_a, inplace=True)

• Support for passing Qubit instances to the qubits kwarg of the qiskit.transpiler.InstructionDurations.get() method has been deprecated and will be removed in a future release. Instead, you should call the get() method with the integer indices of the desired qubits.

• Using @ (__matmul__) for invoking the compose method of BaseOperator subclasses (eg Operator) is deprecated and will be removed in a future release. The qiskit.quantum_info.Operator.compose() method can be used directly or also invoked using the & (__and__) operator.

• Using * (__mul__) for calling the dot() method of BaseOperator subclasses (eg qiskit.quantum_info.Operator) is deprecated and will be removed in a future release. Instead you can just call the dot() directly.

• Using @ (__matmul__) for invoking the evolve() method of the qiskit.quantum_info.Statevector and qiskit.quantum_info.DensityMatrix classes is deprecated and will be removed in a future release.. The evolve method can be used directly or also invoked using the & (__and__) operator.

• The qiskit.pulse.schedule.ParameterizedSchedule class has been deprecated and will be removed in a future release. Instead you can directly parameterize pulse Schedule objects with a Parameter object, for example:

from qiskit.circuit import Parameter
from qiskit.pulse import Schedule
from qiskit.pulse import ShiftPhase, DriveChannel

theta = Parameter('theta')
target_schedule = Schedule()
target_schedule.insert(0, ShiftPhase(theta, DriveChannel(0)), inplace=True)

• The qiskit.pulse.ScheduleComponent class in the qiskit.pulse module has been deprecated and will be removed in a future release. Its usage should be replaced either using a qiskit.pulse.Schedule or qiskit.pulse.Instruction directly. Additionally, the primary purpose of the ScheduleComponent class was as a common base class for both Schedule and Instruction for any place that was explicitly type checking or documenting accepting a ScheduleComponent input should be updated to accept Instruction or Schedule.

• The JSON Schema files and usage for the IBMQ API payloads are deprecated and will be removed in a future release. This includes everything under the qiskit.schemas module and the qiskit.validation module. This also includes the validate kwargs for qiskit.qobj.QasmQobj.to_dict() and qiskit.qobj.QasmQobj.to_dict() along with the module level fastjsonschema validators in qiskit.qobj (which do not raise a deprecation warning). The schema files have been moved to the Qiskit/ibmq-schemas repository and those should be treated as the canonical versions of the API schemas. Moving forward only those schemas will recieve updates and will be used as the source of truth for the schemas. If you were relying on the schemas bundled in qiskit-terra you should update to use that repository instead.

• The qiskit.util module has been deprecated and will be removed in a future release. It has been replaced by qiskit.utils which provides the same functionality and will be expanded in the future. Note that no DeprecationWarning will be emitted regarding this deprecation since it was not feasible on Python 3.6.

• The CXDirection transpiler pass in the qiskit.transpiler.passes module has been deprecated and will be removed in a future release. Instead the GateDirection should be used. It behaves identically to the CXDirection except that it now also supports transforming a circuit with ECRGate gates in addition to CXGate gates.

• The CheckCXDirection transpiler pass in the qiskit.transpiler.passes module has been deprecated and will be removed in a future release. Instead the CheckGateDirection pass should be used. It behaves identically to the CheckCXDirection except that it now also supports checking the direction of all 2-qubit gates, not just CXGate gates.

• The WeightedAdder method num_ancilla_qubits() is deprecated and will be removed in a future release. It has been replaced with the qiskit.circuit.library.WeightedAdder.num_ancillas attribute which is consistent with other circuit libraries’ APIs.

• The following legacy methods of the qiskit.quantum_info.Pauli class have been deprecated. See the method documentation for replacement use in the updated Pauli class.

• Using a list or numpy.ndarray as the channel or target argument for the qiskit.quantum_info.process_fidelity(), qiskit.quantum_info.average_gate_fidelity(), qiskit.quantum_info.gate_error(), and qiskit.quantum_info.diamond_norm() functions has been deprecated and will not be supported in a future release. The inputs should instead be a Gate or a BaseOperator subclass object (eg. Operator, Choi, etc.)

• Accessing references from Qubit and Clbit instances to their containing registers via the register or index properties has been deprecated and will be removed in a future release. Instead, Register objects can be queried to find the Bit objects they contain.

• The current functionality of the qiskit.visualization.pulse_drawer() function is deprecated and will be replaced by qiskit.visualization.pulse_drawer_v2() (which is not backwards compatible) in a future release.

• The use of methods inherited from the set type on the output of the parameters attribute (which used to be a set) of the QuantumCircuit class are deprecated and will be removed in a future release. This includes the methods from the add(), difference(), difference_update(), discard(), intersection(), intersection_update(), issubset(), issuperset(), symmetric_difference(), symmetric_difference_update(), union(), update(), __isub__() (which is the -= operator), and __ixor__() (which is the ^= operator).

• The name of the first (and only) positional argument for the qiskit.circuit.QuantumCircuit.bind_parameters() method has changed from value_dict to values. The passing an argument in with the name values_dict is deprecated and will be removed in future release. For example, if you were previously calling bind_parameters() with a call like: bind_parameters(values_dict={}) this is deprecated and should be replaced by bind_parameters(values={}) or even better just pass the argument positionally bind_parameters({}).

• The name of the first (and only) positional argument for the qiskit.circuit.QuantumCircuit.assign_parameters() method has changed from param_dict to parameters. Passing an argument in with the name param_dict is deprecated and will be removed in future release. For example, if you were previously calling assign_parameters() with a call like: assign_parameters(param_dict={}) this is deprecated and should be replaced by assign_parameters(values={}) or even better just pass the argument positionally assign_parameters({}).

#### Aer 0.8.0¶

##### Prelude¶

The 0.8 release includes several new features and bug fixes. The highlights for this release are: the introduction of a unified AerSimulator backend for running circuit simulations using any of the supported simulation methods; a simulator instruction library (qiskit.providers.aer.library) which includes custom instructions for saving various kinds of simulator data; MPI support for running large simulations on a distributed computing environment.

##### Known Issues¶
• There is a known issue where the simulation of certain circuits with a Kraus noise model using the "matrix_product_state" simulation method can cause the simulator to crash. Refer to #306 for more information.

• The minimum version of Conan has been increased to 1.31.2. This was necessary to fix a compatibility issue with newer versions of the urllib3 (which is a dependency of Conan). It also adds native support for AppleClang 12 which is useful for users with new Apple computers.

• pybind11 minimum version required is 2.6 instead of 2.4. This is needed in order to support CUDA enabled compilation in Windows.

• Cython has been removed as a build dependency.

• Removed x90 gate decomposition from noise models that was deprecated in qiskit-aer 0.7. This decomposition is now done by using regular noise model basis gates and the qiskit transpiler.

• The following options for the "extended_stabilizer" simulation method have changed.

• extended_stabilizer_measure_sampling: This option has been replaced by the options extended_stabilizer_sampling_method, which controls how we simulate qubit measurement.

• extended_stabilizer_mixing_time: This option has been renamed as extended_stabilizer_metropolis_mixing_time to clarify it only applies to the metropolis and resampled_metropolis sampling methods.

• extended_stabilizer_norm_estimation_samples: This option has been renamed to extended_stabilizer_norm_estimation_default_samples.

One additional option, extended_stabilizer_norm_estimation_repetitions has been added, whih controls part of the behaviour of the norm estimation sampling method.

##### Deprecation Notes¶
• Python 3.6 support has been deprecated and will be removed in a future release. When support is removed you will need to upgrade the Python version you’re using to Python 3.7 or above.

##### Bug Fixes¶
• Fixes bug with AerProvider where options set on the returned backends using set_options() were stored in the provider and would persist for subsequent calls to get_backend() for the same named backend. Now every call to and backends() returns a new instance of the simulator backend that can be configured.

• Fixes bug in the error message returned when a circuit contains unsupported simulator instructions. Previously some supported instructions were also being listed in the error message along with the unsupported instructions.

• Fixes issue with setting QasmSimulator basis gates when using "method" and "noise_model" options together, and when using them with a simulator constructed using from_backend(). Now the listed basis gates will be the intersection of gates supported by the backend configuration, simulation method, and noise model basis gates. If the intersection of the noise model basis gates and simulator basis gates is empty a warning will be logged.

• Fix bug where the "sx" gate SXGate was not listed as a supported gate in the C++ code, in StateOpSet of matrix_product_state.hp.

• Fix bug where "csx", "cu2", "cu3" were incorrectly listed as supported basis gates for the "density_matrix" method of the QasmSimulator.

• Fix bug where parameters were passed incorrectly between functions in matrix_product_state_internal.cpp, causing wrong simulation, as well as reaching invalid states, which in turn caused an infinite loop.

• Fixes a bug that resulted in c_if not working when the width of the conditional register was greater than 64. See #1077.

• Fixes a bug #1153) where noise on conditional gates was always being applied regardless of whether the conditional gate was actually applied based on the classical register value. Now noise on a conditional gate will only be applied in the case where the conditional gate is applied.

• Fixes a bug with nested OpenMP flag was being set to true when it shouldn’t be.

• Fixes a bug when applying truncation in the matrix product state method of the QasmSimulator.

• Fixed issue #1126: bug in reporting measurement of a single qubit. The bug occured when copying the measured value to the output data structure.

• In MPS, apply_kraus was operating directly on the input bits in the parameter qubits, instead of on the internal qubits. In the MPS algorithm, the qubits are constantly moving around so all operations should be applied to the internal qubits.

• When invoking MPS::sample_measure, we need to first sort the qubits to the default ordering because this is the assumption in qasm_controller.This is done by invoking the method move_all_qubits_to_sorted_ordering. It was correct in sample_measure_using_apply_measure, but missing in sample_measure_using_probabilities.

• Fixes bug with the from_backend() method of the QasmSimulator that would set the local attribute of the configuration to the backend value rather than always being set to True.

• Fixes bug in from_backend() and from_backend() where basis_gates was set incorrectly for IBMQ devices with basis gate set ['id', 'rz', 'sx', 'x', 'cx']. Now the noise model will always have the same basis gates as the backend basis gates regardless of whether those instructions have errors in the noise model or not.

• Fixes an issue where the Extended “extended_stabilizer” simulation method would give incorrect results on quantum circuits with sparse output distributions. Refer to #306 for more information and examples.

#### Ignis 0.6.0¶

##### New Features¶
• The qiskit.ignis.verification.randomized_benchmarking_seq() function is now using the upgraded CNOTDihedral class, qiskit.ignis.verification.CNOTDihedral, which enables performing CNOT-Dihedral Randomized Benchmarking on more than two qubits.

• The python package retworkx is now a requirement for installing qiskit-ignis. It replaces the previous usage of networkx (which is no longer a requirement) to get better performance.

• The scikit-learn dependency is no longer required and is now an optional requirement. If you’re using the IQ measurement discriminators (IQDiscriminationFitter, LinearIQDiscriminationFitter, QuadraticIQDiscriminationFitter, or SklearnIQDiscriminator) you will now need to manually install scikit-learn, either by running pip install scikit-learn or when you’re also installing qiskit-ignis with pip install qiskit-ignis[iq].

#### Aqua 0.9.0¶

This release officially deprecates the Qiskit Aqua project, in the future (no sooner than 3 months from this release) the Aqua project will have it’s final release and be archived. All the functionality that qiskit-aqua provides has been migrated to either new packages or to other qiskit packages. 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, ie pip install qiskit-nature) or with the rest of the Qiskit metapackage as optional extras (ie, pip install 'qiskit[finance,optimization]' or pip install 'qiskit[all]'. The core building blocks for 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 using Qiskit Aqua you can refer to the Qiskit 아쿠아 마이그레이션 가이드.

No change

### Qiskit 0.24.1¶

No change

No change

No change

No change

#### IBM Q Provider 0.12.2¶

• qiskit.providers.ibmq.IBMQBackend.defaults() now returns the pulse defaults for the backend if the backend supports pulse. However, your provider may not support pulse even if the backend does. The open_pulse flag in backend configuration indicates whether the provider supports it.

### Qiskit 0.24.0¶

No change

#### Aer 0.7.6¶

##### New Features¶
• This is the first release of qiskit-aer that publishes precompiled binaries to PyPI for Linux on aarch64 (arm64). From this release onwards Linux aarch64 packages will be published and supported.

##### Bug Fixes¶
• Fixes a bug #1153 where noise on conditional gates was always being applied regardless of whether the conditional gate was actually applied based on the classical register value. Now noise on a conditional gate will only be applied in the case where the conditional gate is applied.

• Fixed issue #1126: bug in reporting measurement of a single qubit. The bug occured when copying the measured value to the output data structure.

• There was previously a mismatch between the default reported number of qubits the Aer backend objects would say were supported and the the maximum number of qubits the simulator would actually run. This was due to a mismatch between the Python code used for calculating the max number of qubits and the C++ code used for a runtime check for the max number of qubits based on the available memory. This has been correct so by default now Aer backends will allow running circuits that can fit in all the available system memory. Fixes #1114

No change

No change

No change

#### IBM Q Provider 0.12.0¶

##### New Features¶
• A number of previously deprecated methods and features have been removed, including:

• qiskit.providers.ibmq.job.IBMQJob.to_dict()

• qiskit.providers.ibmq.job.IBMQJob.from_dict()

• Qconfig.py support

• Use of proxy URLs that do not include protocols

• A new parameter, limit is now the first parameter for both qiskit.providers.ibmq.experiment.ExperimentService.experiments() and qiskit.providers.ibmq.experiment.ExperimentService.analysis_results() methods. This limit has a default value of 10, meaning by deafult only 10 experiments and analysis results will be returned.

• IBM Quantum credentials are now loaded only from sections of the qiskitrc file that start with ‘ibmq’. This allows the qiskitrc file to be used for other functionality.

##### Bug Fixes¶
• Fixes the issue wherein a job could be left in the CREATING state if job submit fails half-way through.

• Fixes the issue wherein using Jupyter backend widget would fail if the backend’s basis gates do not include the traditional u1, u2, and u3. Fixes #844

• Fixes the infinite loop raised when passing an IBMQRandomService instance to a child process.

• Fixes the issue wherein a TypeError is raised if the server returns an error code but the response data is not in the expected format.

### Qiskit 0.23.6¶

No change

#### Aer 0.7.5¶

##### Prelude¶

This release is a bugfix release that fixes compatibility in the precompiled binary wheel packages with numpy versions < 1.20.0. The previous release 0.7.4 was building the binaries in a way that would require numpy 1.20.0 which has been resolved now, so the precompiled binary wheel packages will work with any numpy compatible version.

No change

No change

No change

### Qiskit 0.23.5¶

#### Terra 0.16.4¶

##### Prelude¶

This release is a bugfix release that primarily fixes compatibility with numpy 1.20.0. This numpy release deprecated their local aliases for Python’s numeric types (np.int -> int, np.float -> float, etc.) and the usage of these aliases in Qiskit resulted in a large number of deprecation warnings being emitted. This release fixes this so you can run Qiskit with numpy 1.20.0 without those deprecation warnings.

#### Aer 0.7.4¶

##### Bug Fixes¶

Fixes compatibility with numpy 1.20.0. This numpy release deprecated their local aliases for Python’s numeric types (np.int -> int, np.float -> float, etc.) and the usage of these aliases in Qiskit Aer resulted in a large number of deprecation warnings being emitted. This release fixes this so you can run Qiskit Aer with numpy 1.20.0 without those deprecation warnings.

#### Ignis 0.5.2¶

##### Prelude¶

This release is a bugfix release that primarily fixes compatibility with numpy 1.20.0. It is also the first release to include support for Python 3.9. Earlier releases (including 0.5.0 and 0.5.1) worked with Python 3.9 but did not indicate this in the package metadata, and there was no upstream testing for those releases. This release fixes that and was tested on Python 3.9 (in addition to 3.6, 3.7, and 3.8).

##### Bug Fixes¶
• networkx is explicitly listed as a dependency now. It previously was an implicit dependency as it was required for the qiskit.ignis.verification.topological_codes module but was not correctly listed as a depdendency as qiskit-terra also requires networkx and is also a depdency of ignis so it would always be installed in practice. However, it is necessary to list it as a requirement for future releases of qiskit-terra that will not require networkx. It’s also important to correctly list the dependencies of ignis in case there were a future incompatibility between version requirements.

No change

No change

No change

No change

No change

### Qiskit 0.23.3¶

#### Terra 0.16.2¶

##### New Features¶
• Python 3.9 support has been added in this release. You can now run Qiskit Terra using Python 3.9.

• The class MCXGrayCode will now create a C3XGate if num_ctrl_qubits is 3 and a C4XGate if num_ctrl_qubits is 4. This is in addition to the previous functionality where for any of the modes of the :class:’qiskit.library.standard_gates.x.MCXGate, if num_ctrl_bits is 1, a CXGate is created, and if 2, a CCXGate is created.

##### Bug Fixes¶
• Pulse Delay instructions are now explicitly assembled as PulseQobjInstruction objects included in the PulseQobj output from assemble().

Previously, we could ignore Delay instructions in a Schedule as part of assemble() as the time was explicit in the PulseQobj objects. But, now with pulse gates, there are situations where we can schedule ONLY a delay, and not including the delay itself would remove the delay.

• Circuits with custom gate calibrations can now be scheduled with the transpiler without explicitly providing the durations of each circuit calibration.

• The BasisTranslator and Unroller passes, in some cases, had not been preserving the global phase of the circuit under transpilation. This has been fixed.

• A bug in qiskit.pulse.builder.frequency_offset() where when compensate_phase was set a factor of $$2\pi$$ was missing from the appended phase.

• Fix the global phase of the output of the QuantumCircuit method repeat(). If a circuit with global phase is appended to another circuit, the global phase is currently not propagated. Simulators rely on this, since the phase otherwise gets applied multiple times. This sets the global phase of repeat() to 0 before appending the repeated circuit instead of multiplying the existing phase times the number of repetitions.

• Fixes bug in SparsePauliOp where multiplying by a certain non Python builtin Numpy scalar types returned incorrect values. Fixes #5408

• The definition of the Hellinger fidelity from has been corrected from the previous defition of $$1-H(P,Q)$$ to $$[1-H(P,Q)^2]^2$$ so that it is equal to the quantum state fidelity of P, Q as diagonal density matrices.

• Reduce the number of CX gates in the decomposition of the 3-controlled X gate, C3XGate. Compiled and optimized in the U CX basis, now only 14 CX and 16 U gates are used instead of 20 and 22, respectively.

• Fixes the issue wherein using Jupyter backend widget or qiskit.tools.backend_monitor() would fail if the backend’s basis gates do not include the traditional u1, u2, and u3.

• When running qiskit.compiler.transpile() on a list of circuits with a single element, the function used to return a circuit instead of a list. Now, when qiskit.compiler.transpile() is called with a list, it will return a list even if that list has a single element. See #5260.

from qiskit import *

qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
qc.measure_all()

transpiled = transpile([qc])
print(type(transpiled), len(transpiled))

<class 'list'> 1


#### Aer 0.7.3¶

##### New Features¶
• Python 3.9 support has been added in this release. You can now run Qiskit Aer using Python 3.9 without building from source.

##### Bug Fixes¶
• Fixes issue with setting QasmSimulator basis gates when using "method" and "noise_model" options together, and when using them with a simulator constructed using from_backend(). Now the listed basis gates will be the intersection of gates supported by the backend configuration, simulation method, and noise model basis gates. If the intersection of the noise model basis gates and simulator basis gates is empty a warning will be logged.

• Fixes a bug that resulted in c_if not working when the width of the conditional register was greater than 64. See #1077.

• Fixes bug in from_backend() and from_backend() where basis_gates was set incorrectly for IBMQ devices with basis gate set ['id', 'rz', 'sx', 'x', 'cx']. Now the noise model will always have the same basis gates as the backend basis gates regardless of whether those instructions have errors in the noise model or not.

• Fixes a bug when applying truncation in the matrix product state method of the QasmSimulator.

No change

No change

No change

### Qiskit 0.23.2¶

No change

#### Aer 0.7.2¶

##### New Features¶
• Add the CMake flag DISABLE_CONAN (default=OFF)s. When installing from source, setting this to ON allows bypassing the Conan package manager to find libraries that are already installed on your system. This is also available as an environment variable DISABLE_CONAN, which takes precedence over the CMake flag. This is not the official procedure to build AER. Thus, the user is responsible of providing all needed libraries and corresponding files to make them findable to CMake.

##### Bug Fixes¶
• Fixes a bug with nested OpenMP flag was being set to true when it shouldn’t be.

No change

No change

No change

### Qiskit 0.23.1¶

#### Terra 0.16.1¶

##### Bug Fixes¶
• Fixed an issue where an error was thrown in execute for valid circuits built with delays.

• The QASM definition of ‘c4x’ in qelib1.inc has been corrected to match the standard library definition for C4XGate.

• Fixes a bug in subtraction for quantum channels $$A - B$$ where $$B$$ was an Operator object. Negation was being applied to the matrix in the Operator representation which is not equivalent to negation in the quantum channel representation.

• Changes the way _evolve_instruction() access qubits to handle the case of an instruction with multiple registers.

#### Aer 0.7.1¶

• The minimum cmake version to build qiskit-aer has increased from 3.6 to 3.8. This change was necessary to enable fixing GPU version builds that support running on x86_64 CPUs lacking AVX2 instructions.

##### Bug Fixes¶
• qiskit-aer with GPU support will now work on systems with x86_64 CPUs lacking AVX2 instructions. Previously, the GPU package would only run if the AVX2 instructions were available. Fixes #1023

• Fixes bug with AerProvider where options set on the returned backends using set_options() were stored in the provider and would persist for subsequent calls to get_backend() for the same named backend. Now every call to and backends() returns a new instance of the simulator backend that can be configured.

• Fixes bug in the error message returned when a circuit contains unsupported simulator instructions. Previously some supported instructions were also being listed in the error message along with the unsupported instructions.

• Fix bug where the “sx” gate SXGate was not listed as a supported gate in the C++ code, in StateOpSet of matrix_product_state.hp.

• Fix bug where "csx", "cu2", "cu3" were incorrectly listed as supported basis gates for the "density_matrix" method of the QasmSimulator.

• In MPS, apply_kraus was operating directly on the input bits in the parameter qubits, instead of on the internal qubits. In the MPS algorithm, the qubits are constantly moving around so all operations should be applied to the internal qubits.

• When invoking MPS::sample_measure, we need to first sort the qubits to the default ordering because this is the assumption in qasm_controller.This is done by invoking the method move_all_qubits_to_sorted_ordering. It was correct in sample_measure_using_apply_measure, but missing in sample_measure_using_probabilities.

#### Ignis 0.5.1¶

##### Bug Fixes¶
• Fix the "auto" method of the TomographyFitter, StateTomographyFitter, and ProcessTomographyFitter to only use "cvx" if CVXPY is installed and a third-party SDP solver other than SCS is available. This is because the SCS solver has lower accuracy than other solver methods and often returns a density matrix or Choi-matrix that is not completely-positive and fails validation when used with the qiskit.quantum_info.state_fidelity() or qiskit.quantum_info.process_fidelity() functions.

#### 0.8.1¶

##### New Features¶
• A new algorithm has been added: the Born Openheimer Potential Energy surface for the calculation of potential energy surface along different degrees of freedom of the molecule. The algorithm is called BOPESSampler. It further provides functionalities of fitting the potential energy surface to an analytic function of predefined potentials.some details.

##### Critical Issues¶
• Be aware that initial_state parameter in QAOA has now different implementation as a result of a bug fix. The previous implementation wrongly mixed the user provided initial_state with Hadamard gates. The issue is fixed now. No attention needed if your code does not make use of the user provided initial_state parameter.

##### Bug Fixes¶
• optimize_svm method of qp_solver would sometimes fail resulting in an error like this ValueError: cannot reshape array of size 1 into shape (200,1) This addresses the issue by adding an L2 norm parameter, lambda2, which defaults to 0.001 but can be changed via the QSVM algorithm, as needed, to facilitate convergence.

• A method one_letter_symbol has been removed from the VarType in the latest build of DOCplex making Aqua incompatible with this version. So instead of using this method an explicit type check of variable types has been introduced in the Aqua optimization module.

• :meth~qiskit.aqua.operators.state_fns.DictStateFn.sample() could only handle real amplitudes, but it is fixed to handle complex amplitudes. #1311 <https://github.com/Qiskit/qiskit-aqua/issues/1311> for more details.

• Trotter class did not use the reps argument in constructor. #1317 <https://github.com/Qiskit/qiskit-aqua/issues/1317> for more details.

• Raise an AquaError if :classqiskit.aqua.operators.converters.CircuitSampler samples an empty operator. #1321 <https://github.com/Qiskit/qiskit-aqua/issues/1321> for more details.

• to_opflow() returns a correct operator when coefficients are complex numbers. #1381 <https://github.com/Qiskit/qiskit-aqua/issues/1381> for more details.

• Let backend simulators validate NoiseModel support instead of restricting to Aer only in QuantumInstance.

• Correctly handle PassManager on QuantumInstance transpile method by calling its run method if it exists.

• A bug that mixes custom initial_state in QAOA with Hadamard gates has been fixed. This doesn’t change functionality of QAOA if no initial_state is provided by the user. Attention should be taken if your implementation uses QAOA with cusom initial_state parameter as the optimization results might differ.

• Previously, setting seed_simulator=0 in the QuantumInstance did not set any seed. This was only affecting the value 0. This has been fixed.

#### IBM Q Provider 0.11.1¶

##### Bug Fixes¶
• Fixes the issue wherein a job could be left in the CREATING state if job submit fails half-way through.

• Fixes the infinite loop raised when passing an IBMQRandomService instance to a child process.

### Qiskit 0.23.0¶

#### Terra 0.16.0¶

##### Prelude¶

The 0.16.0 release includes several new features and bug fixes. The major features in this release are the following:

• Introduction of scheduled circuits, where delays can be used to control the timing and alignment of operations in the circuit.

• Compilation of quantum circuits from classical functions, such as oracles.

• Ability to compile and optimize single qubit rotations over different Euler basis as well as the phase + square-root(X) basis (i.e. ['p', 'sx']), which will replace the older IBM Quantum basis of ['u1', 'u2', 'u3'].

• Tracking of global_phase() on the QuantumCircuit class has been extended through the transpiler, quantum_info, and assembler modules, as well as the BasicAer and Aer simulators. Unitary and state vector simulations will now return global phase-correct unitary matrices and state vectors.

Also of particular importance for this release is that Python 3.5 is no longer supported. If you are using Qiskit Terra with Python 3.5, the 0.15.2 release is that last version which will work.

##### New Features¶
• Global R gates have been added to qiskit.circuit.library. This includes the global R gate (GR), global Rx (GRX) and global Ry (GRY) gates which are derived from the GR gate, and global Rz ( GRZ) that is defined in a similar way to the GR gates. The global R gates are defined on a number of qubits simultaneously, and act as a direct sum of R gates on each qubit.

For example:

from qiskit import QuantumCircuit, QuantumRegister
import numpy as np

num_qubits = 3
qr = QuantumRegister(num_qubits)
qc = QuantumCircuit(qr)

qc.compose(GR(num_qubits, theta=np.pi/3, phi=2*np.pi/3), inplace=True)


will create a QuantumCircuit on a QuantumRegister of 3 qubits and perform a RGate of an angle $$\theta = \frac{\pi}{3}$$ about an axis in the xy-plane of the Bloch spheres that makes an angle of $$\phi = \frac{2\pi}{3}$$ with the x-axis on each qubit.

• A new color scheme, iqx, has been added to the mpl backend for the circuit drawer qiskit.visualization.circuit_drawer() and qiskit.circuit.QuantumCircuit.draw(). This uses the same color scheme as the Circuit Composer on the IBM Quantum Experience website. There are now 3 available color schemes - default, iqx, and bw.

There are two ways to select a color scheme. The first is to use a user config file, by default in the ~/.qiskit directory, in the file settings.conf under the [Default] heading, a user can enter circuit_mpl_style = iqx to select the iqx color scheme.

The second way is to add {'name': 'iqx'} to the style kwarg to the QuantumCircuit.draw method or to the circuit_drawer function. The second way will override the setting in the settings.conf file. For example:

from qiskit.circuit import QuantumCircuit

circuit = QuantumCircuit(2)
circuit.h(0)
circuit.cx(0, 1)
circuit.measure_all()
circuit.draw('mpl', style={'name': 'iqx'})

• In the style kwarg for the the circuit drawer qiskit.visualization.circuit_drawer() and qiskit.circuit.QuantumCircuit.draw() the displaycolor field with the mpl backend now allows for entering both the gate color and the text color for each gate type in the form (gate_color, text_color). This allows the use of light and dark gate colors with contrasting text colors. Users can still set only the gate color, in which case the gatetextcolor field will be used. Gate colors can be set in the style dict for any number of gate types, from one to the entire displaycolor dict. For example:

from qiskit.circuit import QuantumCircuit

circuit = QuantumCircuit(1)
circuit.h(0)

style_dict = {'displaycolor': {'h': ('#FA74A6', '#000000')}}
circuit.draw('mpl', style=style_dict)


or

style_dict = {'displaycolor': {'h': '#FA74A6'}}
circuit.draw('mpl', style=style_dict)

• Two alignment contexts are added to the pulse builder (qiskit.pulse.builder) to facilitate writing a repeated pulse sequence with delays.

• A rep_delay parameter has been added to the QasmQobj class under the run configuration, QasmQobjConfig. This parameter is used to denote the time between program executions. It must be chosen from the backend range given by the BackendConfiguration method rep_delay_range(). If a value is not provided a backend default, qiskit.providers.models.BackendConfiguration.default_rep_delay, will be used. rep_delay will only work on backends which allow for dynamic repetition time. This is can be checked with the BackendConfiguration property dynamic_reprate_enabled.

• The qobj_schema.json JSON Schema file in qiskit.schemas has been updated to include the rep_delay as an optional configuration property for QASM Qobjs.

• The backend_configuration_schema.json JSON Schema file in qiskit.schemas has been updated to include dynamic_reprate_enabled, rep_delay_range and default_rep_delay as optional properties for a QASM backend configuration payload.

• A new optimization pass, qiskit.transpiler.passes.TemplateOptimization has been added to the transpiler. This pass applies a template matching algorithm described in arXiv:1909.05270 that replaces all compatible maximal matches in the circuit.

To implement this new transpiler pass a new module, template_circuits, was added to the circuit library (qiskit.circuit.library). This new module contains all the Toffoli circuit templates used in the TemplateOptimization.

This new pass is not currently included in the preset pass managers (qiskit.transpiler.preset_passmanagers), to use it you will need to create a custom PassManager.

• A new version of the providers interface has been added. This new interface, which can be found in qiskit.providers, provides a new versioning mechanism that will enable changes to the interface to happen in a compatible manner over time. The new interface should be simple to migrate existing providers, as it is mostly identical except for the explicit versioning.

Besides having explicitly versioned abstract classes the key changes for the new interface are that the BackendV1 method run() can now take a QuantumCircuit or Schedule object as inputs instead of Qobj objects. To go along with that options are now part of a backend class so that users can configure run time options when running with a circuit. The final change is that qiskit.providers.JobV1 can now be synchronous or asynchronous, the exact configuration and method for configuring this is up to the provider, but there are interface hook points to make it explicit which execution model a job is running under in the JobV1 abstract class.

• A new kwarg, inplace, has been added to the function qiskit.result.marginal_counts(). This kwarg is used to control whether the contents are marginalized in place or a new copy is returned, for Result object input. This parameter does not have any effect for an input dict or Counts object.

• An initial version of a classical function compiler, qiskit.circuit.classicalfunction, has been added. This enables compiling typed python functions (operating only on bits of type Int1 at the moment) into QuantumCircuit objects. For example:

from qiskit.circuit import classical_function, Int1

@classical_function
def grover_oracle(a: Int1, b: Int1, c: Int1, d: Int1) -> Int1:
x = not a and b
y = d and not c
z = not x or y
return z

quantum_circuit = grover_oracle.synth()
quantum_circuit.draw()


q_0: ──■────o────■─────────■───────
│    │    │         │
q_1: ──o────┼────┼────■────o────■──
│    │    │    │    │    │
q_2: ──┼────┼────o────■────■────┼──
│    │    │    │    │    │
q_3: ──o────┼────■────■────■────o──
┌─┴─┐┌─┴─┐┌─┴─┐┌─┴─┐┌─┴─┐┌─┴─┐
q_4: ┤ X ├┤ X ├┤ X ├┤ X ├┤ X ├┤ X ├
└───┘└───┘└───┘└───┘└───┘└───┘

The parameter registerless=False in the qiskit.circuit.classicalfunction.ClassicalFunction method synth() creates a circuit with registers refering to the parameter names. For example:

quantum_circuit = grover_oracle.synth(registerless=False)
quantum_circuit.draw()


d_0: ──■────o────■─────────■───────
│    │    │         │
c_0: ──o────┼────┼────■────o────■──
│    │    │    │    │    │
b_0: ──┼────┼────o────■────■────┼──
│    │    │    │    │    │
a_0: ──o────┼────■────■────■────o──
┌─┴─┐┌─┴─┐┌─┴─┐┌─┴─┐┌─┴─┐┌─┴─┐
return_0: ┤ X ├┤ X ├┤ X ├┤ X ├┤ X ├┤ X ├
└───┘└───┘└───┘└───┘└───┘└───┘

A decorated classical function can be used the same way as any other quantum gate when appending it to a circuit.

circuit = QuantumCircuit(5)
circuit.append(grover_oracle, range(5))
circuit.draw()

     ┌────────────────┐
q_0: ┤0               ├
│                │
q_1: ┤1               ├
│                │
q_2: ┤2 Grover_oracle ├
│                │
q_3: ┤3               ├
│                │
q_4: ┤4               ├
└────────────────┘

The GROVER_ORACLE gate is synthesized when its decomposition is required.

circuit.decompose().draw()


q_0: ──■────o────■─────────■───────
│    │    │         │
q_1: ──o────┼────┼────■────o────■──
│    │    │    │    │    │
q_2: ──┼────┼────o────■────■────┼──
│    │    │    │    │    │
q_3: ──o────┼────■────■────■────o──
┌─┴─┐┌─┴─┐┌─┴─┐┌─┴─┐┌─┴─┐┌─┴─┐
q_4: ┤ X ├┤ X ├┤ X ├┤ X ├┤ X ├┤ X ├
└───┘└───┘└───┘└───┘└───┘└───┘

The feature requires tweedledum, a library for synthesizing quantum circuits, that can be installed via pip with pip install tweedledum.

• A new class qiskit.circuit.Delay for representing a delay instruction in a circuit has been added. A new method delay() is now available for easily appending delays to circuits. This makes it possible to describe timing-sensitive experiments (e.g. T1/T2 experiment) in the circuit level.

from qiskit import QuantumCircuit

qc = QuantumCircuit(1, 1)
qc.delay(500, 0, unit='ns')
qc.measure(0, 0)

qc.draw()

     ┌────────────────┐┌─┐
q_0: ┤ Delay(500[ns]) ├┤M├
└────────────────┘└╥┘
c: 1/═══════════════════╩═
0 
• A new argument scheduling_method for qiskit.compiler.transpile() has been added. It is required when transpiling circuits with delays. If scheduling_method is specified, the transpiler returns a scheduled circuit such that all idle times in it are padded with delays (i.e. start time of each instruction is uniquely determined). This makes it possible to see how scheduled instructions (gates) look in the circuit level.

from qiskit import QuantumCircuit, transpile
from qiskit.test.mock.backends import FakeAthens

qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)

scheduled_circuit = transpile(qc, backend=FakeAthens(), scheduling_method="alap")
print("Duration in dt:", scheduled_circuit.duration)
scheduled_circuit.draw(idle_wires=False)

Duration in dt: 2016

            ┌─────────┐    ┌────┐┌─────────┐
q_0 -> 0 ───┤ Rz(π/2) ├────┤ √X ├┤ Rz(π/2) ├──■──
┌──┴─────────┴───┐└────┘└─────────┘┌─┴─┐
q_1 -> 1 ┤ Delay(160[dt]) ├─────────────────┤ X ├
└────────────────┘                 └───┘

See also timeline_drawer() for the best visualization of scheduled circuits.

• A new fuction qiskit.compiler.sequence() has been also added so that we can convert a scheduled circuit into a Schedule to make it executable on a pulse-enabled backend.

from qiskit.compiler import sequence

sched = sequence(scheduled_circuit, pulse_enabled_backend)

• The schedule() has been updated so that it can schedule circuits with delays. Now there are two paths to schedule a circuit with delay:

qc = QuantumCircuit(1, 1)
qc.h(0)
qc.delay(500, 0, unit='ns')
qc.h(0)
qc.measure(0, 0)

sched_path1 = schedule(qc.decompose(), backend)
sched_path2 = sequence(transpile(qc, backend, scheduling_method='alap'), backend)


Refer to the release notes and documentation for transpile() and sequence() for the details on the other path.

• Added the GroverOperator to the circuit library (qiskit.circuit.library) to construct the Grover operator used in Grover’s search algorithm and Quantum Amplitude Amplification/Estimation. Provided with an oracle in form of a circuit, GroverOperator creates the textbook Grover operator. To generalize this for amplitude amplification and use a generic operator instead of Hadamard gates as state preparation, the state_in argument can be used.

• The InstructionScheduleMap methods get() and pop() methods now take ParameterExpression instances in addition to numerical values for schedule generator parameters. If the generator is a function, expressions may be bound before or within the function call. If the generator is a ParametrizedSchedule, expressions must be bound before the schedule itself is bound/called.

• A new class LinearAmplitudeFunction was added to the circuit library (qiskit.circuit.library) for mapping (piecewise) linear functions on qubit amplitudes,

$F|x\rangle |0\rangle = \sqrt{1 - f(x)}|x\rangle |0\rangle + \sqrt{f(x)}|x\rangle |1\rangle$

The mapping is based on a controlled Pauli Y-rotations and a Taylor approximation, as described in https://arxiv.org/abs/1806.06893. This circuit can be used to compute expectation values of linear functions using the quantum amplitude estimation algorithm.

• The new jupyter magic monospaced_output has been added to the qiskit.tools.jupyter module. This magic sets the Jupyter notebook output font to “Courier New”, when possible. When used this fonts returns text circuit drawings that are better aligned.

import qiskit.tools.jupyter
%monospaced_output

• A new transpiler pass, Optimize1qGatesDecomposition, has been added. This transpiler pass is an alternative to the existing Optimize1qGates that uses the OneQubitEulerDecomposer class to decompose and simplify a chain of single qubit gates. This method is compatible with any basis set, while Optimize1qGates only works for u1, u2, and u3. The default pass managers for optimization_level 1, 2, and 3 have been updated to use this new pass if the basis set doesn’t include u1, u2, or u3.

• The OneQubitEulerDecomposer now supports two new basis, 'PSX' and 'U'. These can be specified with the basis kwarg on the constructor. This will decompose the matrix into a circuit using PGate and SXGate for 'PSX', and UGate for 'U'.

• A new method remove() has been added to the qiskit.transpiler.PassManager class. This method enables removing a pass from a PassManager instance. It works on indexes, similar to replace(). For example, to remove the RemoveResetInZeroState pass from the pass manager used at optimization level 1:

from qiskit.transpiler.preset_passmanagers import level_1_pass_manager
from qiskit.transpiler.passmanager_config import PassManagerConfig

pm = level_1_pass_manager(PassManagerConfig())
pm.draw()

[0] FlowLinear: UnrollCustomDefinitions, BasisTranslator
[1] FlowLinear: RemoveResetInZeroState
[2] DoWhile: Depth, FixedPoint, Optimize1qGates, CXCancellation


The stage [1] with RemoveResetInZeroState can be removed like this:

pass_manager.remove(1)
pass_manager.draw()

[0] FlowLinear: UnrollCustomDefinitions, BasisTranslator
[1] DoWhile: Depth, FixedPoint, Optimize1qGates, CXCancellation

• Several classes to load probability distributions into qubit amplitudes; UniformDistribution, NormalDistribution, and LogNormalDistribution were added to the circuit library (qiskit.circuit.library). The normal and log-normal distribution support both univariate and multivariate distributions. These circuits are central to applications in finance where quantum amplitude estimation is used.

• Support for pulse gates has been added to the QuantumCircuit class. This enables a QuantumCircuit to override (for basis gates) or specify (for standard and custom gates) a definition of a Gate operation in terms of time-ordered signals across hardware channels. In other words, it enables the option to provide pulse-level custom gate calibrations.

The circuits are built exactly as before. For example:

from qiskit import pulse
from qiskit.circuit import QuantumCircuit, Gate

class RxGate(Gate):
def __init__(self, theta):
super().__init__('rxtheta', 1, [theta])

circ = QuantumCircuit(1)
circ.h(0)
circ.append(RxGate(3.14), [0])


Then, the calibration for the gate can be registered using the QuantumCircuit method add_calibration() which takes a Schedule definition as well as the qubits and parameters that it is defined for:

# Define the gate implementation as a schedule
with pulse.build() as custom_h_schedule:
pulse.play(pulse.library.Drag(...), pulse.DriveChannel(0))

with pulse.build() as q1_x180:
pulse.play(pulse.library.Gaussian(...), pulse.DriveChannel(1))

# Register the schedule to the gate
circ.add_calibration('h', [0], custom_h_schedule)  # or gate.name string to register
circ.add_calibration(RxGate(3.14), [0], q1_x180)   # Can accept gate


Previously, this functionality could only be used through complete Pulse Schedules. Additionally, circuits can now be submitted to backends with your custom definitions (dependent on backend support).

Circuits with pulse gates can still be lowered to a Schedule by using the schedule() function.

The calibrated gate can also be transpiled using the regular transpilation process:

transpiled_circuit = transpile(circ, backend)


The transpiled circuit will leave the calibrated gates on the same qubit as the original circuit and will not unroll them to the basis gates.

• Support for disassembly of PulseQobj objects has been added to the qiskit.assembler.disassemble() function. For example:

from qiskit import pulse
from qiskit.assembler.disassemble import disassemble
from qiskit.compiler.assemble import assemble
from qiskit.test.mock import FakeOpenPulse2Q

backend = FakeOpenPulse2Q()

d0 = pulse.DriveChannel(0)
d1 = pulse.DriveChannel(1)
with pulse.build(backend) as sched:
with pulse.align_right():
pulse.play(pulse.library.Constant(10, 1.0), d0)
pulse.shift_phase(3.11, d0)
pulse.measure_all()

qobj = assemble(sched, backend=backend, shots=512)

• A new kwarg, coord_type has been added to qiskit.visualization.plot_bloch_vector(). This kwarg enables changing the coordinate system used for the input parameter that describes the positioning of the vector on the Bloch sphere in the generated visualization. There are 2 supported values for this new kwarg, 'cartesian' (the default value) and 'spherical'. If the coord_type kwarg is set to 'spherical' the list of parameters taken in are of the form [r, theta,  phi] where r is the radius, theta is the inclination from +z direction, and phi is the azimuth from +x direction. For example:

from numpy import pi

from qiskit.visualization import plot_bloch_vector

x = 0
y = 0
z = 1
r = 1
theta = pi
phi = 0

# Cartesian coordinates, where (x,y,z) are cartesian coordinates
# for bloch vector
plot_bloch_vector([x,y,z])

plot_bloch_vector([x,y,z], coord_type="cartesian")  # Same as line above

# Spherical coordinates, where (r,theta,phi) are spherical coordinates
# for bloch vector
plot_bloch_vector([r, theta, phi], coord_type="spherical")

• Pulse Schedule objects now support using ParameterExpression objects for parameters.

For example:

from qiskit.circuit import Parameter
from qiskit import pulse

alpha = Parameter('⍺')
phi = Parameter('ϕ')
qubit = Parameter('q')
amp = Parameter('amp')

schedule = pulse.Schedule()
schedule += SetFrequency(alpha, DriveChannel(qubit))
schedule += ShiftPhase(phi, DriveChannel(qubit))
schedule += Play(Gaussian(duration=128, sigma=4, amp=amp),
DriveChannel(qubit))
schedule += ShiftPhase(-phi, DriveChannel(qubit))


Parameter assignment is done via the assign_parameters() method:

schedule.assign_parameters({alpha: 4.5e9, phi: 1.57,
qubit: 0, amp: 0.2})


Expressions and partial assignment also work, such as:

beta = Parameter('b')
schedule += SetFrequency(alpha + beta, DriveChannel(0))
schedule.assign_parameters({alpha: 4.5e9})
schedule.assign_parameters({beta: phi / 6.28})

• A new visualization function timeline_drawer() was added to the qiskit.visualization module.

For example:

from qiskit.visualization import timeline_drawer
from qiskit import QuantumCircuit, transpile
from qiskit.test.mock import FakeAthens

qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0,1)
timeline_drawer(transpile(qc, FakeAthens(), scheduling_method='alap'))

• Type checking for the params kwarg of the constructor for the Gate class and its subclasses has been changed. Previously all Gate parameters had to be in a set of allowed types defined in the Instruction class. Now a new method, validate_parameter() is used to determine if a parameter type is valid or not. The definition of this method in a subclass will take priority over its parent. For example, UnitaryGate accepts a parameter of the type numpy.ndarray and defines a custom validate_parameter() method that returns the parameter if it’s an numpy.ndarray. This takes priority over the function defined in its parent class Gate. If UnitaryGate were to be used as parent for a new class, this validate_parameter method would be used unless the new child class defines its own method.

• The previously deprecated methods, arguments, and properties named n_qubits and numberofqubits have been removed. These were deprecated in the 0.13.0 release. The full set of changes are:

Class

Old

New

QuantumCircuit

n_qubits

num_qubits

Pauli

numberofqubits

num_qubits

Function

Old Argument

New Argument

qiskit.circuit.random.random_circuit()

n_qubits

num_qubits

qiskit.circuit.library.MSGate

n_qubits

num_qubits

• Inserting a parameterized Gate instance into a QuantumCircuit now creates a copy of that gate which is used in the circuit. If changes are made to the instance inserted into the circuit it will no longer be reflected in the gate in the circuit. This change was made to fix an issue when inserting a single parameterized Gate object into multiple circuits.

• The function qiskit.result.marginal_counts() now, by default, does not modify the qiskit.result.Result instance parameter. Previously, the Result object was always modified in place. A new kwarg inplace has been added marginal_counts() which enables using the previous behavior when inplace=True is set.

• The U3Gate definition has been changed to be in terms of the UGate class. The UGate class has no definition. It is therefore not possible to unroll every circuit in terms of U3 and CX anymore. Instead, U and CX can be used for every circuit.

• The deprecated support for running Qiskit Terra with Python 3.5 has been removed. To use Qiskit Terra from this release onward you will now need to use at least Python 3.6. If you are using Python 3.5 the last version which will work is Qiskit Terra 0.15.2.

• In the PulseBackendConfiguration in the hamiltonian attributes the vars field is now returned in a unit of Hz instead of the previously used GHz. This change was made to be consistent with the units used with the other attributes in the class.

• The previously deprecated support for passing in a dictionary as the first positional argument to DAGNode constructor has been removed. Using a dictonary for the first positional argument was deprecated in the 0.13.0 release. To create a DAGNode object now you should directly pass the attributes as kwargs on the constructor.

• The keyword arguments for the circuit gate methods (for example: qiskit.circuit.QuantumCircuit.cx) q, ctl*, and tgt*, which were deprecated in the 0.12.0 release, have been removed. Instead, only qubit, control_qubit* and target_qubit* can be used as named arguments for these methods.

• The previously deprecated module qiskit.extensions.standard has been removed. This module has been deprecated since the 0.14.0 release. The qiskit.circuit.library can be used instead. Additionally, all the gate classes previously in qiskit.extensions.standard are still importable from qiskit.extensions.

• The previously deprecated gates in the module qiskit.extensions.quantum_initializer: DiagGate, UCG, UCPauliRotGate, UCRot, UCRXGate, UCX, UCRYGate, UCY, UCRZGate, UCZ have been removed. These were all deprecated in the 0.14.0 release and have alternatives available in the circuit library (qiskit.circuit.library).

• The previously deprecated qiskit.circuit.QuantumCircuit gate method iden() has been removed. This was deprecated in the 0.13.0 release and i() or id() can be used instead.

#### Aer 0.7.0¶

##### Prelude¶

This 0.7.0 release includes numerous performance improvements and significant enhancements to the simulator interface, and drops support for Python 3.5. The main interface changes are configurable simulator backends, and constructing preconfigured simulators from IBMQ backends. Noise model an basis gate support has also been extended for most of the Qiskit circuit library standard gates, including new support for 1 and 2-qubit rotation gates. Performance improvements include adding SIMD support to the density matrix and unitary simulation methods, reducing the used memory and improving the performance of circuits using statevector and density matrix snapshots, and adding support for Kraus instructions to the gate fusion circuit optimization for greatly improving the performance of noisy statevector simulations.

##### New Features¶
• AER now uses Lapack to perform some matrix related computations. It uses the Lapack library bundled with OpenBlas (already available in Linux and Macos typical OpenBlas dsitributions; Windows version distributed with AER) or with the accelerate framework in MacOS.

• The deprecated support for running qiskit-aer with Python 3.5 has been removed. To use qiskit-aer >=0.7.0 you will now need at least Python 3.6. If you are using Python 3.5 the last version which will work is qiskit-aer 0.6.x.

• Updates gate fusion default thresholds so that gate fusion will be applied to circuits with of more than 14 qubits for statevector simulations on the StatevectorSimulator and QasmSimulator.

For the "density_matrix" method of the QasmSimulator and for the UnitarySimulator gate fusion will be applied to circuits with more than 7 qubits.

Custom qubit threshold values can be set using the fusion_threshold backend option ie backend.set_options(fusion_threshold=10)

• Changes fusion_threshold backend option to apply fusion when the number of qubits is above the threshold, not equal or above the threshold, to match the behavior of the OpenMP qubit threshold parameter.

##### Deprecation Notes¶
• qiskit.providers.aer.noise.NoiseModel.set_x90_single_qubit_gates() has been deprecated as unrolling to custom basis gates has been added to the qiskit transpiler. The correct way to use an X90 based noise model is to define noise on the Sqrt(X) "sx" or "rx" gate and one of the single-qubit phase gates "u1", "rx", or "p" in the noise model.

• The variance kwarg of Snapshot instructions has been deprecated. This function computed the sample variance in the snapshot due to noise model sampling, not the variance due to measurement statistics so was often being used incorrectly. If noise modeling variance is required single shot snapshots should be used so variance can be computed manually in post-processing.

##### Bug Fixes¶
• Fixes bug in the StatevectorSimulator that caused it to always run as CPU with double-precision without SIMD/AVX2 support even on systems with AVX2, or when single-precision or the GPU method was specified in the backend options.

• Fixes some for-loops in C++ code that were iterating over copies rather than references of container elements.

• Fixes a bug where snapshot data was always copied from C++ to Python rather than moved where possible. This will halve memory usage and improve simulation time when using large statevector or density matrix snapshots.

• Fix State::snapshot_pauli_expval to return correct Y expectation value in stabilizer simulator. Refer to #895 <https://github.com/Qiskit/qiskit-aer/issues/895> for more details.

• The controller_execute wrappers have been adjusted to be functors (objects) rather than free functions. Among other things, this allows them to be used in multiprocessing.pool.map calls.

• Add missing available memory checks for the StatevectorSimulator and UnitarySimulator. This throws an exception if the memory required to simulate the number of qubits in a circuit exceeds the available memory of the system.

#### Ignis 0.5.0¶

##### Prelude¶

This release includes a new module for expectation value measurement error mitigation, improved plotting functionality for quantum volume experiments, several bug fixes, and drops support for Python 3.5.

##### New Features¶
• The qiskit.ignis.verification.randomized_benchmarking.randomized_benchmarking_seq() function allows an optional input of gate objects as interleaved_elem. In addition, the CNOT-Dihedral class qiskit.ignis.verification.randomized_benchmarking.CNOTDihedral has a new method to_instruction, and the existing from_circuit method has an optional input of an Instruction (in addition to QuantumCircuit).

• The qiskit.ignis.verification.randomized_benchmarking.CNOTDihedral now contains the following new features. Initialization from various types of objects: CNOTDihedral, ScalarOp, QuantumCircuit, Instruction and Pauli. Converting to a matrix using to_matrix and to an operator using to_operator. Tensor product methods tensor and expand. Calculation of the adjoint, conjugate and transpose using conjugate, adjoint and transpose methods. Verify that an element is CNOTDihedral using is_cnotdihedral method. Decomposition method to_circuit of a CNOTDihedral element into a circuit was extended to allow any number of qubits, based on the function decompose_cnotdihedral_general.

• Adds expectation value measurement error mitigation to the mitigation module. This supports using complete N-qubit assignment matrix, single-qubit tensored assignment matrix, or continuous time Markov process (CTMP) [1] measurement error mitigation when computing expectation values of diagonal operators from counts dictionaries. Expectation values are computed using the using the qiskit.ignis.mitigation.expectation_value() function.

Calibration circuits for calibrating a measurement error mitigator are generated using the qiskit.ignis.mitigation.expval_meas_mitigator_circuits() function, and the result fitted using the qiskit.ignis.mitigation.ExpvalMeasMitigatorFitter class. The fitter returns a mitigator object can the be supplied as an argument to the expectation_value() function to apply mitigation.

[1] S Bravyi, S Sheldon, A Kandala, DC Mckay, JM Gambetta,

Mitigating measurement errors in multi-qubit experiments, arXiv:2006.14044 [quant-ph].

Example:

The following example shows calibrating a 5-qubit expectation value measurement error mitigator using the 'tensored' method.

from qiskit import execute
from qiskit.test.mock import FakeVigo
import qiskit.ignis.mitigation as mit

backend = FakeVigo()
num_qubits = backend.configuration().num_qubits

# Generate calibration circuits
num_qubits, method='tensored')
result = execute(circuits, backend, shots=8192).result()

# Fit mitigator

# Plot fitted N-qubit assignment matrix
mitigator.plot_assignment_matrix()

<matplotlib.axes._subplots.AxesSubplot at 0x7f674a6f7790>


The following shows how to use the above mitigator to apply measurement error mitigation to expectation value computations

from qiskit import QuantumCircuit

# Test Circuit with expectation value -1.
qc = QuantumCircuit(num_qubits)
qc.x(range(num_qubits))
qc.measure_all()

# Execute
shots = 8192
seed_simulator = 1999
result = execute(qc, backend, shots=8192, seed_simulator=1999).result()
counts = result.get_counts(0)

# Expectation value of Z^N without mitigation
expval_nomit, error_nomit = mit.expectation_value(counts)
print('Expval (no mitigation): {:.2f} \u00B1 {:.2f}'.format(
expval_nomit, error_nomit))

# Expectation value of Z^N with mitigation
expval_mit, error_mit = mit.expectation_value(counts,
meas_mitigator=mitigator)
print('Expval (with mitigation): {:.2f} \u00B1 {:.2f}'.format(
expval_mit, error_mit))

Expval (no mitigation): -0.65 ± 0.02
Expval (with mitigation): -1.00 ± 0.04

• Adds Numba as an optional dependency. Numba is used to significantly increase the performance of the qiskit.ignis.mitigation.CTMPExpvalMeasMitigator class used for expectation value measurement error mitigation with the CTMP method.

• Add two methods to qiskit.ignis.verification.quantum_volume.QVFitter.

• qiskit.ignis.verification.quantum_volume.QVFitter.calc_z_value() to calculate z value in standard normal distribution using mean and standard deviation sigma. If sigma = 0, it raises a warning and assigns a small value (1e-10) for sigma so that the code still runs.

• qiskit.ignis.verification.quantum_volume.QVFitter.calc_confidence_level() to calculate confidence level using z value.

• Store confidence level even when hmean < 2/3 in qiskit.ignis.verification.quantum_volume.QVFitter.qv_success().

• Add explanations for how to calculate statistics based on binomial distribution in qiskit.ignis.verification.quantum_volume.QVFitter.calc_statistics().

• The qiskit.ignis.verification.QVFitter method plot_qv_data() has been updated to return a matplotlib.Figure object. Previously, it would not return anything. By returning a figure this makes it easier to integrate the visualizations into a larger matplotlib workflow.

• The error bars in the figure produced by the qiskit.ignis.verification.QVFitter method qiskit.ignis.verification.QVFitter.plot_qv_data() has been updated to represent two-sigma confidence intervals. Previously, the error bars represent one-sigma confidence intervals. The success criteria of Quantum Volume benchmarking requires heavy output probability > 2/3 with one-sided two-sigma confidence (~97.7%). Changing error bars to represent two-sigma confidence intervals allows easily identification of success in the figure.

• A new kwarg, figsize has been added to the qiskit.ignis.verification.QVFitter method qiskit.ignis.verification.QVFitter.plot_qv_data(). This kwarg takes in a tuple of the form (x, y) where x and y are the dimension in inches to make the generated plot.

• The qiskit.ignis.verification.quantum_volume.QVFitter.plot_hop_accumulative() method has been added to plot heavy output probability (HOP) vs number of trials similar to Figure 2a of Quantum Volume 64 paper (arXiv:2008.08571). HOP of individual trials are plotted as scatters and cummulative HOP are plotted in red line. Two-sigma confidence intervals are plotted as shaded area and 2/3 success threshold is plotted as dashed line.

• The qiskit.ignis.verification.quantum_volume.QVFitter.plot_qv_trial() method has been added to plot individual trials, leveraging on the qiskit.visualization.plot_histogram() method from Qiskit Terra. Bitstring counts are plotted as overlapping histograms for ideal (hollow) and experimental (filled) values. Experimental heavy output probability are shown on the legend. Median probability is plotted as red dashed line.

• The deprecated support for running qiskit-ignis with Python 3.5 has been removed. To use qiskit-ignis >=0.5.0 you will now need at least Python 3.6. If you are using Python 3.5 the last version which will work is qiskit-ignis 0.4.x.

##### Bug Fixes¶
• Fixing a bug in the class qiskit.ignis.verification.randomized_benchmarking.CNOTDihedral for elements with more than 5 quits.

• Fix the confidence level threshold for qiskit.ignis.verification.quantum_volume.QVFitter.qv_success() to 0.977 corresponding to z = 2 as defined by the QV paper Algorithm 1.

• Fix a bug at qiskit.ignis.verification.randomized_benchmarking.randomized_benchmarking_seq() which caused all the subsystems with the same size in the given rb_pattern to have the same gates when a ‘rand_seed’ parameter was given to the function.

#### Aqua 0.8.0¶

##### Prelude¶

This release introduces an interface for running the available methods for Bosonic problems. In particular we introduced a full interface for running vibronic structure calculations.

This release introduces an interface for excited states calculations. It is now easier for the user to create a general excited states calculation. This calculation is based on a Driver which provides the relevant information about the molecule, a Transformation which provides the information about the mapping of the problem into a qubit Hamiltonian, and finally a Solver. The Solver is the specific way which the excited states calculation is done (the algorithm). This structure follows the one of the ground state calculations. The results are modified to take lists of expectation values instead of a single one. The QEOM and NumpyEigensolver are adapted to the new structure. A factory is introduced to run a numpy eigensolver with a specific filter (to target states of specific symmetries).

VQE expectation computation with Aer qasm_simulator now defaults to a computation that has the expected shot noise behavior.

##### New Features¶
• Introduced an option warm_start that should be used when tuning other options does not help. When this option is enabled, a relaxed problem (all variables are continuous) is solved first and the solution is used to initialize the state of the optimizer before it starts the iterative process in the solve method.

• The amplitude estimation algorithms now use QuantumCircuit objects as inputs to specify the A- and Q operators. This change goes along with the introduction of the GroverOperator in the circuit library, which allows an intuitive and fast construction of different Q operators. For example, a Bernoulli-experiment can now be constructed as

import numpy as np
from qiskit import QuantumCircuit
from qiskit.aqua.algorithms import AmplitudeEstimation

probability = 0.5
angle = 2 * np.sqrt(np.arcsin(probability))
a_operator = QuantumCircuit(1)
a_operator.ry(angle, 0)

# construct directly
q_operator = QuantumCircuit(1)
q_operator.ry(2 * angle, 0)

# construct via Grover operator
from qiskit.circuit.library import GroverOperator
oracle = QuantumCircuit(1)
oracle.z(0)  # good state = the qubit is in state |1>
q_operator = GroverOperator(oracle, state_preparation=a_operator)

# use default construction in QAE
q_operator = None

ae = AmplitudeEstimation(a_operator, q_operator)

• Add the possibility to compute Conditional Value at Risk (CVaR) expectation values.

Given a diagonal observable H, often corresponding to the objective function of an optimization problem, we are often not as interested in minimizing the average energy of our observed measurements. In this context, we are satisfied if at least some of our measurements achieve low energy. (Note that this is emphatically not the case for chemistry problems).

To this end, one might consider using the best observed sample as a cost function during variational optimization. The issue here, is that this can result in a non-smooth optimization surface. To resolve this issue, we can smooth the optimization surface by using not just the best observed sample, but instead average over some fraction of best observed samples. This is exactly what the CVaR estimator accomplishes [1].

Let $$\alpha$$ be a real number in $$[0,1]$$ which specifies the fraction of best observed samples which are used to compute the objective function. Observe that if $$\alpha = 1$$, CVaR is equivalent to a standard expectation value. Similarly, if $$\alpha = 0$$, then CVaR corresponds to using the best observed sample. Intermediate values of $$\alpha$$ interpolate between these two objective functions.

The functionality to use CVaR is included into the operator flow through a new subclass of OperatorStateFn called CVaRMeasurement. This new StateFn object is instantied in the same way as an OperatorMeasurement with the exception that it also accepts an alpha parameter and that it automatically enforces the is_measurement attribute to be True. Observe that it is unclear what a CVaRStateFn would represent were it not a measurement.

Examples:

qc = QuantumCircuit(1)
qc.h(0)
op = CVaRMeasurement(Z, alpha=0.5) @ CircuitStateFn(primitive=qc, coeff=1.0)
result = op.eval()


Similarly, an operator corresponding to a standard expectation value can be converted into a CVaR expectation using the CVaRExpectation converter.

Examples:

qc = QuantumCircuit(1)
qc.h(0)
op = ~StateFn(Z) @ CircuitStateFn(primitive=qc, coeff=1.0)
cvar_expecation = CVaRExpectation(alpha=0.1).convert(op)
result = cvar_expecation.eval()


See [1] for additional details regarding this technique and it’s empircal performance.

References:

[1]: Barkoutsos, P. K., Nannicini, G., Robert, A., Tavernelli, I., and Woerner, S.,

“Improving Variational Quantum Optimization using CVaR” arXiv:1907.04769

• New interface Eigensolver for Eigensolver algorithms.

• An interface for excited states calculation has been added to the chemistry module. It is now easier for the user to create a general excited states calculation. This calculation is based on a Driver which provides the relevant information about the molecule, a Transformation which provides the information about the mapping of the problem into a qubit Hamiltonian, and finally a Solver. The Solver is the specific way which the excited states calculation is done (the algorithm). This structure follows the one of the ground state calculations. The results are modified to take lists of expectation values instead of a single one. The QEOM and NumpyEigensolver are adapted to the new structure. A factory is introduced to run a numpy eigensolver with a specific filter (to target states of specific symmetries).

• In addition to the workflows for solving Fermionic problems, interfaces for calculating Bosonic ground and excited states have been added. In particular we introduced a full interface for running vibronic structure calculations.

• The OrbitalOptimizationVQE has been added as new ground state solver in the chemistry module. This solver allows for the simulatneous optimization of the variational parameters and the orbitals of the molecule. The algorithm is introduced in Sokolov et al., The Journal of Chemical Physics 152 (12).

• A new algorithm has been added: the Born Openheimer Potential Energy surface for the calculation of potential energy surface along different degrees of freedom of the molecule. The algorithm is called BOPESSampler. It further provides functionalities of fitting the potential energy surface to an analytic function of predefined potentials.

• A feasibility check of the obtained solution has been added to all optimizers in the optimization stack. This has been implemented by adding two new methods to QuadraticProgram: * get_feasibility_info(self, x: Union[List[float], np.ndarray]) accepts an array and returns whether this solution is feasible and a list of violated variables(violated bounds) and a list of violated constraints. * is_feasible(self, x: Union[List[float], np.ndarray]) accepts an array and returns whether this solution is feasible or not.

• Add circuit-based versions of FixedIncomeExpectedValue, EuropeanCallDelta, GaussianConditionalIndependenceModel and EuropeanCallExpectedValue to qiskit.finance.applications.

• Gradient Framework. qiskit.operators.gradients Given an operator that represents either a quantum state resp. an expectation value, the gradient framework enables the evaluation of gradients, natural gradients, Hessians, as well as the Quantum Fisher Information.

Suppose a parameterized quantum state |ψ(θ)〉 = V(θ)|ψ〉 with input state |ψ〉 and parametrized Ansatz V(θ), and an Operator O(ω).

Gradients: We want to compute $$d⟨ψ(θ)|O(ω)|ψ(θ)〉/ dω$$ resp. $$d⟨ψ(θ)|O(ω)|ψ(θ)〉/ dθ$$ resp. $$d⟨ψ(θ)|i〉⟨i|ψ(θ)〉/ dθ$$.

The last case corresponds to the gradient w.r.t. the sampling probabilities of |ψ(θ). These gradients can be computed with different methods, i.e. a parameter shift, a linear combination of unitaries and a finite difference method.

Examples:

x = Parameter('x')
ham = x * X
a = Parameter('a')

q = QuantumRegister(1)
qc = QuantumCircuit(q)
qc.h(q)
qc.p(params[0], q[0])
op = ~StateFn(ham) @ CircuitStateFn(primitive=qc, coeff=1.)

value_dict = {x: 0.1, a: np.pi / 4}

params=[a])


Hessians: We want to compute $$d^2⟨ψ(θ)|O(ω)|ψ(θ)〉/ dω^2$$ resp. $$d^2⟨ψ(θ)|O(ω)|ψ(θ)〉/ dθ^2$$ resp. $$d^2⟨ψ(θ)|O(ω)|ψ(θ)〉/ dθdω$$ resp. $$d^2⟨ψ(θ)|i〉⟨i|ψ(θ)〉/ dθ^2$$.

The last case corresponds to the Hessian w.r.t. the sampling probabilities of |ψ(θ). Just as the first order gradients, the Hessians can be evaluated with different methods, i.e. a parameter shift, a linear combination of unitaries and a finite difference method. Given a tuple of parameters Hessian().convert(op, param_tuple) returns the value for the second order derivative. If a list of parameters is given Hessian().convert(op, param_list) returns the full Hessian for all the given parameters according to the given parameter order.

QFI: The Quantum Fisher Information QFI is a metric tensor which is representative for the representation capacity of a parameterized quantum state |ψ(θ)〉 = V(θ)|ψ〉 generated by an input state |ψ〉 and a parametrized Ansatz V(θ). The entries of the QFI for a pure state read $$[QFI]kl= Re[〈∂kψ|∂lψ〉−〈∂kψ|ψ〉〈ψ|∂lψ〉] * 4$$.

Just as for the previous derivative types, the QFI can be computed using different methods: a full representation based on a linear combination of unitaries implementation, a block-diagonal and a diagonal representation based on an overlap method.

Examples:

q = QuantumRegister(1)
qc = QuantumCircuit(q)
qc.h(q)
qc.p(params[0], q[0])
op = ~StateFn(ham) @ CircuitStateFn(primitive=qc, coeff=1.)

value_dict = {x: 0.1, a: np.pi / 4}
qfi = QFI('lin_comb_full').convert(operator=CircuitStateFn(primitive=qc, coeff=1.), params=[a])
qfi.assign_parameters(value_dict).eval()


The combination of the QFI and the gradient lead to a special form of a gradient, namely

NaturalGradients: The natural gradient is a special gradient method which rescales a gradient w.r.t. a state parameter with the inverse of the corresponding Quantum Fisher Information (QFI) $$QFI^-1 d⟨ψ(θ)|O(ω)|ψ(θ)〉/ dθ$$. Hereby, we can choose a gradient as well as a QFI method and a regularization method which is used together with a least square solver instead of exact invertion of the QFI:

Examples:

op = ~StateFn(ham) @ CircuitStateFn(primitive=qc, coeff=1.)
regularization='ridge').convert(operator=op, params=params)


The gradient framework is also compatible with the optimizers from qiskit.aqua.components.optimizers. The derivative classes come with a gradient_wrapper() function which returns the corresponding callable.

• Introduces transformations for the fermionic and bosonic transformation of a problem instance. Transforms the fermionic operator to qubit operator. Respective class for the transformation is fermionic_transformation Introduces in algorithms ground_state_solvers for the calculation of ground state properties. The calculation can be done either using an MinimumEigensolver or using AdaptVQE Introduces chemistry/results where the eigenstate_result and the electronic_structure_result are also used for the algorithms. Introduces Minimum Eigensolver factories minimum_eigensolver_factories where chemistry specific minimum eigensolvers can be initialized Introduces orbital optimization vqe oovqe as a ground state solver for chemistry applications

• New Algorithm result classes:

Grover method _run() returns class GroverResult. AmplitudeEstimation method _run() returns class AmplitudeEstimationResult. IterativeAmplitudeEstimation method _run() returns class IterativeAmplitudeEstimationResult. MaximumLikelihoodAmplitudeEstimation method _run() returns class MaximumLikelihoodAmplitudeEstimationResult.

All new result classes are backwards compatible with previous result dictionary.

• New Linear Solver result classes:

HHL method _run() returns class HHLResult. NumPyLSsolver method _run() returns class NumPyLSsolverResult.

All new result classes are backwards compatible with previous result dictionary.

• MinimumEigenOptimizationResult now exposes properties: samples and eigensolver_result. The latter is obtained from the underlying algorithm used by the optimizer and specific to the algorithm. RecursiveMinimumEigenOptimizer now returns an instance of the result class RecursiveMinimumEigenOptimizationResult which in turn may contains intermediate results obtained from the underlying algorithms. The dedicated result class exposes properties replacements and history that are specific to this optimizer. The depth of the history is managed by the history parameter of the optimizer.

• GroverOptimizer now returns an instance of GroverOptimizationResult and this result class exposes properties operation_counts, n_input_qubits, and n_output_qubits directly. These properties are not available in the raw_results dictionary anymore.

• SlsqpOptimizer now returns an instance of SlsqpOptimizationResult and this result class exposes additional properties specific to the SLSQP implementation.

• Support passing QuantumCircuit objects as generator circuits into the QuantumGenerator.

• Removes the restriction to real input vectors in CircuitStateFn.from_vector. The method calls extensions.Initialize. The latter explicitly supports (in API and documentation) complex input vectors. So this restriction seems unnecessary.

• Simplified AbelianGrouper using a graph coloring algorithm of retworkx. It is faster than the numpy-based coloring algorithm.

• Allow calling eval on state function objects with no argument, which returns the VectorStateFn representation of the state function. This is consistent behavior with OperatorBase.eval, which returns the MatrixOp representation, if no argument is passed.

• Adds max_iterations to the VQEAdapt class in order to allow limiting the maximum number of iterations performed by the algorithm.

• VQE expectation computation with Aer qasm_simulator now defaults to a computation that has the expected shot noise behavior. The special Aer snapshot based computation, that is much faster, with the ideal output similar to state vector simulator, may still be chosen but like before Aqua 0.7 it now no longer defaults to this but can be chosen.

• Extension of the previous Analytic Quantum Gradient Descent (AQGD) classical optimizer with the AQGD with Epochs. Now AQGD performs the gradient descent optimization with a momentum term, analytic gradients, and an added customized step length schedule for parametrized quantum gates. Gradients are computed “analytically” using the quantum circuit when evaluating the objective function.

• The deprecated support for running qiskit-aqua with Python 3.5 has been removed. To use qiskit-aqua >=0.8.0 you will now need at least Python 3.6. If you are using Python 3.5 the last version which will work is qiskit-aqua 0.7.x.

• Added retworkx as a new dependency.

##### Deprecation Notes¶
• The i_objective argument of the amplitude estimation algorithms has been renamed to objective_qubits.

• TransformationType

• QubitMappingType

• Deprecate the CircuitFactory and derived types. The CircuitFactory has been introduced as temporary class when the QuantumCircuit missed some features necessary for applications in Aqua. Now that the circuit has all required functionality, the circuit factory can be removed. The replacements are shown in the following table.

Circuit factory class               | Replacement
------------------------------------+-----------------------------------------------
CircuitFactory                      | use QuantumCircuit
|
UncertaintyModel                    | -
UnivariateDistribution              | -
MultivariateDistribution            | -
NormalDistribution                  | qiskit.circuit.library.NormalDistribution
MultivariateNormalDistribution      | qiskit.circuit.library.NormalDistribution
LogNormalDistribution               | qiskit.circuit.library.LogNormalDistribution
MultivariateLogNormalDistribution   | qiskit.circuit.library.LogNormalDistribution
UniformDistribution                 | qiskit.circuit.library.UniformDistribution
MultivariateUniformDistribution     | qiskit.circuit.library.UniformDistribution
UnivariateVariationalDistribution   | use parameterized QuantumCircuit
MultivariateVariationalDistribution | use parameterized QuantumCircuit
|
UncertaintyProblem                  | -
UnivariateProblem                   | -
MultivariateProblem                 | -
UnivariatePiecewiseLinearObjective  | qiskit.circuit.library.LinearAmplitudeFunction

• The ising convert classes qiskit.optimization.converters.QuadraticProgramToIsing and qiskit.optimization.converters.IsingToQuadraticProgram have been deprecated and will be removed in a future release. Instead the qiskit.optimization.QuadraticProgram methods to_ising() and from_ising() should be used instead.

• Deprecate the WeightedSumOperator which has been ported to the circuit library as WeightedAdder in qiskit.circuit.library.

• Core Hamiltonian class is deprecated in favor of the FermionicTransformation Chemistry Operator class is deprecated in favor of the tranformations minimum_eigen_solvers/vqe_adapt is also deprecated and moved as an implementation of the ground_state_solver interface applications/molecular_ground_state_energy is deprecated in favor of ground_state_solver

• Optimizer.SupportLevel nested enum is replaced by OptimizerSupportLevel and Optimizer.SupportLevel was removed. Use, for example, OptimizerSupportLevel.required instead of Optimizer.SupportLevel.required.

• Deprecate the UnivariateVariationalDistribution and MultivariateVariationalDistribution as input to the QuantumGenerator. Instead, plain QuantumCircuit objects can be used.

• Ignored fast and use_nx options of AbelianGrouper.group_subops to be removed in the future release.

• GSLS optimizer class deprecated __init__ parameter max_iter in favor of maxiter. SPSA optimizer class deprecated __init__ parameter max_trials in favor of maxiter. optimize_svm function deprecated max_iters parameter in favor of maxiter. ADMMParameters class deprecated __init__ parameter max_iter in favor of maxiter.

##### Bug Fixes¶
• The UCCSD excitation list, comprising single and double excitations, was not being generated correctly when an active space was explicitly provided to UCSSD via the active_(un)occupied parameters.

• For the amplitude estimation algorithms, we define the number of oracle queries as number of times the Q operator/Grover operator is applied. This includes the number of shots. That factor has been included in MLAE and IQAE but was missing in the ‘standard’ QAE.

• Fix CircuitSampler.convert, so that the is_measurement property is propagated to converted StateFns.

• Fix double calculation of coefficients in :meth~qiskit.aqua.operators.VectorStateFn.to_circuit_op.

• Calling PauliTrotterEvolution.convert on an operator including a term that is a scalar multiple of the identity gave an incorrect circuit, one that ignored the scalar coefficient. This fix includes the effect of the coefficient in the global_phase property of the circuit.

• Make ListOp.num_qubits check that all ops in list have the same num_qubits Previously, the number of qubits in the first operator in the ListOp was returned. With this change, an additional check is made that all other operators also have the same number of qubits.

• Make PauliOp.exp_i() generate the correct matrix with the following changes. 1) There was previously an error in the phase of a factor of 2. 2) The global phase was ignored when converting the circuit to a matrix. We now use qiskit.quantum_info.Operator, which is generally useful for converting a circuit to a unitary matrix, when possible.

• Fixes the cyclicity detection as reported buggy in https://github.com/Qiskit/qiskit-aqua/issues/1184.

#### IBM Q Provider 0.11.0¶

• The deprecated support for running qiskit-ibmq-provider with Python 3.5 has been removed. To use qiskit-ibmq-provider >=0.11.0 you will now need at least Python 3.6. If you are using Python 3.5 the last version which will work is qiskit-ibmq-provider 0.10.x.

• Prior to this release, websockets 7.0 was used for Python 3.6. With this release, websockets 8.0 or above is required for all Python versions. The package requirements have been updated to reflect this.

### Qiskit 0.22.0¶

No change

No change

No change

No change

#### IBM Q Provider 0.10.0¶

##### New Features¶
• CQC randomness extractors can now be invoked asynchronously, using methods run_async_ext1() and run_async_ext2(). Each of these methods returns a CQCExtractorJob instance that allows you to check on the job status (using status()) and wait for its result (using block_until_ready()). The qiskit.provider.ibmq.random.CQCExtractor.run() method remains synchronous.

• You can now use the new IBMQ experiment service to query, retrieve, and download experiment related data. Interface to this service is located in the new qiskit.providers.ibmq.experiment package. Note that this feature is still in beta, and not all accounts have access to it. It is also subject to heavy modification in both functionality and API without backward compatibility.

• Two Jupyter magic functions, the IQX dashboard and the backend widget, are updated to display backend reservations. If a backend has reservations scheduled in the next 24 hours, time to the next one and its duration are displayed (e.g. Reservation: in 6 hrs 30 min (60m)). If there is a reservation and the backend is active, the backend status is displayed as active [R].

• Starting from this release, the basis_gates returned by qiskit.providers.ibmq.IBMQBackend.configuration() may differ for each backend. You should update your program if it relies on the basis gates being ['id','u1','u2','u3','cx']. We recommend always using the configuration() method to find backend configuration values instead of hard coding them.

• qiskit-ibmq-provider release 0.10 requires qiskit-terra release 0.15 or above. The package metadata has been updated to reflect the new dependency.

### Qiskit 0.21.0¶

No change

No change

No change

No change

#### IBM Q Provider 0.9.0¶

##### New Features¶
• You can now access the IBMQ random number services, such as the CQC randomness extractor, using the new package qiskit.providers.ibmq.random. Note that this feature is still in beta, and not all accounts have access to it. It is also subject to heavy modification in both functionality and API without backward compatibility.

##### Bug Fixes¶
• Fixes an issue that may raise a ValueError if retrieve_job() is used to retrieve a job submitted via the IBM Quantum Experience Composer.

• IBMQJobManager has been updated so that if a time out happens while waiting for an old job to finish, the time out error doesn’t prevent a new job to be submitted. Fixes #737

### Qiskit 0.20.1¶

#### Terra 0.15.2¶

##### Bug Fixes¶
• When accessing the definition attribute of a parameterized Gate instance, the generated QuantumCircuit had been generated with an invalid ParameterTable, such that reading from QuantumCircuit.parameters or calling QuantumCircuit.bind_parameters would incorrectly report the unbound parameters. This has been resolved.

• SXGate().inverse() had previously returned an ‘sx_dg’ gate with a correct definition but incorrect to_matrix. This has been updated such that SXGate().inverse() returns an SXdgGate() and vice versa.

• Instruction.inverse(), when not overridden by a subclass, would in some cases return a Gate instance with an incorrect to_matrix method. The instances of incorrect to_matrix methods have been removed.

• For C3XGate with a non-zero angle, inverting the gate via C3XGate.inverse() had previously generated an incorrect inverse gate. This has been corrected.

• The MCXGate modes have been updated to return a gate of the same mode when calling .inverse(). This resolves an issue where in some cases, transpiling a circuit containing the inverse of an MCXVChain gate would raise an error.

• Previously, when creating a multiply controlled phase gate via PhaseGate.control, an MCU1Gate gate had been returned. This has been had corrected so that an MCPhaseGate is returned.

• Previously, attempting to decompose a circuit containing an MCPhaseGate would raise an error due to an inconsistency in the definition of the MCPhaseGate. This has been corrected.

• QuantumCircuit.compose and DAGCircuit.compose had, in some cases, incorrectly translated conditional gates if the input circuit contained more than one ClassicalRegister. This has been resolved.

• Fixed an issue when creating a qiskit.result.Counts object from an empty data dictionary. Now this will create an empty Counts object. The most_frequent() method is also updated to raise a more descriptive exception when the object is empty. Fixes #5017

• Extending circuits with differing registers updated the qregs and cregs properties accordingly, but not the qubits and clbits lists. As these are no longer generated from the registers but are cached lists, this lead to a discrepancy of registers and bits. This has been fixed and the extend method explicitly updates the cached bit lists.

• Fix bugs of the concrete implementations of meth:~qiskit.circuit.ControlledGate.inverse method which do not preserve the ctrl_state parameter.

• A bug was fixed that caused long pulse schedules to throw a recursion error.

No change

No change

No change

No change

### Qiskit 0.20.0¶

#### Terra 0.15.1¶

##### Prelude¶

The 0.15.0 release includes several new features and bug fixes. Some highlights for this release are:

This release includes the introduction of arbitrary basis translation to the transpiler. This includes support for directly targeting a broader range of device basis sets, e.g. backends implementing RZ, RY, RZ, CZ or iSwap gates.

The QuantumCircuit class now tracks global phase. This means controlling a circuit which has global phase now correctly adds a relative phase, and gate matrix definitions are now exact rather than equal up to a global phase.

##### New Features¶
• A new DAG class qiskit.dagcircuit.DAGDependency for representing the dependency form of circuit, In this DAG, the nodes are operations (gates, measure, barrier, etc…) and the edges corresponds to non-commutation between two operations.

• Four new functions are added to qiskit.converters for converting back and forth to DAGDependency. These functions are:

For example:

from qiskit.converters.dagdependency_to_circuit import dagdependency_to_circuit
from qiskit import QuantumRegister, ClassicalRegister, QuantumCircuit

circuit_in = QuantumCircuit(2)
circuit_in.h(qr[0])
circuit_in.h(qr[1])

dag_dependency = circuit_to_dagdependency(circuit_in)
circuit_out = dagdepency_to_circuit(dag_dependency)

• Two new transpiler passes have been added to qiskit.transpiler.passes The first, UnrollCustomDefinitions, unrolls all instructions in the circuit according to their definition property, stopping when reaching either the specified basis_gates or a set of gates in the provided EquivalenceLibrary. The second, BasisTranslator, uses the set of translations in the provided EquivalenceLibrary to re-write circuit instructions in a specified basis.

• A new translation_method keyword argument has been added to transpile() to allow selection of the method to be used for translating circuits to the available device gates. For example, transpile(circ, backend, translation_method='translator'). Valid choices are:

The default value is 'translator'.

• A new class for handling counts result data, qiskit.result.Counts, has been added. This class is a subclass of dict and can be interacted with like any other dictionary. But, it includes helper methods and attributes for dealing with counts results from experiments and also handles post processing and formatting of binary strings at object initialization. A Counts object can be created by passing a dictionary of counts with the keys being either integers, hexadecimal strings of the form '0x4a', binary strings of the form '0b1101', a bit string formatted across register and memory slots (ie '00 10'), or a dit string. For example:

from qiskit.result import Counts

counts = Counts({"0x0': 1, '0x1', 3, '0x2': 1020})

• A new method for constructing qiskit.dagcircuit.DAGCircuit objects has been added, from_networkx(). This method takes in a networkx MultiDiGraph object (in the format returned by to_networkx()) and will return a new DAGCircuit object. The intent behind this function is to enable transpiler pass authors to leverage networkx’s graph algorithm library if a function is missing from the retworkx API. Although, hopefully in such casses an issue will be opened with retworkx issue tracker (or even better a pull request submitted).

• A new kwarg for init_qubits has been added to assemble() and execute(). For backends that support this feature init_qubits can be used to control whether the backend executing the circuits inserts any initialization sequences at the start of each shot. By default this is set to True meaning that all qubits can assumed to be in the ground state at the start of each shot. However, when init_qubits is set to False qubits will be uninitialized at the start of each experiment and between shots. Note, that the backend running the circuits has to support this feature for this flag to have any effect.

• A new kwarg rep_delay has been added to qiskit.compiler.assemble(), qiskit.execute.execute(), and the constructor for PulseQobjtConfig.qiskit This new kwarg is used to denotes the time between program executions. It must be chosen from the list of valid values set as the rep_delays from a backend’s PulseBackendConfiguration object which can be accessed as backend.configuration().rep_delays).

The rep_delay kwarg will only work on backends which allow for dynamic repetition time. This will also be indicated in the PulseBackendConfiguration object for a backend as the dynamic_reprate_enabled attribute. If dynamic_reprate_enabled is False then the rep_time value specified for qiskit.compiler.assemble(), qiskit.execute.execute(), or the constructor for PulseQobjtConfig will be used rather than rep_delay. rep_time only allows users to specify the duration of a program, rather than the delay between programs.

• The qobj_schema.json JSON Schema file in qiskit.schemas has been updated to include the rep_delay as an optional configuration property for pulse qobjs.

• The backend_configuration_schema.json JSON Schema file in mod:qiskit.schemas has been updated to include rep_delay_range and default_rep_delay as optional properties for a pulse backend configuration.

• A new attribute, global_phase, which is is used for tracking the global phase has been added to the qiskit.circuit.QuantumCircuit class. For example:

import math

from qiskit import QuantumCircuit

circ = QuantumCircuit(1, global_phase=math.pi)
circ.u1(0)


The global phase may also be changed or queried with circ.global_phase in the above example. In either case the setting is in radians. If the circuit is converted to an instruction or gate the global phase is represented by two single qubit rotations on the first qubit.

This allows for other methods and functions which consume a QuantumCircuit object to take global phase into account. For example. with the global_phase attribute the to_matrix() method for a gate can now exactly correspond to its decompositions instead of just up to a global phase.

The same attribute has also been added to the DAGCircuit class so that global phase can be tracked when converting between QuantumCircuit and DAGCircuit.

• Two new classes, AncillaRegister and AncillaQubit have been added to the qiskit.circuit module. These are subclasses of QuantumRegister and Qubit respectively and enable marking qubits being ancillas. This will allow these qubits to be re-used in larger circuits and algorithms.

• A new method, control(), has been added to the QuantumCircuit. This method will return a controlled version of the QuantumCircuit object, with both open and closed controls. This functionality had previously only been accessible via the Gate class.

• A new method repeat() has been added to the QuantumCircuit class. It returns a new circuit object containing a specified number of repetitions of the original circuit. For example:

from qiskit.circuit import QuantumCircuit

qc = QuantumCircuit(2)
qc.h(0)
qc.cx(0, 1)
repeated_qc = qc.repeat(3)
repeated_qc.decompose().draw(output='mpl')


The parameters are copied by reference, meaning that if you update the parameters in one instance of the circuit all repetitions will be updated.

• A new method reverse_bits() has been added to the QuantumCircuit class. This method will reverse the order of bits in a circuit (both quantum and classical bits). This can be used to switch a circuit from little-endian to big-endian and vice-versa.

• A new method, combine_into_edge_map(), was added to the qiskit.transpiler.Layout class. This method enables converting converting two Layout objects into a qubit map for composing two circuits.

• A new class, ConfigurableFakeBackend, has been added to the qiskit.test.mock.utils module. This new class enables the creation of configurable mock backends for use in testing. For example:

from qiskit.test.mock.utils import ConfigurableFakeBackend

backend = ConfigurableFakeBackend("Tashkent",
n_qubits=100,
version="0.0.1",
basis_gates=['u1'],
qubit_t1=99.,
qubit_t2=146.,
qubit_frequency=5.,
single_qubit_gates=['u1'])


will create a backend object with 100 qubits and all the other parameters specified in the constructor.

• A new method draw() has been added to the qiskit.circuit.EquivalenceLibrary class. This method can be used for drawing the contents of an equivalence library, which can be useful for debugging. For example:

from numpy import pi

from qiskit.circuit import EquivalenceLibrary
from qiskit.circuit import QuantumCircuit
from qiskit.circuit import QuantumRegister
from qiskit.circuit import Parameter
from qiskit.circuit.library import HGate
from qiskit.circuit.library import U2Gate
from qiskit.circuit.library import U3Gate

my_equiv_library = EquivalenceLibrary()

q = QuantumRegister(1, 'q')
def_h = QuantumCircuit(q)
def_h.append(U2Gate(0, pi), [q[0]], [])

theta = Parameter('theta')
phi = Parameter('phi')
lam = Parameter('lam')
def_u2 = QuantumCircuit(q)
def_u2.append(U3Gate(pi / 2, phi, lam), [q[0]], [])

my_equiv_library.draw()

• A new Phase instruction, SetPhase, has been added to qiskit.pulse. This instruction sets the phase of the subsequent pulses to the specified phase (in radians. For example:

import numpy as np

from qiskit.pulse import DriveChannel
from qiskit.pulse import Schedule
from qiskit.pulse import SetPhase

sched = Schedule()
sched += SetPhase(np.pi, DriveChannel(0))


In this example, the phase of the pulses applied to DriveChannel(0) after the SetPhase instruction will be set to $$\pi$$ radians.

• A new pulse instruction ShiftFrequency has been added to qiskit.pulse.instructions. This instruction enables shifting the frequency of a channel from its set frequency. For example:

from qiskit.pulse import DriveChannel
from qiskit.pulse import Schedule
from qiskit.pulse import ShiftFrequency

sched = Schedule()
sched += ShiftFrequency(-340e6, DriveChannel(0))


In this example all the pulses applied to DriveChannel(0) after the ShiftFrequency command will have the envelope a frequency decremented by 340MHz.

• A new method conjugate() has been added to the ParameterExpression class. This enables calling numpy.conj() without raising an error. Since a ParameterExpression object is real, it will return itself. This behaviour is analogous to Python floats/ints.

• A new class PhaseEstimation has been added to qiskit.circuit.library. This circuit library class is the circuit used in the original formulation of the phase estimation algorithm in arXiv:quant-ph/9511026. Phase estimation is the task to to estimate the phase $$\phi$$ of an eigenvalue $$e^{2\pi i\phi}$$ of a unitary operator $$U$$, provided with the corresponding eigenstate $$|psi\rangle$$. That is

$U|\psi\rangle = e^{2\pi i\phi} |\psi\rangle$

This estimation (and thereby this circuit) is a central routine to several well-known algorithms, such as Shor’s algorithm or Quantum Amplitude Estimation.

• The qiskit.visualization function plot_state_qsphere() has a new kwarg show_state_labels which is used to control whether each blob in the qsphere visualization is labeled. By default this kwarg is set to True and shows the basis states next to each blob by default. This feature can be disabled, reverting to the previous behavior, by setting the show_state_labels kwarg to False.

• The qiskit.visualization function plot_state_qsphere() has a new kwarg show_state_phases which is set to False by default. When set to True it displays the phase of each basis state.

• The qiskit.visualization function plot_state_qsphere() has a new kwarg use_degrees which is set to False by default. When set to True it displays the phase of each basis state in degrees, along with the phase circle at the bottom right.

• A new class, QuadraticForm to the qiskit.circuit.library module for implementing a a quadratic form on binary variables. The circuit library element implements the operation

$|x\rangle |0\rangle \mapsto |x\rangle |Q(x) \mod 2^m\rangle$

for the quadratic form $$Q$$ and $$m$$ output qubits. The result is in the $$m$$ output qubits is encoded in two’s complement. If $$m$$ is not specified, the circuit will choose the minimal number of qubits required to represent the result without applying a modulo operation. The quadratic form is specified using a matrix for the quadratic terms, a vector for the linear terms and a constant offset. If all terms are integers, the circuit implements the quadratic form exactly, otherwise it is only an approximation.

For example:

import numpy as np

A = np.array([[1, 2], [-1, 0]])
b = np.array([3, -3])
c = -2
m = 4

• Add qiskit.quantum_info.Statevector.expectation_value() and qiskit.quantum_info.DensityMatrix.expectation_value() methods for computing the expectation value of an qiskit.quantum_info.Operator.

• For the seed kwarg in the constructor for qiskit.circuit.library.QuantumVolume numpy random Generator objects can now be used. Previously, only integers were a valid input. This is useful when integrating QuantumVolume as part of a larger function with its own random number generation, e.g. generating a sequence of QuantumVolume circuits.

• The QuantumCircuit method compose() has a new kwarg front which can be used for prepending the other circuit before the origin circuit instead of appending. For example:

from qiskit.circuit import QuantumCircuit

circ1 = QuantumCircuit(2)
circ2 = QuantumCircuit(2)

circ2.h(0)
circ1.cx(0, 1)

circ1.compose(circ2, front=True).draw(output='mpl')

• Two new passes, SabreLayout and SabreSwap for layout and routing have been added to qiskit.transpiler.passes. These new passes are based on the algorithm presented in Li et al., “Tackling the Qubit Mapping Problem for NISQ-Era Quantum Devices”, ASPLOS 2019. They can also be selected when using the transpile() function by setting the layout_method kwarg to 'sabre' and/or the routing_method to 'sabre' to use SabreLayout and SabreSwap respectively.

• Added the method replace() to the qiskit.pulse.Schedule class which allows a pulse instruction to be replaced with another. For example:

.. code-block:: python


from qiskit import pulse

d0 = pulse.DriveChannel(0)

sched = pulse.Schedule()

old = pulse.Play(pulse.Constant(100, 1.0), d0) new = pulse.Play(pulse.Constant(100, 0.1), d0)

sched += old

sched = sched.replace(old, new)

assert sched == pulse.Schedule(new)

• Added new gate classes to qiskit.circuit.library for the $$\sqrt{X}$$, its adjoint $$\sqrt{X}^\dagger$$, and controlled $$\sqrt{X}$$ gates as SXGate, SXdgGate, and CSXGate. They can also be added to a QuantumCircuit object using the sx(), sxdg(), and csx() respectively.

• Add support for Reset instructions to qiskit.quantum_info.Statevector.from_instruction(). Note that this involves RNG sampling in choosing the projection to the zero state in the case where the qubit is in a superposition state. The seed for sampling can be set using the seed() method.

• The methods qiskit.circuit.ParameterExpression.subs() and qiskit.circuit.QuantumCircuit.assign_parameters() now accept ParameterExpression as the target value to be substituted.

For example,

from qiskit.circuit import QuantumCircuit, Parameter

p = Parameter('p')
source = QuantumCircuit(1)
source.rz(p, 0)

x = Parameter('x')
source.assign_parameters({p: x*x})

     ┌──────────┐
q_0: ┤ Rz(x**2) ├
└──────────┘

• The QuantumCircuit() method to_gate() has a new kwarg label which can be used to set a label for for the output Gate object. For example:

from qiskit.circuit import QuantumCircuit

circuit_gate = QuantumCircuit(2)
circuit_gate.h(0)
circuit_gate.cx(0, 1)
custom_gate = circuit_gate.to_gate(label='My Special Bell')
new_circ = QuantumCircuit(2)
new_circ.append(custom_gate, [0, 1], [])
new_circ.draw(output='mpl')

• Added the UGate, CUGate, PhaseGate, and CPhaseGate with the corresponding QuantumCircuit methods u(), cu(), p(), and cp(). The UGate gate is the generic single qubit rotation gate with 3 Euler angles and the CUGate gate its controlled version. CUGate has 4 parameters to account for a possible global phase of the U gate. The PhaseGate and CPhaseGate gates are the general Phase gate at an arbitrary angle and it’s controlled version.

• A new kwarg, cregbundle has been added to the qiskit.visualization.circuit_drawer() function and the QuantumCircuit method draw(). When set to True the cregs will be bundled into a single line in circuit visualizations for the text and mpl drawers. The default value is True. Addresses issue #4290.

For example:

from qiskit import QuantumCircuit
circuit = QuantumCircuit(2)
circuit.measure_all()
circuit.draw(output='mpl', cregbundle=True)

• A new kwarg, initial_state has been added to the qiskit.visualization.circuit_drawer() function and the QuantumCircuit method draw(). When set to True the initial state will now be included in circuit visualizations for all drawers. Addresses issue #4293.

For example:

from qiskit import QuantumCircuit
circuit = QuantumCircuit(2)
circuit.measure_all()
circuit.draw(output='mpl', initial_state=True)

• Labels will now be displayed when using the ‘mpl’ drawer. There are 2 types of labels - gate labels and control labels. Gate labels will replace the gate name in the display. Control labels will display above or below the controls for a gate. Fixes issues #3766, #4580 Addresses issues #3766 and #4580.

For example:

from qiskit import QuantumCircuit
from qiskit.circuit.library.standard_gates import YGate
circuit = QuantumCircuit(2)
circuit.append(YGate(label='A Y Gate').control(label='Y Control'), [0, 1])
circuit.draw(output='mpl')

• Implementations of the multi-controlled X Gate ( MCXGrayCode, MCXRecursive, and MCXVChain) have had their name properties changed to more accurately describe their implementation: mcx_gray, mcx_recursive, and mcx_vchain respectively. Previously, these gates shared the name mcx with MCXGate, which caused these gates to be incorrectly transpiled and simulated.

• By default the preset passmanagers in qiskit.transpiler.preset_passmanagers are using UnrollCustomDefinitions and BasisTranslator to handle basis changing instead of the previous default Unroller. This was done because the new passes are more flexible and allow targeting any basis set, however the output may differ. To use the previous default you can set the translation_method kwarg on transpile() to 'unroller'.

• The qiskit.converters.circuit_to_gate() and :funcqiskit.converters.circuit_to_instruction converter functions had previously automatically included the generated gate or instruction in the active SessionEquivalenceLibrary. These converters now accept an optional equivalence_library keyword argument to specify if and where the converted instances should be registered. The default behavior has changed to not register the converted instance.

• The default value of the cregbundle kwarg for the qiskit.circuit.QuantumCircuit.draw() method and qiskit.visualization.circuit_drawer() function has been changed to True. This means that by default the classical bits in the circuit diagram will now be bundled by default, for example:

from qiskit.circuit import QuantumCircuit

circ = QuantumCircuit(4)
circ.x(0)
circ.h(1)
circ.measure_all()
circ.draw(output='mpl')


If you want to have your circuit drawing retain the previous behavior and show each classical bit in the diagram you can set the cregbundle kwarg to False. For example:

from qiskit.circuit import QuantumCircuit

circ = QuantumCircuit(4)
circ.x(0)
circ.h(1)
circ.measure_all()
circ.draw(output='mpl', cregbundle=False)

• Schedule plotting with qiskit.pulse.Schedule.draw() and qiskit.visualization.pulse_drawer() will no longer display the event table by default. This can be reenabled by setting the table kwarg to True.

• The pass RemoveResetInZeroState was previously included in the preset pass manager level_0_pass_manager() which was used with the optimization_level=0 for transpile() and execute() functions. However, RemoveResetInZeroState is an optimization pass and should not have been included in optimization level 0 and was removed. If you need to run transpile() with RemoveResetInZeroState either use a custom pass manager or optimization_level 1, 2, or 3.

• The deprecated kwarg line_length for the qiskit.visualization.circuit_drawer() function and qiskit.circuit.QuantumCircuit.draw() method has been removed. It had been deprecated since the 0.10.0 release. Instead you can use the fold kwarg to adjust the width of the circuit diagram.

• The 'mpl' output mode for the qiskit.circuit.QuantumCircuit.draw() method and circuit_drawer() now requires the pylatexenc library to be installed. This was already an optional dependency for visualization, but was only required for the 'latex' output mode before. It is now also required for the matplotlib drawer because it is needed to handle correctly sizing gates with matplotlib’s mathtext labels for gates.

• The deprecated get_tokens methods for the qiskit.qasm.Qasm and qiskit.qasm.QasmParser has been removed. These methods have been deprecated since the 0.9.0 release. The qiskit.qasm.Qasm.generate_tokens() and qiskit.qasm.QasmParser.generate_tokens() methods should be used instead.

• The deprecated kwarg channels_to_plot for qiskit.pulse.Schedule.draw(), qiskit.pulse.Instruction.draw(), qiskit.visualization.pulse.matplotlib.ScheduleDrawer.draw and pulse_drawer() has been removed. The kwarg has been deprecated since the 0.11.0 release and was replaced by the channels kwarg, which functions identically and should be used instead.

• The deprecated circuit_instruction_map attribute of the qiskit.providers.models.PulseDefaults class has been removed. This attribute has been deprecated since the 0.12.0 release and was replaced by the instruction_schedule_map attribute which can be used instead.

• The union method of Schedule and Instruction have been deprecated since the 0.12.0 release and have now been removed. Use qiskit.pulse.Schedule.insert() and qiskit.pulse.Instruction.meth() methods instead with the kwargtime=0.

• The deprecated scaling argument to the draw method of Schedule and Instruction has been replaced with scale since the 0.12.0 release and now has been removed. Use the scale kwarg instead.

• The deprecated period argument to qiskit.pulse.library functions have been replaced by freq since the 0.13.0 release and now removed. Use the freq kwarg instead of period.

• The qiskit.pulse.commands module containing Commands classes was deprecated in the 0.13.0 release and has now been removed. You will have to upgrade your Pulse code if you were still using commands. For example:

Old

New

Command(args)(channel)

Instruction(args, channel)

Acquire(duration)(AcquireChannel(0))

Acquire(duration, AcquireChannel(0))

Delay(duration)(channel)

Delay(duration, channel)

FrameChange(angle)(DriveChannel(0))

# FrameChange was also renamed
ShiftPhase(angle, DriveChannel(0))

Gaussian(...)(DriveChannel(0))

# Pulses need to be Playd
Play(Gaussian(...), DriveChannel(0))

• All classes and function in the qiskit.tool.qi module were deprecated in the 0.12.0 release and have now been removed. Instead use the qiskit.quantum_info module and the new methods and classes that it has for working with quantum states and operators.

• The qiskit.quantum_info.basis_state and qiskit.quantum_info.projector functions are deprecated as of Qiskit Terra 0.12.0 as are now removed. Use the qiskit.quantum_info.QuantumState and its derivatives qiskit.quantum_info.Statevector and qiskit.quantum_info.DensityMatrix to work with states.

• The interactive plotting functions from qiskit.visualization, iplot_bloch_multivector, iplot_state_city, iplot_state_qsphere, iplot_state_hinton, iplot_histogram, iplot_state_paulivec now are just deprecated aliases for the matplotlib based equivalents and are no longer interactive. The hosted static JS code that these functions relied on has been removed and they no longer could work. A normal deprecation wasn’t possible because the site they depended on no longer exists.

• The validation components using marshmallow from qiskit.validation have been removed from terra. Since they are no longer used to build any objects in terra.

• The marshmallow schema classes in qiskit.result` have been removed since they are no longer used by the