qiskit 1.0.2__cp38-abi3-win32.whl → 1.1.0__cp38-abi3-win32.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- qiskit/VERSION.txt +1 -1
- qiskit/__init__.py +27 -16
- qiskit/_accelerate.pyd +0 -0
- qiskit/_numpy_compat.py +73 -0
- qiskit/assembler/__init__.py +5 -10
- qiskit/assembler/disassemble.py +5 -6
- qiskit/circuit/__init__.py +1061 -232
- qiskit/circuit/_classical_resource_map.py +10 -6
- qiskit/circuit/_utils.py +18 -8
- qiskit/circuit/annotated_operation.py +21 -0
- qiskit/circuit/barrier.py +10 -13
- qiskit/circuit/bit.py +0 -1
- qiskit/circuit/classical/__init__.py +2 -2
- qiskit/circuit/classical/expr/__init__.py +39 -5
- qiskit/circuit/classical/expr/constructors.py +84 -1
- qiskit/circuit/classical/expr/expr.py +83 -13
- qiskit/circuit/classical/expr/visitors.py +83 -0
- qiskit/circuit/classical/types/__init__.py +5 -4
- qiskit/circuit/classicalfunction/__init__.py +1 -0
- qiskit/circuit/commutation_checker.py +86 -51
- qiskit/circuit/controlflow/_builder_utils.py +9 -1
- qiskit/circuit/controlflow/break_loop.py +8 -22
- qiskit/circuit/controlflow/builder.py +116 -1
- qiskit/circuit/controlflow/continue_loop.py +8 -22
- qiskit/circuit/controlflow/control_flow.py +47 -8
- qiskit/circuit/controlflow/for_loop.py +8 -23
- qiskit/circuit/controlflow/if_else.py +13 -27
- qiskit/circuit/controlflow/switch_case.py +14 -21
- qiskit/circuit/controlflow/while_loop.py +9 -23
- qiskit/circuit/controlledgate.py +2 -2
- qiskit/circuit/delay.py +7 -5
- qiskit/circuit/gate.py +20 -7
- qiskit/circuit/instruction.py +31 -30
- qiskit/circuit/instructionset.py +9 -22
- qiskit/circuit/library/__init__.py +3 -13
- qiskit/circuit/library/arithmetic/integer_comparator.py +2 -2
- qiskit/circuit/library/arithmetic/quadratic_form.py +3 -2
- qiskit/circuit/library/blueprintcircuit.py +29 -7
- qiskit/circuit/library/data_preparation/state_preparation.py +6 -5
- qiskit/circuit/library/generalized_gates/diagonal.py +5 -4
- qiskit/circuit/library/generalized_gates/isometry.py +51 -254
- qiskit/circuit/library/generalized_gates/pauli.py +2 -2
- qiskit/circuit/library/generalized_gates/permutation.py +4 -1
- qiskit/circuit/library/generalized_gates/rv.py +15 -11
- qiskit/circuit/library/generalized_gates/uc.py +2 -98
- qiskit/circuit/library/generalized_gates/unitary.py +9 -4
- qiskit/circuit/library/hamiltonian_gate.py +11 -5
- qiskit/circuit/library/n_local/efficient_su2.py +5 -5
- qiskit/circuit/library/n_local/n_local.py +100 -49
- qiskit/circuit/library/n_local/two_local.py +3 -59
- qiskit/circuit/library/overlap.py +3 -3
- qiskit/circuit/library/phase_oracle.py +1 -1
- qiskit/circuit/library/quantum_volume.py +39 -38
- qiskit/circuit/library/standard_gates/equivalence_library.py +50 -0
- qiskit/circuit/library/standard_gates/global_phase.py +4 -2
- qiskit/circuit/library/standard_gates/i.py +1 -2
- qiskit/circuit/library/standard_gates/iswap.py +1 -2
- qiskit/circuit/library/standard_gates/multi_control_rotation_gates.py +11 -5
- qiskit/circuit/library/standard_gates/p.py +31 -15
- qiskit/circuit/library/standard_gates/r.py +4 -3
- qiskit/circuit/library/standard_gates/rx.py +7 -4
- qiskit/circuit/library/standard_gates/rxx.py +4 -3
- qiskit/circuit/library/standard_gates/ry.py +7 -4
- qiskit/circuit/library/standard_gates/ryy.py +4 -3
- qiskit/circuit/library/standard_gates/rz.py +7 -4
- qiskit/circuit/library/standard_gates/rzx.py +4 -3
- qiskit/circuit/library/standard_gates/rzz.py +4 -3
- qiskit/circuit/library/standard_gates/s.py +4 -8
- qiskit/circuit/library/standard_gates/t.py +2 -4
- qiskit/circuit/library/standard_gates/u.py +16 -11
- qiskit/circuit/library/standard_gates/u1.py +6 -2
- qiskit/circuit/library/standard_gates/u2.py +4 -2
- qiskit/circuit/library/standard_gates/u3.py +9 -5
- qiskit/circuit/library/standard_gates/x.py +22 -11
- qiskit/circuit/library/standard_gates/xx_minus_yy.py +4 -3
- qiskit/circuit/library/standard_gates/xx_plus_yy.py +7 -5
- qiskit/circuit/library/standard_gates/z.py +1 -2
- qiskit/circuit/measure.py +4 -1
- qiskit/circuit/operation.py +13 -8
- qiskit/circuit/parameter.py +11 -6
- qiskit/circuit/quantumcircuit.py +1910 -260
- qiskit/circuit/quantumcircuitdata.py +2 -2
- qiskit/circuit/reset.py +5 -2
- qiskit/circuit/store.py +95 -0
- qiskit/compiler/assembler.py +22 -22
- qiskit/compiler/transpiler.py +63 -112
- qiskit/converters/__init__.py +17 -2
- qiskit/converters/circuit_to_dag.py +7 -0
- qiskit/converters/circuit_to_dagdependency_v2.py +47 -0
- qiskit/converters/circuit_to_gate.py +2 -0
- qiskit/converters/circuit_to_instruction.py +22 -0
- qiskit/converters/dag_to_circuit.py +4 -0
- qiskit/converters/dag_to_dagdependency_v2.py +44 -0
- qiskit/dagcircuit/collect_blocks.py +15 -10
- qiskit/dagcircuit/dagcircuit.py +434 -124
- qiskit/dagcircuit/dagdependency.py +19 -12
- qiskit/dagcircuit/dagdependency_v2.py +641 -0
- qiskit/dagcircuit/dagdepnode.py +19 -16
- qiskit/dagcircuit/dagnode.py +14 -4
- qiskit/passmanager/passmanager.py +11 -11
- qiskit/primitives/__init__.py +22 -12
- qiskit/primitives/backend_estimator.py +3 -5
- qiskit/primitives/backend_estimator_v2.py +410 -0
- qiskit/primitives/backend_sampler_v2.py +287 -0
- qiskit/primitives/base/base_estimator.py +4 -9
- qiskit/primitives/base/base_sampler.py +2 -2
- qiskit/primitives/containers/__init__.py +6 -4
- qiskit/primitives/containers/bit_array.py +293 -2
- qiskit/primitives/containers/data_bin.py +123 -50
- qiskit/primitives/containers/estimator_pub.py +10 -3
- qiskit/primitives/containers/observables_array.py +2 -2
- qiskit/primitives/containers/pub_result.py +1 -1
- qiskit/primitives/containers/sampler_pub.py +19 -3
- qiskit/primitives/containers/sampler_pub_result.py +74 -0
- qiskit/primitives/containers/shape.py +4 -4
- qiskit/primitives/statevector_estimator.py +4 -4
- qiskit/primitives/statevector_sampler.py +7 -12
- qiskit/providers/__init__.py +65 -34
- qiskit/providers/backend.py +2 -2
- qiskit/providers/backend_compat.py +8 -10
- qiskit/providers/basic_provider/__init__.py +2 -23
- qiskit/providers/basic_provider/basic_provider_tools.py +67 -31
- qiskit/providers/basic_provider/basic_simulator.py +81 -21
- qiskit/providers/fake_provider/__init__.py +1 -1
- qiskit/providers/fake_provider/fake_1q.py +1 -1
- qiskit/providers/fake_provider/fake_backend.py +3 -408
- qiskit/providers/fake_provider/generic_backend_v2.py +26 -14
- qiskit/providers/models/__init__.py +2 -2
- qiskit/providers/provider.py +16 -0
- qiskit/pulse/builder.py +4 -1
- qiskit/pulse/parameter_manager.py +60 -4
- qiskit/pulse/schedule.py +29 -13
- qiskit/pulse/utils.py +61 -20
- qiskit/qasm2/__init__.py +1 -5
- qiskit/qasm2/parse.py +1 -4
- qiskit/qasm3/__init__.py +42 -5
- qiskit/qasm3/ast.py +19 -0
- qiskit/qasm3/exporter.py +178 -106
- qiskit/qasm3/printer.py +27 -5
- qiskit/qobj/converters/pulse_instruction.py +6 -6
- qiskit/qpy/__init__.py +299 -67
- qiskit/qpy/binary_io/circuits.py +216 -47
- qiskit/qpy/binary_io/schedules.py +42 -36
- qiskit/qpy/binary_io/value.py +201 -22
- qiskit/qpy/common.py +1 -1
- qiskit/qpy/exceptions.py +20 -0
- qiskit/qpy/formats.py +29 -0
- qiskit/qpy/type_keys.py +21 -0
- qiskit/quantum_info/analysis/distance.py +3 -3
- qiskit/quantum_info/analysis/make_observable.py +2 -1
- qiskit/quantum_info/analysis/z2_symmetries.py +2 -1
- qiskit/quantum_info/operators/channel/chi.py +9 -8
- qiskit/quantum_info/operators/channel/choi.py +10 -9
- qiskit/quantum_info/operators/channel/kraus.py +2 -1
- qiskit/quantum_info/operators/channel/ptm.py +10 -9
- qiskit/quantum_info/operators/channel/quantum_channel.py +2 -1
- qiskit/quantum_info/operators/channel/stinespring.py +2 -1
- qiskit/quantum_info/operators/channel/superop.py +12 -11
- qiskit/quantum_info/operators/channel/transformations.py +12 -11
- qiskit/quantum_info/operators/dihedral/dihedral.py +5 -4
- qiskit/quantum_info/operators/operator.py +43 -30
- qiskit/quantum_info/operators/scalar_op.py +10 -9
- qiskit/quantum_info/operators/symplectic/base_pauli.py +70 -59
- qiskit/quantum_info/operators/symplectic/clifford.py +36 -9
- qiskit/quantum_info/operators/symplectic/pauli.py +53 -6
- qiskit/quantum_info/operators/symplectic/pauli_list.py +36 -14
- qiskit/quantum_info/operators/symplectic/random.py +3 -2
- qiskit/quantum_info/operators/symplectic/sparse_pauli_op.py +61 -36
- qiskit/quantum_info/states/densitymatrix.py +13 -13
- qiskit/quantum_info/states/stabilizerstate.py +3 -3
- qiskit/quantum_info/states/statevector.py +14 -13
- qiskit/quantum_info/states/utils.py +5 -3
- qiskit/result/__init__.py +6 -0
- qiskit/result/mitigation/correlated_readout_mitigator.py +3 -2
- qiskit/result/mitigation/local_readout_mitigator.py +2 -1
- qiskit/result/mitigation/utils.py +3 -2
- qiskit/scheduler/__init__.py +10 -1
- qiskit/scheduler/methods/__init__.py +1 -8
- qiskit/synthesis/__init__.py +3 -6
- qiskit/synthesis/discrete_basis/commutator_decompose.py +2 -2
- qiskit/synthesis/evolution/lie_trotter.py +7 -14
- qiskit/synthesis/evolution/qdrift.py +3 -4
- qiskit/synthesis/linear/cnot_synth.py +1 -3
- qiskit/synthesis/linear/linear_circuits_utils.py +1 -1
- qiskit/synthesis/linear_phase/cz_depth_lnn.py +4 -18
- qiskit/synthesis/permutation/__init__.py +1 -0
- qiskit/synthesis/permutation/permutation_reverse_lnn.py +90 -0
- qiskit/synthesis/qft/qft_decompose_lnn.py +2 -6
- qiskit/synthesis/two_qubit/two_qubit_decompose.py +165 -954
- qiskit/synthesis/two_qubit/xx_decompose/circuits.py +13 -12
- qiskit/synthesis/two_qubit/xx_decompose/decomposer.py +7 -1
- qiskit/synthesis/unitary/aqc/__init__.py +1 -1
- qiskit/synthesis/unitary/aqc/cnot_structures.py +2 -1
- qiskit/synthesis/unitary/aqc/fast_gradient/fast_gradient.py +2 -1
- qiskit/synthesis/unitary/qsd.py +3 -2
- qiskit/transpiler/__init__.py +7 -3
- qiskit/transpiler/layout.py +140 -61
- qiskit/transpiler/passes/__init__.py +10 -2
- qiskit/transpiler/passes/basis/basis_translator.py +9 -4
- qiskit/transpiler/passes/basis/unroll_3q_or_more.py +1 -1
- qiskit/transpiler/passes/basis/unroll_custom_definitions.py +1 -1
- qiskit/transpiler/passes/calibration/rzx_builder.py +2 -1
- qiskit/transpiler/passes/layout/apply_layout.py +8 -3
- qiskit/transpiler/passes/layout/sabre_layout.py +15 -3
- qiskit/transpiler/passes/layout/set_layout.py +1 -1
- qiskit/transpiler/passes/optimization/__init__.py +2 -0
- qiskit/transpiler/passes/optimization/commutation_analysis.py +2 -2
- qiskit/transpiler/passes/optimization/commutative_cancellation.py +1 -1
- qiskit/transpiler/passes/optimization/consolidate_blocks.py +1 -1
- qiskit/transpiler/passes/optimization/cx_cancellation.py +10 -0
- qiskit/transpiler/passes/optimization/elide_permutations.py +114 -0
- qiskit/transpiler/passes/optimization/optimize_1q_decomposition.py +9 -3
- qiskit/transpiler/passes/optimization/optimize_annotated.py +248 -12
- qiskit/transpiler/passes/optimization/remove_final_reset.py +37 -0
- qiskit/transpiler/passes/optimization/template_matching/forward_match.py +1 -3
- qiskit/transpiler/passes/routing/__init__.py +1 -0
- qiskit/transpiler/passes/routing/basic_swap.py +13 -2
- qiskit/transpiler/passes/routing/commuting_2q_gate_routing/commuting_2q_gate_router.py +8 -1
- qiskit/transpiler/passes/routing/lookahead_swap.py +7 -1
- qiskit/transpiler/passes/routing/sabre_swap.py +10 -6
- qiskit/transpiler/passes/routing/star_prerouting.py +417 -0
- qiskit/transpiler/passes/routing/stochastic_swap.py +24 -8
- qiskit/transpiler/passes/scheduling/__init__.py +1 -1
- qiskit/transpiler/passes/scheduling/alap.py +1 -2
- qiskit/transpiler/passes/scheduling/alignments/align_measures.py +1 -2
- qiskit/transpiler/passes/scheduling/alignments/check_durations.py +9 -6
- qiskit/transpiler/passes/scheduling/alignments/pulse_gate_validation.py +8 -0
- qiskit/transpiler/passes/scheduling/alignments/reschedule.py +13 -4
- qiskit/transpiler/passes/scheduling/asap.py +1 -2
- qiskit/transpiler/passes/scheduling/base_scheduler.py +21 -2
- qiskit/transpiler/passes/scheduling/dynamical_decoupling.py +26 -4
- qiskit/transpiler/passes/scheduling/padding/dynamical_decoupling.py +24 -2
- qiskit/transpiler/passes/scheduling/time_unit_conversion.py +28 -4
- qiskit/transpiler/passes/synthesis/aqc_plugin.py +2 -2
- qiskit/transpiler/passes/synthesis/high_level_synthesis.py +120 -13
- qiskit/transpiler/passes/synthesis/unitary_synthesis.py +162 -55
- qiskit/transpiler/passes/utils/gates_basis.py +3 -3
- qiskit/transpiler/passmanager.py +44 -1
- qiskit/transpiler/preset_passmanagers/__init__.py +3 -3
- qiskit/transpiler/preset_passmanagers/builtin_plugins.py +34 -16
- qiskit/transpiler/preset_passmanagers/common.py +4 -6
- qiskit/transpiler/preset_passmanagers/plugin.py +9 -1
- qiskit/utils/__init__.py +3 -2
- qiskit/utils/optionals.py +6 -2
- qiskit/utils/parallel.py +24 -15
- qiskit/visualization/array.py +1 -1
- qiskit/visualization/bloch.py +2 -3
- qiskit/visualization/circuit/matplotlib.py +44 -14
- qiskit/visualization/circuit/text.py +38 -18
- qiskit/visualization/counts_visualization.py +3 -6
- qiskit/visualization/dag_visualization.py +6 -7
- qiskit/visualization/gate_map.py +9 -1
- qiskit/visualization/pulse_v2/interface.py +8 -3
- qiskit/visualization/state_visualization.py +3 -2
- qiskit/visualization/timeline/interface.py +18 -8
- {qiskit-1.0.2.dist-info → qiskit-1.1.0.dist-info}/METADATA +12 -8
- {qiskit-1.0.2.dist-info → qiskit-1.1.0.dist-info}/RECORD +261 -251
- {qiskit-1.0.2.dist-info → qiskit-1.1.0.dist-info}/WHEEL +1 -1
- qiskit/_qasm2.pyd +0 -0
- qiskit/_qasm3.pyd +0 -0
- {qiskit-1.0.2.dist-info → qiskit-1.1.0.dist-info}/LICENSE.txt +0 -0
- {qiskit-1.0.2.dist-info → qiskit-1.1.0.dist-info}/entry_points.txt +0 -0
- {qiskit-1.0.2.dist-info → qiskit-1.1.0.dist-info}/top_level.txt +0 -0
qiskit/qpy/__init__.py
CHANGED
@@ -11,9 +11,9 @@
|
|
11
11
|
# that they have been altered from the originals.
|
12
12
|
|
13
13
|
"""
|
14
|
-
|
14
|
+
=====================================
|
15
15
|
QPY serialization (:mod:`qiskit.qpy`)
|
16
|
-
|
16
|
+
=====================================
|
17
17
|
|
18
18
|
.. currentmodule:: qiskit.qpy
|
19
19
|
|
@@ -32,9 +32,8 @@ which will preserve the Qiskit object exactly but will only work for a single Qi
|
|
32
32
|
version (it is also
|
33
33
|
`potentially insecure <https://docs.python.org/3/library/pickle.html#module-pickle>`__).
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
*********
|
35
|
+
Basic Usage
|
36
|
+
===========
|
38
37
|
|
39
38
|
Using QPY is defined to be straightforward and mirror the user API of the
|
40
39
|
serializers in Python's standard library, ``pickle`` and ``json``. There are
|
@@ -79,6 +78,12 @@ during serialization or deserialization.
|
|
79
78
|
|
80
79
|
.. autoexception:: QpyError
|
81
80
|
|
81
|
+
When a lower-than-maximum target QPY version is set for serialization, but the object to be
|
82
|
+
serialized contains features that cannot be represented in that format, a subclass of
|
83
|
+
:exc:`QpyError` is raised:
|
84
|
+
|
85
|
+
.. autoexception:: UnsupportedFeatureForVersion
|
86
|
+
|
82
87
|
Attributes:
|
83
88
|
QPY_VERSION (int): The current QPY format version as of this release. This
|
84
89
|
is the default value of the ``version`` keyword argument on
|
@@ -111,11 +116,139 @@ and how the feature will be internally handled.
|
|
111
116
|
|
112
117
|
.. autoexception:: QPYLoadingDeprecatedFeatureWarning
|
113
118
|
|
119
|
+
QPY format version history
|
120
|
+
--------------------------
|
121
|
+
|
122
|
+
If you're planning to load a QPY file between different Qiskit versions knowing
|
123
|
+
which versions were available in a given release are useful. As the QPY is
|
124
|
+
backwards compatible but not forwards compatible you need to ensure a given
|
125
|
+
QPY format version was released in the release you're calling :func:`.load`
|
126
|
+
with. The following table lists the QPY versions that were supported in every
|
127
|
+
Qiskit (and qiskit-terra prior to Qiskit 1.0.0) release going back to the introduction
|
128
|
+
of QPY in qiskit-terra 0.18.0.
|
129
|
+
|
130
|
+
.. list-table: QPY Format Version History
|
131
|
+
:header-rows: 1
|
132
|
+
|
133
|
+
* - Qiskit (qiskit-terra for < 1.0.0) version
|
134
|
+
- :func:`.dump` format(s) output versions
|
135
|
+
- :func:`.load` maximum supported version (older format versions can always be read)
|
136
|
+
* - 1.1.0
|
137
|
+
- 10, 11, 12
|
138
|
+
- 12
|
139
|
+
* - 1.0.2
|
140
|
+
- 10, 11
|
141
|
+
- 12
|
142
|
+
* - 1.0.1
|
143
|
+
- 10, 11
|
144
|
+
- 11
|
145
|
+
* - 1.0.0
|
146
|
+
- 10, 11
|
147
|
+
- 11
|
148
|
+
* - 0.46.1
|
149
|
+
- 10
|
150
|
+
- 10
|
151
|
+
* - 0.45.3
|
152
|
+
- 10
|
153
|
+
- 10
|
154
|
+
* - 0.45.2
|
155
|
+
- 10
|
156
|
+
- 10
|
157
|
+
* - 0.45.1
|
158
|
+
- 10
|
159
|
+
- 10
|
160
|
+
* - 0.45.0
|
161
|
+
- 10
|
162
|
+
- 10
|
163
|
+
* - 0.25.3
|
164
|
+
- 9
|
165
|
+
- 9
|
166
|
+
* - 0.25.2
|
167
|
+
- 9
|
168
|
+
- 9
|
169
|
+
* - 0.25.1
|
170
|
+
- 9
|
171
|
+
- 9
|
172
|
+
* - 0.24.2
|
173
|
+
- 8
|
174
|
+
- 8
|
175
|
+
* - 0.24.1
|
176
|
+
- 7
|
177
|
+
- 7
|
178
|
+
* - 0.24.0
|
179
|
+
- 7
|
180
|
+
- 7
|
181
|
+
* - 0.23.3
|
182
|
+
- 6
|
183
|
+
- 6
|
184
|
+
* - 0.23.2
|
185
|
+
- 6
|
186
|
+
- 6
|
187
|
+
* - 0.23.1
|
188
|
+
- 6
|
189
|
+
- 6
|
190
|
+
* - 0.23.0
|
191
|
+
- 6
|
192
|
+
- 6
|
193
|
+
* - 0.22.4
|
194
|
+
- 5
|
195
|
+
- 5
|
196
|
+
* - 0.22.3
|
197
|
+
- 5
|
198
|
+
- 5
|
199
|
+
* - 0.22.2
|
200
|
+
- 5
|
201
|
+
- 5
|
202
|
+
* - 0.22.1
|
203
|
+
- 5
|
204
|
+
- 5
|
205
|
+
* - 0.22.0
|
206
|
+
- 5
|
207
|
+
- 5
|
208
|
+
* - 0.21.2
|
209
|
+
- 5
|
210
|
+
- 5
|
211
|
+
* - 0.21.1
|
212
|
+
- 5
|
213
|
+
- 5
|
214
|
+
* - 0.21.0
|
215
|
+
- 5
|
216
|
+
- 5
|
217
|
+
* - 0.20.2
|
218
|
+
- 4
|
219
|
+
- 4
|
220
|
+
* - 0.20.1
|
221
|
+
- 4
|
222
|
+
- 4
|
223
|
+
* - 0.20.0
|
224
|
+
- 4
|
225
|
+
- 4
|
226
|
+
* - 0.19.2
|
227
|
+
- 4
|
228
|
+
- 4
|
229
|
+
* - 0.19.1
|
230
|
+
- 3
|
231
|
+
- 3
|
232
|
+
* - 0.19.0
|
233
|
+
- 2
|
234
|
+
- 2
|
235
|
+
* - 0.18.3
|
236
|
+
- 1
|
237
|
+
- 1
|
238
|
+
* - 0.18.2
|
239
|
+
- 1
|
240
|
+
- 1
|
241
|
+
* - 0.18.1
|
242
|
+
- 1
|
243
|
+
- 1
|
244
|
+
* - 0.18.0
|
245
|
+
- 1
|
246
|
+
- 1
|
247
|
+
|
114
248
|
.. _qpy_format:
|
115
249
|
|
116
|
-
**********
|
117
250
|
QPY Format
|
118
|
-
|
251
|
+
==========
|
119
252
|
|
120
253
|
The QPY serialization format is a portable cross-platform binary
|
121
254
|
serialization format for :class:`~qiskit.circuit.QuantumCircuit` objects in Qiskit. The basic
|
@@ -156,16 +289,116 @@ compatibility.
|
|
156
289
|
The file header is immediately followed by the circuit payloads.
|
157
290
|
Each individual circuit is composed of the following parts:
|
158
291
|
|
159
|
-
``HEADER | METADATA | REGISTERS | CUSTOM_DEFINITIONS | INSTRUCTIONS``
|
292
|
+
``HEADER | METADATA | REGISTERS | STANDALONE_VARS | CUSTOM_DEFINITIONS | INSTRUCTIONS``
|
293
|
+
|
294
|
+
The ``STANDALONE_VARS`` are new in QPY version 12; before that, there was no data between
|
295
|
+
``REGISTERS`` and ``CUSTOM_DEFINITIONS``.
|
160
296
|
|
161
297
|
There is a circuit payload for each circuit (where the total number is dictated
|
162
298
|
by ``num_circuits`` in the file header). There is no padding between the
|
163
299
|
circuits in the data.
|
164
300
|
|
301
|
+
.. _qpy_version_12:
|
302
|
+
|
303
|
+
Version 12
|
304
|
+
----------
|
305
|
+
|
306
|
+
Version 12 adds support for:
|
307
|
+
|
308
|
+
* circuits containing memory-owning :class:`.expr.Var` variables.
|
309
|
+
|
310
|
+
Changes to HEADER
|
311
|
+
~~~~~~~~~~~~~~~~~
|
312
|
+
|
313
|
+
The HEADER struct for an individual circuit has added three ``uint32_t`` counts of the input,
|
314
|
+
captured and locally declared variables in the circuit. The new form looks like:
|
315
|
+
|
316
|
+
.. code-block:: c
|
317
|
+
|
318
|
+
struct {
|
319
|
+
uint16_t name_size;
|
320
|
+
char global_phase_type;
|
321
|
+
uint16_t global_phase_size;
|
322
|
+
uint32_t num_qubits;
|
323
|
+
uint32_t num_clbits;
|
324
|
+
uint64_t metadata_size;
|
325
|
+
uint32_t num_registers;
|
326
|
+
uint64_t num_instructions;
|
327
|
+
uint32_t num_vars;
|
328
|
+
} HEADER_V12;
|
329
|
+
|
330
|
+
The ``HEADER_V12`` struct is followed immediately by the same name, global-phase, metadata
|
331
|
+
and register information as the V2 version of the header. Immediately following the registers is
|
332
|
+
``num_vars`` instances of ``EXPR_VAR_STANDALONE`` that define the variables in this circuit. After
|
333
|
+
that, the data continues with custom definitions and instructions as in prior versions of QPY.
|
334
|
+
|
335
|
+
|
336
|
+
EXPR_VAR_DECLARATION
|
337
|
+
~~~~~~~~~~~~~~~~~~~~
|
338
|
+
|
339
|
+
An ``EXPR_VAR_DECLARATION`` defines an :class:`.expr.Var` instance that is standalone; that is, it
|
340
|
+
represents a self-owned memory location rather than wrapping a :class:`.Clbit` or
|
341
|
+
:class:`.ClassicalRegister`. The payload is a C struct:
|
342
|
+
|
343
|
+
.. code-block:: c
|
344
|
+
|
345
|
+
struct {
|
346
|
+
char uuid_bytes[16];
|
347
|
+
char usage;
|
348
|
+
uint16_t name_size;
|
349
|
+
}
|
350
|
+
|
351
|
+
which is immediately followed by an ``EXPR_TYPE`` payload and then ``name_size`` bytes of UTF-8
|
352
|
+
encoding string data containing the name of the variable.
|
353
|
+
|
354
|
+
The ``char`` usage type code takes the following values:
|
355
|
+
|
356
|
+
========= =========================================================================================
|
357
|
+
Type code Meaning
|
358
|
+
========= =========================================================================================
|
359
|
+
``I`` An ``input`` variable to the circuit.
|
360
|
+
|
361
|
+
``C`` A ``capture`` variable to the circuit.
|
362
|
+
|
363
|
+
``L`` A locally declared variable to the circuit.
|
364
|
+
========= =========================================================================================
|
365
|
+
|
366
|
+
|
367
|
+
Changes to EXPR_VAR
|
368
|
+
~~~~~~~~~~~~~~~~~~~
|
369
|
+
|
370
|
+
The EXPR_VAR variable has gained a new type code and payload, in addition to the pre-existing ones:
|
371
|
+
|
372
|
+
=========================== ========= ============================================================
|
373
|
+
Python class Type code Payload
|
374
|
+
=========================== ========= ============================================================
|
375
|
+
:class:`.UUID` ``U`` One ``uint32_t`` index of the variable into the series of
|
376
|
+
``EXPR_VAR_STANDALONE`` variables that were written
|
377
|
+
immediately after the circuit header.
|
378
|
+
=========================== ========= ============================================================
|
379
|
+
|
380
|
+
Notably, this new type-code indexes into pre-defined variables from the circuit header, rather than
|
381
|
+
redefining the variable again in each location it is used.
|
382
|
+
|
383
|
+
|
384
|
+
Changes to EXPRESSION
|
385
|
+
---------------------
|
386
|
+
|
387
|
+
The EXPRESSION type code has a new possible entry, ``i``, corresponding to :class:`.expr.Index`
|
388
|
+
nodes.
|
389
|
+
|
390
|
+
====================== ========= ======================================================= ========
|
391
|
+
Qiskit class Type code Payload Children
|
392
|
+
====================== ========= ======================================================= ========
|
393
|
+
:class:`~.expr.Index` ``i`` No additional payload. The children are the target 2
|
394
|
+
and the index, in that order.
|
395
|
+
====================== ========= ======================================================= ========
|
396
|
+
|
397
|
+
|
165
398
|
.. _qpy_version_11:
|
166
399
|
|
167
400
|
Version 11
|
168
|
-
|
401
|
+
----------
|
169
402
|
|
170
403
|
Version 11 is identical to Version 10 except for the following.
|
171
404
|
First, the names in the CUSTOM_INSTRUCTION blocks
|
@@ -183,7 +416,7 @@ MODIFIER struct.
|
|
183
416
|
.. _modifier_qpy:
|
184
417
|
|
185
418
|
MODIFIER
|
186
|
-
|
419
|
+
~~~~~~~~
|
187
420
|
|
188
421
|
This represents :class:`~qiskit.circuit.annotated_operation.Modifier`
|
189
422
|
|
@@ -206,19 +439,20 @@ operation, and in the third case the field ``power`` represents the power of the
|
|
206
439
|
.. _qpy_version_10:
|
207
440
|
|
208
441
|
Version 10
|
209
|
-
|
442
|
+
----------
|
443
|
+
|
444
|
+
Version 10 adds support for:
|
210
445
|
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
0.45.0 release.
|
446
|
+
* symengine-native serialization for objects of type :class:`~.ParameterExpression` as well as
|
447
|
+
symbolic expressions in Pulse schedule blocks.
|
448
|
+
* new fields in the :class:`~.TranspileLayout` class added in the Qiskit 0.45.0 release.
|
215
449
|
|
216
450
|
The symbolic_encoding field is added to the file header, and a new encoding type char
|
217
451
|
is introduced, mapped to each symbolic library as follows: ``p`` refers to sympy
|
218
452
|
encoding and ``e`` refers to symengine encoding.
|
219
453
|
|
220
|
-
FILE_HEADER
|
221
|
-
|
454
|
+
Changes to FILE_HEADER
|
455
|
+
~~~~~~~~~~~~~~~~~~~~~~
|
222
456
|
|
223
457
|
The contents of FILE_HEADER after V10 are defined as a C struct as:
|
224
458
|
|
@@ -231,10 +465,10 @@ The contents of FILE_HEADER after V10 are defined as a C struct as:
|
|
231
465
|
uint8_t qiskit_patch_version;
|
232
466
|
uint64_t num_circuits;
|
233
467
|
char symbolic_encoding;
|
234
|
-
}
|
468
|
+
} FILE_HEADER_V10;
|
235
469
|
|
236
|
-
LAYOUT
|
237
|
-
|
470
|
+
Changes to LAYOUT
|
471
|
+
~~~~~~~~~~~~~~~~~
|
238
472
|
|
239
473
|
The ``LAYOUT`` struct is updated to have an additional ``input_qubit_count`` field.
|
240
474
|
With version 10 the ``LAYOUT`` struct is now:
|
@@ -257,14 +491,14 @@ and ``_output_qubit_list`` in the :class:`~.TranspileLayout` object are ``None``
|
|
257
491
|
.. _qpy_version_9:
|
258
492
|
|
259
493
|
Version 9
|
260
|
-
|
494
|
+
---------
|
261
495
|
|
262
496
|
Version 9 adds support for classical :class:`~.expr.Expr` nodes and their associated
|
263
497
|
:class:`~.types.Type`\\ s.
|
264
498
|
|
265
499
|
|
266
500
|
EXPRESSION
|
267
|
-
|
501
|
+
~~~~~~~~~~
|
268
502
|
|
269
503
|
An :class:`~.expr.Expr` node is represented by a stream of variable-width data. A node itself is
|
270
504
|
represented by (in order in the byte stream):
|
@@ -296,7 +530,7 @@ Qiskit class Type code Payload
|
|
296
530
|
|
297
531
|
|
298
532
|
EXPR_TYPE
|
299
|
-
|
533
|
+
~~~~~~~~~
|
300
534
|
|
301
535
|
A :class:`~.types.Type` is encoded by a single-byte ASCII ``char`` that encodes the kind of type,
|
302
536
|
followed by a payload that varies depending on the type. The defined codes are:
|
@@ -311,7 +545,7 @@ Qiskit class Type code Payload
|
|
311
545
|
|
312
546
|
|
313
547
|
EXPR_VAR
|
314
|
-
|
548
|
+
~~~~~~~~
|
315
549
|
|
316
550
|
This represents a runtime variable of a :class:`~.expr.Var` node. These are a type code, followed
|
317
551
|
by a type-code-specific payload:
|
@@ -328,7 +562,7 @@ Python class Type code Payload
|
|
328
562
|
|
329
563
|
|
330
564
|
EXPR_VALUE
|
331
|
-
|
565
|
+
~~~~~~~~~~
|
332
566
|
|
333
567
|
This represents a literal object in the classical type system, such as an integer. Currently there
|
334
568
|
are very few such literals. These are encoded as a type code, followed by a type-code-specific
|
@@ -346,7 +580,7 @@ Python type Type code Payload
|
|
346
580
|
|
347
581
|
|
348
582
|
Changes to INSTRUCTION
|
349
|
-
|
583
|
+
~~~~~~~~~~~~~~~~~~~~~~
|
350
584
|
|
351
585
|
To support the use of :class:`~.expr.Expr` nodes in the fields :attr:`.IfElseOp.condition`,
|
352
586
|
:attr:`.WhileLoopOp.condition` and :attr:`.SwitchCaseOp.target`, the INSTRUCTION struct is changed
|
@@ -393,7 +627,7 @@ Value Effects
|
|
393
627
|
|
394
628
|
|
395
629
|
Changes to INSTRUCTION_PARAM
|
396
|
-
|
630
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
397
631
|
|
398
632
|
A new type code ``x`` is added that defines an EXPRESSION parameter.
|
399
633
|
|
@@ -401,7 +635,7 @@ A new type code ``x`` is added that defines an EXPRESSION parameter.
|
|
401
635
|
.. _qpy_version_8:
|
402
636
|
|
403
637
|
Version 8
|
404
|
-
|
638
|
+
---------
|
405
639
|
|
406
640
|
Version 8 adds support for handling a :class:`~.TranspileLayout` stored in the
|
407
641
|
:attr:`.QuantumCircuit.layout` attribute. In version 8 immediately following the
|
@@ -410,7 +644,7 @@ calibrations block at the end of the circuit payload there is now the
|
|
410
644
|
:class:`~.TranspileLayout` class.
|
411
645
|
|
412
646
|
LAYOUT
|
413
|
-
|
647
|
+
~~~~~~
|
414
648
|
|
415
649
|
.. code-block:: c
|
416
650
|
|
@@ -432,7 +666,7 @@ are ``initial_layout_size`` ``INITIAL_LAYOUT_BIT`` structs to define the
|
|
432
666
|
:attr:`.TranspileLayout.initial_layout` attribute.
|
433
667
|
|
434
668
|
INITIAL_LAYOUT_BIT
|
435
|
-
|
669
|
+
~~~~~~~~~~~~~~~~~~
|
436
670
|
|
437
671
|
.. code-block:: c
|
438
672
|
|
@@ -458,7 +692,7 @@ circuit.
|
|
458
692
|
.. _qpy_version_7:
|
459
693
|
|
460
694
|
Version 7
|
461
|
-
|
695
|
+
---------
|
462
696
|
|
463
697
|
Version 7 adds support for :class:`.~Reference` instruction and serialization of
|
464
698
|
a :class:`.~ScheduleBlock` program while keeping its reference to subroutines::
|
@@ -504,7 +738,7 @@ condition of an INSTRUCTION field <qpy_instructions>`.
|
|
504
738
|
.. _qpy_version_6:
|
505
739
|
|
506
740
|
Version 6
|
507
|
-
|
741
|
+
---------
|
508
742
|
|
509
743
|
Version 6 adds support for :class:`.~ScalableSymbolicPulse`. These objects are saved and read
|
510
744
|
like `SymbolicPulse` objects, and the class name is added to the data to correctly handle
|
@@ -531,7 +765,7 @@ identical to :ref:`qpy_version_5`.
|
|
531
765
|
.. _qpy_version_5:
|
532
766
|
|
533
767
|
Version 5
|
534
|
-
|
768
|
+
---------
|
535
769
|
|
536
770
|
Version 5 changes from :ref:`qpy_version_4` by adding support for :class:`.~ScheduleBlock`
|
537
771
|
and changing two payloads the INSTRUCTION metadata payload and the CUSTOM_INSTRUCTION block.
|
@@ -566,7 +800,7 @@ immediately follows the file header block to represent the program type stored i
|
|
566
800
|
.. _qpy_schedule_block:
|
567
801
|
|
568
802
|
SCHEDULE_BLOCK
|
569
|
-
|
803
|
+
~~~~~~~~~~~~~~
|
570
804
|
|
571
805
|
:class:`~.ScheduleBlock` is first supported in QPY Version 5. This allows
|
572
806
|
users to save pulse programs in the QPY binary format as follows:
|
@@ -591,7 +825,7 @@ no extra option is required to save the schedule block.
|
|
591
825
|
.. _qpy_schedule_block_header:
|
592
826
|
|
593
827
|
SCHEDULE_BLOCK_HEADER
|
594
|
-
|
828
|
+
~~~~~~~~~~~~~~~~~~~~~
|
595
829
|
|
596
830
|
:class:`~.ScheduleBlock` block starts with the following header:
|
597
831
|
|
@@ -610,7 +844,7 @@ attached to the schedule.
|
|
610
844
|
.. _qpy_schedule_alignments:
|
611
845
|
|
612
846
|
SCHEDULE_BLOCK_ALIGNMENTS
|
613
|
-
|
847
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
614
848
|
|
615
849
|
Then, alignment context of the schedule block starts with ``char``
|
616
850
|
representing the supported context type followed by the :ref:`qpy_sequence` block representing
|
@@ -628,7 +862,7 @@ stored in the context parameters.
|
|
628
862
|
.. _qpy_schedule_instructions:
|
629
863
|
|
630
864
|
SCHEDULE_BLOCK_INSTRUCTIONS
|
631
|
-
|
865
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
632
866
|
|
633
867
|
This alignment block is further followed by ``num_element`` length of block elements which may
|
634
868
|
consist of nested schedule blocks and schedule instructions.
|
@@ -653,7 +887,7 @@ The mapping of type char to the instruction subclass is defined as follows:
|
|
653
887
|
.. _qpy_schedule_operands:
|
654
888
|
|
655
889
|
SCHEDULE_BLOCK_OPERANDS
|
656
|
-
|
890
|
+
~~~~~~~~~~~~~~~~~~~~~~~
|
657
891
|
|
658
892
|
The operands of these instances can be serialized through the standard QPY value serialization
|
659
893
|
mechanism, however there are special object types that only appear in the schedule operands.
|
@@ -670,7 +904,7 @@ Special objects start with the following type key:
|
|
670
904
|
.. _qpy_schedule_channel:
|
671
905
|
|
672
906
|
CHANNEL
|
673
|
-
|
907
|
+
~~~~~~~
|
674
908
|
|
675
909
|
Channel block starts with channel subtype ``char`` that maps an object data to
|
676
910
|
:class:`~qiskit.pulse.channels.Channel` subclass. Mapping is defined as follows:
|
@@ -687,7 +921,7 @@ The key is immediately followed by the channel index serialized as the INSTRUCTI
|
|
687
921
|
.. _qpy_schedule_waveform:
|
688
922
|
|
689
923
|
Waveform
|
690
|
-
|
924
|
+
~~~~~~~~
|
691
925
|
|
692
926
|
Waveform block starts with WAVEFORM header:
|
693
927
|
|
@@ -709,7 +943,7 @@ INSTRUCTION_PARAM pack struct, which can be string or ``None``.
|
|
709
943
|
.. _qpy_schedule_symbolic_pulse:
|
710
944
|
|
711
945
|
SymbolicPulse
|
712
|
-
|
946
|
+
~~~~~~~~~~~~~
|
713
947
|
|
714
948
|
SymbolicPulse block starts with SYMBOLIC_PULSE header:
|
715
949
|
|
@@ -743,7 +977,7 @@ INSTRUCTION_PARAM pack struct, which can be string or ``None``.
|
|
743
977
|
.. _qpy_mapping:
|
744
978
|
|
745
979
|
MAPPING
|
746
|
-
|
980
|
+
~~~~~~~
|
747
981
|
|
748
982
|
The MAPPING is a representation for arbitrary mapping object. This is a fixed length
|
749
983
|
:ref:`qpy_sequence` of key-value pair represented by the MAP_ITEM payload.
|
@@ -765,7 +999,7 @@ QPY serializable ``type``.
|
|
765
999
|
.. _qpy_circuit_calibrations:
|
766
1000
|
|
767
1001
|
CIRCUIT_CALIBRATIONS
|
768
|
-
|
1002
|
+
~~~~~~~~~~~~~~~~~~~~
|
769
1003
|
|
770
1004
|
The CIRCUIT_CALIBRATIONS block is a dictionary to define pulse calibrations of the custom
|
771
1005
|
instruction set. This block starts with the following CALIBRATION header:
|
@@ -800,7 +1034,7 @@ Finally, :ref:`qpy_schedule_block` payload is packed for each CALIBRATION_DEF en
|
|
800
1034
|
.. _qpy_instruction_v5:
|
801
1035
|
|
802
1036
|
INSTRUCTION
|
803
|
-
|
1037
|
+
~~~~~~~~~~~
|
804
1038
|
|
805
1039
|
The INSTRUCTION block was modified to add two new fields ``num_ctrl_qubits`` and ``ctrl_state``
|
806
1040
|
which are used to model the :attr:`.ControlledGate.num_ctrl_qubits` and
|
@@ -826,7 +1060,7 @@ The rest of the instruction payload is the same. You can refer to
|
|
826
1060
|
:ref:`qpy_instructions` for the details of the full payload.
|
827
1061
|
|
828
1062
|
CUSTOM_INSTRUCTION
|
829
|
-
|
1063
|
+
~~~~~~~~~~~~~~~~~~
|
830
1064
|
|
831
1065
|
The CUSTOM_INSTRUCTION block in QPY version 5 adds a new field
|
832
1066
|
``base_gate_size`` which is used to define the size of the
|
@@ -869,7 +1103,7 @@ indicate the custom instruction is a custom :class:`~.ControlledGate`.
|
|
869
1103
|
.. _qpy_version_4:
|
870
1104
|
|
871
1105
|
Version 4
|
872
|
-
|
1106
|
+
---------
|
873
1107
|
|
874
1108
|
Version 4 is identical to :ref:`qpy_version_3` except that it adds 2 new type strings
|
875
1109
|
to the INSTRUCTION_PARAM struct, ``z`` to represent ``None`` (which is encoded as
|
@@ -899,7 +1133,7 @@ part of the circuit or not.
|
|
899
1133
|
.. _qpy_range_pack:
|
900
1134
|
|
901
1135
|
RANGE
|
902
|
-
|
1136
|
+
~~~~~
|
903
1137
|
|
904
1138
|
A RANGE is a representation of a ``range`` object. It is defined as:
|
905
1139
|
|
@@ -914,7 +1148,7 @@ A RANGE is a representation of a ``range`` object. It is defined as:
|
|
914
1148
|
.. _qpy_sequence:
|
915
1149
|
|
916
1150
|
SEQUENCE
|
917
|
-
|
1151
|
+
~~~~~~~~
|
918
1152
|
|
919
1153
|
A SEQUENCE is a representation of an arbitrary sequence object. As sequence are just fixed length
|
920
1154
|
containers of arbitrary python objects their QPY can't fully represent any sequence,
|
@@ -936,7 +1170,7 @@ into proper type, e.g. ``tuple``, afterwards.
|
|
936
1170
|
.. _qpy_version_3:
|
937
1171
|
|
938
1172
|
Version 3
|
939
|
-
|
1173
|
+
---------
|
940
1174
|
|
941
1175
|
Version 3 of the QPY format is identical to :ref:`qpy_version_2` except that it defines
|
942
1176
|
a struct format to represent a :class:`~qiskit.circuit.library.PauliEvolutionGate`
|
@@ -951,7 +1185,7 @@ as follows:
|
|
951
1185
|
.. _pauli_evo_qpy:
|
952
1186
|
|
953
1187
|
PAULI_EVOLUTION
|
954
|
-
|
1188
|
+
~~~~~~~~~~~~~~~
|
955
1189
|
|
956
1190
|
This represents the high level :class:`~qiskit.circuit.library.PauliEvolutionGate`
|
957
1191
|
|
@@ -979,7 +1213,7 @@ the :class:`.EvolutionSynthesis` class used by the gate.
|
|
979
1213
|
.. _qpy_pauli_sum_op:
|
980
1214
|
|
981
1215
|
SPARSE_PAULI_OP_LIST_ELEM
|
982
|
-
|
1216
|
+
~~~~~~~~~~~~~~~~~~~~~~~~~
|
983
1217
|
|
984
1218
|
This represents an instance of :class:`.SparsePauliOp`.
|
985
1219
|
|
@@ -1003,7 +1237,7 @@ parameters are defined below as :ref:`qpy_param_vector`.
|
|
1003
1237
|
.. _qpy_param_vector:
|
1004
1238
|
|
1005
1239
|
PARAMETER_VECTOR_ELEMENT
|
1006
|
-
|
1240
|
+
~~~~~~~~~~~~~~~~~~~~~~~~
|
1007
1241
|
|
1008
1242
|
A PARAMETER_VECTOR_ELEMENT represents a :class:`~qiskit.circuit.ParameterVectorElement`
|
1009
1243
|
object the data for a INSTRUCTION_PARAM. The contents of the PARAMETER_VECTOR_ELEMENT are
|
@@ -1025,7 +1259,7 @@ the parameter's vector name.
|
|
1025
1259
|
|
1026
1260
|
|
1027
1261
|
PARAMETER_EXPR
|
1028
|
-
|
1262
|
+
~~~~~~~~~~~~~~
|
1029
1263
|
|
1030
1264
|
Additionally, since QPY format version v3 distinguishes between a
|
1031
1265
|
:class:`~qiskit.circuit.Parameter` and :class:`~qiskit.circuit.ParameterVectorElement`
|
@@ -1079,14 +1313,14 @@ and size will be 0 as the value will just be the same as the key. If
|
|
1079
1313
|
.. _qpy_version_2:
|
1080
1314
|
|
1081
1315
|
Version 2
|
1082
|
-
|
1316
|
+
---------
|
1083
1317
|
|
1084
1318
|
Version 2 of the QPY format is identical to version 1 except for the HEADER
|
1085
1319
|
section is slightly different. You can refer to the :ref:`qpy_version_1` section
|
1086
1320
|
for the details on the rest of the payload format.
|
1087
1321
|
|
1088
1322
|
HEADER
|
1089
|
-
|
1323
|
+
~~~~~~
|
1090
1324
|
|
1091
1325
|
The contents of HEADER are defined as a C struct are:
|
1092
1326
|
|
@@ -1101,7 +1335,6 @@ The contents of HEADER are defined as a C struct are:
|
|
1101
1335
|
uint64_t metadata_size;
|
1102
1336
|
uint32_t num_registers;
|
1103
1337
|
uint64_t num_instructions;
|
1104
|
-
uint64_t num_custom_gates;
|
1105
1338
|
}
|
1106
1339
|
|
1107
1340
|
This is immediately followed by ``name_size`` bytes of utf8 data for the name
|
@@ -1117,10 +1350,10 @@ object which is represented by a PARAM struct (see below), ``e`` defines a
|
|
1117
1350
|
.. _qpy_version_1:
|
1118
1351
|
|
1119
1352
|
Version 1
|
1120
|
-
|
1353
|
+
---------
|
1121
1354
|
|
1122
1355
|
HEADER
|
1123
|
-
|
1356
|
+
~~~~~~
|
1124
1357
|
|
1125
1358
|
The contents of HEADER as defined as a C struct are:
|
1126
1359
|
|
@@ -1134,14 +1367,13 @@ The contents of HEADER as defined as a C struct are:
|
|
1134
1367
|
uint64_t metadata_size;
|
1135
1368
|
uint32_t num_registers;
|
1136
1369
|
uint64_t num_instructions;
|
1137
|
-
uint64_t num_custom_gates;
|
1138
1370
|
}
|
1139
1371
|
|
1140
1372
|
This is immediately followed by ``name_size`` bytes of utf8 data for the name
|
1141
1373
|
of the circuit.
|
1142
1374
|
|
1143
1375
|
METADATA
|
1144
|
-
|
1376
|
+
~~~~~~~~
|
1145
1377
|
|
1146
1378
|
The METADATA field is a UTF8 encoded JSON string. After reading the HEADER
|
1147
1379
|
(which is a fixed size at the start of the QPY file) and the ``name`` string
|
@@ -1151,7 +1383,7 @@ the metadata for the circuit.
|
|
1151
1383
|
.. _qpy_registers:
|
1152
1384
|
|
1153
1385
|
REGISTERS
|
1154
|
-
|
1386
|
+
~~~~~~~~~
|
1155
1387
|
|
1156
1388
|
The contents of REGISTERS is a number of REGISTER object. If num_registers is
|
1157
1389
|
> 0 then after reading METADATA you read that number of REGISTER structs defined
|
@@ -1201,7 +1433,7 @@ the register ``qr`` would be a standalone register. While something like::
|
|
1201
1433
|
.. _qpy_custom_definition:
|
1202
1434
|
|
1203
1435
|
CUSTOM_DEFINITIONS
|
1204
|
-
|
1436
|
+
~~~~~~~~~~~~~~~~~~
|
1205
1437
|
|
1206
1438
|
This section specifies custom definitions for any of the instructions in the circuit.
|
1207
1439
|
|
@@ -1241,7 +1473,7 @@ it will be a :class:`~qiskit.circuit.Instruction` object.
|
|
1241
1473
|
.. _qpy_instructions:
|
1242
1474
|
|
1243
1475
|
INSTRUCTIONS
|
1244
|
-
|
1476
|
+
~~~~~~~~~~~~
|
1245
1477
|
|
1246
1478
|
The contents of INSTRUCTIONS is a list of INSTRUCTION metadata objects
|
1247
1479
|
|
@@ -1317,7 +1549,7 @@ and in QPY :ref:`qpy_version_3` ``'v'`` represents a
|
|
1317
1549
|
.. _qpy_param_struct:
|
1318
1550
|
|
1319
1551
|
PARAMETER
|
1320
|
-
|
1552
|
+
~~~~~~~~~
|
1321
1553
|
|
1322
1554
|
A PARAMETER represents a :class:`~qiskit.circuit.Parameter` object the data for
|
1323
1555
|
a INSTRUCTION_PARAM. The contents of the PARAMETER are defined as:
|
@@ -1335,7 +1567,7 @@ parameter name.
|
|
1335
1567
|
.. _qpy_param_expr:
|
1336
1568
|
|
1337
1569
|
PARAMETER_EXPR
|
1338
|
-
|
1570
|
+
~~~~~~~~~~~~~~
|
1339
1571
|
|
1340
1572
|
A PARAMETER_EXPR represents a :class:`~qiskit.circuit.ParameterExpression`
|
1341
1573
|
object that the data for an INSTRUCTION_PARAM. The contents of a PARAMETER_EXPR
|
@@ -1374,7 +1606,7 @@ Finally, if type is ``i`` it represents an integer which is an ``int64_t``.
|
|
1374
1606
|
.. _qpy_complex:
|
1375
1607
|
|
1376
1608
|
COMPLEX
|
1377
|
-
|
1609
|
+
~~~~~~~
|
1378
1610
|
|
1379
1611
|
When representing a double precision complex value in QPY the following
|
1380
1612
|
struct is used:
|
@@ -1395,7 +1627,7 @@ this matches the internal C representation of Python's complex type. [#f3]_
|
|
1395
1627
|
.. [#f3] https://docs.python.org/3/c-api/complex.html#c.Py_complex
|
1396
1628
|
"""
|
1397
1629
|
|
1398
|
-
from .exceptions import QpyError, QPYLoadingDeprecatedFeatureWarning
|
1630
|
+
from .exceptions import QpyError, UnsupportedFeatureForVersion, QPYLoadingDeprecatedFeatureWarning
|
1399
1631
|
from .interface import dump, load
|
1400
1632
|
|
1401
1633
|
# For backward compatibility. Provide, Runtime, Experiment call these private functions.
|