Skip to content

laboneq_applications.experiments.two_qubit_rb

This module defines a two-qubit randomized benchmarking experiment.

In this experiment, random sequences of two-qubit Clifford gates are applied to qubit pairs, followed by a recovery gate that should return the system to |00⟩ for perfect gates.

The experiment has the following pulse sequence:

qb0 --- [2q-clifford sequence] --- [recovery gate] --- [ measure ]
qb1 --- [2q-clifford sequence] --- [recovery gate] --- [ measure ]

If multiple qubit pairs are passed, the above pulses are applied in parallel on all pairs. A different random Clifford sequence is played on each pair. Shorter sequences start later, so that every sequence ends right before the measurement.

TwoQubitRBExperimentOptions

Experiment options for two-qubit randomized benchmarking.

Sets averaging_mode to SINGLE_SHOT and acquisition_type to DISCRIMINATION, the only values that create_experiment accepts. The analysis computes the joint populations of each pair from the states that the single shots of its qubits are assigned to.

acquisition_type = workflow.option_field(AcquisitionType.DISCRIMINATION, description='Acquisition type. Must be DISCRIMINATION.', converter=AcquisitionType) class-attribute instance-attribute

averaging_mode = workflow.option_field(AveragingMode.SINGLE_SHOT, description='Averaging mode. Must be SINGLE_SHOT.', converter=AveragingMode) class-attribute instance-attribute

create_experiment(qpu, qubits, qubit_pairs, clifford_sequences, options=None)

Creates a two-qubit randomized benchmarking experiment.

Parameters:

Name Type Description Default
qpu QPU

The qpu consisting of the original qubits and quantum operations.

required
qubits QuantumElements

The qubits and couplers that flatten_qubit_pairs returns. @dsl.qubit_experiment registers their signals.

required
qubit_pairs list[list[str]]

List of [q0, q1] qubit pairs to run the experiments on, passed by UID. The pairs must not share qubits.

required
clifford_sequences dict[str, tuple[list[tuple], ...]]

The RB sequences of each pair, keyed by "q0_uid-q1_uid", as generate_clifford_sequences returns them.

required
options TwoQubitRBExperimentOptions | None

The options for building the workflow.

None

Returns:

Name Type Description
experiment Experiment

The generated LabOne Q experiment instance to be compiled and executed.

Raises:

Type Description
ValueError

If two pairs share a qubit, if the transition option is not "ge", or if the averaging_mode and acquisition_type options are not SINGLE_SHOT and DISCRIMINATION.

experiment_workflow(session, qpu, qubit_pairs, *, length_cliffords, variations=1, seed=None, gate_map=None, temporary_parameters=None, options=None)

The Randomized Benchmarking Workflow for two-qubit pairs.

The workflow consists of the following steps:

Changed in version 27.1.0

The experiment moved out of contrib and no longer needs Qiskit.

  • Each pair plays its own random Clifford sequences, so the pairs must not share qubits.
  • The same seed gives different sequences than before.
  • gate_map accepts only the gates sx, x and rz and one two-qubit gate, cz, cx or iswap.
  • The experiment supports only the ge transition, and only single-shot, discriminated data: the averaging_mode and acquisition_type options must be SINGLE_SHOT and DISCRIMINATION.
  • It resets the qubits actively before every sequence when the active_reset option is set.
  • The tasks take the qubit pairs as UIDs.
  • create_tq_rb_qasm is now generate_clifford_sequences, and resolve_qubit_pairs, get_gate_map and add_qasm_operations are gone.

Parameters:

Name Type Description Default
session Session

The connected session to use for running the experiment.

required
qpu QPU

The qpu consisting of the original qubits and quantum operations.

required
qubit_pairs list[list[str]]

List of [q0, q1] qubit pairs to run the experiments on, passed by UID. The pairs must not share qubits.

required
length_cliffords list[int]

List of numbers of 2-qubit Clifford gates to sweep.

required
variations int

Number of random seeds for RB.

