qibolab.instruments package#

Subpackages#

Submodules#

qibolab.instruments.abstract module#

class qibolab.instruments.abstract.InstrumentSettings[source]#

Bases: object

Container of settings that are dumped in the platform runcard yaml.

dump()[source]#

Dictionary containing the settings.

Useful when dumping the instruments to the runcard YAML.

class qibolab.instruments.abstract.Instrument(name, address)[source]#

Bases: ABC

Parent class for all the instruments connected via TCPIP.

Parameters:
  • name (str) – Instrument name.

  • address (str) – Instrument network address.

property signature#
abstract connect()[source]#

Establish connection to the physical instrument.

abstract disconnect()[source]#

Close connection to the physical instrument.

abstract setup(*args, **kwargs)[source]#

Set instrument settings.

class qibolab.instruments.abstract.Controller(name, address)[source]#

Bases: Instrument

Instrument that can play pulses (using waveform generator).

PortType#

Class used by the instrument to instantiate ports.

alias of Port

abstract property sampling_rate#

Sampling rate of control electronics in giga samples per second (GSps).

ports(port_name, *args, **kwargs)[source]#

Get ports associated to this controller.

Parameters:

port_name – Identifier for the port. The type of the identifier depends on the specialized port defined for each instrument.

Returns:

qibolab.instruments.port.Port object providing the interface for setting instrument parameters.

abstract play(*args, **kwargs)[source]#

Play a pulse sequence and retrieve feedback.

Returns:

(Dict[ResultType]) mapping the serial of the readout pulses used to the acquired qibolab.result.ExecutionResults object.

split_batches(sequences)[source]#

Split sequences to batches each of which can be unrolled and played as a single sequence.

Parameters:

sequence (list) – List of qibolab.pulses.PulseSequence to be played.

Returns:

Iterator of batches that can be unrolled in a single one. Default will return all sequences as a single batch.

abstract sweep(*args, **kwargs)[source]#

Play a pulse sequence while sweeping one or more parameters.

Returns:

(dict) mapping the serial of the readout pulses used to the acquired qibolab.result.ExecutionResults object.

exception qibolab.instruments.abstract.InstrumentException(instrument: Instrument, message: str)[source]#

Bases: Exception

qibolab.instruments.dummy module#

class qibolab.instruments.dummy.DummyPort(name: str, offset: float = 0.0, lo_frequency: int = 0, lo_power: int = 0, gain: int = 0, attenuation: int = 0, power_range: int = 0, filters: dict | None = None)[source]#

Bases: Port

name: str#

Name of the port that acts as its identifier.

offset: float = 0.0#

DC offset that is applied to this port.

lo_frequency: int = 0#

Local oscillator frequency for the given port.

Relevant only for controllers with internal local oscillators.

lo_power: int = 0#

Local oscillator power for the given port.

Relevant only for controllers with internal local oscillators.

gain: int = 0#

Gain that is applied to this port.

attenuation: int = 0#

Attenuation that is applied to this port.

power_range: int = 0#

Similar to attenuation (negative) and gain (positive) for (Zurich instruments).

filters: dict | None = None#

Filters to be applied to the channel to reduce the distortions when sending flux pulses.

class qibolab.instruments.dummy.DummyDevice[source]#

Bases: object

Dummy device that does nothing but follows the QCoDeS interface.

Used by qibolab.instruments.dummy.DummyLocalOscillator.

set(name, value)[source]#

Set device property.

get(name)[source]#

Get device property.

on()[source]#

Turn device on.

off()[source]#

Turn device on.

close()[source]#

Close connection with device.

class qibolab.instruments.dummy.DummyLocalOscillator(name, address, ref_osc_source=None)[source]#

Bases: LocalOscillator

Dummy local oscillator instrument.

Useful for testing the interface defined in qibolab.instruments.oscillator.LocalOscillator.

create()[source]#

Create instance of physical device.

class qibolab.instruments.dummy.DummyInstrument(name, address)[source]#

Bases: Controller

Dummy instrument that returns random voltage values.

Useful for testing code without requiring access to hardware.

Parameters:
  • name (str) – name of the instrument.

  • address (int) – address to connect to the instrument. Not used since the instrument is dummy, it only exists to keep the same interface with other instruments.

PortType#

alias of DummyPort

property sampling_rate#

Sampling rate of control electronics in giga samples per second (GSps).

connect()[source]#

