iqm.iqm_client.iqm_client

iqm.iqm_client.iqm_client#

Client for connecting to the IQM quantum computer server interface.

The Circuit class represents quantum circuits to be executed, consisting of native quantum operations, each represented by an instance of the Instruction class. Different Instruction types are distinguished by their name. Each Instruction type acts on a number of qubits, and expects certain args.

Instructions#

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.

barrier

>= 1

Execution barrier.

move

2

Moves 1 state between resonator and qubit.

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 only be measured once. The measurement must be the last operation on each qubit, i.e. it cannot be followed by gates.

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={})

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 1-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 1-qubit barriers (e.g. during circuit optimization), therefore having them is allowed.

Circuit output#

The RunResult class represents the results of the quantum circuit execution job. If the job succeeded, RunResult.measurements contains the output of the batch of circuits, consisting of the results of the measurement operations in each circuit. It is a list of dictionaries, where each dict maps each measurement key to a 2D array of measurement results, represented as a nested list. RunResult.measurements[circuit_index][key][shot][qubit_index] is the result of measuring the qubit_index’th qubit in measurement operation key in the shot shot in the circuit_index’th circuit of the batch.

The results are non-negative integers representing the computational basis state (for qubits, 0 or 1) that was the measurement outcome.


Module Attributes

CircuitBatch

Type that represents a list of quantum circuits to be executed together in a single batch.

QubitMapping

Type that represents a qubit mapping for a circuit, i.e. a list of single qubit mappings for all qubits in the circuit.

CircuitMeasurementResults

Measurement results from a single circuit.

CircuitMeasurementResultsBatch

Type that represents measurement results for a batch of circuits.

Functions

serialize_qubit_mapping(qubit_mapping)

Serializes a qubit mapping dict into the corresponding IQM data transfer format.

validate_circuit(circuit)

Validates a submitted quantum circuit using Pydantic tooling.

Classes

AuthRequest(*, client_id[, grant_type, ...])

Request sent to authentication server for access token and refresh token, or for terminating the session.

Circuit(*, name, instructions[, metadata])

Quantum circuit to be executed.

Credentials(*, auth_server_url, username, ...)

Credentials and tokens for maintaining a session with the authentication server.

ExternalToken(*, auth_server_url, access_token)

Externally managed token for maintaining a session with the authentication server.

GrantType(value)

Type of token request.

HeraldingMode(value)

Heralding mode for circuit execution.

IQMClient(url, *[, client_signature, ...])

Provides access to IQM quantum computers.

Metadata(*[, calibration_set_id, ...])

Metadata describing a circuit execution job.

RunRequest(*, circuits[, custom_settings, ...])

Request for an IQM quantum computer to run a job that executes a batch of quantum circuits.

RunResult(*, status[, measurements, ...])

Results of a circuit execution job.

RunStatus(*, status[, message, warnings])

Status of a circuit execution job.

SingleQubitMapping(*, logical_name, ...)

Mapping of a logical qubit name to a physical qubit name.

Status(value)

Status of a job.

Exceptions

APITimeoutError

Exception for when executing a job on the server takes too long.

CircuitExecutionError

Something went wrong on the server.

CircuitValidationError

Circuit validation failed.

ClientAuthenticationError

Something went wrong with user authentication.

ClientConfigurationError

Wrong configuration provided.

JobAbortionError

Job abortion failed.

Inheritance

Inheritance diagram of iqm.iqm_client.iqm_client