The 0.10.0 release includes several new features and bug fixes. The biggest change for this release is the addition of initial support for using Qiskit with trapped ion trap backends.
Introduced new methods in
QuantumCircuitwhich allows the seamless adding or removing of measurements at the end of a circuit.
barrierfollowed by a
measureoperation to all qubits in the circuit. Creates a
ClassicalRegisterof size equal to the number of qubits in the circuit, which store the measurements.
barrierfollowed by a
measureoperation to all active qubits in the circuit. A qubit is active if it has at least one other operation acting upon it. Creates a
ClassicalRegisterof size equal to the number of active qubits in the circuit, which store the measurements.
Removes all final measurements and preceeding
barrierfrom a circuit. A measurement is considered “final” if it is not followed by any other operation, excluding barriers and other measurements. After the measurements are removed, if all of the classical bits in the
ClassicalRegisterare idle (have no operations attached to them), then the
# Using measure_all() circuit = QuantumCircuit(2) circuit.h(0) circuit.measure_all() circuit.draw() # A ClassicalRegister with prefix measure was created. # It has 2 clbits because there are 2 qubits to measure ┌───┐ ░ ┌─┐ q_0: |0>┤ H ├─░─┤M├─── └───┘ ░ └╥┘┌─┐ q_1: |0>──────░──╫─┤M├ ░ ║ └╥┘ measure_0: 0 ═════════╩══╬═ ║ measure_1: 0 ════════════╩═ # Using measure_active() circuit = QuantumCircuit(2) circuit.h(0) circuit.measure_active() circuit.draw() # This ClassicalRegister only has 1 clbit because only 1 qubit is active ┌───┐ ░ ┌─┐ q_0: |0>┤ H ├─░─┤M├ └───┘ ░ └╥┘ q_1: |0>──────░──╫─ ░ ║ measure_0: 0 ═════════╩═ # Using remove_final_measurements() # Assuming circuit_all and circuit_active are the circuits from the measure_all and # measure_active examples above respectively circuit_all.remove_final_measurements() circuit_all.draw() # The ClassicalRegister is removed because, after the measurements were removed, # all of its clbits were idle ┌───┐ q_0: |0>┤ H ├ └───┘ q_1: |0>───── circuit_active.remove_final_measurements() circuit_active.draw() # This will result in the same circuit ┌───┐ q_0: |0>┤ H ├ └───┘ q_1: |0>─────
Initial support for executing experiments on ion trap backends has been added.
An Rxx gate (rxx) and a global Mølmer–Sørensen gate (ms) have been added to the standard gate set.
A Cnot to Rxx/Rx/Ry decomposer
cnot_rxx_decomposeand a single qubit Euler angle decomposer
OneQubitEulerDecomposerhave been added to the
A transpiler pass
MSBasisDecomposerhas been added to unroll circuits defined over U3 and Cnot gates into a circuit defined over Rxx,Ry and Rx. This pass will be included in preset pass managers for backends which include the ‘rxx’ gate in their supported basis gates.
The backends in
qiskit.test.mocknow contain a snapshot of real device calibration data. This is accessible via the
properties()method for each backend. This can be used to test any code that depends on backend properties, such as noise-adaptive transpiler passes or device noise models for simulation. This will create a faster testing and development cycle without the need to go to live backends.
Allows the Result class to return partial results. If a valid result schema is loaded that contains some experiments which succeeded and some which failed, this allows accessing the data from experiments that succeeded, while raising an exception for experiments that failed and displaying the appropriate error message for the failed results.
axkwarg has been added to the following visualization functions:
This kwarg is used to pass in a
matplotlib.axes.Axesobject to the visualization functions. This enables integrating these visualization functions into a larger visualization workflow. Also, if an ax kwarg is specified then there is no return from the visualization functions.
ax_imagkwarg has been added to the following visualization functions:
These new kargs work the same as the newly added
axkwargs for other visualization functions. However because these plots use two axes (one for the real component, the other for the imaginary component). Having two kwargs also provides the flexibility to only generate a visualization for one of the components instead of always doing both. For example:
from matplotlib import pyplot as plt from qiskit.visualization import plot_state_hinton ax = plt.gca() plot_state_hinton(psi, ax_real=ax)
will only generate a plot of the real component.
A given pass manager now can be edited with the new method replace. This method allows to replace a particular stage in a pass manager, which can be handy when dealing with preset pass managers. For example, let’s edit the layout selector of the pass manager used at optimization level 0:
from qiskit.transpiler.preset_passmanagers.level0 import level_0_pass_manager from qiskit.transpiler.transpile_config import TranspileConfig pass_manager = level_0_pass_manager(TranspileConfig(coupling_map=CouplingMap([[0,1]]))) pass_manager.draw()
 FlowLinear: SetLayout  Conditional: TrivialLayout  FlowLinear: FullAncillaAllocation, EnlargeWithAncilla, ApplyLayout  FlowLinear: Unroller
The layout selection is set in the stage . Let’s replace it with DenseLayout:
from qiskit.transpiler.passes import DenseLayout pass_manager.replace(1, DenseLayout(coupling_map), condition=lambda property_set: not property_set['layout']) pass_manager.draw()
 FlowLinear: SetLayout  Conditional: DenseLayout  FlowLinear: FullAncillaAllocation, EnlargeWithAncilla, ApplyLayout  FlowLinear: Unroller