Establish connection to the physical instrument.

disconnect()[source]#

Close connection to the physical instrument.

setup(*args, **kwargs)[source]#

Set instrument settings.

get_values(options, ro_pulse, shape)[source]#
play(qubits: Dict[str | int, Qubit], couplers: Dict[str | int, Coupler], sequence: PulseSequence, options: ExecutionParameters)[source]#

Play a pulse sequence and retrieve feedback.

Returns:

(Dict[ResultType]) mapping the serial of the readout pulses used to the acquired qibolab.result.ExecutionResults object.

split_batches(sequences)[source]#

Split sequences to batches each of which can be unrolled and played as a single sequence.

Parameters:

sequence (list) – List of qibolab.pulses.PulseSequence to be played.

Returns:

Iterator of batches that can be unrolled in a single one. Default will return all sequences as a single batch.

sweep(qubits: Dict[str | int, Qubit], couplers: Dict[str | int, Coupler], sequence: PulseSequence, options: ExecutionParameters, *sweepers: List[Sweeper])[source]#

Play a pulse sequence while sweeping one or more parameters.

Returns:

(dict) mapping the serial of the readout pulses used to the acquired qibolab.result.ExecutionResults object.

qibolab.instruments.erasynth module#

qibolab.instruments.erasynth.RECONNECTION_ATTEMPTS = 10#

Number of times to attempt sending requests to the web server in case of failure.

qibolab.instruments.erasynth.TIMEOUT = 10#

Timeout time for HTTP requests in seconds.

class qibolab.instruments.erasynth.ERASynthEthernet(name, address)[source]#

Bases: object

ERA ethernet driver that follows the QCoDeS interface.

Controls the instrument via HTTP requests to the instrument’s web server.

property url#
post(name, value)[source]#

Post a value to the instrument’s web server.

Try to post multiple times, waiting for 0.1 seconds between each attempt.

Parameters:
  • name – str = The name of the value to post.

  • value – str = The value to post.

get(name)[source]#

Get a value from the instrument’s web server.

Try to get multiple times, waiting for 0.1 seconds between each attempt.

Parameters:

name – str = The name of the value to get.

set(name, value)[source]#

Set a value to the instrument’s web server.

Parameters:
  • name (str) – Name of the paramater that we are updating. In qibolab this can be frequency, power or ref_osc_source, however the instrument’s web server may support more values.

  • value – New value to set to the given parameter. The type of value depends on the parameter being updated.

on()[source]#
off()[source]#
close()[source]#
class qibolab.instruments.erasynth.ERA(name, address, ethernet=True, ref_osc_source=None)[source]#

Bases: LocalOscillator

Driver to control the ERAsynth++ local oscillator.

This driver is using: https://qcodes.github.io/Qcodes_contrib_drivers/api/generated/qcodes_contrib_drivers.drivers.ERAInstruments.html#qcodes_contrib_drivers.drivers.ERAInstruments.erasynth.ERASynthPlusPlus

or the custom qibolab.instruments.erasynth.ERASynthEthernet object if we are connected via ethernet.

create()[source]#

Create instance of physical device.

qibolab.instruments.icarusq module#

qibolab.instruments.icarusqfpga module#

qibolab.instruments.oscillator module#

qibolab.instruments.oscillator.RECONNECTION_ATTEMPTS = 3#

Number of times to attempt connecting to instrument in case of failure.

class qibolab.instruments.oscillator.LocalOscillatorSettings(power: float | None = None, frequency: float | None = None, ref_osc_source: str | None = None)[source]#

Bases: InstrumentSettings

Local oscillator parameters that are saved in the platform runcard.

power: float | None = None#
frequency: float | None = None#
ref_osc_source: str | None = None#
dump()[source]#

Dictionary containing local oscillator settings.

The reference clock is excluded as it is not a calibrated parameter. None values are also excluded.

class qibolab.instruments.oscillator.LocalOscillator(name, address, ref_osc_source=None)[source]#

Bases: Instrument

Abstraction for local oscillator instruments.

Local oscillators are used to upconvert signals, when the controllers cannot send sufficiently high frequencies to address the qubits and resonators. They cannot be used to play or sweep pulses.

property frequency#
property power#
property ref_osc_source#
abstract create()[source]#

Create instance of physical device.

connect()[source]#

Connects to the instrument using the IP address set in the runcard.

disconnect()[source]#

Close connection to the physical instrument.

sync(parameter)[source]#

Sync parameter value between our cache and the instrument.

If the parameter value exists in our cache, it is uploaded to the instrument. If the value does not exist in our cache, it is downloaded

Parameters:

parameter (str) – Parameter name to be synced.

setup(**kwargs)[source]#

Update instrument settings.

If the instrument is connected the value is automatically uploaded to the instrument. Otherwise the value is cached and will be uploaded when connection is established.

Parameters:

**kwargs – Instrument settings loaded from the runcard.

qibolab.instruments.port module#

class qibolab.instruments.port.Port[source]#

Bases: object

Abstract interface for instrument parameters.

These parameters are exposed to the user through qibolab.channels.Channel.

Drivers should subclass this interface and implement the getters and setters for all the parameters that are available for the corresponding instruments.

Each port is identified by the name attribute. Note that the type of the identifier can be different of each port implementation.

name: str#

Name of the port that acts as its identifier.

offset: float#

DC offset that is applied to this port.

lo_frequency: float#

Local oscillator frequency for the given port.

Relevant only for controllers with internal local oscillators.

lo_power: float#

Local oscillator power for the given port.

Relevant only for controllers with internal local oscillators.

gain: float#

Gain that is applied to this port.

attenuation: float#

Attenuation that is applied to this port.

power_range: int#

Similar to attenuation (negative) and gain (positive) for (Zurich instruments).

filters: dict#

Filters to be applied to the channel to reduce the distortions when sending flux pulses.

qibolab.instruments.rohde_schwarz module#

class qibolab.instruments.rohde_schwarz.SGS100A(name, address, ref_osc_source=None)[source]#

Bases: LocalOscillator

Driver to control the Rohde-Schwarz SGS100A local oscillator.

This driver is using: https://qcodes.github.io/Qcodes/api/generated/qcodes.instrument_drivers.rohde_schwarz.html#module-qcodes.instrument_drivers.rohde_schwarz.SGS100A

create()[source]#

Create instance of physical device.

qibolab.instruments.unrolling module#

Utilities for sequence unrolling.

May be reused by different instruments.

qibolab.instruments.unrolling.batch_max_sequences(sequences, max_size)[source]#

Split a list of sequences to batches with a maximum number of sequences in each.

Parameters:
qibolab.instruments.unrolling.batch_max_readout(sequences, max_measurements)[source]#

Split a list of sequences to batches with a maximum number of readout pulses in each.

Useful for sequence unrolling on instruments that support a maximum number of readout pulses in a single sequence due to memory limitations.

Parameters:

qibolab.instruments.zhinst module#

Instrument for using the Zurich Instruments (Zhinst) devices.

qibolab.instruments.zhinst.COMPILER_SETTINGS = {'HDAWG_MIN_PLAYWAVE_HINT': 64, 'HDAWG_MIN_PLAYZERO_HINT': 64, 'SHFSG_MIN_PLAYWAVE_HINT': 32, 'SHFSG_MIN_PLAYZERO_HINT': 32}#

Translating to Zurich ExecutionParameters.

qibolab.instruments.zhinst.MAX_SEQUENCES = 150#

Maximum number of subsequences in a single sequence.

qibolab.instruments.zhinst.select_pulse(pulse, pulse_type)[source]#

Pulse translation.

class qibolab.instruments.zhinst.ZhPort(name: Tuple[str, str], offset: float = 0.0, power_range: int = 0)[source]#

Bases: Port

name: Tuple[str, str]#

Name of the port that acts as its identifier.

offset: float = 0.0#

DC offset that is applied to this port.

power_range: int = 0#

Similar to attenuation (negative) and gain (positive) for (Zurich instruments).

class qibolab.instruments.zhinst.ZhPulse(pulse)[source]#

Bases: object

Zurich pulse from qibolab pulse translation.

pulse#

Qibolab pulse.

signal#

Line associated with the pulse.

zhpulse#

Zurich pulse.

class qibolab.instruments.zhinst.ZhSweeper(pulse, sweeper, qubit)[source]#

Bases: object

Zurich sweeper from qibolab sweeper for pulse parameters Amplitude, Duration, Frequency (and maybe Phase)

sweeper#

Qibolab sweeper.

pulse#

Qibolab pulse associated to the sweeper.

signal#

Line associated with the pulse.

zhpulse#

Zurich pulse associated to the sweeper.

zhsweeper#

Zurich sweeper.

