qibolab.instruments.qm package#
Submodules#
qibolab.instruments.qm.acquisition module#
- class qibolab.instruments.qm.acquisition.Acquisition(name: str, qubit: str | int, average: bool, keys: list[str] = <factory>)[source]#
Bases:
ABC
QUA variables used for saving of acquisition results.
This class can be instantiated only within a QUA program scope. Each readout pulse is associated with its own set of acquisition variables.
- RESULT_CLS#
Result object type that corresponds to this acquisition type.
alias of
IntegratedResults
- AVERAGED_RESULT_CLS#
Averaged result object type that corresponds to this acquisition type.
alias of
AveragedIntegratedResults
- property npulses#
- abstract assign_element(element)[source]#
Assign acquisition variables to the corresponding QM controlled.
Proposed to do by QM to avoid crashes.
- Parameters:
element (str) – Element (from
config
) that the pulse will be applied on.
- class qibolab.instruments.qm.acquisition.RawAcquisition(name: str, qubit: str | int, average: bool, keys: list[str] = <factory>, adc_stream: qm.qua._dsl._ResultSource = <factory>)[source]#
Bases:
Acquisition
QUA variables used for raw waveform acquisition.
- adc_stream: qm.qua._dsl._ResultSource#
Stream to collect raw ADC data.
- RESULT_CLS#
alias of
RawWaveformResults
- AVERAGED_RESULT_CLS#
alias of
AveragedRawWaveformResults
- assign_element(element)[source]#
Assign acquisition variables to the corresponding QM controlled.
Proposed to do by QM to avoid crashes.
- Parameters:
element (str) – Element (from
config
) that the pulse will be applied on.
- class qibolab.instruments.qm.acquisition.IntegratedAcquisition(name: str, qubit: str | int, average: bool, keys: list[str] = <factory>, i: qm.qua._dsl._Variable = <factory>, q: qm.qua._dsl._Variable = <factory>, istream: qm.qua._dsl._ResultSource = <factory>, qstream: qm.qua._dsl._ResultSource = <factory>)[source]#
Bases:
Acquisition
QUA variables used for integrated acquisition.
- i: qm.qua._dsl._Variable#
- q: qm.qua._dsl._Variable#
Variables to save the (I, Q) values acquired from a single shot.
- istream: qm.qua._dsl._ResultSource#
- qstream: qm.qua._dsl._ResultSource#
Streams to collect the results of all shots.
- RESULT_CLS#
alias of
IntegratedResults
- AVERAGED_RESULT_CLS#
alias of
AveragedIntegratedResults
- assign_element(element)[source]#
Assign acquisition variables to the corresponding QM controlled.
Proposed to do by QM to avoid crashes.
- Parameters:
element (str) – Element (from
config
) that the pulse will be applied on.
- class qibolab.instruments.qm.acquisition.ShotsAcquisition(name: str, qubit: str | int, average: bool, keys: list[str] = <factory>, threshold: float | None = None, angle: float | None = None, i: qm.qua._dsl._Variable = <factory>, q: qm.qua._dsl._Variable = <factory>, shot: qm.qua._dsl._Variable = <factory>, shots: qm.qua._dsl._ResultSource = <factory>)[source]#
Bases:
Acquisition
QUA variables used for shot classification.
Threshold and angle must be given in order to classify shots.
- i: qm.qua._dsl._Variable#
- q: qm.qua._dsl._Variable#
Variables to save the (I, Q) values acquired from a single shot.
- shot: qm.qua._dsl._Variable#
Variable for calculating an individual shots.
- shots: qm.qua._dsl._ResultSource#
Stream to collect multiple shots.
- RESULT_CLS#
alias of
SampleResults
- AVERAGED_RESULT_CLS#
alias of
AveragedSampleResults
- assign_element(element)[source]#
Assign acquisition variables to the corresponding QM controlled.
Proposed to do by QM to avoid crashes.
- Parameters:
element (str) – Element (from
config
) that the pulse will be applied on.
- qibolab.instruments.qm.acquisition.declare_acquisitions(ro_pulses, qubits, options)[source]#
Declares variables for saving acquisition in the QUA program.
- Parameters:
ro_pulses (list) – List of readout pulses in the sequence.
qubits (dict) – Dictionary containing all the
qibolab.qubits.Qubit
objects of the platform.options (
qibolab.execution_parameters.ExecutionParameters
) – Execution options containing acquisition type and averaging mode.
- Returns:
List of all
qibolab.instruments.qm.acquisition.Acquisition
objects.
- qibolab.instruments.qm.acquisition.fetch_results(result, acquisitions)[source]#
Fetches results from an executed experiment.
- Parameters:
result – Result of the executed experiment.
acquisition (dict) – Dictionary containing
qibolab.instruments.qm.acquisition.Acquisition
objects.
- Returns:
Dictionary with the results in the format required by the platform.
qibolab.instruments.qm.config module#
- qibolab.instruments.qm.config.SAMPLING_RATE = 1#
Sampling rate of Quantum Machines OPX in GSps.
- qibolab.instruments.qm.config.DEFAULT_INPUTS = {1: {}, 2: {}}#
Default controller config section.
Inputs are always registered to avoid issues with automatic mixer calibration when using Octaves.
- class qibolab.instruments.qm.config.QMConfig(version: int = 1, controllers: dict = <factory>, octaves: dict = <factory>, elements: dict = <factory>, pulses: dict = <factory>, waveforms: dict = <factory>, digital_waveforms: dict = <factory>, integration_weights: dict = <factory>, mixers: dict = <factory>)[source]#
Bases:
object
Configuration for communicating with the
QuantumMachinesManager
.- register_port(port)[source]#
Register controllers and octaves sections in the
config
.- Parameters:
ports (QMPort) – Port we are registering. Contains information about the controller and port number and some parameters, such as offset, gain, filter, etc.).
- static iq_imbalance(g, phi)[source]#
Creates the correction matrix for the mixer imbalance caused by the gain and phase imbalances.
More information here: https://docs.qualang.io/libs/examples/mixer-calibration/#non-ideal-mixer
- register_drive_element(qubit, intermediate_frequency=0)[source]#
Register qubit drive elements and controllers in the QM config.
- Parameters:
qubit (
qibolab.platforms.utils.Qubit
) – Qubit to add elements for.intermediate_frequency (int) – Intermediate frequency that the OPX will send to this qubit. This frequency will be mixed with the LO connected to the same channel.
- register_readout_element(qubit, intermediate_frequency=0, time_of_flight=0, smearing=0)[source]#
Register resonator elements and controllers in the QM config.
- Parameters:
qubit (
qibolab.platforms.utils.Qubit
) – Qubit to add elements for.intermediate_frequency (int) – Intermediate frequency that the OPX will send to this qubit. This frequency will be mixed with the LO connected to the same channel.
- register_flux_element(qubit, intermediate_frequency=0)[source]#
Register qubit flux elements and controllers in the QM config.
- Parameters:
qubit (
qibolab.platforms.utils.Qubit
) – Qubit to add elements for.intermediate_frequency (int) – Intermediate frequency that the OPX will send to this qubit. This frequency will be mixed with the LO connected to the same channel.
- register_pulse(qubit, qmpulse)[source]#
Registers pulse, waveforms and integration weights in QM config.
- Parameters:
qubit (
qibolab.platforms.utils.Qubit
) – Qubit that the pulse acts on.pulse (
qibolab.pulses.Pulse
) – Pulse object to register.
- Returns:
- Name of the element this pulse will be played on.
Elements are a part of the QM config and are generated during instantiation of the Qubit objects. They are named as “drive0”, “drive1”, “flux0”, “readout0”, …
- Return type:
element (str)
- register_waveform(pulse, mode='i')[source]#
Registers waveforms in QM config.
- QM supports two kinds of waveforms, examples:
“zero_wf”: {“type”: “constant”, “sample”: 0.0} “x90_wf”: {“type”: “arbitrary”, “samples”: x90_wf.tolist()}
- Parameters:
pulse (
qibolab.pulses.Pulse
) – Pulse object to read the waveform from.mode (str) – “i” or “q” specifying which channel the waveform will be played.
- Returns:
- String with a serialization of the waveform.
Used as key to identify the waveform in the config.
- Return type:
serial (str)
qibolab.instruments.qm.controller module#
- qibolab.instruments.qm.controller.OCTAVE_ADDRESS_OFFSET = 11000#
Offset to be added to Octave addresses, because they must be 11xxx, where xxx are the last three digits of the Octave IP address.
- qibolab.instruments.qm.controller.declare_octaves(octaves, host, calibration_path=None)[source]#
Initiate Octave configuration and add octaves info.
- Parameters:
octaves (dict) – Dictionary containing
qibolab.instruments.qm.devices.Octave
objects for each Octave device in the experiment configuration.host (str) – IP of the Quantum Machines controller.
calibration_path (str) – Path to the JSON file with the mixer calibration.
- qibolab.instruments.qm.controller.find_baking_pulses(sweepers)[source]#
Find pulses that require baking because we are sweeping their duration.
- Parameters:
sweepers (list) – List of
qibolab.sweeper.Sweeper
objects.
- qibolab.instruments.qm.controller.controllers_config(qubits, time_of_flight, smearing=0)[source]#
Create a Quantum Machines configuration without pulses.
This contains the readout and drive elements and controllers and is used by
qibolab.instruments.qm.controller.QMController.calibrate_mixers()
.- Parameters:
qubits (list) – List of
qibolab.qubits.Qubit
objects to be included in the config.time_of_flight (int) – Time of flight used on readout elements.
smearing (int) – Smearing used on readout elements.
- class qibolab.instruments.qm.controller.QMController(name: str, address: str, opxs: ~typing.Dict[int, ~qibolab.instruments.qm.devices.OPXplus] = <factory>, octaves: ~typing.Dict[int, ~qibolab.instruments.qm.devices.Octave] = <factory>, time_of_flight: int = 0, smearing: int = 0, bounds: ~qibolab.unrolling.Bounds = Bounds(waveforms=0, readout=0, instructions=0), calibration_path: str | None = None, script_file_name: str | None = None, manager: qm.QuantumMachinesManager | None = None, config: ~qibolab.instruments.qm.config.QMConfig = <factory>, is_connected: bool = False, simulation_duration: int | None = None, cloud: bool = False)[source]#
Bases:
Controller
qibolab.instruments.abstract.Controller
object for controlling a Quantum Machines cluster.A cluster consists of multiple
qibolab.instruments.qm.devices.QMDevice
devices.Playing pulses on QM controllers requires a
config
dictionary and a program written in QUA language. Theconfig
file is generated in parts inqibolab.instruments.qm.config.QMConfig
. Controllers, elements and pulses are all registered after a pulse sequence is given, so that the config contains only elements related to the participating qubits. The QUA program for executing an arbitraryqibolab.pulses.PulseSequence
is written inqibolab.instruments.qm.controller.QMController.play()
and executed inqibolab.instruments.qm.controller.QMController.execute_program()
.- address: str#
IP address and port for connecting to the OPX instruments.
Has the form XXX.XXX.XXX.XXX:XXX.
- opxs: Dict[int, OPXplus]#
Dictionary containing the
qibolab.instruments.qm.devices.OPXplus
instruments being used.
- octaves: Dict[int, Octave]#
Dictionary containing the
qibolab.instruments.qm.devices.Octave
instruments being used.
- bounds: Bounds = Bounds(waveforms=0, readout=0, instructions=0)#
Maximum bounds used for batching in sequence unrolling.
- script_file_name: str | None = None#
Name of the file that the QUA program will dumped in that after every execution.
If
None
the program will not be dumped.
- manager: qm.QuantumMachinesManager | None = None#
Manager object used for controlling the Quantum Machines cluster.
- simulation_duration: int | None = None#
Duration for the simulation in ns.
If given the simulator will be used instead of actual hardware execution.
- cloud: bool = False#
If
True
the QM cloud simulator is used which does not require access to physical instruments.This assumes that a proper cloud address has been given. If
False
andsimulation_duration
was given, then the built-in simulator of the instruments is used. This requires connection to instruments. Default isFalse
.
- ports(name, output=True)[source]#
Provides instrument ports to the user.
Note that individual ports can also be accessed from the corresponding devices using
qibolab.instruments.qm.devices.QMDevice.ports()
.- Parameters:
name (tuple) – Contains the numbers of controller and port to be obtained. For example
((conX, Y),)
returns port-Y of OPX+ controller X.((conX, Y), (conX, Z))
returns port-Y and Z of OPX+ controller X as anqibolab.instruments.qm.ports.OPXIQ
port pair.output (bool) –
True
for obtaining an output port, otherwise an input port is returned. Default isTrue
.
- property sampling_rate#
Sampling rate of Quantum Machines instruments.
- calibrate_mixers(qubits)[source]#
Calibrate Octave mixers for readout and drive lines of given qubits.
- Parameters:
qubits (list) – List of
qibolab.qubits.Qubit
objects for which mixers will be calibrated.
- execute_program(program)[source]#
Executes an arbitrary program written in QUA language.
- Parameters:
program – QUA program.
- simulate_program(program)[source]#
Simulates an arbitrary program written in QUA language.
- Parameters:
program – QUA program.
- create_sequence(qubits, sequence, sweepers)[source]#
Translates a
qibolab.pulses.PulseSequence
to aqibolab.instruments.qm.sequence.Sequence
.- Parameters:
qubits (list) – List of
qibolab.platforms.abstract.Qubit
objects passed from the platform.sequence (
qibolab.pulses.PulseSequence
) –sweepers (list) – List of sweeper objects so that pulses that require baking are identified.
- Returns:
(
qibolab.instruments.qm.sequence.Sequence
) containing the pulses from given pulse sequence.
qibolab.instruments.qm.devices module#
- class qibolab.instruments.qm.devices.PortsDefaultdict[source]#
Bases:
defaultdict
Dictionary mapping port numbers to
qibolab.instruments.qm.ports.QMPort
objects.Automatically instantiates ports that have not yet been created. Used by
qibolab.instruments.qm.devices.QMDevice
- class qibolab.instruments.qm.devices.QMDevice(name: str)[source]#
Bases:
Instrument
Abstract class for an individual Quantum Machines devices.
- ports(number, output=True)[source]#
Provides instrument’s ports to the user.
- Parameters:
number (int) – Port number. Can be 1 to 10 for
qibolab.instruments.qm.devices.OPXplus
and 1 to 5 forqibolab.instruments.qm.devices.Octave
.output (bool) –
True
for obtaining an output port, otherwise an input port is returned. Default isTrue
.
- connect()[source]#
Only applicable for
qibolab.instruments.qm.controller.QMController
, not individual devices.
- disconnect()[source]#
Only applicable for
qibolab.instruments.qm.controller.QMController
, not individual devices.
- class qibolab.instruments.qm.devices.OPXplus(name: str)[source]#
Bases:
QMDevice
Device handling OPX+ controllers.
- class qibolab.instruments.qm.devices.Octave(name: str, port: int, connectivity: OPXplus)[source]#
Bases:
QMDevice
Device handling Octaves.
- ports(number, output=True)[source]#
Provides Octave ports.
Extension of the abstract
qibolab.instruments.qm.devices.QMDevice.ports()
because Octave ports are used for mixing two existing (I, Q) OPX+ ports.
qibolab.instruments.qm.ports module#
- qibolab.instruments.qm.ports.DIGITAL_BUFFER = 18#
Default calibration parameters for digital pulses.
https://docs.quantum-machines.co/1.1.7/qm-qua-sdk/docs/Guides/octave/#calibrating-the-digital-pulse
Digital markers are used for LO triggering.
- class qibolab.instruments.qm.ports.QMPort(device: str, number: int)[source]#
Bases:
object
Abstract representation of Quantum Machine instrument ports.
Contains the ports settings for each device.
- key: ClassVar[str | None] = None#
Key corresponding to this port type in the Quantum Machines config.
Used in
qibolab.instruments.qm.config.QMConfig.register_port()
.
- property pair#
Representation of the port in the Quantum Machines config.
- property settings#
Serialization of the port settings to dump in the runcard YAML.
Only fields that provide the
metadata['settings']
flag are dumped in the serialization.
- property config#
Port settings in the format of the Quantum Machines config.
Field
metadata['config']
are used to translate qibolab port setting names to the corresponding Quantum Machine config properties.
- class qibolab.instruments.qm.ports.QMOutput(device: str, number: int)[source]#
Bases:
QMPort
Abstract Quantum Machines output port.
- property name#
Name of the port when dumping instrument settings on the runcard YAML.
- class qibolab.instruments.qm.ports.QMInput(device: str, number: int)[source]#
Bases:
QMPort
Abstract Quantum Machines input port.
- property name#
Name of the port when dumping instrument settings on the runcard YAML.
- class qibolab.instruments.qm.ports.OPXOutput(device: str, number: int, offset: float = 0.0, filter: Dict[str, float] = <factory>)[source]#
Bases:
QMOutput
- key: ClassVar[str] = 'analog_outputs'#
Key corresponding to this port type in the Quantum Machines config.
Used in
qibolab.instruments.qm.config.QMConfig.register_port()
.
- property settings#
OPX+ output settings to be dumped to the runcard YAML.
Filter is removed if empty to simplify the runcard.
- class qibolab.instruments.qm.ports.OPXInput(device: str, number: int, offset: float = 0.0, gain: int = 0)[source]#
Bases:
QMInput
- key: ClassVar[str] = 'analog_inputs'#
Key corresponding to this port type in the Quantum Machines config.
Used in
qibolab.instruments.qm.config.QMConfig.register_port()
.
- class qibolab.instruments.qm.ports.OPXIQ(i: OPXOutput | OPXInput, q: OPXOutput | OPXInput)[source]#
Bases:
object
Pair of I-Q ports.
- class qibolab.instruments.qm.ports.OctaveOutput(device: str, number: int, lo_frequency: float = 0.0, gain: int = 0, lo_source: str = 'internal', output_mode: str = 'triggered', digital_delay: int = 57, digital_buffer: int = 18, opx_port: qibolab.instruments.qm.ports.OPXOutput | None = None)[source]#
Bases:
QMOutput
- key: ClassVar[str] = 'RF_outputs'#
Key corresponding to this port type in the Quantum Machines config.
Used in
qibolab.instruments.qm.config.QMConfig.register_port()
.
- output_mode: str = 'triggered'#
“always_on” / “always_off”/ “triggered” / “triggered_reversed”.
- Type:
Can be
- property digital_inputs#
Generates digitalInputs entry for elements in QM config.
Digital markers are used to switch LOs on in triggered mode.
- class qibolab.instruments.qm.ports.OctaveInput(device: str, number: int, lo_frequency: float = 0.0, lo_source: str = 'internal', IF_mode_I: str = 'direct', IF_mode_Q: str = 'direct', opx_port: qibolab.instruments.qm.ports.OPXIQ | None = None)[source]#
Bases:
QMInput
- key: ClassVar[str] = 'RF_inputs'#
Key corresponding to this port type in the Quantum Machines config.
Used in
qibolab.instruments.qm.config.QMConfig.register_port()
.
qibolab.instruments.qm.sequence module#
- qibolab.instruments.qm.sequence.DurationsType#
Type of values that can be accepted in a duration sweeper.
- class qibolab.instruments.qm.sequence.QMPulse(pulse: ~qibolab.pulses.Pulse, element: str | None = None, operation: str | None = None, relative_phase: float | None = None, wait_time: int = 0, wait_time_variable: qm.qua._dsl._Variable | None = None, swept_duration: qm.qua._dsl._Variable | None = None, acquisition: ~qibolab.instruments.qm.acquisition.Acquisition | None = None, next_: ~typing.Set[~qibolab.instruments.qm.sequence.QMPulse] = <factory>, elements_to_align: ~typing.Set[str] = <factory>)[source]#
Bases:
object
Wrapper around
qibolab.pulses.Pulse
for easier translation to QUA program.These pulses are defined when
qibolab.instruments.qm.QMOPX.play()
is called and hold attributes for theelement
andoperation
that corresponds to each pulse, as defined in the QM config.- pulse: Pulse#
qibolab.pulses.Pulse
corresponding to theQMPulse
.
- operation: str | None = None#
Name of the operation that is implementing the pulse in the QM config.
- relative_phase: float | None = None#
Relative phase of the pulse normalized to follow QM convention.
May be overwritten when sweeping phase.
- wait_time: int = 0#
Time (in clock cycles) to wait before playing this pulse.
Calculated and assigned by :meth: qibolab.instruments.qm.Sequence.add.
- wait_time_variable: qm.qua._dsl._Variable | None = None#
Time (in clock cycles) to wait before playing this pulse when we are sweeping start.
- acquisition: Acquisition | None = None#
Data class containing the variables required for data acquisition for the instrument.
- next_: Set[QMPulse]#
Pulses that will be played after the current pulse.
These pulses need to be re-aligned if we are sweeping the start or duration.
- property duration#
Duration of the pulse as defined in the
qibolab.pulses.PulseSequence
.Remains constant even when we are sweeping the duration of this pulse.
- property wait_cycles#
Instrument clock cycles (1 cycle = 4ns) to wait before playing the pulse.
This property will be used in the QUA
wait
command, so that it is compatible with and without start sweepers.
- class qibolab.instruments.qm.sequence.BakedPulse(pulse: ~qibolab.pulses.Pulse, element: str | None = None, operation: str | None = None, relative_phase: float | None = None, wait_time: int = 0, wait_time_variable: qm.qua._dsl._Variable | None = None, swept_duration: qm.qua._dsl._Variable | None = None, acquisition: ~qibolab.instruments.qm.acquisition.Acquisition | None = None, next_: ~typing.Set[~qibolab.instruments.qm.sequence.QMPulse] = <factory>, elements_to_align: ~typing.Set[str] = <factory>, segments: ~typing.List[~qualang_tools.bakery.bakery.Baking] = <factory>, amplitude: float | None = None, durations: ~typing.List[int] | ~numpy.ndarray[~typing.Any, ~numpy.dtype[int]] | None = None)[source]#
Bases:
QMPulse
Baking allows 1ns resolution in the pulse waveforms.
- amplitude: float | None = None#
Amplitude of the baked pulse.
Relevant only when sweeping amplitude.
- property duration#
Duration of the pulse as defined in the
qibolab.pulses.PulseSequence
.Remains constant even when we are sweeping the duration of this pulse.
- property amplitude_array#
- class qibolab.instruments.qm.sequence.Sequence(qmpulses: ~typing.List[~qibolab.instruments.qm.sequence.QMPulse] = <factory>, pulse_to_qmpulse: ~typing.Dict[~qibolab.pulses.Pulse, ~qibolab.instruments.qm.sequence.QMPulse] = <factory>, clock: ~typing.Dict[str, int] = <factory>, pulse_finish: ~typing.Dict[int, ~typing.List[~qibolab.instruments.qm.sequence.QMPulse]] = <factory>)[source]#
Bases:
object
Pulse sequence containing QM specific pulses (
qmpulse
).Defined in
qibolab.instruments.qm.QMOPX.play()
. Holds attributes for theelement
andoperation
that corresponds to each pulse, as defined in the QM config.- qmpulses: List[QMPulse]#
List of
qibolab.instruments.qm.QMPulse
objects corresponding to the original pulses.
- clock: Dict[str, int]#
Dictionary used to keep track of times of each element, in order to calculate wait times.
qibolab.instruments.qm.sweepers module#
- qibolab.instruments.qm.sweepers.maximum_sweep_value(values, value0)[source]#
Calculates maximum value that is reached during a sweep.
Useful to check whether a sweep exceeds the range of allowed values. Note that both the array of values we sweep and the center value can be negative, so we need to make sure that the maximum absolute value is within range.