QpyModelV13ToV17
pydantic model QpyModelV13ToV17
Bases: QpyModel
QPY encoded circuits with restricted version range.
circuit_b64
field
Type: str [Required]
Base-64 encoded data of the QPY serialization of a single quantum circuit.
Validated by
cross_validate_qpy_version
qpy_version
field
Type: int [Required]
The QPY encoding version.
Constraints
- ge = 13
- le = 17
Validated by
cross_validate_qpy_version
cross_validate_qpy_version
validator cross_validate_qpy_version
Check that the reported version matches the encoded version.
from_quantum_circuit
classmethod from_quantum_circuit(circuit, qpy_version=17)
Create a model instance from a quantum circuit.
The returned instance owns a reference to the provided circuit. This instance may be returned by to_quantum_circuit() depending on the value of use_cached. Users of this class are responsible for managing cached instances of the circuit and possible side-effects of their mutations.
Parameters
- circuit (QuantumCircuit) – The circuit to encode into the model.
- qpy_version (int) – The QPY version to encode with.
Returns
A new model instance.
to_quantum_circuit
to_quantum_circuit(use_cached=False)
Return a decoded quantum circuit instance.
When use_cached is false, or when no cached version exists, circuit_b64 is decoded and loaded into a new instance. Users of this class are responsible for managing cached instances of the circuit and possible side-effects of their mutations.
Parameters
use_cached (bool) – Whether to return the cached instance (if it exists).
Returns
A quantum circuit.
Return type