If you want to replace it without any condition, you can use set-item shortcut:
pass_manager = DenseLayout(coupling_map) pass_manager.draw()
 FlowLinear: SetLayout  FlowLinear: DenseLayout  FlowLinear: FullAncillaAllocation, EnlargeWithAncilla, ApplyLayout  FlowLinear: Unroller
Introduced a new pulse command
Delaywhich may be inserted into a pulse
Schedule. This command accepts a
durationand may be added to any
Channel. Other commands may not be scheduled on a channel during a delay.
The delay can be added just like any other pulse command. For example:
from qiskit import pulse from qiskit.pulse.utils import pad dc0 = pulse.DriveChannel(0) delay = pulse.Delay(1) test_pulse = pulse.SamplePulse([1.0]) sched = pulse.Schedule() sched += test_pulse(dc0).shift(1) # build padded schedule by hand ref_sched = delay(dc0) | sched # pad schedule padded_sched = pad(sched) assert padded_sched == ref_sched
One may also pass additional channels to be padded and a time to pad until, for example:
from qiskit import pulse from qiskit.pulse.utils import pad dc0 = pulse.DriveChannel(0) dc1 = pulse.DriveChannel(1) delay = pulse.Delay(1) test_pulse = pulse.SamplePulse([1.0]) sched = pulse.Schedule() sched += test_pulse(dc0).shift(1) # build padded schedule by hand ref_sched = delay(dc0) | delay(dc1) | sched # pad schedule across both channels until up until the first time step padded_sched = pad(sched, channels=[dc0, dc1], until=1) assert padded_sched == ref_sched
Assignments and modifications to the
qiskit.QuantumCircuitobjects are now validated following the same rules used throughout the
QuantumCircuitAPI. This was done to improve the performance of the circuits API since we can now assume the
dataattribute is in a known format. If you were manually modifying the
dataattribute of a circuit object before this may no longer work if your modifications resulted in a data structure other than the list of instructions with context in the format
[(instruction, qargs, cargs)]
The transpiler default passmanager for optimization level 2 now uses the
DenseLayoutlayout selection mechanism by default instead of
Denselayoutpass has also been modified to be made noise-aware.
DeviceSpecificationclass has been removed. Instead you should use the
PulseChannelSpec. For example, you can run something like:
device = pulse.PulseChannelSpec.from_backend(backend) device.drives # for DeviceSpecification, this was device.q.drive device.memoryslots # this was device.mem
The deprecated module
qiskit.pulse.opshas been removed. Use
Instructionmethods directly. For example, rather than:
ops.union(schedule_0, schedule_1) ops.union(instruction, schedule) # etc
Instead please use:
This same pattern applies to other
- Using the
qiskit.circuit.Instructionfor classical control is now deprecated. In the future this property will be used for quantum control. Classically conditioned operations will instead be handled by the
- Support for setting
qiskit.circuit.Instructionparameters with an object of type
qiskit.qasm.node.Nodehas been deprecated.
Nodeobjects that were previously used as parameters should be converted to a supported type prior to initializing a new
Instructionobject or calling the
Instruction.paramssetter. Supported types are
- In the qiskit 0.9.0 release the representation of bits (both qubits and classical bits) changed from tuples of the form
(register, index)to be instances of the classes
qiskit.circuit.Clbit. For backwards compatibility comparing the equality between a legacy tuple and the bit classes was supported as everything transitioned from tuples to being objects. This support is now deprecated and will be removed in the future. Everything should use the bit classes instead of tuples moving forward.
- When the
mploutput is used for either
stylekwarg is used, passing in unsupported dictionary keys as part of the
style`dictionary is now deprecated. Where these unknown arguments were previously silently ignored, in the future, unsupported keys will raise an exception.
line lengthkwarg for the
qiskit.QuantumCircuit.draw()method and the
qiskit.visualization.circuit_drawer()function with the text output mode is deprecated. It has been replaced by the
foldkwarg which will behave identically for the text output mode (but also now supports the mpl output mode too).
line_lengthwill be removed in a future release so calls should be updated to use
foldfield in the
styledict kwarg for the
qiskit.QuantumCircuit.draw()method and the
qiskit.visualization.circuit_drawer()function has been deprecated. It has been replaced by the
foldkwarg on both functions. This kwarg behaves identically to the field in the style dict.
- Instructions layering which underlies all types of circuit drawing has changed to address right/left justification. This sometimes results in output which is topologically equivalent to the rendering in prior versions but visually different than previously rendered. Fixes issue #2802 (opens in a new tab)
QobjExperimentHeaderof pulse Qobj. This fixes a bug in the data format of
meas_level=2results of pulse experiments. Measured quantum states are returned as a bit string with zero padding based on the number set for
- Fixed the visualization of the rzz gate in the latex circuit drawer to match the cu1 gate to reflect the symmetry in the rzz gate. The fix is based on the cds command of the qcircuit latex package. Fixes issue #1957 (opens in a new tab)
matplotlib.figure.Figureobjects returned by visualization functions are no longer always closed by default. Instead the returned figure objects are only closed if the configured matplotlib backend is an inline jupyter backend(either set with
%matplotlib notebook). Output figure objects are still closed with these backends to avoid duplicate outputs in jupyter notebooks (which is why the
Figure.close()were originally added).