Skip to content

laboneq.dsl.quantum

laboneq.dsl.quantum.quantum_element

QuantumElement

A quantum element within a quantum device.

For example, a qubit or a coupler.

Attributes:

Name Type Description
uid str

A unique identifier for the quantum element. E.g. q0.

signals Dict[str, str]

A mapping for experiment signal names to logical signal paths.

parameters QuantumParameters

Parameter values for the quantum element. For example, qubit frequency, drive pulse lengths.

Class attributes

PARAMETERS_TYPE: The type of the parameters used. Should be a sub-class of QuantumParameters. REQUIRED_SIGNALS: A tuple of experiment signal names that must be provided. OPTIONAL_SIGNALS: A tuple of optional signal names. Optional signals are used by the class but not required. SIGNAL_ALIASES: A mapping from alternative names for signals to their canonical names. Signal names are translated to canonical signal names when a quantum element is instantiated.

This attribute is provided as a means to provide backwards
compatibility with existing device configurations when signal naming
conventions change.

OPTIONAL_SIGNALS = () class-attribute instance-attribute

PARAMETERS_TYPE = QuantumParameters class-attribute instance-attribute

REQUIRED_SIGNALS = () class-attribute instance-attribute

SIGNAL_ALIASES = {} class-attribute instance-attribute

parameters: QuantumParameters = attrs.field(converter=attrs.Converter(_parameters_converter, takes_self=True), default=None) class-attribute instance-attribute

signals: Dict[str, str] = attrs.field(converter=attrs.Converter(_signals_converter, takes_self=True), default=None) class-attribute instance-attribute

uid: str = attrs.field() class-attribute instance-attribute

calibration()

Return the calibration for this quantum element.

Calibration for each experiment signal is generated from the quantum element parameters.

Returns:

Type Description
Calibration

The experiment calibration.

create_parameters(**parameters) classmethod

Create a new instance of parameters for this qubit class.

Parameters:

Name Type Description Default
parameters dict[str, object]

Parameter values for the new parameter instance.

{}

Returns:

Type Description
QuantumParameters

A new parameter instance.

experiment_signals()

Return the list of the experiment signals for this quantum element.

Returns:

Type Description
List[ExperimentSignal]

A list of experiment signals.

from_device_setup(device_setup, qubit_uids=None) classmethod

Create a list of quantum elements from a device setup.

Parameters:

Name Type Description Default
device_setup DeviceSetup

The device setup to create the quantum elements from.

required
qubit_uids list[str] | None

The set of logical signal group uids to create qubits from, or None to create qubits from all logical signal groups.

None

Returns:

Type Description
list[QuantumElement]

A list of quantum elements.

Note

The device setup does not contain the qubit parameters so they will need to be set separately.

from_logical_signal_group(uid, lsg, parameters=None) classmethod

Create a quantum element from a logical signal group.

Parameters:

Name Type Description Default
uid str

A unique identifier for the quantum element. E.g. q0.

required
lsg LogicalSignalGroup

The logical signal group containing the quantum elements signals.

required
parameters QuantumParameters | dict[str, Any] | None

A dictionary of quantum element parameters.

None

Returns:

Type Description
QuantumElement

A quantum element.

Note

The logical signal group prefix, /logical_signal_group/, will be removed from any signal paths if it is present.

load(filename) classmethod

Loads a QuantumElement object from a JSON file.

Parameters:

Name Type Description Default
filename Union[str, bytes, PathLike]

The name of the JSON file to load the QuantumElement object from.

required

Deprecated in version 2.43.0.

Use q = laboneq.serializers.load(filename) instead.

replace(**parameter_changes)

Return a new quantum element with the parameter changes applied.

Parameters:

Name Type Description Default
parameter_changes dict[str, object]

Parameter changes to apply passed as keyword arguments.

{}
Return

A new quantum element with the parameter changes applied.

save(filename)

Save a QuantumElement object to a JSON file.

Parameters:

Name Type Description Default
filename Union[str, bytes, PathLike]

The name of the JSON file to save the QuantumElement object.

required

Deprecated in version 2.43.0.

Use laboneq.serializers.save(q, filename) instead.

update(**parameter_changes)

Update this quantum element with supplied parameter changes.

Parameters:

Name Type Description Default
parameter_changes dict[str, object]

Parameter changes to apply passed as keyword arguments.

{}

Note

The parameters attribute of this quantum element is replaced with a new parameter instance.

QuantumParameters

Calibration parameters for a QuantumElement.

replace(**changes)

Return a new set of parameters with changes applied.

Parameters:

Name Type Description Default
changes dict[str, object]

