-
DataGraph — The main graph structure to represent problem data.
-
InteractionEmbedder — A matrix to graph embedder using the interaction embedding algorithm.
-
InteractionEmbeddingConfig — Configuration parameters for the interaction embedding.
-
SpringLayoutConfig — Configuration parameters for the spring-layout embedding.
-
SpringLayoutEmbedder — A graph to graph embedder using the spring layout algorithm.
-
BladeConfig — Configuration parameters to embed with BLaDE.
-
Blade — A matrix to graph embedder using the BLaDE algorithm.
-
Blackman — A Blackman window of a specified duration and area under the curve.
-
Constant — A constant waveform over a given duration.
-
Delay — An empty waveform.
-
Interpolated — A waveform created from interpolation of a set of data points.
-
PiecewiseLinear — A piecewise linear waveform.
-
Ramp — A ramp that linearly interpolates between an initial and final value.
-
Sin — An arbitrary sine over a given duration.
-
Drive — The drive Hamiltonian acting over a duration.
-
Register — The Register in QoolQit, representing a set of qubits with coordinates.
-
QuantumProgram — A program representing a Sequence acting on a Register of qubits.
-
SequenceCompiler — Compiles a QoolQit Register and Drive to a Device.
-
AnalogDevice — A realistic device for analog sequence execution.
-
DigitalAnalogDevice — A device with digital and analog capabilities.
-
MockDevice — A virtual device for unconstrained prototyping.
-
Device — QoolQit Device wrapper around a Pulser BaseDevice.
qoolqit
A Python library for algorithm development in the Rydberg Analog Model.
Classes
Functions
-
available_default_devices — Show the default available devices in QooQit.
class
DataGraph
(edges: Iterable = [])
Bases : BaseGraph
The main graph structure to represent problem data.
Default constructor for the BaseGraph.
Parameters
-
edges : Iterable — set of edge tuples (i, j)
Attributes
-
adj — Graph adjacency object holding the neighbors of each node.
-
name — String identifier of the graph.
-
nodes — A NodeView of the Graph as G.nodes or G.nodes().
-
edges — An EdgeView of the Graph as G.edges or G.edges().
-
degree — A DegreeView for the Graph as G.degree or G.degree().
-
sorted_edges : set — Returns the set of edges (u, v) such that (u < v).
-
all_node_pairs : set — Return a list of all possible node pairs in the graph.
-
has_coords : bool — Check if the graph has coordinates.
-
has_edges : bool — Check if the graph has edges.
-
coords : dict — Return the dictionary of node coordinates.
-
node_weights : dict — Return the dictionary of node weights.
-
edge_weights : dict — Return the dictionary of edge weights.
-
has_node_weights : bool — Check if the graph has node weights.
-
has_edge_weights : bool — Check if the graph has edge weights.
Methods
-
line — Constructs a line graph, with the respective coordinates.
-
circle — Constructs a circle graph, with the respective coordinates.
-
random_er — Constructs an Erdős–Rényi random graph.
-
triangular — Constructs a triangular lattice graph, with respective coordinates.
-
hexagonal — Constructs a hexagonal lattice graph, with respective coordinates.
-
heavy_hexagonal — Constructs a heavy-hexagonal lattice graph, with respective coordinates.
-
square — Constructs a square lattice graph, with respective coordinates.
-
random_ud — Constructs a random unit-disk graph.
-
from_matrix — Constructs a graph from a symmetric square matrix.
-
set_ud_edges — Reset the set of edges to be equal to the set of unit-disk edges.
classmethod
line
(n: int, spacing: float = 1.0) → DataGraph
Constructs a line graph, with the respective coordinates.
Parameters
-
n : int — number of nodes.
-
spacing : float — distance between each node.
classmethod
circle
(n: int, spacing: float = 1.0, center: tuple = (0.0, 0.0)) → DataGraph
Constructs a circle graph, with the respective coordinates.
Parameters
-
n : int — number of nodes.
-
spacing : float — distance between each node.
-
center : tuple — point (x, y) to set as the center of the graph.
classmethod
random_er
(n: int, p: float, seed: int | None = None) → DataGraph
Constructs an Erdős–Rényi random graph.
Parameters
-
n : int — number of nodes.
-
p : float — probability that any two nodes connect.
-
seed : int | None — random seed.
classmethod
triangular
(m: int, n: int, spacing: float = 1.0) → DataGraph
Constructs a triangular lattice graph, with respective coordinates.
Parameters
-
m : int — Number of rows of triangles.
-
n : int — Number of columns of triangles.
-
spacing : float — The distance between adjacent nodes on the final lattice.
classmethod
hexagonal
(m: int, n: int, spacing: float = 1.0) → DataGraph
Constructs a hexagonal lattice graph, with respective coordinates.
Parameters
-
m : int — Number of rows of hexagons.
-
n : int — Number of columns of hexagons.
-
spacing : float — The distance between adjacent nodes on the final lattice.
classmethod
heavy_hexagonal
(m: int, n: int, spacing: float = 1.0) → DataGraph
Constructs a heavy-hexagonal lattice graph, with respective coordinates.
Parameters
-
m : int — Number of rows of hexagons.
-
n : int — Number of columns of hexagons.
-
spacing : float — The distance between adjacent nodes on the final lattice.
classmethod
square
(m: int, n: int, spacing: float = 1.0) → DataGraph
Constructs a square lattice graph, with respective coordinates.
Parameters
-
m : int — Number of rows of square.
-
n : int — Number of columns of square.
-
spacing : float — The distance between adjacent nodes on the final lattice.
classmethod
random_ud
(n: int, radius: float = 1.0, L: float | None = None) → DataGraph
Constructs a random unit-disk graph.
The nodes are sampled uniformly from a square of size (L x L). If L is not given, it is estimated based on a rough heuristic that of packing N nodes on a square of side L such that the expected minimum distance is R, leading to L ~ (R / 2) * sqrt(π * n).
Parameters
-
n : int — number of nodes.
-
radius : float — radius to use for defining the unit-disk edges.
-
L : float | None — size of the square on which to sample the node coordinates.
classmethod
from_matrix
(data: ArrayLike) → DataGraph
Constructs a graph from a symmetric square matrix.
The diagonal values are set as the node weights. For each entry (i, j) where M[i, j] != 0 an edge (i, j) is added to the graph and the value M[i, j] is set as its weight.
Parameters
-
data : ArrayLike — symmetric square matrix.
Raises
-
ValueError
property
node_weights
: dict
Return the dictionary of node weights.
property
edge_weights
: dict
Return the dictionary of edge weights.
property
has_node_weights
: bool
Check if the graph has node weights.
Requires all nodes to have a weight.
property
has_edge_weights
: bool
Check if the graph has edge weights.
Requires all edges to have a weight.
method
set_ud_edges
(radius: float) → None
Reset the set of edges to be equal to the set of unit-disk edges.
class
InteractionEmbedder
()
Bases : MatrixToGraphEmbedder[InteractionEmbeddingConfig]
A matrix to graph embedder using the interaction embedding algorithm.
Attributes
-
config : ConfigType — Returns the config for the embedding algorithm.
-
algorithm : Callable — Returns the callable to the embedding algorithm.
-
info : str — Prints info about the embedding algorithm.
dataclass
InteractionEmbeddingConfig
(method: str = 'Nelder-Mead', maxiter: int = 200000, tol: float = 1e-08)
Bases : EmbeddingConfig
Configuration parameters for the interaction embedding.
dataclass
SpringLayoutConfig
(iterations: int = 100, threshold: float = 0.0001, seed: int | None = None)
Bases : EmbeddingConfig
Configuration parameters for the spring-layout embedding.
class
SpringLayoutEmbedder
(config: SpringLayoutConfig = SpringLayoutConfig())
Bases : GraphToGraphEmbedder[SpringLayoutConfig]
A graph to graph embedder using the spring layout algorithm.
Inits SpringLayoutEmbedder.
Attributes
-
config : ConfigType — Returns the config for the embedding algorithm.
-
algorithm : Callable — Returns the callable to the embedding algorithm.
-
info : str — Prints info about the embedding algorithm.
dataclass
BladeConfig
(max_min_dist_ratio: float | None = None, dimensions: tuple[int, ...] = (5, 4, 3, 2, 2, 2), starting_positions: np.ndarray | None = None, pca: bool = False, steps_per_round: int = 200, compute_weight_relative_threshold: Callable[[float], float] = lambda _: 0.1, compute_max_distance_to_walk: Callable[[float, float | None], float | tuple[float, float, float]] = lambda x, max_radial_dist: np.inf, starting_ratio_factor: int = 2, draw_steps: bool | list[int] = False, device: InitVar[Device | None] = None)
Bases : EmbeddingConfig
Configuration parameters to embed with BLaDE.
class
Blade
(config: BladeConfig = BladeConfig())
Bases : MatrixToGraphEmbedder[BladeConfig]
A matrix to graph embedder using the BLaDE algorithm.
Inits Blade.
Parameters
-
config : BladeConfig — configuration object for the BLaDE algorithm.
Attributes
-
config : ConfigType — Returns the config for the embedding algorithm.
-
algorithm : Callable — Returns the callable to the embedding algorithm.
-
info : str — Prints info about the embedding algorithm.
Methods
-
embed — Return a DataGraph with coordinates that embeds the input matrix.
method
embed
(data: np.ndarray) → DataGraph
Return a DataGraph with coordinates that embeds the input matrix.
Validates the input, runs the embedding algorithm, and validates the output.
Parameters
-
data : np.ndarray — the matrix to embed into a DataGraph with coordinates.
class
Blackman
(duration: float, area: float)
Bases : Waveform
A Blackman window of a specified duration and area under the curve.
Implements the Blackman window shaped waveform blackman(t) = A(0.42 - 0.5cos(αt) + 0.08cos(2αt)) A = area/(0.42duration) α = 2π/duration
Initializes a new Blackman waveform.
See
Parameters
-
duration : float — The waveform duration.
-
area : float — The integral of the waveform.
Example
blackman_wf = Blackman(100.0, area=3.14)Attributes
-
duration : float — Returns the duration of the waveform.
-
params : dict[str, float | np.ndarray] — Dictionary of parameters used by the waveform.
Methods
method
function
(t: float) → float
method
max
() → float
method
min
() → float
class
Constant
(duration: float, value: float)
Bases : Waveform
A constant waveform over a given duration.
Parameters
-
duration : float — the total duration.
-
value : float — the value to take during the duration.
Attributes
-
duration : float — Returns the duration of the waveform.
-
params : dict[str, float | np.ndarray] — Dictionary of parameters used by the waveform.
Methods
method
function
(t: float) → float
method
max
() → float
method
min
() → float
class
Delay
(duration: float, *args: float, **kwargs: float | np.ndarray)
Bases : Waveform
An empty waveform.
Initializes the Waveform.
Parameters
-
duration : float — the total duration of the waveform.
Attributes
-
duration : float — Returns the duration of the waveform.
-
params : dict[str, float | np.ndarray] — Dictionary of parameters used by the waveform.
Methods
method
function
(t: float) → float
method
max
() → float
method
min
() → float
class
Interpolated
(duration: float, values: ArrayLike, times: Optional[ArrayLike] = None, interpolator: str = 'PchipInterpolator', **interpolator_kwargs: Any)
Bases : Waveform
A waveform created from interpolation of a set of data points.
Initializes a new Interpolated waveform.
Parameters
-
duration : int — The waveform duration (in ns).
-
values : ArrayLike — Values of the interpolation points. Must be a list of castable to float or a parametrized object.
-
times : ArrayLike — Fractions of the total duration (between 0 and 1), indicating where to place each value on the time axis. Must be a list of castable to float or a parametrized object. If not given, the values are spread evenly throughout the full duration of the waveform.
-
interpolator : str — The SciPy interpolation class to use. Supports "PchipInterpolator" and "interp1d".
Attributes
-
duration : float — Returns the duration of the waveform.
-
params : dict[str, float | np.ndarray] — Dictionary of parameters used by the waveform.
Methods
method
function
(t: float) → float
method
min
() → float
method
max
() → float
class
PiecewiseLinear
(durations: list | tuple, values: list | tuple)
Bases : CompositeWaveform
A piecewise linear waveform.
Creates a composite waveform of N ramps that linearly interpolate through the given N+1 values.
Parameters
-
durations : list | tuple — list or tuple of N duration values.
-
values : list | tuple — list or tuple of N+1 waveform values.
Attributes
-
duration : float — Returns the duration of the waveform.
-
params : dict[str, float | np.ndarray] — Dictionary of parameters used by the waveform.
-
durations : list[float] — Returns the list of durations of each individual waveform.
-
times : list[float] — Returns the list of times when each individual waveform starts.
-
waveforms : list[Waveform] — Returns a list of the individual waveforms.
-
n_waveforms : int — Returns the number of waveforms.
class
Ramp
(duration: float, initial_value: float, final_value: float)
Bases : Waveform
A ramp that linearly interpolates between an initial and final value.
Parameters
-
duration : float — the total duration.
-
initial_value : float — the initial value at t = 0.
-
final_value : float — the final value at t = duration.
Attributes
-
duration : float — Returns the duration of the waveform.
-
params : dict[str, float | np.ndarray] — Dictionary of parameters used by the waveform.
Methods
method
function
(t: float) → float
method
max
() → float
method
min
() → float
class
Sin
(duration: float, amplitude: float = 1.0, omega: float = 1.0, phi: float = 0.0, shift: float = 0.0)
Bases : Waveform
An arbitrary sine over a given duration.
Parameters
-
duration : float — the total duration.
-
amplitude : float — the amplitude of the sine wave.
-
omega : float — the frequency of the sine wave.
-
phi : float — the phase of the sine wave.
-
shift : float — the vertical shift of the sine wave.
Attributes
-
duration : float — Returns the duration of the waveform.
-
params : dict[str, float | np.ndarray] — Dictionary of parameters used by the waveform.
Methods
method
function
(t: float) → float
class
Drive
(*args: Any, amplitude: Waveform | None = None, detuning: Waveform | None = None, weighted_detunings: list[WeightedDetuning] | None = None, phase: float = 0.0)
The drive Hamiltonian acting over a duration.
Default constructor for the Drive.
Must be instantiated with keyword arguments. Accepts either an amplitude waveform, a detuning waveform, or both. A phase value can also be passed.
Parameters
-
amplitude : Waveform | None — waveform representing Ω(t) in the drive Hamiltonian.
-
detuning : Waveform | None — waveform representing δ(t) in the drive Hamiltonian.
-
phase : float — phase value ɸ for the amplitude term.
-
weighted_detunings : list[WeightedDetuning] | None — additional waveforms and weights applied to individual qubits. Note that these detunings are not supported on all devices.
Attributes
-
amplitude : Waveform — The amplitude waveform in the drive.
-
detuning : Waveform — The detuning waveform in the drive.
-
weighted_detunings : Sequence[WeightedDetuning] — Detunings applied to individual qubits.
-
phase : float — The phase value in the drive.
Methods
property
amplitude
: Waveform
The amplitude waveform in the drive.
property
detuning
: Waveform
The detuning waveform in the drive.
property
weighted_detunings
: Sequence[WeightedDetuning]
Detunings applied to individual qubits.
property
phase
: float
The phase value in the drive.
property
duration
: float
method
draw
(n_points: int = 500, return_fig: bool = False) → Figure | None
class
Register
(qubits: dict)
The Register in QoolQit, representing a set of qubits with coordinates.
Default constructor for the Register.
Parameters
-
qubits : dict — a dictionary of qubits and respective coordinates {q: (x, y), ...}.
Attributes
-
qubits : dict — Returns the dictionary of qubits and respective coordinates.
-
qubits_ids : list — Returns the qubit keys.
-
n_qubits : int — Number of qubits in the Register.
Methods
-
from_graph — Initializes a Register from a graph that has coordinates.
-
from_coordinates — Initializes a Register from a list of coordinates.
-
distances — Distance between each qubit pair.
-
min_distance — Minimum distance between all qubit pairs.
-
radial_distances — Radial distance of each qubit from the origin.
-
max_radial_distance — Maximum radial distance between all qubits.
-
interactions — Interaction 1/r^6 between each qubit pair.
-
draw — Draw the register.
classmethod
from_graph
(graph: DataGraph) → Register
Initializes a Register from a graph that has coordinates.
Parameters
-
graph : DataGraph — a DataGraph instance.
Raises
-
ValueError
classmethod
from_coordinates
(coords: list) → Register
Initializes a Register from a list of coordinates.
Parameters
-
coords : list — a list of coordinates [(x, y), ...]
Raises
-
TypeError
property
qubits
: dict
Returns the dictionary of qubits and respective coordinates.
property
qubits_ids
: list
Returns the qubit keys.
property
n_qubits
: int
Number of qubits in the Register.
method
distances
() → dict
Distance between each qubit pair.
method
min_distance
() → float
Minimum distance between all qubit pairs.
method
radial_distances
() → dict
Radial distance of each qubit from the origin.
method
max_radial_distance
() → float
Maximum radial distance between all qubits.
method
interactions
() → dict
Interaction 1/r^6 between each qubit pair.
method
draw
(return_fig: bool = False) → plt.Figure | None
Draw the register.
Parameters
-
return_fig : bool — boolean argument to return the plt.Figure instance.
class
QuantumProgram
(register: Register, drive: Drive)
A program representing a Sequence acting on a Register of qubits.
Parameters
Attributes
Methods
-
compile_to — Compiles the given program to a device.
property
register
: Register
The register of qubits.
property
drive
: Drive
The driving waveforms.
property
is_compiled
: bool
Check if the program has been compiled.
property
compiled_sequence
: PulserSequence
The Pulser sequence compiled to a specific device.
method
compile_to
(device: Device, profile: CompilerProfile = CompilerProfile.DEFAULT) → None
Compiles the given program to a device.
Parameters
-
device : Device — the Device to compile to.
-
profile : CompilerProfile — the compiler profile to use during compilation.
method
draw
(n_points: int = 500, compiled: bool = False, return_fig: bool = False) → Figure | None
Raises
-
ValueError
enum
CompilerProfile
(*args, **kwds)
class
SequenceCompiler
(register: Register, drive: Drive, device: Device)
Compiles a QoolQit Register and Drive to a Device.
Initializes the compiler.
Parameters
Attributes
-
profile : CompilerProfile — The compiler profile to use.
Methods
property
register
: Register
property
drive
: Drive
property
device
: Device
property
profile
: CompilerProfile
The compiler profile to use.
method
compile_sequence
() → PulserSequence
Raises
-
error
available_default_devices () → None
Show the default available devices in QooQit.
class
AnalogDevice
()
Bases : Device
A realistic device for analog sequence execution.
Attributes
-
specs : dict[str, float | None] — Return the device specification constraints.
-
energy_ratio : float | None — Return the ratio between the max amplitude and max interaction energy on this device.
class
DigitalAnalogDevice
()
Bases : Device
A device with digital and analog capabilities.
Attributes
-
specs : dict[str, float | None] — Return the device specification constraints.
-
energy_ratio : float | None — Return the ratio between the max amplitude and max interaction energy on this device.
class
MockDevice
()
Bases : Device
A virtual device for unconstrained prototyping.
Attributes
-
specs : dict[str, float | None] — Return the device specification constraints.
-
energy_ratio : float | None — Return the ratio between the max amplitude and max interaction energy on this device.
class
Device
(pulser_device: BaseDevice, default_converter: Optional[UnitConverter] = None)
QoolQit Device wrapper around a Pulser BaseDevice.
Parameters
-
pulser_device : BaseDevice — a
BaseDeviceto build the QoolQit device from. -
default_converter : Optional[UnitConverter] — optional unit converter to handle unit conversion. Defaults to the unit converter that rescales energies by the maximum allowed amplitude by the device.
Examples
From Pulser device:
qoolqit_device = Device(pulser_device=pulser_device)From remote Pulser device:
from pulser_pasqal import PasqalCloudfrom qoolqit import Device
# Fetch the remote device from the connectionconnection = PasqalCloud()pulser_fresnel_device = connection.fetch_available_devices()["FRESNEL"]
# Wrap a Pulser device object into a QoolQit Devicefresnel_device = Device(pulser_device=PulserFresnelDevice)From custom Pulser device:
from dataclasses import replacefrom pulser import AnalogDevicefrom qoolqit import Device
# Converting the pulser Device object in a VirtualDevice objectVirtualAnalog = AnalogDevice.to_virtual()# Replacing desired valuesModdedAnalogDevice = replace( VirtualAnalog, max_radial_distance=100, max_sequence_duration=7000 )
# Wrap a Pulser device object into a QoolQit Devicemod_analog_device = Device(pulser_device=ModdedAnalogDevice)Attributes
-
specs : dict[str, float | None] — Return the device specification constraints.
-
energy_ratio : float | None — Return the ratio between the max amplitude and max interaction energy on this device.
Methods
-
reset_converter — Resets the unit converter to the default one.
-
set_time_unit — Changes the unit converter according to a reference time unit.
-
set_energy_unit — Changes the unit converter according to a reference energy unit.
-
set_distance_unit — Changes the unit converter according to a reference distance unit.
-
info — Show the device short description and constraints.
-
from_connection — Return the specified device from the selected device from a connection.
property
converter
: UnitConverter
method
reset_converter
() → None
Resets the unit converter to the default one.
method
set_time_unit
(time: float) → None
Changes the unit converter according to a reference time unit.
method
set_energy_unit
(energy: float) → None
Changes the unit converter according to a reference energy unit.
method
set_distance_unit
(distance: float) → None
Changes the unit converter according to a reference distance unit.
property
specs
: dict[str, float | None]
Return the device specification constraints.
property
energy_ratio
: float | None
Return the ratio between the max amplitude and max interaction energy on this device.
property
name
: str
method
info
() → None
Show the device short description and constraints.
classmethod
from_connection
(connection: RemoteConnection, name: str) → Device
Return the specified device from the selected device from a connection.
Available devices through the provided connection are can be seen with
the connection.fetch_available_devices() method.
Parameters
-
connection : RemoteConnection — connection object to fetch the available devices.
-
name : str — The name of the desired device.
Example
fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")Raises
-
ValueError
