iqm.iqm_client.models.Instruction#
- class iqm.iqm_client.models.Instruction(*, name: str, implementation: str | None = None, qubits: tuple[str, ...], args: dict[str, Any])#
Bases:
BaseModel
Native quantum operation instance with particular arguments and locus.
This class represents a native quantum operation acting on
qubits
, with the argumentsargs
. The operation is determined byname
.We currently support the following native operations:
name
# of qubits
args
description
measure
>= 1
key: str
,feedback_key: str
Measurement in the Z basis.
prx
1
angle_t: float
,phase_t: float
Phased x-rotation gate.
cc_prx
1
angle_t: float
,phase_t: float
,feedback_qubit: str
,feedback_key: str
Classically controlled PRX gate.
cz
2
Controlled-Z gate.
move
2
Moves a qubit state between a qubit and a computational resonator, as long as at least one of the components is in the \(|0\rangle\) state.
barrier
>= 1
Execution barrier.
For each Instruction you may also optionally specify
implementation
, which contains the name of an implementation of the operation to use. Support for multiple implementations is currently experimental and in normal use the field should be omitted, this selects the default implementation for the operation for that locus.Measure#
Measurement in the computational (Z) basis. The measurement results are the output of the circuit. Takes two string arguments:
key
, denoting the measurement key the returned results are labeled with, andfeedback_key
, which is only needed if the measurement result is used for classical control within the circuit. All the measurement keys and feedback keys used in a circuit must be unique (but the two groups of keys are independent namespaces). Each qubit may be measured multiple times, i.e. mid-circuit measurements are allowed.Instruction(name='measure', qubits=('alice', 'bob', 'charlie'), args={'key': 'm1'})
PRX#
Phased x-rotation gate, i.e. an x-rotation conjugated by a z-rotation. Takes two arguments, the rotation angle
angle_t
and the phase anglephase_t
, both measured in units of full turns (\(2\pi\) radians). The gate is represented in the standard computational basis by the matrix\[\text{PRX}(\theta, \phi) = \exp(-i (X \cos (2 \pi \; \phi) + Y \sin (2 \pi \; \phi)) \: \pi \; \theta) = \text{RZ}(\phi) \: \text{RX}(\theta) \: \text{RZ}^\dagger(\phi),\]where \(\theta\) =
angle_t
, \(\phi\) =phase_t
, and \(X\) and \(Y\) are Pauli matrices.Instruction(name='prx', qubits=('bob',), args={'angle_t': 0.7, 'phase_t': 0.25})
CC_PRX#
Classically controlled PRX gate. Takes four arguments.
angle_t
andphase_t
are exactly as in PRX.feedback_key
is a string that identifies themeasure
instruction whose result controls the gate (the one that shares the feedback key).feedback_qubit
is the name of the physical qubit within themeasure
instruction that produces the feedback. If the measurement result is 1, the PRX gate is applied. If it is 0, an identity gate of similar time duration gate is applied instead. The measurement instruction must precede the classically controlled gate instruction in the quantum circuit.CZ#
Controlled-Z gate. Represented in the standard computational basis by the matrix
\[\text{CZ} = \text{diag}(1, 1, 1, -1).\]It is symmetric wrt. the qubits it’s acting on, and takes no arguments.
Instruction(name='cz', qubits=('alice', 'bob'), args={})
MOVE#
The MOVE operation is a unitary population exchange operation between a qubit and a resonator. Its effect is only defined in the invariant subspace \(S = \text{span}\{|00\rangle, |01\rangle, |10\rangle\}\), where it swaps the populations of the states \(|01\rangle\) and \(|10\rangle\). Its effect on the orthogonal subspace is undefined.
MOVE has the following presentation in the subspace \(S\):
\[\text{MOVE}_S = |00\rangle \langle 00| + a |10\rangle \langle 01| + a^{-1} |01\rangle \langle 10|,\]where \(a\) is an undefined complex phase that is canceled when the MOVE gate is applied a second time.
To ensure that the state of the qubit and resonator has no overlap with \(|11\rangle\), it is recommended that no single qubit gates are applied to the qubit in between a pair of MOVE operations.
Instruction(name='move', qubits=('alice', 'resonator'), args={})
Note
MOVE is only available in quantum computers with the IQM Star architecture.
Barrier#
A barrier instruction affects the physical execution order of the instructions elsewhere in the circuit that act on qubits spanned by the barrier. It ensures that any such instructions that succeed the barrier are only executed after all such instructions that precede the barrier have been completed. Hence it can be used to guarantee a specific causal order for the other instructions. It takes no arguments, and has no other effect.
Instruction(name='barrier', qubits=('alice', 'bob'), args={})
Note
One-qubit barriers will not have any effect on circuit’s compilation and execution. Higher layers that sit on top of IQM Client can make actual use of one-qubit barriers (e.g. during circuit optimization), therefore having them is allowed.
Attributes
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
name of the quantum operation
name of the implementation, for experimental use only
names of the locus components (typically qubits) the operation acts on
arguments for the operation
Methods
args_validator
(value, info)Check argument names and types for a given instruction
implementation_validator
(value)Check if the implementation of the instruction is set to a non-empty string.
name_validator
(value)Check if the name of instruction is set to one of the supported quantum operations.
qubits_validator
(value, info)Check if the instruction has the correct number of qubits for its operation.
- qubits: Locus#
names of the locus components (typically qubits) the operation acts on
- classmethod name_validator(value)#
Check if the name of instruction is set to one of the supported quantum operations.
- classmethod implementation_validator(value)#
Check if the implementation of the instruction is set to a non-empty string.
- classmethod qubits_validator(value, info: ValidationInfo)#
Check if the instruction has the correct number of qubits for its operation.
- Parameters:
info (ValidationInfo) –
- classmethod args_validator(value, info: ValidationInfo)#
Check argument names and types for a given instruction
- Parameters:
info (ValidationInfo) –
- model_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}#
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'args': FieldInfo(annotation=dict[str, Any], required=True, examples=[{'key': 'm'}]), 'implementation': FieldInfo(annotation=Union[Annotated[str, Strict(strict=True)], NoneType], required=False, default=None), 'name': FieldInfo(annotation=str, required=True, examples=['measure']), 'qubits': FieldInfo(annotation=tuple[Annotated[str, Strict(strict=True)], ...], required=True, examples=[('alice',)])}#
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.