1
seed int | None

The seed of the random sequences. The sequences of a pair depend only on the seed and the UIDs of its qubits. Default is None and provides a random seed.

None
gate_map dict | None

Maps the native gates sx, x and rz and one two-qubit gate, cz, cx or iswap, to the quantum operations that implement them. Needs sx, rz and the two-qubit gate; x is optional. With cx, the operations must follow the conventions that generate_clifford_sequences states. Default: {"sx": "x90", "x": "x180", "rz": "rz", "cz": "cz"}.

None
temporary_parameters dict[str, dict | QuantumParameters] | None

The temporary QPU parameters.

None
options TuneUpWorkflowOptions | None

The options for building the workflow.

None

Returns:

Name Type Description
WorkflowBuilder None

The builder for the experiment workflow.

Example
options = experiment_workflow.options()
options.count(10)
# QPU from a two-qubit device setup
qpu = QPU(
    quantum_elements=TunableTransmonQubit.from_device_setup(setup),
    quantum_operations=TunableTransmonOperations(),
)
result = experiment_workflow(
    session=session,
    qpu=qpu,
    qubit_pairs=[["q0", "q1"]],
    length_cliffords=[1, 5, 10, 20, 50],
    variations=5,
    options=options,
).run()

flatten_qubit_pairs(qpu, qubit_pairs)

Returns the qubits of qubit_pairs and the elements on the edges between them.

create_experiment passes this list to @dsl.qubit_experiment, which registers the signals of the qubits and of the couplers that the two-qubit gates drive.

Parameters:

Name Type Description Default
qpu QPU

The QPU, whose topology holds the edges between the qubits.

required
qubit_pairs list[list[str]]

List of [q0, q1] pairs, passed by UID.

required

Returns:

Type Description
list[QuantumElement]

The qubits of all pairs, each followed by the quantum elements on the edges between them, without duplicates: [q0, q1, coupler_q0q1, q2, q3, coupler_q2q3, ...].

generate_clifford_sequences(qubit_pairs, length_cliffords, gate_map=None, variations=1, seed=None)

Creates the two-qubit RB Clifford sequences of each pair as lists of gates.

Each sequence draws its two-qubit Cliffords uniformly at random and ends with the Clifford that inverts them. Each Clifford takes the fewest two-qubit gates, then the fewest pulses, that the gates of gate_map allow. Every pair gets its own sequences.

Parameters:

Name Type Description Default
qubit_pairs list[list[str]]

List of [q0, q1] pairs to create the sequences for, passed by UID.

required
length_cliffords list

A list of RB sequence lengths (number of 2-qubit Cliffords).

required
gate_map dict | None

Maps the native gates sx, x and rz and one two-qubit gate, cz, cx or iswap, to the quantum operations that implement them. Needs sx, rz and the two-qubit gate; x is optional. With cx, the sequences return to |00⟩ only if rz(θ) implements exp(-iθZ/2) and sx implements exp(-iπX/4), or both implement the inverses, and if cx takes its control qubit first. With cz and iswap, the directions of these rotations do not matter. Default: {"sx": "x90", "x": "x180", "rz": "rz", "cz": "cz"}.

None
variations int

Number of random sequences per sequence length.

1
seed int | None

The seed of the random sequences. The sequences of a pair depend only on the seed and the UIDs of its qubits.

None

Returns:

Type Description
dict[str, tuple[list[tuple], ...]]

A dictionary of Clifford sequences, keyed by "q0_uid-q1_uid". Each sequence is a list of (operation, qubits, *parameters) gates, where operation is the name of a quantum operation and qubits holds the positions in the pair of the qubits it acts on. A pair has one sequence per variation and length, ordered by variation and then by length: for length_cliffords=[1, 5] and variations=2, the lengths are 1, 5, 1, 5.

Raises:

Type Description
ValueError

If gate_map names a gate other than sx, x, rz, cz, cx and iswap, lacks sx or rz, or does not name exactly one two-qubit gate.