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. |
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 = attrs.field(converter=attrs.Converter(_parameters_converter, takes_self=True), default=None)
class-attribute
instance-attribute
¶
signals = attrs.field(converter=attrs.Converter(_signals_converter, takes_self=True), default=None)
class-attribute
instance-attribute
¶
uid = 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. |
copy()
¶
Returns a copy of the qubit.
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, parameters=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
|
parameters
|
dict[str, QuantumParameters | dict[str, Any]] | None
|
A dictionary mapping quantum element UIDs to the parameters for
that quantum element. Parameters may be specified either as
a dictionary of parameter names and values, or as instances of
the appropriate sub-class of |
None
|
Returns:
Type | Description |
---|---|
list[QuantumElement]
|
A list of quantum elements. |
!!! version-changed "Changed in version 2.46.0
The `parameters` argument was added.
In earlier versions, parameters needed to be set separately
after the quantum elements were created.
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. |
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 or an instance of QuantumParameters. |
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
¶
replace(**parameter_changes)
¶
save(filename)
¶
update(**parameter_changes)
¶
QuantumParameters
¶
Calibration parameters for a QuantumElement.
copy()
¶
Returns a copy of the parameters.
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 |
{}
|
Return
A new parameters instance.
laboneq.dsl.quantum.quantum_operations
¶
Core classes for defining sets of quantum operations on qubits.
QuantumOperations(qpu=None)
¶
Quantum operations for a given qubit type.
qpu: The quantum processing unit (QPU).
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 = None
class-attribute
instance-attribute
¶
QUBIT_TYPES = None
class-attribute
instance-attribute
¶
qpu = qpu
instance-attribute
¶
attach_qpu(qpu)
¶
Attach a QPU to the set of quantum operations.
detach_qpu()
¶
Detach a QPU from the set of quantum operations.
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 The qubits Additional non-qubit arguments may be passed to |
required |
name
|
str | None
|
The name of the operation. Defaults to |
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 a 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. |
None
|
broadcast
|
bool
|
If true, the operation may be broadcast across multiple qubits
using |
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 |
Callable
|
Otherwise returns a partial evaluation of |
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 quantum element parameters
and definition of operations on quantum elements.
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(quantum_elements, 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 quantum element parameters and the definition of
operations on those quantum elements.
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.
Deprecated in version 2.52.0.
The argument qubits
was deprecated and replaced with the argument quantum_elements
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quantum_elements
|
QuantumElements
|
The quantum elements to run the experiments on. |
required |
quantum_operations
|
QuantumOperations | type[QuantumOperations]
|
The quantum operations to use when building the experiment. |
required |
quantum_elements = [quantum_elements] if isinstance(quantum_elements, QuantumElement) else list(quantum_elements)
instance-attribute
¶
quantum_operations = quantum_operations
instance-attribute
¶
qubits
property
¶
Return qubits.
Deprecated in version 2.52.0.
The attribute qubits
was deprecated and replaced with the attribute quantum_elements
.
copy_quantum_elements()
¶
Return new quantum elements that are a copy of the original quantum elements.
copy_qubits()
¶
Return new qubits that are a copy of the original qubits.
Deprecated in version 2.52.0.
The method copy_qubits
was deprecated and replaced with the method copy_quantum_elements
.
measure_section_length(quantum_elements)
staticmethod
¶
Calculates the length of the measure section for multiplexed readout.
In order to allow the quantum elements to have different readout and/or integration lengths, the measure section length needs to be fixed to the longest one across the quantum elements used in the experiment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quantum_elements
|
QuantumElements
|
The quantum elements that are being measured. |
required |
Returns: The length of the multiplexed-readout measure section.
override_quantum_elements(quantum_element_parameters)
¶
Override quantum element parameters and return a new QPU.
Note
This method detaches the quantum operations from the QPU and attaches them to the new QPU.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quantum_element_parameters
|
dict[str, dict[str, int | float | str | dict | None]]
|
The quantum elements and their parameters that need to be updated passed a dict of the form:
|
required |
Returns: A new QPU with overridden quantum element parameters. Raises: ValueError: If one of the quantum elements passed is not found in the qpu. If one of the parameters passed is not found in the quantum element.
override_qubits(qubit_parameters)
¶
Override qubit parameters and return a new QPU.
Note
This method detaches the quantum operations from the QPU and attaches them to the new QPU.
Deprecated in version 2.52.0.
The method override_qubits
was deprecated and replaced with the method override_quantum_elements
.
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:
|
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.
quantum_element_by_uid(uid)
¶
Returns quantum element by UID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uid
|
str
|
Unique identifier of the quantum element within the QPU. |
required |
Returns:
Quantum element with given uid
.
Raises:
KeyError: Quantum element does not exist.
qubit_by_uid(uid)
¶
Returns qubit by UID.
Deprecated in version 2.52.0.
The method qubit_by_uid
was deprecated and replaced with the method quantum_element_by_uid
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
uid
|
str
|
Unique identifier of the qubit within the QPU. |
required |
Returns:
Qubit with given uid
.
Raises:
KeyError: Qubit does not exist.
update_quantum_elements(quantum_element_parameters)
¶
Updates quantum element parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quantum_element_parameters
|
dict[str, dict[str, int | float | str | dict | None]]
|
The quantum elements and their parameters that need to be updated passed a dict of the form:
|
required |
Raises: ValueError: If one of the quantum elements passed is not found in the qpu. If one of the parameters passed is not found in the quantum element.
update_qubits(qubit_parameters)
¶
Updates qubit parameters.
Deprecated in version 2.52.0.
The method update_qubits
was deprecated and replaced with the method update_quantum_elements
.
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:
|
required |
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.
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 |
required |
qpu
|
QPU
|
The |
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 |
laboneq.dsl.quantum.qubit
¶
laboneq.dsl.quantum.transmon
¶
Transmon
¶
Bases: QuantumElement
A class for a superconducting, flux-tunable 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-tunable 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
property
¶
Qubit drive frequency for the e-f transition.
drive_frequency_ge
property
¶
Qubit drive frequency for the g-e transition.
drive_lo_frequency = None
class-attribute
instance-attribute
¶
drive_range = 10
class-attribute
instance-attribute
¶
flux_offset_voltage = 0
class-attribute
instance-attribute
¶
readout_frequency
property
¶
Readout baseband frequency.