qibolab package#
- qibolab.get_platforms_path()[source]#
Get path to repository containing the platforms.
Path is specified using the environment variable QIBOLAB_PLATFORMS.
- qibolab.create_platform(name, runcard=None)[source]#
A platform for executing quantum algorithms.
It consists of a quantum processor QPU and a set of controlling instruments.
- Parameters:
name (str) – name of the platform. Options are ‘tiiq’, ‘qili’ and ‘icarusq’.
- Returns:
The plaform class.
Subpackages#
- qibolab.compilers package
- qibolab.instruments package
- Subpackages
- qibolab.instruments.qblox package
- Submodules
- qibolab.instruments.qblox.cluster module
- qibolab.instruments.qblox.cluster_qcm_bb module
- qibolab.instruments.qblox.cluster_qcm_rf module
- qibolab.instruments.qblox.cluster_qrm_rf module
- qibolab.instruments.qblox.controller module
- qibolab.instruments.qblox.debug module
- qibolab.instruments.qblox.port module
- qibolab.instruments.qblox.q1asm module
- qibolab.instruments.qblox.sequencer module
- qibolab.instruments.qblox.sweeper module
- qibolab.instruments.qm package
- qibolab.instruments.rfsoc package
- qibolab.instruments.qblox package
- Submodules
- qibolab.instruments.abstract module
- qibolab.instruments.dummy module
- qibolab.instruments.erasynth module
- qibolab.instruments.icarusq module
TektronixAWG5204
TektronixAWG5204.rw_property_wrapper()
TektronixAWG5204.connect()
TektronixAWG5204.setup()
TektronixAWG5204.generate_waveforms_from_pulse()
TektronixAWG5204.translate()
TektronixAWG5204.upload()
TektronixAWG5204.start()
TektronixAWG5204.play_sequence()
TektronixAWG5204.stop()
TektronixAWG5204.disconnect()
TektronixAWG5204.close()
MCAttenuator
QuicSyn
AlazarADC
- qibolab.instruments.icarusqfpga module
- qibolab.instruments.oscillator module
- qibolab.instruments.port module
- qibolab.instruments.qutech module
- qibolab.instruments.rohde_schwarz module
- qibolab.instruments.zhinst module
COMPILER_SETTINGS
select_pulse()
ZhPort
ZhPulse
ZhSweeper
ZhSweeperLine
Zurich
Zurich.PortType
Zurich.name
Zurich.descriptor
Zurich.emulation
Zurich.is_connected
Zurich.signal_map
Zurich.calibration
Zurich.device
Zurich.chip
Zurich.results
Zurich.acquisition_type
Zurich.sequence
Zurich.nt_sweeps
Zurich.connect()
Zurich.create_device_setup()
Zurich.start()
Zurich.stop()
Zurich.disconnect()
Zurich.setup()
Zurich.calibration_step()
Zurich.register_readout_line()
Zurich.register_drive_line()
Zurich.register_flux_line()
Zurich.register_couplerflux_line()
Zurich.run_exp()
Zurich.frequency_from_pulses()
Zurich.experiment_flow()
Zurich.play()
Zurich.sequence_zh()
Zurich.create_exp()
Zurich.define_exp()
Zurich.select_exp()
Zurich.play_sweep_select_single()
Zurich.play_sweep_select_dual()
Zurich.play_sweep()
Zurich.couplerflux()
Zurich.flux()
Zurich.drive()
Zurich.play_after_set()
Zurich.measure_relax()
Zurich.fast_reset()
Zurich.rearrange_sweepers()
Zurich.offsets_off()
Zurich.sweep()
Zurich.sweep_recursion()
Zurich.sweep_recursion_nt()
Zurich.play_sequences()
Zurich.play_sim()
Zurich.run_sim()
- Subpackages
- qibolab.transpilers package
- Submodules
- qibolab.transpilers.abstract module
- qibolab.transpilers.blocks module
- qibolab.transpilers.optimizer module
- qibolab.transpilers.pipeline module
- qibolab.transpilers.placer module
- qibolab.transpilers.router module
ConnectivityError
assert_connectivity()
ShortestPaths
ShortestPaths.connectivity
ShortestPaths.verbose
ShortestPaths.initial_layout
ShortestPaths.added_swaps
ShortestPaths._gates_qubits_pairs
ShortestPaths._mapping
ShortestPaths._graph
ShortestPaths._qubit_map
ShortestPaths._circuit_position
ShortestPaths.transpiler_step()
ShortestPaths.first_transpiler_step()
ShortestPaths.sampling_split
ShortestPaths.reduce()
ShortestPaths.map_list()
ShortestPaths.relocate()
ShortestPaths.initial_checks()
ShortestPaths.add_gates()
ShortestPaths.add_swaps()
ShortestPaths.update_swap_map()
ShortestPaths.update_qubit_map()
ShortestPaths.added_swaps
ShortestPaths.remap_circuit()
CircuitMap
CircuitMap.circuit_blocks
CircuitMap._physical_logical
CircuitMap._circuit_logical
CircuitMap._routed_blocks
CircuitMap._swaps
CircuitMap.blocks_qubits_pairs()
CircuitMap.execute_block()
CircuitMap.routed_circuit()
CircuitMap.final_layout()
CircuitMap.update()
CircuitMap.get_logical_qubits()
CircuitMap.get_physical_qubits()
CircuitMap.logical_to_physical()
CircuitMap.circuit_to_logical()
CircuitMap.circuit_to_physical()
Sabre
draw_dag()
create_dag()
remove_redundant_connections()
- qibolab.transpilers.star_connectivity module
- qibolab.transpilers.unitary_decompositions module
- qibolab.transpilers.unroller module
Submodules#
qibolab.backends module#
- class qibolab.backends.QibolabBackend(platform, runcard=None)[source]#
Bases:
NumpyBackend
- assign_measurements(measurement_map, readout)[source]#
Assigning measurement outcomes to
qibo.states.MeasurementResult
for each gate.This allows properly obtaining the measured shots from the
qibolab.pulses.ReadoutPulse
object obtaned after pulse sequence execution.- Parameters:
measurement_map (dict) – Map from each measurement gate to the sequence of readout pulses implementing it.
readout (
qibolab.pulses.ReadoutPulse
) – Readout result object containing the readout measurement shots. This is created inexecute_circuit
.
- execute_circuit(circuit, initial_state=None, nshots=1000, fuse_one_qubit=False, check_transpiled=False)[source]#
Executes a quantum circuit.
- Parameters:
circuit (
qibo.models.circuit.Circuit
) – Circuit to execute.initial_state (
qibo.models.circuit.Circuit
) – Circuit to prepare the initial state. IfNone
the default|00...0>
state is used.nshots (int) – Number of shots to sample from the experiment. If
None
the default value provided as hardware_avg in the calibration yml will be used.fuse_one_qubit (bool) – If
True
it fuses one qubit gates during transpilation to reduce circuit depth.check_transpiled (bool) – If
True
it checks that the transpiled circuit is equivalent to the original using simulation.
- Returns:
MeasurementOutcomes object containing the results acquired from the execution.
qibolab.channels module#
- qibolab.channels.check_max_offset(offset, max_offset)[source]#
Checks if a given offset value exceeds the maximum supported offset.
This is to avoid sending high currents that could damage lab equipment such as amplifiers.
- class qibolab.channels.Channel(name: str, port: Port | None = None, local_oscillator: LocalOscillator | None = None, max_offset: float | None = None)[source]#
Bases:
object
Representation of physical wire connection (channel).
- local_oscillator: LocalOscillator | None = None#
Instrument object controlling the local oscillator connected to this channel.
Not applicable for setups that do not use external local oscillators because the controller can send sufficiently high frequencies or contains internal local oscillators.
- max_offset: float | None = None#
Maximum DC voltage that we can safely send through this channel.
Sending high voltages for prolonged times may damage amplifiers or other lab equipment. If the user attempts to send a higher value an error will be raised to prevent execution in real instruments.
- property offset#
DC offset that is applied to this port.
- property lo_frequency#
- property lo_power#
- property gain#
- property attenuation#
- property power_range#
- property filters#
- class qibolab.channels.ChannelMap(_channels: ~typing.Dict[str, ~qibolab.channels.Channel] = <factory>)[source]#
Bases:
object
Collection of
qibolab.designs.channel.Channel
objects identified by name.Essentially, it allows creating a mapping of names to channels just specifying the names.
- add(*items)[source]#
Add multiple items to the channel map.
If
qibolab.channels.Channel
objects are given they are added to the channel map. If a different type is given, aqibolab.channels.Channel
with the corresponding name is created and added to the channel map.
qibolab.couplers module#
- class qibolab.couplers.Coupler(name: str | int, sweetspot: float = 0, flux: ~qibolab.channels.Channel | None = None, qubits: ~typing.Dict = <factory>)[source]#
Bases:
object
Representation of a physical coupler.
Coupler objects are instantiated by
qibolab.platforms.platform.Platform
but they are passed to instrument designs in order to play pulses.- flux: Channel | None = None#
Channel used to send flux pulses to the qubit.
- Type:
flux (
qibolab.platforms.utils.Channel
)
- property channels#
qibolab.dummy module#
qibolab.execution_parameters module#
- class qibolab.execution_parameters.AcquisitionType(value)[source]#
Bases:
Enum
Data acquisition from hardware
- DISCRIMINATION = 1#
Demodulate, integrate the waveform and discriminate among states based on the voltages
- INTEGRATION = 2#
Demodulate and integrate the waveform
- RAW = 3#
Acquire the waveform as it is
- SPECTROSCOPY = 4#
Zurich Integration mode for RO frequency sweeps
- class qibolab.execution_parameters.AveragingMode(value)[source]#
Bases:
Enum
Data averaging modes from hardware
- CYCLIC = 1#
Better averaging for short timescale noise
- SINGLESHOT = 2#
No averaging
- Type:
SINGLESHOT
- SEQUENTIAL = 3#
Worse averaging for noise[Avoid]
- Type:
SEQUENTIAL
- class qibolab.execution_parameters.ExecutionParameters(nshots: int | None = None, relaxation_time: int | None = None, fast_reset: bool = False, acquisition_type: AcquisitionType = AcquisitionType.DISCRIMINATION, averaging_mode: AveragingMode = AveragingMode.SINGLESHOT)[source]#
Bases:
object
Data structure to deal with execution parameters
- nshots: int | None = None#
Number of shots to sample from the experiment. Default is the runcard value.
- relaxation_time: int | None = None#
Time to wait for the qubit to relax to its ground Sample between shots in ns. Default is the runcard value.
- acquisition_type: AcquisitionType = 1#
Data acquisition type
- averaging_mode: AveragingMode = 2#
Data averaging mode
- property results_type#
Returns corresponding results class
qibolab.native module#
- class qibolab.native.NativeType(value)[source]#
Bases:
Flag
Define available types of native gates.
Should have the same names with qibo gates.
- M = 1#
- Z = 2#
- RZ = 4#
- GPI2 = 8#
- CZ = 16#
- iSWAP = 32#
- class qibolab.native.NativePulse(name: str, duration: int, amplitude: float, shape: str, pulse_type: PulseType, qubit: qubits.Qubit, frequency: int = 0, relative_start: int = 0, if_frequency: int | None = None, start: int = 0, phase: float = 0.0)[source]#
Bases:
object
Container with parameters required to generate a pulse implementing a native gate.
- qubit: qubits.Qubit#
- relative_start: int = 0#
Relative start is relevant for two-qubit gate operations which correspond to a pulse sequence.
- property raw#
- pulse(start, relative_phase=0.0)[source]#
Construct the
qibolab.pulses.Pulse
object implementing the gate.- Parameters:
- Returns:
A
qibolab.pulses.DrivePulse
orqibolab.pulses.DrivePulse
orqibolab.pulses.FluxPulse
with the pulse parameters of the gate.
- class qibolab.native.VirtualZPulse(phase: float, qubit: qubits.Qubit)[source]#
Bases:
object
Container with parameters required to add a virtual Z phase in a pulse sequence.
- qubit: qubits.Qubit#
- property raw#
- class qibolab.native.CouplerPulse(duration: int, amplitude: float, shape: str, coupler: couplers.Coupler, relative_start: int = 0)[source]#
Bases:
object
Container with parameters required to add a coupler pulse in a pulse sequence.
- coupler: couplers.Coupler#
- property raw#
- pulse(start)[source]#
Construct the
qibolab.pulses.Pulse
object implementing the gate.- Parameters:
start (int) – Start time of the pulse in the sequence.
- Returns:
A
qibolab.pulses.FluxPulse
with the pulse parameters of the gate.
- class qibolab.native.NativeSequence(name: str, pulses: ~typing.List[~qibolab.native.NativePulse | ~qibolab.native.VirtualZPulse] = <factory>, coupler_pulses: ~typing.List[~qibolab.native.CouplerPulse] = <factory>)[source]#
Bases:
object
List of
qibolab.platforms.native.NativePulse
objects implementing a gate.Relevant for two-qubit gates, which usually require a sequence of pulses to be implemented. These pulses may act on qubits different than the qubits the gate is targeting.
- pulses: List[NativePulse | VirtualZPulse]#
- coupler_pulses: List[CouplerPulse]#
- classmethod from_dict(name, sequence, qubits, couplers)[source]#
Constructs the native sequence from the dictionaries provided in the runcard.
- Parameters:
name (str) – Name of the gate the sequence is applying.
sequence (dict) – Dictionary describing the sequence as provided in the runcard.
qubits (list) – List of
qibolab.qubits.Qubit
object for all qubits in the platform. All qubits are required because the sequence may be acting on qubits that the implemented gate is not targeting.couplres (list) – List of
qibolab.couplers.Coupler
object for all couplers in the platform. All couplers are required because the sequence may be acting on couplers that the implemented gate is not targeting.
- property raw#
- sequence(start=0)[source]#
Creates a
qibolab.pulses.PulseSequence
object implementing the sequence.
- class qibolab.native.SingleQubitNatives(RX: NativePulse | None = None, RX12: NativePulse | None = None, MZ: NativePulse | None = None)[source]#
Bases:
object
Container with the native single-qubit gates acting on a specific qubit.
- RX: NativePulse | None = None#
Pulse to drive the qubit from state 0 to state 1.
- RX12: NativePulse | None = None#
Pulse to drive to qubit from state 1 to state 2.
- MZ: NativePulse | None = None#
Measurement pulse.
- property RX90: NativePulse#
RX90 native pulse is inferred from RX by halving its amplitude.
- classmethod from_dict(qubit, native_gates)[source]#
Parse native gates of the qubit from the runcard.
- Parameters:
qubit (
qibolab.platforms.abstract.Qubit
) – Qubit object that the native gates are acting on.native_gates (dict) – Dictionary with native gate pulse parameters as loaded from the runcard.
- property raw#
Serialize native gate pulses.
None
gates are not included.
- class qibolab.native.TwoQubitNatives(CZ: NativeSequence | None = None, iSWAP: NativeSequence | None = None)[source]#
Bases:
object
Container with the native two-qubit gates acting on a specific pair of qubits.
- CZ: NativeSequence | None = None#
- iSWAP: NativeSequence | None = None#
- property raw#
- property types#
qibolab.platform module#
A platform for executing quantum algorithms.
- class qibolab.platform.Settings(nshots: int = 1024, sampling_rate: int = 1000000000, relaxation_time: int = 100000)[source]#
Bases:
object
Default execution settings read from the runcard.
- class qibolab.platform.Platform(name: str, qubits: ~typing.Dict[str | int, ~qibolab.qubits.Qubit], pairs: ~typing.Dict[~typing.Tuple[str | int, str | int], ~qibolab.qubits.QubitPair], instruments: ~typing.Dict[str, ~qibolab.instruments.abstract.Instrument], settings: ~qibolab.platform.Settings = <factory>, resonator_type: str | None = None, couplers: ~typing.Dict[str | int, ~qibolab.couplers.Coupler] | None = None, is_connected: bool = False, two_qubit_native_types: ~qibolab.native.NativeType = <factory>, topology: ~networkx.classes.graph.Graph = <factory>)[source]#
Bases:
object
Platform for controlling quantum devices.
- pairs: Dict[Tuple[str | int, str | int], QubitPair]#
Dictionary mapping sorted tuples of qubit names to
qibolab.qubits.QubitPair
objects.
- instruments: Dict[str, Instrument]#
Dictionary mapping instrument names to
qibolab.instruments.abstract.Instrument
objects.
- resonator_type: str | None = None#
Type of resonator (2D or 3D) in the used QPU. Default is 3D for single-qubit chips and 2D for multi-qubit.
- couplers: Dict[str | int, Coupler] | None = None#
Dictionary mapping coupler names to
qibolab.couplers.Coupler
objects.
- two_qubit_native_types: NativeType#
Types of two qubit native gates. Used by the transpiler.
- topology: Graph#
Graph representing the qubit connectivity in the quantum chip.
- setup()[source]#
Prepares instruments to execute experiments.
Sets flux port offsets to the qubit sweetspots.
- execute_pulse_sequence(sequences: PulseSequence, options: ExecutionParameters, **kwargs)[source]#
- Parameters:
sequence (
qibolab.pulses.PulseSequence
) – Pulse sequences to execute.options (
qibolab.platforms.platform.ExecutionParameters
) – Object holding the execution options.**kwargs – May need them for something
- Returns:
Readout results acquired by after execution.
- execute_pulse_sequences(sequences: List[PulseSequence], options: ExecutionParameters, **kwargs)[source]#
- Parameters:
sequence (List[
qibolab.pulses.PulseSequence
]) – Pulse sequences to execute.options (
qibolab.platforms.platform.ExecutionParameters
) – Object holding the execution options.**kwargs – May need them for something
- Returns:
Readout results acquired by after execution.
- sweep(sequence: PulseSequence, options: ExecutionParameters, *sweepers: Sweeper)[source]#
Executes a pulse sequence for different values of sweeped parameters.
Useful for performing chip characterization.
Example
import numpy as np from qibolab.dummy import create_dummy from qibolab.sweeper import Sweeper, Parameter from qibolab.pulses import PulseSequence from qibolab.execution_parameters import ExecutionParameters platform = create_dummy() sequence = PulseSequence() parameter = Parameter.frequency pulse = platform.create_qubit_readout_pulse(qubit=0, start=0) sequence.add(pulse) parameter_range = np.random.randint(10, size=10) sweeper = Sweeper(parameter, parameter_range, [pulse]) platform.sweep(sequence, ExecutionParameters(), sweeper)
- Returns:
Readout results acquired by after execution.
- get_qubit(qubit)[source]#
Return the name of the physical qubit corresponding to a logical qubit.
Temporary fix for the compiler to work for platforms where the qubits are not named as 0, 1, 2, …
- set_lo_twpa_frequency(qubit, freq)[source]#
Set frequency of the local oscillator of the TWPA to which the qubit’s feedline is connected to.
- get_lo_twpa_frequency(qubit)[source]#
Get frequency of the local oscillator of the TWPA to which the qubit’s feedline is connected to in Hz.
- set_lo_twpa_power(qubit, power)[source]#
Set power of the local oscillator of the TWPA to which the qubit’s feedline is connected to.
- get_lo_twpa_power(qubit)[source]#
Get power of the local oscillator of the TWPA to which the qubit’s feedline is connected to in dBm.
- set_attenuation(qubit, att)[source]#
Set attenuation value. Usefeul for calibration routines such as punchout.
- get_attenuation(qubit)[source]#
Get attenuation value. Usefeul for calibration routines such as punchout.
- set_gain(qubit, gain)[source]#
Set gain value. Usefeul for calibration routines such as Rabi oscillations.
- get_gain(qubit)[source]#
Get gain value. Usefeul for calibration routines such as Rabi oscillations.
qibolab.pulses module#
Pulse and PulseSequence classes.
- class qibolab.pulses.PulseType(value)[source]#
Bases:
Enum
An enumeration to distinguish different types of pulses.
READOUT pulses triger acquisitions. DRIVE pulses are used to control qubit states. FLUX pulses are used to shift the frequency of flux tunable qubits and with it implement two-qubit gates.
- READOUT = 'ro'#
- DRIVE = 'qd'#
- FLUX = 'qf'#
- COUPLERFLUX = 'cf'#
- class qibolab.pulses.Waveform(data)[source]#
Bases:
object
A class to save pulse waveforms.
A waveform is a list of samples, or discrete data points, used by the digital to analogue converters (DACs) to synthesise pulses.
- data#
a numpy array containing the samples.
- Type:
np.ndarray
- serial#
a string that can be used as a lable to identify the waveform. It is not automatically generated, it must be set by the user.
- Type:
- DECIMALS = 5#
- exception qibolab.pulses.ShapeInitError(msg=None, *args)[source]#
Bases:
RuntimeError
Error raised when a pulse has not been fully defined.
- default_msg = 'PulseShape attribute pulse must be initialised in order to be able to generate pulse waveforms'#
- class qibolab.pulses.PulseShape[source]#
Bases:
ABC
Abstract class for pulse shapes.
A PulseShape object is responsible for generating envelope and modulated waveforms from a set of pulse parameters, its type and a predefined SAMPLING_RATE. PulsShape generates both i (in-phase) and q (quadrature) components.
- SAMPLING_RATE(int): sampling rate in samples per second (SaPS) = 1000000000.0#
sampling rate in samples per second (SaPS)
- Type:
SAMPLING_RATE (int)
- pulse = None#
the pulse associated with it. Its parameters are used to generate pulse waveforms.
- Type:
pulse (Pulse)
- property envelope_waveforms#
A tuple with the i and q envelope waveforms of the pulse.
- property modulated_waveform_i: Waveform#
The waveform of the i component of the pulse, modulated with its frequency.
- property modulated_waveform_q: Waveform#
The waveform of the q component of the pulse, modulated with its frequency.
- property modulated_waveforms#
A tuple with the i and q waveforms of the pulse, modulated with its frequency.
- class qibolab.pulses.Rectangular[source]#
Bases:
PulseShape
Rectangular pulse shape.
- class qibolab.pulses.Exponential(tau: float, upsilon: float, g: float = 0.1)[source]#
Bases:
PulseShape
Exponential pulse shape (Square pulse with an exponential decay).
- Parameters:
\[A\frac{\exp\left(-\frac{x}{\text{upsilon}}\right) + g \exp\left(-\frac{x}{\text{tau}}\right)}{1 + g}\]
- class qibolab.pulses.Gaussian(rel_sigma: float)[source]#
Bases:
PulseShape
Gaussian pulse shape.
- Parameters:
rel_sigma (float) – relative sigma so that the pulse standard deviation (sigma) = duration / rel_sigma
\[A\exp^{-\frac{1}{2}\frac{(t-\mu)^2}{\sigma^2}}\]
- class qibolab.pulses.Drag(rel_sigma, beta)[source]#
Bases:
PulseShape
Derivative Removal by Adiabatic Gate (DRAG) pulse shape.
- Parameters:
\[\]
- class qibolab.pulses.IIR(b, a, target: PulseShape)[source]#
Bases:
PulseShape
IIR Filter using scipy.signal lfilter.
- property pulse#
- class qibolab.pulses.SNZ(t_half_flux_pulse=None, b_amplitude=1)[source]#
Bases:
PulseShape
Sudden variant Net Zero. https://arxiv.org/abs/2008.07411
- class qibolab.pulses.eCap(alpha: float)[source]#
Bases:
PulseShape
eCap pulse shape.
- Parameters:
alpha (float) –
\[\begin{split}e_{\cap(t,\alpha)} &=& A[1 + \tanh(\alpha t/t_\theta)][1 + \tanh(\alpha (1 - t/t_\theta))]\\ &\times& [1 + \tanh(\alpha/2)]^{-2}\end{split}\]
- class qibolab.pulses.Custom(envelope_i, envelope_q=None)[source]#
Bases:
PulseShape
Arbitrary shape.
- class qibolab.pulses.Pulse(start, duration, amplitude, frequency, relative_phase, shape, channel=0, type=PulseType.DRIVE, qubit=0)[source]#
Bases:
object
A class to represent a pulse to be sent to the QPU.
- Parameters:
start (int | intSymbolicExpression) – Start time of pulse in ns.
duration (int | intSymbolicExpression) – Pulse duration in ns.
amplitude (float) – Pulse digital amplitude (unitless) [-1 to 1].
frequency (int) – Pulse Intermediate Frequency in Hz [10e6 to 300e6].
relative_phase (float) – To be added.
shape – (PulseShape | str): {‘Rectangular()’, ‘Gaussian(rel_sigma)’, ‘DRAG(rel_sigma, beta)’} Pulse shape. See
qibolab.pulses
for list of available shapes.channel (int | str) – the channel on which the pulse should be synthesised.
type (PulseType | str) – {‘ro’, ‘qd’, ‘qf’} type of pulse {ReadOut, Qubit Drive, Qubit Flux}
qubit (int) – qubit or coupler associated with the pulse
Example
from qibolab.pulses import Pulse, Gaussian # define Gaussian drive pulse drive_pulse = Pulse( start=0, duration=60, amplitude=0.3, frequency=-200_000_000, relative_phase=0.0, shape=Gaussian(5), channel=1, type=PulseType.DRIVE, qubit=0, ) # define Rectangular readout pulse readout_pulse = Pulse( start=intSymbolicExpression(60), duration=2000, amplitude=0.3, frequency=20_000_000, relative_phase=0.0, shape=Rectangular(), channel=2, type=PulseType.READOUT, qubit=0, )
- property finish: int#
Returns the time when the pulse is scheduled to finish.
Calculated as pulse.start - pulse finish.
- property se_start: intSymbolicExpression#
Returns a symbolic expression for the pulse start.
- property se_duration: intSymbolicExpression#
Returns a symbolic expression for the pulse duration.
- property se_finish: intSymbolicExpression#
Returns a symbolic expression for the pulse finish.
- property amplitude: float#
Returns the amplitude of the pulse.
Pulse amplitudes are normalised between -1 and 1.
- property global_phase#
Returns the global phase of the pulse, in radians.
This phase is calculated from the pulse start time and frequency as 2 * pi * frequency * start.
- property phase: float#
Returns the total phase of the pulse, in radians.
The total phase is computed as the sum of the global and relative phases.
- property shape: PulseShape#
Returns the shape of the pulse, as a PulseShape object.
- property channel#
Returns the channel on which the pulse should be played.
When a sequence of pulses is sent to the platform for execution, each pulse is sent to the instrument responsible for playing pulses the pulse channel. The connection of instruments with channels is defined in the platform runcard.
- property qubit#
Returns the qubit addressed by the pulse.
- property envelope_waveforms#
A tuple with the i and q envelope waveforms of the pulse.
- property modulated_waveform_i: Waveform#
The waveform of the i component of the pulse, modulated with its frequency.
- property modulated_waveform_q: Waveform#
The waveform of the q component of the pulse, modulated with its frequency.
- property modulated_waveforms#
A tuple with the i and q waveforms of the pulse, modulated with its frequency.
- class qibolab.pulses.ReadoutPulse(start, duration, amplitude, frequency, relative_phase, shape, channel=0, qubit=0)[source]#
Bases:
Pulse
Describes a readout pulse.
See
qibolab.pulses.Pulse
for argument desciption.- property serial#
Returns a string representation of the pulse.
- property global_phase#
Returns the global phase of the pulse, in radians.
This phase is calculated from the pulse start time and frequency as 2 * pi * frequency * start.
- class qibolab.pulses.DrivePulse(start, duration, amplitude, frequency, relative_phase, shape, channel=0, qubit=0)[source]#
Bases:
Pulse
Describes a qubit drive pulse.
See
qibolab.pulses.Pulse
for argument desciption.- property serial#
Returns a string representation of the pulse.
- class qibolab.pulses.FluxPulse(start, duration, amplitude, shape, channel=0, qubit=0)[source]#
Bases:
Pulse
Describes a qubit flux pulse.
Flux pulses have frequency and relative_phase equal to 0. Their i and q components are equal. See
qibolab.pulses.Pulse
for argument desciption.- PULSE_TYPE = 'qf'#
- property envelope_waveforms#
A tuple with the i and q envelope waveforms of the pulse.
- property modulated_waveform_i: Waveform#
The waveform of the i component of the pulse, modulated with its frequency.
- property modulated_waveform_q: Waveform#
The waveform of the q component of the pulse, modulated with its frequency.
- property modulated_waveforms#
A tuple with the i and q waveforms of the pulse, modulated with its frequency.
- property serial#
Returns a string representation of the pulse.
- class qibolab.pulses.CouplerFluxPulse(start, duration, amplitude, shape, channel=0, qubit=0)[source]#
Bases:
FluxPulse
Describes a coupler flux pulse. See
qibolab.pulses.FluxPulse
for argument desciption.- PULSE_TYPE = 'cf'#
- class qibolab.pulses.SplitPulse(pulse: Pulse, window_start: int | None = None, window_finish: int | None = None)[source]#
Bases:
Pulse
A supporting class to represent sections or slices of a pulse.
- property window_start#
- property window_finish#
- property window_duration#
- property serial#
Returns a string representation of the pulse.
- property envelope_waveforms#
A tuple with the i and q envelope waveforms of the pulse.
- property modulated_waveform_i: Waveform#
The waveform of the i component of the pulse, modulated with its frequency.
- property modulated_waveform_q: Waveform#
The waveform of the q component of the pulse, modulated with its frequency.
- property modulated_waveforms#
A tuple with the i and q waveforms of the pulse, modulated with its frequency.
- class qibolab.pulses.PulseConstructor(value)[source]#
Bases:
Enum
An enumeration to map each
PulseType
to the proper pulse constructor.- READOUT = <class 'qibolab.pulses.ReadoutPulse'>#
- DRIVE = <class 'qibolab.pulses.DrivePulse'>#
- FLUX = <class 'qibolab.pulses.FluxPulse'>#
- class qibolab.pulses.PulseSequence(*pulses)[source]#
Bases:
object
A collection of scheduled pulses.
A quantum circuit can be translated into a set of scheduled pulses that implement the circuit gates. This class contains many supporting fuctions to facilitate the creation and manipulation of these collections of pulses. None of the methods of PulseSequence modify any of the properties of its pulses.
- property serial#
Returns a string representation of the pulse sequence.
- property count#
Returns the number of pulses in the sequence.
- shallow_copy()[source]#
Returns a shallow copy of the sequence.
It returns a new PulseSequence object with references to the same Pulse objects.
- copy()[source]#
Returns a deep copy of the sequence.
It returns a new PulseSequence with replicates of each of the pulses contained in the original sequence.
- property ro_pulses#
Returns a new PulseSequence containing only its readout pulses.
- property qd_pulses#
Returns a new PulseSequence containing only its qubit drive pulses.
- property qf_pulses#
Returns a new PulseSequence containing only its qubit flux pulses.
- get_channel_pulses(*channels)[source]#
Returns a new PulseSequence containing only the pulses on a specific set of channels.
- get_qubit_pulses(*qubits)[source]#
Returns a new PulseSequence containing only the pulses on a specific set of qubits.
- coupler_pulses(*couplers)[source]#
Returns a new PulseSequence containing only the pulses on a specific set of couplers.
- property is_empty#
Returns True if the sequence does not contain any pulses.
- property qubits: list#
Returns list containing the qubits associated with the pulses in the sequence.
- get_pulse_overlaps()[source]#
Returns a dictionary of slices of time (tuples with start and finish times) where pulses overlap.
qibolab.qubits module#
- qibolab.qubits.CHANNEL_NAMES = ('readout', 'feedback', 'drive', 'flux', 'twpa')#
Names of channels that belong to a qubit. Not all channels are required to operate a qubit.
- qibolab.qubits.EXCLUDED_FIELDS = ('readout', 'feedback', 'drive', 'flux', 'twpa', 'name', 'native_gates')#
Qubit dataclass fields that are excluded by the
characterization
property.
- class qibolab.qubits.Qubit(name: str | int, bare_resonator_frequency: int = 0, readout_frequency: int = 0, drive_frequency: int = 0, anharmonicity: int = 0, sweetspot: float = 0.0, flux_to_bias: float = 0.0, asymmetry: float = 0.0, bare_resonator_frequency_sweetspot: float = 0.0, ssf_brf: float = 0.0, Ec: float = 0.0, Ej: float = 0.0, g: float = 0.0, assignment_fidelity: float = 0.0, readout_fidelity: float = 0.0, peak_voltage: float = 0, pi_pulse_amplitude: float = 0, T1: int = 0, T2: int = 0, T2_spin_echo: int = 0, state0_voltage: int = 0, state1_voltage: int = 0, mean_gnd_states: ~typing.List[float] = <factory>, mean_exc_states: ~typing.List[float] = <factory>, threshold: float | None = None, iq_angle: float = 0.0, mixer_drive_g: float = 0.0, mixer_drive_phi: float = 0.0, mixer_readout_g: float = 0.0, mixer_readout_phi: float = 0.0, readout: ~qibolab.channels.Channel | None = None, feedback: ~qibolab.channels.Channel | None = None, twpa: ~qibolab.channels.Channel | None = None, drive: ~qibolab.channels.Channel | None = None, flux: ~qibolab.channels.Channel | None = None, native_gates: ~qibolab.native.SingleQubitNatives = <factory>)[source]#
Bases:
object
Representation of a physical qubit.
Qubit objects are instantiated by
qibolab.platforms.platform.Platform
but they are passed to instrument designs in order to play pulses.- Parameters:
readout (
qibolab.platforms.utils.Channel
) – Channel used to readout pulses to the qubit.feedback (
qibolab.platforms.utils.Channel
) – Channel used to get readout feedback from the qubit.drive (
qibolab.platforms.utils.Channel
) – Channel used to send drive pulses to the qubit.flux (
qibolab.platforms.utils.Channel
) – Channel used to send flux pulses to the qubit.qubit (Other characterization parameters for the) –
runcard. (loaded from the) –
- native_gates: SingleQubitNatives#
- property channels#
- property characterization#
Dictionary containing characterization parameters.
- qibolab.qubits.QubitPairId#
Type for holding
QubitPair``s in the ``platform.pairs
dictionary.
- class qibolab.qubits.QubitPair(qubit1: ~qibolab.qubits.Qubit, qubit2: ~qibolab.qubits.Qubit, coupler: ~qibolab.couplers.Coupler | None = None, native_gates: ~qibolab.native.TwoQubitNatives = <factory>)[source]#
Bases:
object
Data structure for holding the native two-qubit gates acting on a pair of qubits.
This is needed for symmetry to the single-qubit gates which are storred in the
qibolab.platforms.abstract.Qubit
.Qubits are sorted according to
qubit.name
such thatqubit1.name < qubit2.name
.- native_gates: TwoQubitNatives#
qibolab.result module#
- class qibolab.result.IntegratedResults(data: ndarray)[source]#
Bases:
object
Data structure to deal with the output of
qibolab.platforms.abstract.AbstractPlatform.execute_pulse_sequence()
qibolab.platforms.abstract.AbstractPlatform.sweep()
Associated with AcquisitionType.INTEGRATION and AveragingMode.SINGLESHOT
- property voltage_i#
Signal component i in volts.
- property voltage_q#
Signal component q in volts.
- property magnitude#
Signal magnitude in volts.
- property phase#
Signal phase in radians.
- property serialize#
Serialize as a dictionary.
- property average#
Perform average over i and q
- class qibolab.result.AveragedIntegratedResults(data: ndarray, std: ndarray = array([], dtype=float64))[source]#
Bases:
IntegratedResults
Data structure to deal with the output of
qibolab.platforms.abstract.AbstractPlatform.execute_pulse_sequence()
qibolab.platforms.abstract.AbstractPlatform.sweep()
Associated with AcquisitionType.INTEGRATION and AveragingMode.CYCLIC or the averages of
IntegratedResults
- class qibolab.result.RawWaveformResults(data: ndarray)[source]#
Bases:
IntegratedResults
Data structure to deal with the output of
qibolab.platforms.abstract.AbstractPlatform.execute_pulse_sequence()
qibolab.platforms.abstract.AbstractPlatform.sweep()
Associated with AcquisitionType.RAW and AveragingMode.SINGLESHOT may also be used to store the integration weights ?
- class qibolab.result.AveragedRawWaveformResults(data: ndarray, std: ndarray = array([], dtype=float64))[source]#
Bases:
AveragedIntegratedResults
Data structure to deal with the output of
qibolab.platforms.abstract.AbstractPlatform.execute_pulse_sequence()
qibolab.platforms.abstract.AbstractPlatform.sweep()
Associated with AcquisitionType.RAW and AveragingMode.CYCLIC or the averages of
RawWaveformResults
- class qibolab.result.SampleResults(data: ndarray)[source]#
Bases:
object
Data structure to deal with the output of
qibolab.platforms.abstract.AbstractPlatform.execute_pulse_sequence()
qibolab.platforms.abstract.AbstractPlatform.sweep()
Associated with AcquisitionType.DISCRIMINATION and AveragingMode.SINGLESHOT
- property serialize#
Serialize as a dictionary.
- property average#
Perform samples average
- class qibolab.result.AveragedSampleResults(statistical_frequency: ndarray, samples: ndarray = array([], dtype=float64), std: ndarray = array([], dtype=float64))[source]#
Bases:
SampleResults
Data structure to deal with the output of
qibolab.platforms.abstract.AbstractPlatform.execute_pulse_sequence()
qibolab.platforms.abstract.AbstractPlatform.sweep()
Associated with AcquisitionType.DISCRIMINATION and AveragingMode.CYCLIC or the averages of
SampleResults
qibolab.serialize module#
Helper methods for loading and saving to runcards.
The format of runcards in the qiboteam/qibolab_platforms_qrc
repository is assumed here. See Using runcards
example for more details.
- qibolab.serialize.load_settings(runcard: dict) Settings [source]#
Load platform settings section from the runcard.
- qibolab.serialize.load_qubits(runcard: dict) Tuple[Dict[str | int, Qubit], Dict[str | int, Coupler], Dict[Tuple[str | int, str | int], QubitPair]] [source]#
Load qubits and pairs from the runcard.
Uses the native gate and characterization sections of the runcard to parse the
qibolab.qubits.Qubit
andqibolab.qubits.QubitPair
objects.
- qibolab.serialize.register_gates(runcard: dict, qubits: Dict[str | int, Qubit], pairs: Dict[Tuple[str | int, str | int], QubitPair], couplers: Dict[str | int, Coupler] | None = None) Tuple[Dict[str | int, Qubit], Dict[Tuple[str | int, str | int], QubitPair]] [source]#
Register single qubit native gates to
Qubit
objects from the runcard.Uses the native gate and characterization sections of the runcard to parse the
qibolab.qubits.Qubit
andqibolab.qubits.QubitPair
objects.
- qibolab.serialize.load_instrument_settings(runcard: dict, instruments: Dict[str, Instrument]) Dict[str, Instrument] [source]#
Setup instruments according to the settings given in the runcard.
- qibolab.serialize.dump_qubits(qubits: Dict[str | int, Qubit], pairs: Dict[Tuple[str | int, str | int], QubitPair], couplers: Dict[str | int, Coupler] | None = None) dict [source]#
Dump qubit and pair objects to a dictionary following the runcard format.
- qibolab.serialize.dump_instruments(instruments: Dict[str, Instrument]) dict [source]#
Dump instrument settings to a dictionary following the runcard format.
- qibolab.serialize.dump_runcard(platform: Platform, path: Path)[source]#
Serializes the platform and saves it as a yaml runcard file.
The file saved follows the format explained in Using runcards.
- Parameters:
platform (qibolab.platform.Platform) – The platform to be serialized.
path (pathlib.Path) – Path that the yaml file will be saved.
qibolab.sweeper module#
- class qibolab.sweeper.Parameter(value)[source]#
Bases:
Enum
Sweeping parameters.
- frequency = 1#
- amplitude = 2#
- duration = 3#
- relative_phase = 4#
- start = 5#
- attenuation = 6#
- gain = 7#
- bias = 8#
- lo_frequency = 9#
- class qibolab.sweeper.SweeperType(value)[source]#
Bases:
Enum
Type of the Sweeper
- ABSOLUTE = functools.partial(<function SweeperType.<lambda>>)#
- FACTOR = <built-in function mul>#
- OFFSET = <built-in function add>#
- class qibolab.sweeper.Sweeper(parameter: Parameter, values: ndarray[Any, dtype[ScalarType]], pulses: list | None = None, qubits: list | None = None, couplers: list | None = None, type: SweeperType | None = SweeperType.ABSOLUTE)[source]#
Bases:
object
Data structure for Sweeper object.
This object is passed as an argument to the method
qibolab.platforms.abstract.Platform.sweep()
which enables the user to sweep a specific parameter for one or more pulses. For information on how to perform sweeps seeqibolab.platforms.abstract.Platform.sweep()
.Example
import numpy as np from qibolab.dummy import create_dummy from qibolab.sweeper import Sweeper, Parameter from qibolab.pulses import PulseSequence from qibolab import ExecutionParameters platform = create_dummy() sequence = PulseSequence() parameter = Parameter.frequency pulse = platform.create_qubit_readout_pulse(qubit=0, start=0) sequence.add(pulse) parameter_range = np.random.randint(10, size=10) sweeper = Sweeper(parameter, parameter_range, [pulse]) platform.sweep(sequence, ExecutionParameters(), sweeper)
- Parameters:
parameter (qibolab.sweeper.Parameter) – parameter to be swept, possible choices are frequency, attenuation, amplitude, current and gain.
_values (np.ndarray) – sweep range. If the parameter of the sweep is a pulse parameter, if the sweeper type is not ABSOLUTE, the base value will be taken from the runcard pulse parameters. If the sweep parameter is Bias, the base value will be the sweetspot of the qubits.
pulses (list) – list of qibolab.pulses.Pulse to be swept (optional).
qubits (list) – list of qibolab.platforms.abstract.Qubit to be swept (optional).
type (SweeperType) – can be ABSOLUTE (the sweeper range is swept directly), FACTOR (sweeper values are multiplied by base value), OFFSET (sweeper values are added to base value)
- type: SweeperType | None = functools.partial(<function SweeperType.<lambda>>)#
qibolab.symbolic module#
- class qibolab.symbolic.SymbolicExpression(type: type, expression=0, symbol: str = '')[source]#
Bases:
object
- supported_types = (<class 'int'>, <class 'float'>)#
- property name#
- property expression#
- property value#
- count = 0#
- instances = {}#
- class qibolab.symbolic.intSymbolicExpression(expression=0, symbol: str = '')[source]#
Bases:
SymbolicExpression
- class qibolab.symbolic.floatSymbolicExpression(expression=0, symbol: str = '')[source]#
Bases:
SymbolicExpression