Parameter changes to apply passed as keyword arguments. Dotted key names such as a.b.c update nested parameters or items within parameter values that are dictionaries.

{}
Return

A new parameters instance.

laboneq.dsl.quantum.quantum_operations

Core classes for defining sets of quantum operations on qubits.

QuantumOperations()

Quantum operations for a given qubit type.

Attributes:

Name Type Description
QUBIT_TYPES type[QuantumElement] | tuple[type[QuantumElement]] | None

(class attribute) The classes of qubits supported by this set of operations. The value may be a single class or a tuple of classes.

BASE_OPS dict[str, Callable]

(class attribute) A dictionary of names and functions that define the base operations provided.

BASE_OPS: dict[str, Callable] = None class-attribute instance-attribute

QUBIT_TYPES: type[QuantumElement] | tuple[type[QuantumElement]] | None = None class-attribute instance-attribute

keys()

Return the names of the registered quantum operations.

register(f, name=None)

Registers a quantum operation.

The given operation is wrapped in a Operation instance and added to this set of operations.

Parameters:

Name Type Description Default
f Callable

The function to register as a quantum operation.

The first parameter of f should be the set of quantum operations to use. This allows f to use other quantum operations if needed.

The qubits f operates on must be passed as positional arguments, not keyword arguments.

Additional non-qubit arguments may be passed to f as either positional or keyword arguments.

required
name str | None

The name of the operation. Defaults to f.__name__.

None
Example

Create a custom operation function, register and call it:

qop = qpu.quantum_operations


def custom_op(qop, q, amplitude):
    pulse = ...
    play(
        q.signals["drive"],
        amplitude=amplitude,
        pulse=pulse,
    )


qop.register(custom_op)
qop.custom_op(q, amplitude=0.5)

In the example above the qop argument to custom_op is unused, but custom_op could call another quantum operation using, e.g., qop.x90(q), if needed.

quantum_operation(f=None, *, broadcast=True, neartime=False)

Decorator that marks an method as a quantum operation.

Methods marked as quantum operations are moved into the BASE_OPS dictionary of the QuantumOperations class they are defined in at the end of class creation.

Functions marked as quantum operations take the QuantumOperations instance they are registered on as their initial self parameter.

Parameters:

Name Type Description Default
f Callable | None

The method to decorate. f should take as positional arguments the qubits to operate on. It may take additional arguments that specify other parameters of the operation.

None
broadcast bool

If true, the operation may be broadcast across multiple qubits using .broadcast. Broadcasting requires that all operation arguments do not accept sequences of values (when not broadcasting).

True
neartime bool

If true, the operation is marked as a near-time operation. Its section is set to near-time and no qubit signals are reserved.

False

Returns:

Type Description
Callable

If f is given, returns the decorated method.

Callable

Otherwise returns a partial evaluation of quantum_operation with

Callable

the other arguments set.

laboneq.dsl.quantum.qpu

This module defines the QuantumPlatform and QPU classes.

A QPU contains the "physics" of a quantum device -- the qubit parameters and definition of operations on qubits.

A QuantumPlatform contains the QPU, and the DeviceSetup which describes the control hardware used to interface to the device.

By itself a QPU provides everything needed to build or design an experiment for a quantum device. The DeviceSetup provides the additional information needed to compile an experiment for specific control hardware.

Together these provide a QuantumPlatform -- i.e. everything needed to build, compile and run experiments on real devices.

QPU(qubits, quantum_operations)

A Quantum Processing Unit (QPU).

A QPU provides the logical description of a quantum device needed to build experiments for it. For example, the qubit parameters and the definition of operations on those qubits.

It does not provide a description of the control hardware needed to compile an experiment.

In short, a QPU defines the device physics and a DeviceSetup defines the control hardware being used.

Parameters:

Name Type Description Default
qubits QuantumElements

The qubits to run the experiments on.

required
quantum_operations QuantumOperations

The quantum operations to use when building the experiment.

required

quantum_operations = quantum_operations instance-attribute

qubits: list[QuantumElement] = [qubits] if isinstance(qubits, QuantumElement) else list(qubits) instance-attribute

copy_qubits()

Return new qubits that are a copy of the original qubits.

measure_section_length(qubits) staticmethod

Calculates the length of the measure section for multiplexed readout.

In order to allow the qubits to have different readout and/or integration lengths, the measure section length needs to be fixed to the longest one across the qubits used in the experiment.

Parameters:

Name Type Description Default
qubits QuantumElements

The qubits that are being measured.

required

Returns:

Type Description
float

The length of the multiplexed-readout measure section.

override_qubits(qubit_parameters)

Override qubit parameters and return a new QPU.

Parameters:

