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

The Instruction class represents a native quantum operation.

Different Instruction types are distinguished by their name. Each Instruction type acts on a number of qubits, and expects certain args.

We currently support the following native instruction types:

name

# of qubits

args

description

measure

>= 1

key: str

Measurement in the Z basis.

prx

1

angle_t: float, phase_t: float

Phased x-rotation gate.

cz

2

Controlled-Z gate.

move

2

Moves a qubit state between a qubit and a computational resonator.

barrier

>= 1

Execution barrier.

For each Instruction you may also optionally specify implementation, which contains the name of an implementation of the instruction 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 instruction.

Note

The following instruction names are deprecated, but supported for backwards compatibility for now:

  • phased_rxprx

  • measurementmeasure

Measure#

Measurement in the computational (Z) basis. The measurement results are the output of the circuit. Takes one string argument, key, denoting the measurement key the results are labeled with. All the measurement keys in a circuit must be unique. Each qubit may be measured multiple times, i.e. mid-circuit measurements are allowed.

Example#
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 angle phase_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.

Example#
Instruction(name='prx', qubits=('bob',), args={'angle_t': 0.7, 'phase_t': 0.25})

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.

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

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

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

model_computed_fields

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.

name

name of the quantum operation

implementation

name of the implementation, for experimental use only

qubits

names of the logical qubits the operation acts on

args

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 according to the instruction's type

implementation: StrictStr | None#

name of the implementation, for experimental use only

qubits: Locus#

names of the logical qubits the operation acts on

args: dict[str, Any]#

arguments for the operation

name: str#

name of the quantum operation

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 according to the instruction’s type

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.

Parameters: