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 |
|
Measurement in the Z basis. |
prx |
1 |
|
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_rx
↦prx
measurement
↦measure
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.
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
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})
CZ#
Controlled-Z gate. Represented in the standard computational basis by the matrix
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\):
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={})
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 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
Type that represents a list of quantum circuits to be executed together in a single batch. |
|
Type that represents a qubit mapping for a circuit, i.e. a list of single qubit mappings for all qubits in the circuit. |
|
Measurement results from a single circuit. |
|
Type that represents measurement results for a batch of circuits. |
Functions
|
Serializes a qubit mapping dict into the corresponding IQM data transfer format. |
|
Validates a submitted quantum circuit using Pydantic tooling. |
Classes
|
Request sent to authentication server for access token and refresh token, or for terminating the session. |
|
Quantum circuit to be executed. |
|
Credentials and tokens for maintaining a session with the authentication server. |
|
Externally managed token for maintaining a session with the authentication server. |
|
Type of token request. |
|
Heralding mode for circuit execution. |
|
Provides access to IQM quantum computers. |
|
Metadata describing a circuit execution job. |
|
Request for an IQM quantum computer to run a job that executes a batch of quantum circuits. |
|
Results of a circuit execution job. |
|
Status of a circuit execution job. |
|
Mapping of a logical qubit name to a physical qubit name. |
|
Status of a job. |
Exceptions
Exception for when executing a job on the server takes too long. |
|
Something went wrong on the server. |
|
Circuit validation failed. |
|
Something went wrong with user authentication. |
|
Wrong configuration provided. |
|
Job abortion failed. |
Inheritance