Name Type Description Default
qubit_parameters dict[str, dict[str, int | float | str | dict | None]]

The qubits and their parameters that need to be updated passed a dict of the form:

{qb_uid: {qb_param_name: qb_param_value}}
required

Returns: A new QPU with overridden qubit parameters. Raises: ValueError: If one of the qubits passed is not found in the qpu. If one of the parameters passed is not found in the qubit.

qubit_by_uid(uid)

Returns qubit by UID.

Parameters:

Name Type Description Default
uid str

Unique identifier of the qubit within the QPU.

required

Returns:

Type Description
QuantumElement

Qubit with given uid.

Raises:

Type Description
KeyError

Qubit does not exist.

update_qubits(qubit_parameters)

Updates qubit parameters.

Parameters:

Name Type Description Default
qubit_parameters dict[str, dict[str, int | float | str | dict | None]]

The qubits and their parameters that need to be updated passed a dict of the form:

{qb_uid: {qb_param_name: qb_param_value}}
required

Raises:

Type Description
ValueError

If one of the qubits passed is not found in the qpu. If one of the parameters passed is not found in the qubit.

QuantumPlatform(setup, qpu)

A quantum hardware platform.

A QuantumPlatform provides the logical description of a quantum device needed to define experiments (the QPU) and the description of the control hardware needed to compile an experiment (the DeviceSetup).

In short, a QPU defines the device physics and a DeviceSetup defines the control hardware being used.

Parameters:

Name Type Description Default
setup DeviceSetup

The DeviceSetup describing the control hardware of the device.

required
qpu QPU

The QPU describing the parameters and topology of the quantum device and providing the definition of quantum operations on the device.

required

Initialize a new QPU.

Parameters:

Name Type Description Default
setup DeviceSetup

The device setup to use when running an experiment.

required
qpu QPU

The QPU to use when building an experiment.

required

qpu = qpu instance-attribute

setup = setup instance-attribute

session(do_emulation=False)

Return a new LabOne Q session.

Parameters:

Name Type Description Default
do_emulation bool

Specifies if the session should connect to a emulator (in the case of 'True'), or the real system (in the case of 'False')

False

laboneq.dsl.quantum.qubit

Qubit = Transmon module-attribute

QubitParameters = TransmonParameters module-attribute

laboneq.dsl.quantum.transmon

Transmon

Bases: QuantumElement

A class for a superconducting, flux-tuneable Transmon Qubit.

Deprecated in version 2.43.0.

This class is deprecated and was intended primarily for demonstration purposes. Instead of using it write a class that directly inherits from QuantumElement.

OPTIONAL_SIGNALS = ('drive_ef', 'drive_cr', 'flux') class-attribute instance-attribute

PARAMETERS_TYPE = TransmonParameters class-attribute instance-attribute

REQUIRED_SIGNALS = ('acquire', 'drive', 'measure') class-attribute instance-attribute

SIGNAL_ALIASES = {'acquire_line': 'acquire', 'drive_line': 'drive', 'measure_line': 'measure', 'drive_ef_line': 'drive_ef', 'drive_line_ef': 'drive_ef', 'drive_cr_line': 'drive_cr', 'flux_line': 'flux'} class-attribute instance-attribute

calibration()

Return the experiment calibration for this transmon.

Calibration for each experiment signal is generated from the transmon parameters.

Returns:

Type Description
Calibration

The experiment calibration.

TransmonParameters

Bases: QuantumParameters

A class for the parameters of a superconducting, flux-tuneable transmon qubit.

Deprecated in version 2.43.0.

This class is deprecated and was intended primarily for demonstration purposes. Instead of using it write a class that directly inherits from QuantumParameters.

drive_frequency_ef: float | None property

Qubit drive frequency.

drive_frequency_ge: float | None property

Qubit drive frequency.

drive_lo_frequency: Optional[float] = None class-attribute instance-attribute

drive_range: Optional[float] = 10 class-attribute instance-attribute

flux_offset_voltage: Optional[float] = 0 class-attribute instance-attribute

readout_frequency: float | None property

Readout baseband frequency.

readout_integration_delay: Optional[float] = 2e-08 class-attribute instance-attribute

readout_lo_frequency: Optional[float] = None class-attribute instance-attribute

readout_range_in: Optional[float] = 10 class-attribute instance-attribute

readout_range_out: Optional[float] = 5 class-attribute instance-attribute

readout_resonator_frequency: Optional[float] = None class-attribute instance-attribute

resonance_frequency_ef: Optional[float] = None class-attribute instance-attribute

resonance_frequency_ge: Optional[float] = None class-attribute instance-attribute

user_defined: dict | None = attrs.field(factory=dict) class-attribute instance-attribute