zhsweepers#

Zurich sweepers, Need something better to store multiple sweeps on the same pulse.

Not properly implemented as it was only used on Rabi amplitude vs lenght and it was an unused routine.

static select_sweeper(ptype, sweeper, qubit)[source]#

Sweeper translation.

add_sweeper(sweeper, qubit)[source]#

Add sweeper to list of sweepers.

class qibolab.instruments.zhinst.ZhSweeperLine(sweeper, qubit=None, sequence=None, pulse=None)[source]#

Bases: object

Zurich sweeper from qibolab sweeper for non pulse parameters Bias, Delay (, power_range, local_oscillator frequency, offset ???)

For now Parameter.bias sweepers are implemented as Parameter.Amplitude on a flux pulse. We may want to keep this class separate for future Near Time sweeps

sweeper#

Qibolab sweeper.

static select_sweeper(sweeper)[source]#

Sweeper translation.

class qibolab.instruments.zhinst.Zurich(name, device_setup, use_emulation=False, time_of_flight=0.0, smearing=0.0)[source]#

Bases: Controller

Zurich driver main class.

PortType#

alias of ZhPort

name: InstrumentId#

Setup name (str)

emulation#

Enable emulation mode (bool)

is_connected: bool#

Is the device connected ? (bool)

signal_map#

Signals to lines mapping

calibration#

Zurich calibration object)

device#

Zurich device parameters for connection

chip#

Parameters read from the runcard not part of ExecutionParameters

results#

Zurich experiment definitions

acquisition_type#

To store if the AcquisitionType.SPECTROSCOPY needs to be enabled by parsing the sequence

sequence#

Zurich pulse sequence

sub_sequences#

Sub sequences between each measurement

nt_sweeps#

Storing sweepers

property sampling_rate#

Sampling rate of control electronics in giga samples per second (GSps).

connect()[source]#

Establish connection to the physical instrument.

disconnect()[source]#

Close connection to the physical instrument.

setup(*args, **kwargs)[source]#

Empty method to comply with Instrument interface.

calibration_step(qubits, couplers, options)[source]#

Zurich general pre experiment calibration definitions.

Change to get frequencies from sequence

register_readout_line(qubit, intermediate_frequency, options)[source]#

Registers qubit measure and acquire lines to calibration and signal map.

Note

To allow debugging with and oscilloscope, just set the following:

self.calibration[f"/logical_signal_groups/q{q}/measure_line"] = lo.SignalCalibration(
    ...,
    local_oscillator=lo.Oscillator(
        ...
        frequency=0.0,
    ),
    ...,
    port_mode=lo.PortMode.LF,
    ...,
)
register_drive_line(qubit, intermediate_frequency)[source]#

Registers qubit drive line to calibration and signal map.

register_flux_line(qubit)[source]#

Registers qubit flux line to calibration and signal map.

register_couplerflux_line(coupler)[source]#

Registers qubit flux line to calibration and signal map.

run_exp()[source]#

Compilation settings, compilation step, execution step and data retrival - Save a experiment Python object: self.experiment.save(“saved_exp”) - Save a experiment compiled experiment (): self.exp.save(“saved_exp”) # saving compiled experiment

static frequency_from_pulses(qubits, sequence)[source]#

Gets the frequencies from the pulses to the qubits.

create_sub_sequence(line_name: str, quantum_elements: Dict[str, Qubit] | Dict[str, Coupler])[source]#

Create a list of sequences for each measurement.

Parameters:
  • line_name (str) – Name of the line from which extract the sequence.

  • quantum_elements (dict[str, Qubit]|dict[str, Coupler]) – qubits or couplers for the platform.

create_sub_sequences(qubits: Dict[str, Qubit], couplers: Dict[str, Coupler])[source]#

Create subsequences for different lines (drive, flux, coupler flux).

Parameters:
experiment_flow(qubits, couplers, sequence, options, sweepers=[])[source]#

Create the experiment object for the devices, following the steps separated one on each method:

Translation, Calibration, Experiment Definition.

play(qubits, couplers, sequence, options)[source]#

Play pulse sequence.

sequence_zh(sequence, qubits, couplers, sweepers)[source]#

Qibo sequence to Zurich sequence.

create_exp(qubits, couplers, options)[source]#

Zurich experiment initialization using their Experiment class.

define_exp(qubits, couplers, exp_options, exp, exp_calib)[source]#

Real time definition.

