Skip to content

laboneq_applications.experiments.single_qubit_rb

This module defines the single-qubit randomized benchmarking experiment.

In this experiment, we apply sequences of random Clifford gates of increasing length to a qubit, each followed by the recovery gate that returns the qubit to its initial state. The decay of the return probability with the sequence length gives the average error of the Clifford gates.

The experiment has the following pulse sequence:

qb --- [ prep transition ] --- [ clifford sequence ] --- [ recovery gate ] ---
[ measure ]

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

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

Creates a single-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 to run the experiments on. May be either a single qubit or a list of qubits.

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

The RB sequences of each qubit that generate_clifford_sequences returns.

required
options TuneupExperimentOptions | None

The options for building the workflow. In addition to options from WorkflowOptions, the following custom options are supported:

  • create_experiment: The options for creating the experiment.
None

Returns:

Name Type Description
experiment Experiment

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

Raises:

Type Description
ValueError

If the quantum operations cannot prepare the initial state of the transition or one of the calibration states.

Example
options = TuneupExperimentOptions()
options.count = 10
# QPU from a two-qubit device setup
qpu = QPU(
    quantum_elements=TunableTransmonQubit.from_device_setup(setup),
    quantum_operations=TunableTransmonOperations(),
)
q0, q1 = qpu["q0"], qpu["q1"]
clifford_sequences = generate_clifford_sequences(
    [q0, q1],
    length_cliffords=[1, 5, 10, 20, 50],
    variations=5,
)
create_experiment(
    qpu=qpu,
    qubits=[q0, q1],
    clifford_sequences=clifford_sequences,
    options=options,
)

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

The Randomized Benchmarking Workflow for single qubits.

The workflow consists of the following steps:

Changed in version 27.1.0

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

  • The workflow is named single_qubit_rb instead of single_qubit_randomized_benchmarking.
  • Each qubit plays its own random Clifford sequences instead of the same ones.
  • The same seed gives different sequences than before.
  • gate_map accepts only the gates sx, x and rz.
  • Its operations play on the transition of the transition option, which they take as the keyword argument transition.
  • generate_clifford_sequences takes the qubits as its first argument, returns the sequences per qubit UID and no longer takes options.

Changed in version 26.10.0

The experiment no longer routes its Clifford sequences through OpenQASM. create_sq_rb_qasm is now generate_clifford_sequences, returns the gates themselves and applies the default gate_map itself, so add_qasm_operations and get_gate_map are gone.

Removed in version 26.7.0

The qubits argument of type QuantumElements has been removed. Please pass qubits of type list[str] | str instead, i.e., the quantum element UIDs instead of the quantum element instances.

Changed in version 26.4.0

All arguments apart from session, qpu, and qubits are now keyword arguments.

Changed in version 26.1.0

The temporary_parameters positional argument was added in the penultimate position. Note that this is a breaking change if calling the experiment workflow with the options positional argument.

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
qubits list[str] | str

The qubits to run the experiments on, passed by UID. May be either a single qubit or a list of qubits.

required
length_cliffords list

list of numbers of 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 qubit depend only on the seed and the qubit UID. Default is None and provides a random seed.

None
gate_map dict | None

Maps the native gates sx, x and rz to the quantum operations that implement them. Needs sx and rz; x is optional. The operations take the transition of the experiment as the keyword argument transition. Default: {"sx": "x90", "x": "x180", "rz": "rz"}.

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

The temporary parameters to update the qubits with.

None
options TuneUpWorkflowOptions | None

The options for building the workflow. In addition to options from WorkflowOptions, the following custom options are supported:

  • create_experiment: The options for creating the experiment.
None

Returns:

Name Type Description
result None

The result of the workflow.

Example
options = experiment_workflow.options()
options.count(10)
options.transition("ge")
# 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,
    qubits=["q0", "q1"],
    length_cliffords=[1, 5, 10, 20, 50],
    variations=5,
    options=options,
).run()

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

Creates the RB Clifford sequences for each qubit.

Each sequence draws its Cliffords uniformly at random and ends with the Clifford that inverts them. Each Clifford takes the fewest pulses that the gates of gate_map allow. A sequence drops the rz gates before its first pulse, because Z rotations of the prepared state do not change the measured populations. Every qubit gets its own sequences.

Parameters:

Name Type Description Default
qubits QuantumElements

The qubits to create the sequences for. May be either a single qubit or a list of qubits.

required
length_cliffords list

A list of RB sequences lengths.

required
gate_map dict | None

Maps the native gates sx, x and rz to the quantum operations that implement them. Needs sx and rz; x is optional. The operations take the transition of the experiment as the keyword argument transition. Default: {"sx": "x90", "x": "x180", "rz": "rz"}.

None
variations int

Number of samples to generate for each sequence length.

1
seed int | None

The seed of the random sequences. The sequences of a qubit depend only on the seed and the qubit UID.

None

Returns:

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

A dictionary of Clifford sequences, keyed by qubit UID. Each sequence is a list of (operation, *parameters) gates, where operation is the name of a quantum operation. A qubit 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 and rz, or lacks sx or rz.