select_exp(exp, qubits, couplers, exp_options)[source]#

Build Zurich Experiment selecting the relevant sections.

static play_sweep_select_single(exp, qubit, pulse, section, parameters, partial_sweep)[source]#

Play Zurich pulse when a single sweeper is involved.

static play_sweep_select_dual(exp, qubit, pulse, section, parameters)[source]#

Play Zurich pulse when two sweepers are involved on the same pulse.

play_sweep(exp, qubit, pulse, section)[source]#

Takes care of playing the sweepers and involved pulses for different options.

couplerflux(exp: Experiment, couplers: Dict[str, Coupler])[source]#

Coupler flux for bias sweep or pulses.

Parameters:
  • exp (lo.Experiment) – laboneq experiment on which register sequences.

  • couplers (dict[str, Coupler]) – coupler on which pulses are played.

flux(exp: Experiment, qubits: Dict[str, Qubit])[source]#

Qubit flux for bias sweep or pulses.

Parameters:
  • exp (lo.Experiment) – laboneq experiment on which register sequences.

  • qubits (dict[str, Qubit]) – qubits on which pulses are played.

drive(exp: Experiment, qubits: Dict[str, Qubit])[source]#

Qubit driving pulses.

Parameters:
  • exp (lo.Experiment) – laboneq experiment on which register sequences.

  • qubits (dict[str, Qubit]) – qubits on which pulses are played.

find_subsequence_finish(measurement_number: int, line: str, quantum_elements: Dict[str, Qubit] | Dict[str, Coupler]) Tuple[int, str][source]#

Find the finishing time and qubit for a given sequence.

Parameters:
  • measurement_number (int) – number of the measure pulse.

  • line (str) – line from which measure the finishing time. e.g.: “drive”, “flux”, “couplerflux”

  • quantum_elements (dict[str, Qubit]|dict[str, Coupler]) – qubits or couplers from which measure the finishing time.

Returns:

Finish time of the last pulse of the subsequence

before the measurement.

sequence_finish (str): Name of the last subsequence before measurement. If

there are no sequences after the previous measurement, use “None”.

Return type:

time_finish (int)

measure_relax(exp, qubits, couplers, relaxation_time, acquisition_type)[source]#

Qubit readout pulse, data acquisition and qubit relaxation.

fast_reset(exp, qubits, fast_reset)[source]#

Conditional fast reset after readout - small delay for signal processing This is a very naive approach that can be improved by repeating this step until we reach non fast reset fidelity https://quantum-computing.ibm.com/lab/docs/iql/manage/systems/reset/backend_reset

static rearrange_sweepers(sweepers: List[Sweeper]) Tuple[ndarray, List[Sweeper]][source]#

Rearranges sweepers from qibocal based on device hardware limitations.

Frequency sweepers must be applied before bias or amplitude sweepers.

Parameters:

sweepers (list[Sweeper]) – list of sweepers used in the experiment.

Returns:

array of shape (2,) and dtype=int containing

the indexes of the sweepers to be swapped. Defaults to np.array([0, 0]) if no swap is needed.

sweepers (list[Sweeper]): updated list of sweepers used in the experiment. If

sweepers must be swapped, the list is updated accordingly.

Return type:

rearranging_axes (np.ndarray)

offsets_off()[source]#

Sets the offsets from the HDAWGs to 0 after each experiment.

sweep(qubits, couplers, sequence: PulseSequence, options, *sweepers)[source]#

Play pulse and sweepers sequence.

sweep_recursion(qubits, couplers, exp, exp_calib, exp_options)[source]#

Sweepers recursion for multiple nested Real Time sweepers.

sweep_recursion_nt(qubits, couplers, options, exp, exp_calib)[source]#

Sweepers recursion for Near Time sweepers. Faster than regular software sweepers as they are executed on the actual device by (software ? or slower hardware ones)

You want to avoid them so for now they are implement for a specific sweep.

split_batches(sequences)[source]#

Split sequences to batches each of which can be unrolled and played as a single sequence.

Parameters:

sequence (list) – List of qibolab.pulses.PulseSequence to be played.

Returns:

Iterator of batches that can be unrolled in a single one. Default will return all sequences as a single batch.

play_sim(qubits, sequence, options, sim_time)[source]#

Play pulse sequence.

run_sim(sim_time)[source]#

Run the simulation.

Parameters:

sim_time (float) – Time[s] to simulate starting from 0