API reference
qoolqit
A Python library for algorithm development in the Rydberg Analog Model.
Modules:
-
devices– -
drive– -
embedding–Collection of graph and matrix embedding algorithms.
-
exceptions– -
execution–QoolQit module to execute quantum programs on QPUs or local/remote emulators.
-
graphs–Graph creation and manipulation in QoolQit.
-
program– -
register– -
waveforms–
Classes:
-
AnalogDevice–A realistic device for analog sequence execution.
-
Blackman–A Blackman window of a specified duration and area under the curve.
-
Constant–A constant waveform over a given duration.
-
DataGraph–The main graph structure to represent problem data.
-
Delay–An empty waveform.
-
Device–QoolQit Device wrapper around a Pulser BaseDevice.
-
DigitalAnalogDevice–A device with digital and analog capabilities.
-
Drive–The drive Hamiltonian acting over a duration.
-
Interpolated–A waveform created from interpolation of a set of data points.
-
MockDevice–A virtual device for unconstrained prototyping.
-
PiecewiseLinear–A piecewise linear waveform.
-
QuantumProgram–A program representing a Sequence acting on a Register of qubits.
-
Ramp–A ramp that linearly interpolates between an initial and final value.
-
Register–The Register in QoolQit, representing a set of qubits with coordinates.
-
SequenceCompiler–Compiles a QoolQit Register and Drive to a Device.
-
Sin–An arbitrary sine over a given duration.
Functions:
-
available_default_devices–Show the default available devices in QooQit.
AnalogDevice()
A realistic device for analog sequence execution.
Methods:
-
from_connection–Return the specified device from the selected device from a connection.
-
info–Show the device short description and constraints.
-
reset_converter–Resets the unit converter to the default one.
-
set_distance_unit–Changes the unit converter according to a reference distance unit.
-
set_energy_unit–Changes the unit converter according to a reference energy unit.
Attributes:
-
specs(dict[str, float | None]) –Return the device specification constraints.
Source code in qoolqit/devices/device.py
specs: dict[str, float | None]
property
Return the device specification constraints.
from_connection(connection: RemoteConnection, name: str) -> Device
classmethod
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:
-
(connectionRemoteConnection) –connection object to fetch the available devices.
-
(namestr) –The name of the desired device.
Returns:
-
Device(Device) –The requested device.
Raises:
-
ValueError–If the requested device is not available through the provided connection.
Example:
from pulser_pasqal import PasqalCloud
fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")
Source code in qoolqit/devices/device.py
info() -> None
reset_converter() -> None
set_distance_unit(distance: float) -> None
Changes the unit converter according to a reference distance unit.
set_energy_unit(energy: float) -> None
Changes the unit converter according to a reference energy unit.
Blackman(duration: float, area: float)
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
See: https://en.wikipedia.org/wiki/Window_function#:~:text=Blackman%20window
Parameters:
-
(durationfloat) –The waveform duration.
-
(areafloat) –The integral of the waveform.
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
Source code in qoolqit/waveforms/waveforms.py
duration: float
property
Returns the duration of the waveform.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
Constant(duration: float, value: float)
A constant waveform over a given duration.
Parameters:
-
(durationfloat) –the total duration.
-
(valuefloat) –the value to take during the duration.
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
Source code in qoolqit/waveforms/waveforms.py
duration: float
property
Returns the duration of the waveform.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
DataGraph(edges: Iterable = [])
The main graph structure to represent problem data.
Parameters:
-
(edgesIterable, default:[]) –set of edge tuples (i, j)
Methods:
-
circle–Constructs a circle graph, with the respective coordinates.
-
distances–Returns a dictionary of distances for a given set of edges.
-
draw–Draw the graph.
-
from_coordinates–Construct a base graph from a set of coordinates.
-
from_matrix–Constructs a graph from a symmetric square matrix.
-
from_nodes–Construct a base graph from a set of nodes.
-
from_nx–Convert a NetworkX Graph object into a QoolQit graph instance.
-
from_pyg–Convert a PyTorch Geometric Data object into a DataGraph instance.
-
heavy_hexagonal–Constructs a heavy-hexagonal lattice graph, with respective coordinates.
-
hexagonal–Constructs a hexagonal lattice graph, with respective coordinates.
-
interactions–Rydberg model interaction 1/r^6 between pair of nodes.
-
is_ud_graph–Check if the graph is unit-disk.
-
line–Constructs a line graph, with the respective coordinates.
-
max_distance–Returns the maximum distance in the graph.
-
min_distance–Returns the minimum distance in the graph.
-
random_er–Constructs an Erdős–Rényi random graph.
-
random_ud–Constructs a random unit-disk graph.
-
rescale_coords–Rescales the node coordinates by a factor.
-
set_ud_edges–Reset the set of edges to be equal to the set of unit-disk edges.
-
square–Constructs a square lattice graph, with respective coordinates.
-
to_pyg–Convert the DataGraph to a PyTorch Geometric Data object.
-
triangular–Constructs a triangular lattice graph, with respective coordinates.
-
ud_edges–Returns the set of edges given by the intersection of circles of a given radius.
-
ud_radius_range–Return the range (R_min, R_max) where the graph is unit-disk.
Attributes:
-
all_node_pairs(set) –Return a list of all possible node pairs in the graph.
-
coords(dict) –Return the dictionary of node coordinates.
-
edge_weights(dict) –Return the dictionary of edge weights.
-
has_coords(bool) –Check if the graph has coordinates.
-
has_edge_weights(bool) –Check if the graph has edge weights.
-
has_edges(bool) –Check if the graph has edges.
-
has_node_weights(bool) –Check if the graph has node weights.
-
node_weights(dict) –Return the dictionary of node weights.
-
sorted_edges(set) –Returns the set of edges (u, v) such that (u < v).
Source code in qoolqit/graphs/data_graph.py
all_node_pairs: set
property
Return a list of all possible node pairs in the graph.
coords: dict
property
writable
Return the dictionary of node coordinates.
edge_weights: dict
property
writable
Return the dictionary of edge weights.
has_coords: bool
property
Check if the graph has coordinates.
Requires all nodes to have coordinates.
has_edge_weights: bool
property
Check if the graph has edge weights.
Requires all edges to have a weight.
has_edges: bool
property
Check if the graph has edges.
has_node_weights: bool
property
Check if the graph has node weights.
Requires all nodes to have a weight.
node_weights: dict
property
writable
Return the dictionary of node weights.
sorted_edges: set
property
Returns the set of edges (u, v) such that (u < v).
circle(n: int, spacing: float = 1.0, center: tuple = (0.0, 0.0)) -> DataGraph
classmethod
Constructs a circle graph, with the respective coordinates.
Parameters:
-
(nint) –number of nodes.
-
(spacingfloat, default:1.0) –distance between each node.
-
(centertuple, default:(0.0, 0.0)) –point (x, y) to set as the center of the graph.
Source code in qoolqit/graphs/data_graph.py
distances(edge_list: Iterable | None = None) -> dict
Returns a dictionary of distances for a given set of edges.
Distances are calculated directly from the coordinates. Raises an error if there are no coordinates on the graph.
Parameters:
-
(edge_listIterable | None, default:None) –set of edges.
Source code in qoolqit/graphs/base_graph.py
draw(ax: Axes | None = None, **kwargs: Any) -> None
Draw the graph.
Uses the draw_networkx function from NetworkX.
Parameters:
-
(axAxes | None, default:None) –Axes object to draw on. If None, uses the current Axes.
-
(**kwargsAny, default:{}) –keyword-arguments to pass to draw_networkx.
Source code in qoolqit/graphs/base_graph.py
from_coordinates(coords: list | dict) -> BaseGraph
classmethod
Construct a base graph from a set of coordinates.
Parameters:
-
(coordslist | dict) –list or dictionary of coordinate pairs.
Source code in qoolqit/graphs/base_graph.py
from_matrix(data: ArrayLike) -> DataGraph
classmethod
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:
-
(dataArrayLike) –symmetric square matrix.
Source code in qoolqit/graphs/data_graph.py
from_nodes(nodes: Iterable) -> BaseGraph
classmethod
Construct a base graph from a set of nodes.
Parameters:
-
(nodesIterable) –set of nodes.
Source code in qoolqit/graphs/base_graph.py
from_nx(g: nx.Graph) -> BaseGraph
classmethod
Convert a NetworkX Graph object into a QoolQit graph instance.
The input networkx.Graph graph must be defined only with the following allowed
Node attributes
pos (tuple): represents the node 2D position. Must be a list/tuple of real numbers. weight: represents the node weight. Must be a real number.
Edge attributes: weight: represents the edge weight. Must be a real number.
Returns an instance of the class with following attributes
- _node_weights : dict[node, float or None]
- _edge_weights : dict[(u,v), float or None]
- _coords : dict[node, (float,float) or None]
Source code in qoolqit/graphs/base_graph.py
from_pyg(data: torch_geometric.data.Data, node_attrs: Iterable[str] | None = None, edge_attrs: Iterable[str] | None = None, graph_attrs: Iterable[str] | None = None, node_weights_attr: str | None = None, edge_weights_attr: str | None = None) -> DataGraph
classmethod
Convert a PyTorch Geometric Data object into a DataGraph instance.
Requires torch_geometric. Uses to_networkx internally.
Default attributes copied (if present on data ):
- Node:
x,pos(posis also stored in_coords) - Edge:
edge_attr - Graph:
y
Use node_attrs, edge_attrs, graph_attrs for extras.
QoolQit weights (_node_weights, _edge_weights) are not
populated automatically — use the explicit parameters:
node_weights_attr: real-valued tensor of shape(N,)or(N, 1). Defaults toNone.edge_weights_attr: real-valued tensor of shape(E,)or(E, 1)whereE = edge_index.shape[1](directed count). Defaults toNone.
The weight attribute is also stored as a regular node/edge attribute.
Parameters:
-
(dataData) –PyTorch Geometric Data object to convert.
-
(node_attrsIterable[str] | None, default:None) –extra node attributes to copy (beyond x and pos).
-
(edge_attrsIterable[str] | None, default:None) –extra edge attributes to copy (beyond edge_attr).
-
(graph_attrsIterable[str] | None, default:None) –extra graph-level attributes to copy (beyond y).
-
(node_weights_attrstr | None, default:None) –Data attribute to use as node weights.
-
(edge_weights_attrstr | None, default:None) –Data attribute to use as edge weights.
Returns:
-
DataGraph–DataGraph with
_coords,_node_weights,_edge_weights -
DataGraph–populated where applicable.
Raises:
-
ImportError–if
torch_geometricis not installed. -
TypeError–if
datais not atorch_geometric.data.Datainstance, or if a weight attribute is not atorch.Tensor. -
AttributeError–if a specified weight attribute is missing.
-
ValueError–if a weight tensor has an incompatible shape or size.
Source code in qoolqit/graphs/data_graph.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | |
heavy_hexagonal(m: int, n: int, spacing: float = 1.0) -> DataGraph
classmethod
Constructs a heavy-hexagonal lattice graph, with respective coordinates.
Parameters:
-
(mint) –Number of rows of hexagons.
-
(nint) –Number of columns of hexagons.
-
(spacingfloat, default:1.0) –The distance between adjacent nodes on the final lattice.
Notes
The heavy-hexagonal lattice is a regular hexagonal lattice where each edge is decorated with an additional lattice site.
Source code in qoolqit/graphs/data_graph.py
hexagonal(m: int, n: int, spacing: float = 1.0) -> DataGraph
classmethod
Constructs a hexagonal lattice graph, with respective coordinates.
Parameters:
-
(mint) –Number of rows of hexagons.
-
(nint) –Number of columns of hexagons.
-
(spacingfloat, default:1.0) –The distance between adjacent nodes on the final lattice.
Source code in qoolqit/graphs/data_graph.py
interactions() -> dict
is_ud_graph() -> bool
line(n: int, spacing: float = 1.0) -> DataGraph
classmethod
Constructs a line graph, with the respective coordinates.
Parameters:
-
(nint) –number of nodes.
-
(spacingfloat, default:1.0) –distance between each node.
Source code in qoolqit/graphs/data_graph.py
max_distance(connected: bool | None = None) -> float
Returns the maximum distance in the graph.
Parameters:
-
(connectedbool | None, default:None) –if True/False, computes only over connected/disconnected nodes.
Source code in qoolqit/graphs/base_graph.py
min_distance(connected: bool | None = None) -> float
Returns the minimum distance in the graph.
Parameters:
-
(connectedbool | None, default:None) –if True/False, computes only over connected/disconnected nodes.
Source code in qoolqit/graphs/base_graph.py
random_er(n: int, p: float, seed: int | None = None) -> DataGraph
classmethod
Constructs an Erdős–Rényi random graph.
Parameters:
-
(nint) –number of nodes.
-
(pfloat) –probability that any two nodes connect.
-
(seedint | None, default:None) –random seed.
Source code in qoolqit/graphs/data_graph.py
random_ud(n: int, radius: float = 1.0, L: float | None = None) -> DataGraph
classmethod
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:
-
(nint) –number of nodes.
-
(radiusfloat, default:1.0) –radius to use for defining the unit-disk edges.
-
(Lfloat | None, default:None) –size of the square on which to sample the node coordinates.
Source code in qoolqit/graphs/data_graph.py
rescale_coords(*args: Any, scaling: float | None = None, spacing: float | None = None) -> None
Rescales the node coordinates by a factor.
Accepts either a scaling or a spacing factor.
Parameters:
-
(scalingfloat | None, default:None) –value to scale by.
-
(spacingfloat | None, default:None) –value to set as the minimum distance in the graph.
Source code in qoolqit/graphs/base_graph.py
set_ud_edges(radius: float) -> None
Reset the set of edges to be equal to the set of unit-disk edges.
square(m: int, n: int, spacing: float = 1.0) -> DataGraph
classmethod
Constructs a square lattice graph, with respective coordinates.
Parameters:
-
(mint) –Number of rows of square.
-
(nint) –Number of columns of square.
-
(spacingfloat, default:1.0) –The distance between adjacent nodes on the final lattice.
Source code in qoolqit/graphs/data_graph.py
to_pyg(node_attrs: Iterable[str] | None = None, edge_attrs: Iterable[str] | None = None, graph_attrs: Iterable[str] | None = None, node_weights_attr: str = 'weight', edge_weights_attr: str = 'edge_weight') -> torch_geometric.data.Data
Convert the DataGraph to a PyTorch Geometric Data object.
Requires torch_geometric. Uses from_networkx internally.
Default attributes exported (if present on the graph):
- Node
"x"→data.x; Edge"edge_attr"→data.edge_attr - Graph
"y"→data.y
Use node_attrs, edge_attrs, graph_attrs for extras.
QoolQit internal dicts exported when populated:
_coords→data.pos(float64, shape(N, 2))_node_weights→data.<node_weights_attr>(float64, shape(N,)). Defaults to"weight"._edge_weights→data.<edge_weights_attr>(float64, shape(2*E,)). Defaults to"edge_weight".
Parameters:
-
(node_attrsIterable[str] | None, default:None) –extra node attributes to export (beyond x).
-
(edge_attrsIterable[str] | None, default:None) –extra edge attributes to export (beyond edge_attr).
-
(graph_attrsIterable[str] | None, default:None) –extra graph-level attributes to export (beyond y).
-
(node_weights_attrstr, default:'weight') –Data attribute name for node weights. Defaults to
"weight". -
(edge_weights_attrstr, default:'edge_weight') –Data attribute name for edge weights. Defaults to
"edge_weight".
Returns:
-
Data–PyTorch Geometric Data object.
Raises:
-
ImportError–if
torch_geometricis not installed.
Source code in qoolqit/graphs/data_graph.py
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 | |
triangular(m: int, n: int, spacing: float = 1.0) -> DataGraph
classmethod
Constructs a triangular lattice graph, with respective coordinates.
Parameters:
-
(mint) –Number of rows of triangles.
-
(nint) –Number of columns of triangles.
-
(spacingfloat, default:1.0) –The distance between adjacent nodes on the final lattice.
Source code in qoolqit/graphs/data_graph.py
ud_edges(radius: float) -> set
Returns the set of edges given by the intersection of circles of a given radius.
Parameters:
-
(radiusfloat) –the value
Source code in qoolqit/graphs/base_graph.py
ud_radius_range() -> tuple
Return the range (R_min, R_max) where the graph is unit-disk.
The graph is unit-disk if the maximum distance between all connected nodes is smaller than the minimum distance between disconnected nodes. This means that for any value R in that interval, the following condition is true:
graph.ud_edges(radius = R) == graph.sorted edges
Source code in qoolqit/graphs/base_graph.py
Delay(duration: float, *args: float, **kwargs: float | np.ndarray)
An empty waveform.
Parameters:
-
(durationfloat) –the total duration of the waveform.
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
Source code in qoolqit/waveforms/base_waveforms.py
duration: float
property
Returns the duration of the waveform.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
Device(pulser_device: BaseDevice, default_converter: Optional[UnitConverter] = None)
QoolQit Device wrapper around a Pulser BaseDevice.
Parameters:
-
(pulser_deviceBaseDevice) –a
BaseDeviceto build the QoolQit device from. -
(default_converterOptional[UnitConverter], default:None) –optional unit converter to handle unit conversion.
Examples:
From Pulser device:
From remote Pulser device:
from pulser_pasqal import PasqalCloud
from qoolqit import Device
# Fetch the remote device from the connection
connection = PasqalCloud()
pulser_fresnel_device = connection.fetch_available_devices()["FRESNEL"]
# Wrap a Pulser device object into a QoolQit Device
fresnel_device = Device(pulser_device=PulserFresnelDevice)
From custom Pulser device:
from dataclasses import replace
from pulser import AnalogDevice
from qoolqit import Device
# Converting the pulser Device object in a VirtualDevice object
VirtualAnalog = AnalogDevice.to_virtual()
# Replacing desired values
ModdedAnalogDevice = replace(
VirtualAnalog,
max_radial_distance=100,
max_sequence_duration=7000
)
# Wrap a Pulser device object into a QoolQit Device
mod_analog_device = Device(pulser_device=ModdedAnalogDevice)
Methods:
-
from_connection–Return the specified device from the selected device from a connection.
-
info–Show the device short description and constraints.
-
reset_converter–Resets the unit converter to the default one.
-
set_distance_unit–Changes the unit converter according to a reference distance unit.
-
set_energy_unit–Changes the unit converter according to a reference energy unit.
Attributes:
-
specs(dict[str, float | None]) –Return the device specification constraints.
Source code in qoolqit/devices/device.py
specs: dict[str, float | None]
property
Return the device specification constraints.
from_connection(connection: RemoteConnection, name: str) -> Device
classmethod
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:
-
(connectionRemoteConnection) –connection object to fetch the available devices.
-
(namestr) –The name of the desired device.
Returns:
-
Device(Device) –The requested device.
Raises:
-
ValueError–If the requested device is not available through the provided connection.
Example:
from pulser_pasqal import PasqalCloud
fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")
Source code in qoolqit/devices/device.py
info() -> None
reset_converter() -> None
set_distance_unit(distance: float) -> None
Changes the unit converter according to a reference distance unit.
set_energy_unit(energy: float) -> None
Changes the unit converter according to a reference energy unit.
DigitalAnalogDevice()
A device with digital and analog capabilities.
Methods:
-
from_connection–Return the specified device from the selected device from a connection.
-
info–Show the device short description and constraints.
-
reset_converter–Resets the unit converter to the default one.
-
set_distance_unit–Changes the unit converter according to a reference distance unit.
-
set_energy_unit–Changes the unit converter according to a reference energy unit.
Attributes:
-
specs(dict[str, float | None]) –Return the device specification constraints.
Source code in qoolqit/devices/device.py
specs: dict[str, float | None]
property
Return the device specification constraints.
from_connection(connection: RemoteConnection, name: str) -> Device
classmethod
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:
-
(connectionRemoteConnection) –connection object to fetch the available devices.
-
(namestr) –The name of the desired device.
Returns:
-
Device(Device) –The requested device.
Raises:
-
ValueError–If the requested device is not available through the provided connection.
Example:
from pulser_pasqal import PasqalCloud
fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")
Source code in qoolqit/devices/device.py
info() -> None
reset_converter() -> None
set_distance_unit(distance: float) -> None
Changes the unit converter according to a reference distance unit.
set_energy_unit(energy: float) -> None
Changes the unit converter according to a reference energy unit.
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.
Must be instantiated with keyword arguments. Accepts either an amplitude waveform, a detuning waveform, or both. A phase value can also be passed.
Parameters:
-
(amplitudeWaveform | None, default:None) –waveform representing Ω(t) in the drive Hamiltonian.
-
(detuningWaveform | None, default:None) –waveform representing δ(t) in the drive Hamiltonian.
-
(phasefloat, default:0.0) –phase value ɸ for the amplitude term.
-
(weighted_detuningslist[WeightedDetuning] | None, default: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.
-
phase(float) –The phase value in the drive.
-
weighted_detunings(Sequence[WeightedDetuning]) –Detunings applied to individual qubits.
Source code in qoolqit/drive.py
amplitude: Waveform
property
The amplitude waveform in the drive.
detuning: Waveform
property
The detuning waveform in the drive.
phase: float
property
The phase value in the drive.
weighted_detunings: Sequence[WeightedDetuning]
property
Detunings applied to individual qubits.
Interpolated(duration: float, values: ArrayLike, times: Optional[ArrayLike] = None, interpolator: str = 'PchipInterpolator', **interpolator_kwargs: Any)
A waveform created from interpolation of a set of data points.
Parameters:
-
(durationint) –The waveform duration (in ns).
-
(valuesArrayLike) –Values of the interpolation points. Must be a list of castable to float or a parametrized object.
-
(timesArrayLike, default:None) –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.
-
(interpolatorstr, default:'PchipInterpolator') –The SciPy interpolation class to use. Supports "PchipInterpolator" and "interp1d".
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
Source code in qoolqit/waveforms/waveforms.py
duration: float
property
Returns the duration of the waveform.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
MockDevice()
A virtual device for unconstrained prototyping.
Methods:
-
from_connection–Return the specified device from the selected device from a connection.
-
info–Show the device short description and constraints.
-
reset_converter–Resets the unit converter to the default one.
-
set_distance_unit–Changes the unit converter according to a reference distance unit.
-
set_energy_unit–Changes the unit converter according to a reference energy unit.
Attributes:
-
specs(dict[str, float | None]) –Return the device specification constraints.
Source code in qoolqit/devices/device.py
specs: dict[str, float | None]
property
Return the device specification constraints.
from_connection(connection: RemoteConnection, name: str) -> Device
classmethod
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:
-
(connectionRemoteConnection) –connection object to fetch the available devices.
-
(namestr) –The name of the desired device.
Returns:
-
Device(Device) –The requested device.
Raises:
-
ValueError–If the requested device is not available through the provided connection.
Example:
from pulser_pasqal import PasqalCloud
fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")
Source code in qoolqit/devices/device.py
info() -> None
reset_converter() -> None
set_distance_unit(distance: float) -> None
Changes the unit converter according to a reference distance unit.
set_energy_unit(energy: float) -> None
Changes the unit converter according to a reference energy unit.
PiecewiseLinear(durations: list | tuple, values: list | tuple)
A piecewise linear waveform.
Creates a composite waveform of N ramps that linearly interpolate through the given N+1 values.
Parameters:
-
(durationslist | tuple) –list or tuple of N duration values.
-
(valueslist | tuple) –list or tuple of N+1 waveform values.
Methods:
-
function–Identifies the right waveform in the composition and evaluates it at time t.
-
max–Get the maximum value of the waveform.
-
min–Get the approximate minimum value of the waveform.
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
durations(list[float]) –Returns the list of durations of each individual waveform.
-
n_waveforms(int) –Returns the number of waveforms.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
-
times(list[float]) –Returns the list of times when each individual waveform starts.
-
waveforms(list[Waveform]) –Returns a list of the individual waveforms.
Source code in qoolqit/waveforms/waveforms.py
duration: float
property
Returns the duration of the waveform.
durations: list[float]
property
Returns the list of durations of each individual waveform.
n_waveforms: int
property
Returns the number of waveforms.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
times: list[float]
property
Returns the list of times when each individual waveform starts.
waveforms: list[Waveform]
property
Returns a list of the individual waveforms.
function(t: float) -> float
Identifies the right waveform in the composition and evaluates it at time t.
Source code in qoolqit/waveforms/base_waveforms.py
max() -> float
min() -> float
Get the approximate minimum value of the waveform.
This is a brute-force method that samples the waveform over a pre-defined number of points to find the minimum value in the duration. Custom waveforms that have an easy to compute maximum value should override this method.
Source code in qoolqit/waveforms/base_waveforms.py
QuantumProgram(register: Register, drive: Drive)
A program representing a Sequence acting on a Register of qubits.
Parameters:
-
(registerRegister) –the register of qubits, defining their positions.
-
(driveDrive) –the drive acting on qubits, defining amplitude, detuning and phase.
Methods:
-
compile_to–Compiles the quantum program for execution on a specific device.
Attributes:
-
compiled_sequence(Sequence) –The Pulser sequence compiled to a specific device.
-
drive(Drive) –The driving waveforms.
-
is_compiled(bool) –Check if the program has been compiled.
-
register(Register) –The register of qubits.
Source code in qoolqit/program.py
compiled_sequence: PulserSequence
property
The Pulser sequence compiled to a specific device.
drive: Drive
property
The driving waveforms.
is_compiled: bool
property
Check if the program has been compiled.
register: Register
property
The register of qubits.
compile_to(device: Device, profile: CompilerProfile = CompilerProfile.MAX_ENERGY, device_max_duration_ratio: float | None = None) -> None
Compiles the quantum program for execution on a specific device.
The compilation process adapts the program to the device's constraints while preserving the relative ratios of the original program parameters. Different compilation profiles optimize for specific objectives:
- CompilerProfile.MAX_ENERGY (default): Scales the program to utilize the device's maximum capabilities. The drive amplitude and the register positions are rescaled to achieve respectively the maximum amplitude and the minimum pairwise distance compatible with the input program and the device's constraints.
- CompilerProfile.WORKING_POINT: .
Further options DO NOT preserve the input program, but rather adapts the program to the device's constraint. Programs compiled this way are not guaranteed to be portable across devices.
- device_max_duration_ratio: Rescale the drive duration to a fraction of the device's maximum allowed duration. This option is useful in adiabatic protocols where one simply seek to minimize the time derivative of the drive's amplitude.
Parameters:
-
(deviceDevice) –The target device for compilation.
-
(profileCompilerProfile, default:MAX_ENERGY) –The compilation strategy to optimize the program. Defaults to CompilerProfile.MAX_ENERGY.
-
(device_max_duration_ratiofloat | None, default:None) –Whether to set the program duration to a fraction of the device's maximum allowed duration. Must be a number in the range (0, 1]. Can only be set if the device has a maximum allowed duration.
Raises:
-
CompilationError–If the compilation fails due to device constraints.
Source code in qoolqit/program.py
Ramp(duration: float, initial_value: float, final_value: float)
A ramp that linearly interpolates between an initial and final value.
Parameters:
-
(durationfloat) –the total duration.
-
(initial_valuefloat) –the initial value at t = 0.
-
(final_valuefloat) –the final value at t = duration.
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
Source code in qoolqit/waveforms/waveforms.py
duration: float
property
Returns the duration of the waveform.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
Register(qubits: dict)
The Register in QoolQit, representing a set of qubits with coordinates.
Parameters:
-
(qubitsdict) –a dictionary of qubits and respective coordinates {q: (x, y), ...}.
Methods:
-
distances–Distance between each qubit pair.
-
draw–Draw the register.
-
from_coordinates–Initializes a Register from a list of coordinates.
-
from_graph–Initializes a Register from a graph that has coordinates.
-
interactions–Interaction 1/r^6 between each qubit pair.
-
max_radial_distance–Maximum radial distance between all qubits.
-
min_distance–Minimum distance between all qubit pairs.
-
radial_distances–Radial distance of each qubit from the origin.
Attributes:
-
n_qubits(int) –Number of qubits in the Register.
-
qubits(dict) –Returns the dictionary of qubits and respective coordinates.
-
qubits_ids(list) –Returns the qubit keys.
Source code in qoolqit/register.py
n_qubits: int
property
Number of qubits in the Register.
qubits: dict
property
Returns the dictionary of qubits and respective coordinates.
qubits_ids: list
property
Returns the qubit keys.
distances() -> dict
draw(return_fig: bool = False) -> Figure | None
Draw the register.
Parameters:
-
(return_figbool, default:False) –boolean argument to return the matplotlib figure.
Source code in qoolqit/register.py
from_coordinates(coords: list) -> Register
classmethod
Initializes a Register from a list of coordinates.
Parameters:
-
(coordslist) –a list of coordinates [(x, y), ...]
Source code in qoolqit/register.py
from_graph(graph: DataGraph) -> Register
classmethod
Initializes a Register from a graph that has coordinates.
Parameters:
-
(graphDataGraph) –a DataGraph instance.
Source code in qoolqit/register.py
interactions() -> dict
max_radial_distance() -> float
min_distance() -> float
SequenceCompiler(register: Register, drive: Drive, device: Device, profile: CompilerProfile, device_max_duration_ratio: float | None = None)
Compiles a QoolQit Register and Drive to a Device.
Parameters:
-
(registerRegister) –the QoolQit Register.
-
(driveDrive) –the QoolQit Drive.
-
(deviceDevice) –the QoolQit Device.
-
(profileCompilerProfile) –the CompilerProfile to use.
-
(device_max_duration_ratiofloat | None, default:None) –optionally set the program duration to a fraction of the device's maximum allowed duration.
Source code in qoolqit/execution/sequence_compiler.py
Sin(duration: float, amplitude: float = 1.0, omega: float = 1.0, phi: float = 0.0, shift: float = 0.0)
An arbitrary sine over a given duration.
Parameters:
-
(durationfloat) –the total duration.
-
(amplitudefloat, default:1.0) –the amplitude of the sine wave.
-
(omegafloat, default:1.0) –the frequency of the sine wave.
-
(phifloat, default:0.0) –the phase of the sine wave.
-
(shiftfloat, default:0.0) –the vertical shift of the sine wave.
Methods:
-
max–Get the approximate maximum value of the waveform.
-
min–Get the approximate minimum value of the waveform.
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
Source code in qoolqit/waveforms/waveforms.py
duration: float
property
Returns the duration of the waveform.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
max() -> float
Get the approximate maximum value of the waveform.
This is a brute-force method that samples the waveform over a pre-defined number of points to find the maximum value in the duration. Custom waveforms that have an easy to compute maximum value should override this method.
Source code in qoolqit/waveforms/base_waveforms.py
min() -> float
Get the approximate minimum value of the waveform.
This is a brute-force method that samples the waveform over a pre-defined number of points to find the minimum value in the duration. Custom waveforms that have an easy to compute maximum value should override this method.
Source code in qoolqit/waveforms/base_waveforms.py
available_default_devices() -> None
devices
Modules:
-
device– -
unit_converter–
Classes:
-
AnalogDevice–A realistic device for analog sequence execution.
-
Device–QoolQit Device wrapper around a Pulser BaseDevice.
-
DigitalAnalogDevice–A device with digital and analog capabilities.
-
MockDevice–A virtual device for unconstrained prototyping.
Functions:
-
available_default_devices–Show the default available devices in QooQit.
AnalogDevice()
A realistic device for analog sequence execution.
Methods:
-
from_connection–Return the specified device from the selected device from a connection.
-
info–Show the device short description and constraints.
-
reset_converter–Resets the unit converter to the default one.
-
set_distance_unit–Changes the unit converter according to a reference distance unit.
-
set_energy_unit–Changes the unit converter according to a reference energy unit.
Attributes:
-
specs(dict[str, float | None]) –Return the device specification constraints.
Source code in qoolqit/devices/device.py
specs: dict[str, float | None]
property
Return the device specification constraints.
from_connection(connection: RemoteConnection, name: str) -> Device
classmethod
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:
-
(connectionRemoteConnection) –connection object to fetch the available devices.
-
(namestr) –The name of the desired device.
Returns:
-
Device(Device) –The requested device.
Raises:
-
ValueError–If the requested device is not available through the provided connection.
Example:
from pulser_pasqal import PasqalCloud
fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")
Source code in qoolqit/devices/device.py
info() -> None
reset_converter() -> None
set_distance_unit(distance: float) -> None
Changes the unit converter according to a reference distance unit.
set_energy_unit(energy: float) -> None
Changes the unit converter according to a reference energy unit.
Device(pulser_device: BaseDevice, default_converter: Optional[UnitConverter] = None)
QoolQit Device wrapper around a Pulser BaseDevice.
Parameters:
-
(pulser_deviceBaseDevice) –a
BaseDeviceto build the QoolQit device from. -
(default_converterOptional[UnitConverter], default:None) –optional unit converter to handle unit conversion.
Examples:
From Pulser device:
From remote Pulser device:
from pulser_pasqal import PasqalCloud
from qoolqit import Device
# Fetch the remote device from the connection
connection = PasqalCloud()
pulser_fresnel_device = connection.fetch_available_devices()["FRESNEL"]
# Wrap a Pulser device object into a QoolQit Device
fresnel_device = Device(pulser_device=PulserFresnelDevice)
From custom Pulser device:
from dataclasses import replace
from pulser import AnalogDevice
from qoolqit import Device
# Converting the pulser Device object in a VirtualDevice object
VirtualAnalog = AnalogDevice.to_virtual()
# Replacing desired values
ModdedAnalogDevice = replace(
VirtualAnalog,
max_radial_distance=100,
max_sequence_duration=7000
)
# Wrap a Pulser device object into a QoolQit Device
mod_analog_device = Device(pulser_device=ModdedAnalogDevice)
Methods:
-
from_connection–Return the specified device from the selected device from a connection.
-
info–Show the device short description and constraints.
-
reset_converter–Resets the unit converter to the default one.
-
set_distance_unit–Changes the unit converter according to a reference distance unit.
-
set_energy_unit–Changes the unit converter according to a reference energy unit.
Attributes:
-
specs(dict[str, float | None]) –Return the device specification constraints.
Source code in qoolqit/devices/device.py
specs: dict[str, float | None]
property
Return the device specification constraints.
from_connection(connection: RemoteConnection, name: str) -> Device
classmethod
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:
-
(connectionRemoteConnection) –connection object to fetch the available devices.
-
(namestr) –The name of the desired device.
Returns:
-
Device(Device) –The requested device.
Raises:
-
ValueError–If the requested device is not available through the provided connection.
Example:
from pulser_pasqal import PasqalCloud
fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")
Source code in qoolqit/devices/device.py
info() -> None
reset_converter() -> None
set_distance_unit(distance: float) -> None
Changes the unit converter according to a reference distance unit.
set_energy_unit(energy: float) -> None
Changes the unit converter according to a reference energy unit.
DigitalAnalogDevice()
A device with digital and analog capabilities.
Methods:
-
from_connection–Return the specified device from the selected device from a connection.
-
info–Show the device short description and constraints.
-
reset_converter–Resets the unit converter to the default one.
-
set_distance_unit–Changes the unit converter according to a reference distance unit.
-
set_energy_unit–Changes the unit converter according to a reference energy unit.
Attributes:
-
specs(dict[str, float | None]) –Return the device specification constraints.
Source code in qoolqit/devices/device.py
specs: dict[str, float | None]
property
Return the device specification constraints.
from_connection(connection: RemoteConnection, name: str) -> Device
classmethod
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:
-
(connectionRemoteConnection) –connection object to fetch the available devices.
-
(namestr) –The name of the desired device.
Returns:
-
Device(Device) –The requested device.
Raises:
-
ValueError–If the requested device is not available through the provided connection.
Example:
from pulser_pasqal import PasqalCloud
fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")
Source code in qoolqit/devices/device.py
info() -> None
reset_converter() -> None
set_distance_unit(distance: float) -> None
Changes the unit converter according to a reference distance unit.
set_energy_unit(energy: float) -> None
Changes the unit converter according to a reference energy unit.
MockDevice()
A virtual device for unconstrained prototyping.
Methods:
-
from_connection–Return the specified device from the selected device from a connection.
-
info–Show the device short description and constraints.
-
reset_converter–Resets the unit converter to the default one.
-
set_distance_unit–Changes the unit converter according to a reference distance unit.
-
set_energy_unit–Changes the unit converter according to a reference energy unit.
Attributes:
-
specs(dict[str, float | None]) –Return the device specification constraints.
Source code in qoolqit/devices/device.py
specs: dict[str, float | None]
property
Return the device specification constraints.
from_connection(connection: RemoteConnection, name: str) -> Device
classmethod
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:
-
(connectionRemoteConnection) –connection object to fetch the available devices.
-
(namestr) –The name of the desired device.
Returns:
-
Device(Device) –The requested device.
Raises:
-
ValueError–If the requested device is not available through the provided connection.
Example:
from pulser_pasqal import PasqalCloud
fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")
Source code in qoolqit/devices/device.py
info() -> None
reset_converter() -> None
set_distance_unit(distance: float) -> None
Changes the unit converter according to a reference distance unit.
set_energy_unit(energy: float) -> None
Changes the unit converter according to a reference energy unit.
available_default_devices() -> None
device
Classes:
-
AnalogDevice–A realistic device for analog sequence execution.
-
Device–QoolQit Device wrapper around a Pulser BaseDevice.
-
DigitalAnalogDevice–A device with digital and analog capabilities.
-
MockDevice–A virtual device for unconstrained prototyping.
Functions:
-
available_default_devices–Show the default available devices in QooQit.
AnalogDevice()
A realistic device for analog sequence execution.
Methods:
-
from_connection–Return the specified device from the selected device from a connection.
-
info–Show the device short description and constraints.
-
reset_converter–Resets the unit converter to the default one.
-
set_distance_unit–Changes the unit converter according to a reference distance unit.
-
set_energy_unit–Changes the unit converter according to a reference energy unit.
Attributes:
-
specs(dict[str, float | None]) –Return the device specification constraints.
Source code in qoolqit/devices/device.py
specs: dict[str, float | None]
property
Return the device specification constraints.
from_connection(connection: RemoteConnection, name: str) -> Device
classmethod
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:
-
(connectionRemoteConnection) –connection object to fetch the available devices.
-
(namestr) –The name of the desired device.
Returns:
-
Device(Device) –The requested device.
Raises:
-
ValueError–If the requested device is not available through the provided connection.
Example:
from pulser_pasqal import PasqalCloud
fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")
Source code in qoolqit/devices/device.py
info() -> None
reset_converter() -> None
set_distance_unit(distance: float) -> None
Changes the unit converter according to a reference distance unit.
set_energy_unit(energy: float) -> None
Changes the unit converter according to a reference energy unit.
Device(pulser_device: BaseDevice, default_converter: Optional[UnitConverter] = None)
QoolQit Device wrapper around a Pulser BaseDevice.
Parameters:
-
(pulser_deviceBaseDevice) –a
BaseDeviceto build the QoolQit device from. -
(default_converterOptional[UnitConverter], default:None) –optional unit converter to handle unit conversion.
Examples:
From Pulser device:
From remote Pulser device:
from pulser_pasqal import PasqalCloud
from qoolqit import Device
# Fetch the remote device from the connection
connection = PasqalCloud()
pulser_fresnel_device = connection.fetch_available_devices()["FRESNEL"]
# Wrap a Pulser device object into a QoolQit Device
fresnel_device = Device(pulser_device=PulserFresnelDevice)
From custom Pulser device:
from dataclasses import replace
from pulser import AnalogDevice
from qoolqit import Device
# Converting the pulser Device object in a VirtualDevice object
VirtualAnalog = AnalogDevice.to_virtual()
# Replacing desired values
ModdedAnalogDevice = replace(
VirtualAnalog,
max_radial_distance=100,
max_sequence_duration=7000
)
# Wrap a Pulser device object into a QoolQit Device
mod_analog_device = Device(pulser_device=ModdedAnalogDevice)
Methods:
-
from_connection–Return the specified device from the selected device from a connection.
-
info–Show the device short description and constraints.
-
reset_converter–Resets the unit converter to the default one.
-
set_distance_unit–Changes the unit converter according to a reference distance unit.
-
set_energy_unit–Changes the unit converter according to a reference energy unit.
Attributes:
-
specs(dict[str, float | None]) –Return the device specification constraints.
Source code in qoolqit/devices/device.py
specs: dict[str, float | None]
property
Return the device specification constraints.
from_connection(connection: RemoteConnection, name: str) -> Device
classmethod
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:
-
(connectionRemoteConnection) –connection object to fetch the available devices.
-
(namestr) –The name of the desired device.
Returns:
-
Device(Device) –The requested device.
Raises:
-
ValueError–If the requested device is not available through the provided connection.
Example:
from pulser_pasqal import PasqalCloud
fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")
Source code in qoolqit/devices/device.py
info() -> None
reset_converter() -> None
set_distance_unit(distance: float) -> None
Changes the unit converter according to a reference distance unit.
set_energy_unit(energy: float) -> None
Changes the unit converter according to a reference energy unit.
DigitalAnalogDevice()
A device with digital and analog capabilities.
Methods:
-
from_connection–Return the specified device from the selected device from a connection.
-
info–Show the device short description and constraints.
-
reset_converter–Resets the unit converter to the default one.
-
set_distance_unit–Changes the unit converter according to a reference distance unit.
-
set_energy_unit–Changes the unit converter according to a reference energy unit.
Attributes:
-
specs(dict[str, float | None]) –Return the device specification constraints.
Source code in qoolqit/devices/device.py
specs: dict[str, float | None]
property
Return the device specification constraints.
from_connection(connection: RemoteConnection, name: str) -> Device
classmethod
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:
-
(connectionRemoteConnection) –connection object to fetch the available devices.
-
(namestr) –The name of the desired device.
Returns:
-
Device(Device) –The requested device.
Raises:
-
ValueError–If the requested device is not available through the provided connection.
Example:
from pulser_pasqal import PasqalCloud
fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")
Source code in qoolqit/devices/device.py
info() -> None
reset_converter() -> None
set_distance_unit(distance: float) -> None
Changes the unit converter according to a reference distance unit.
set_energy_unit(energy: float) -> None
Changes the unit converter according to a reference energy unit.
MockDevice()
A virtual device for unconstrained prototyping.
Methods:
-
from_connection–Return the specified device from the selected device from a connection.
-
info–Show the device short description and constraints.
-
reset_converter–Resets the unit converter to the default one.
-
set_distance_unit–Changes the unit converter according to a reference distance unit.
-
set_energy_unit–Changes the unit converter according to a reference energy unit.
Attributes:
-
specs(dict[str, float | None]) –Return the device specification constraints.
Source code in qoolqit/devices/device.py
specs: dict[str, float | None]
property
Return the device specification constraints.
from_connection(connection: RemoteConnection, name: str) -> Device
classmethod
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:
-
(connectionRemoteConnection) –connection object to fetch the available devices.
-
(namestr) –The name of the desired device.
Returns:
-
Device(Device) –The requested device.
Raises:
-
ValueError–If the requested device is not available through the provided connection.
Example:
from pulser_pasqal import PasqalCloud
fresnel_device = Device.from_connection(connection=PasqalCloud(), name="FRESNEL")
Source code in qoolqit/devices/device.py
info() -> None
reset_converter() -> None
set_distance_unit(distance: float) -> None
Changes the unit converter according to a reference distance unit.
set_energy_unit(energy: float) -> None
Changes the unit converter according to a reference energy unit.
available_default_devices() -> None
unit_converter
Classes:
-
UnitConverter–A dataclass representing a unit converter in the Rydberg-Analog model.
UnitConverter(C6: float, time: float, energy: float, distance: float)
dataclass
A dataclass representing a unit converter in the Rydberg-Analog model.
Includes three inter-dependent factors for TIME, ENERGY and DISTANCE conversion, also depending on the interaction coefficient C6. The converter checks the following invariants, based on the units used by Pulser:
Conversion invariants: 1. TIME * ENERGY = 1000 ( <=> TIME = 1000 / ENERGY ) 2. DISTANCE^6 * ENERGY = C6 ( <=> ENERGY = C6 / (DISTANCE ^ 6) )
Methods:
-
factors_from_distance–Get factors from a different reference distance than the one set.
-
factors_from_energy–Get factors from a different reference energy than the one set.
-
factors_from_time–Get factors from a different reference time than the one set.
-
from_distance–Instantiate from a reference C6 value and a reference distance unit.
-
from_energy–Instantiate from a reference C6 value and a reference energy unit.
-
from_time–Instantiate from a reference C6 value and a reference time unit.
-
validate_factors–Returns True if the conversion invariants are respected.
Attributes:
-
C6(float) –Time conversion factor.
-
energy(float) –Distance conversion factor.
-
factors(tuple[float, ...]) –Return the current conversion factors set.
-
time(float) –Energy conversion factor.
C6: float = field(repr=False)
class-attribute
instance-attribute
Time conversion factor.
energy: float
instance-attribute
Distance conversion factor.
factors: tuple[float, ...]
property
writable
Return the current conversion factors set.
time: float
instance-attribute
Energy conversion factor.
factors_from_distance(distance: float) -> tuple[float, ...]
Get factors from a different reference distance than the one set.
factors_from_energy(energy: float) -> tuple[float, ...]
Get factors from a different reference energy than the one set.
factors_from_time(time: float) -> tuple[float, ...]
from_distance(C6: float, distance: float) -> UnitConverter
classmethod
Instantiate from a reference C6 value and a reference distance unit.
Source code in qoolqit/devices/unit_converter.py
from_energy(C6: float, energy: float) -> UnitConverter
classmethod
Instantiate from a reference C6 value and a reference energy unit.
Source code in qoolqit/devices/unit_converter.py
from_time(C6: float, time: float) -> UnitConverter
classmethod
Instantiate from a reference C6 value and a reference time unit.
Source code in qoolqit/devices/unit_converter.py
validate_factors(time: float, energy: float, distance: float) -> bool
Returns True if the conversion invariants are respected.
Source code in qoolqit/devices/unit_converter.py
drive
Classes:
-
Drive–The drive Hamiltonian acting over a duration.
-
WeightedDetuning–A weighted detuning.
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.
Must be instantiated with keyword arguments. Accepts either an amplitude waveform, a detuning waveform, or both. A phase value can also be passed.
Parameters:
-
(amplitudeWaveform | None, default:None) –waveform representing Ω(t) in the drive Hamiltonian.
-
(detuningWaveform | None, default:None) –waveform representing δ(t) in the drive Hamiltonian.
-
(phasefloat, default:0.0) –phase value ɸ for the amplitude term.
-
(weighted_detuningslist[WeightedDetuning] | None, default: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.
-
phase(float) –The phase value in the drive.
-
weighted_detunings(Sequence[WeightedDetuning]) –Detunings applied to individual qubits.
Source code in qoolqit/drive.py
amplitude: Waveform
property
The amplitude waveform in the drive.
detuning: Waveform
property
The detuning waveform in the drive.
phase: float
property
The phase value in the drive.
weighted_detunings: Sequence[WeightedDetuning]
property
Detunings applied to individual qubits.
WeightedDetuning(weights: dict[Any, float], waveform: Waveform)
dataclass
A weighted detuning.
See https://pasqal-io.github.io/qoolqit/latest/theory/rydberg_model/#weighted-detuning for details on weighted detunings.
Note: detuning with positive waveforms cannot be instantiated.
Attributes:
-
waveform(Waveform) –The waveform for this detuning.
-
weights(dict[Any, float]) –Association of weights to qubits.
waveform: Waveform
instance-attribute
The waveform for this detuning.
In the companion documentation, this is the function Delta(t).
weights: dict[Any, float]
instance-attribute
Association of weights to qubits.
Each weight must be in [0, 1], where 0 means that the
waveform is ignored for this qubit and 1 means that the waveform is fully applied to this
qubit.
In the companion documentation, these are the value epsilon_i.
embedding
Collection of graph and matrix embedding algorithms.
Modules:
Classes:
-
BaseEmbedder–Abstract base class for all embedders.
-
Blade–A matrix to graph embedder using the BLaDE algorithm.
-
BladeConfig–Configuration parameters to embed with BLaDE.
-
EmbedderConfig–Base abstract dataclass for all embedding algorithm configurations.
-
GraphToGraphEmbedder–A family of embedders that map a graph to a graph.
-
InteractionEmbedder–A matrix to graph embedder using the interaction embedding algorithm.
-
InteractionEmbedderConfig–Configuration parameters for the interaction embedding.
-
MatrixToGraphEmbedder–A family of embedders that map a matrix to a graph.
-
SpringLayoutConfig–Configuration parameters for the spring-layout embedding.
-
SpringLayoutEmbedder–A graph to graph embedder using the spring layout algorithm.
BaseEmbedder(algorithm: Callable, config: ConfigType)
Abstract base class for all embedders.
An embedder is a function that maps a InDataType to an OutDataType through an embedding algorithm. Parameters of the embedding algorithm can be customized through the EmbedderConfig.
An algorithm should be a standalone function that takes a piece of data of an InDataType and maps it to an OutDataType. Any extra configuration parameters taken as input by the algorithm function should be defined in the config dataclass, inheriting from EmbedderConfig.
Parameters:
-
(algorithmCallable) –a callable to the algorithm function.
-
(configConfigType) –a config dataclass holding parameter values for the algorithm.
Methods:
-
embed–Validates the input, runs the embedding algorithm, and validates the output.
-
validate_input–Checks if the given data is compatible with the embedder.
-
validate_output–Checks if the resulting output is expected by the embedder.
Attributes:
-
algorithm(Callable) –Returns the callable to the embedding algorithm.
-
config(ConfigType) –Returns the config for the embedding algorithm.
-
info(str) –Prints info about the embedding algorithm.
Source code in qoolqit/embedding/base_embedder.py
algorithm: Callable
property
Returns the callable to the embedding algorithm.
config: ConfigType
property
Returns the config for the embedding algorithm.
info: str
property
Prints info about the embedding algorithm.
embed(data: InDataType) -> OutDataType
Validates the input, runs the embedding algorithm, and validates the output.
Parameters:
-
(dataInDataType) –the data to embed.
Source code in qoolqit/embedding/base_embedder.py
validate_input(data: InDataType) -> None
abstractmethod
Checks if the given data is compatible with the embedder.
Each embedder should write its own data validator. If the data is not of the supported type or in the specific supported format for that embedder, an error should be raised.
Parameters:
-
(dataInDataType) –the data to validate.
Raises:
-
TypeError–if the data is not of the supported type.
-
SomeError–some other error if other constraints are not met.
Source code in qoolqit/embedding/base_embedder.py
validate_output(result: OutDataType) -> None
abstractmethod
Checks if the resulting output is expected by the embedder.
Each embedder should write its own output validator. If the result is not of the supported type or in the specific supported format for that embedder, an error should be raised.
Parameters:
-
(resultOutDataType) –the output to validate.
Raises:
-
TypeError–if the output is not of the supported type.
-
SomeError–some other error if other constraints are not met.
Source code in qoolqit/embedding/base_embedder.py
Blade(config: BladeConfig = BladeConfig())
A matrix to graph embedder using the BLaDE algorithm.
Parameters:
-
(configBladeConfig, default:BladeConfig()) –configuration object for the BLaDE algorithm.
Methods:
-
embed–Return a DataGraph with coordinates that embeds the input matrix.
Attributes:
-
algorithm(Callable) –Returns the callable to the embedding algorithm.
-
config(ConfigType) –Returns the config for the embedding algorithm.
-
info(str) –Prints info about the embedding algorithm.
Source code in qoolqit/embedding/matrix_embedder.py
algorithm: Callable
property
Returns the callable to the embedding algorithm.
config: ConfigType
property
Returns the config for the embedding algorithm.
info: str
property
Prints info about the embedding algorithm.
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:
-
(datandarray) –the matrix to embed into a DataGraph with coordinates.
Source code in qoolqit/embedding/matrix_embedder.py
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)
dataclass
Configuration parameters to embed with BLaDE.
Methods:
-
__post_init__–Post initialization of the
BladeConfigdataclass. -
dict–Returns the dataclass as a dictionary.
__post_init__(device: Device | None) -> None
Post initialization of the BladeConfig dataclass.
Set the max_min_dist_ratio argument of the blade_embedding algorithm
based on the specification of the selected device.
Parameters:
-
(deviceDevice) –the QoolQit device to use to set the maximum ratio between the maximum radial distance and the minimum pairwise distance between atoms.
Source code in qoolqit/embedding/algorithms/blade/blade.py
EmbedderConfig()
dataclass
Base abstract dataclass for all embedding algorithm configurations.
Subclasses define parameters specific to their algorithms. Each config should define fields that directly translate to arguments in the respective embedding function it configures.
Methods:
-
dict–Returns the dataclass as a dictionary.
GraphToGraphEmbedder(algorithm: Callable, config: ConfigType)
A family of embedders that map a graph to a graph.
Focused on unit-disk graph embedding, where the goal is to find a set of coordinates for a graph that has no coordinates, such that the final unit-disk edges matches the set of edges in the original graph.
A custom algorithm and configuration can be set at initialization.
An algorithm should be a standalone function that takes a piece of data of an InDataType and maps it to an OutDataType. Any extra configuration parameters taken as input by the algorithm function should be defined in the config dataclass, inheriting from EmbedderConfig.
Parameters:
-
(algorithmCallable) –a callable to the algorithm function.
-
(configConfigType) –a config dataclass holding parameter values for the algorithm.
Methods:
-
embed–Validates the input, runs the embedding algorithm, and validates the output.
Attributes:
-
algorithm(Callable) –Returns the callable to the embedding algorithm.
-
config(ConfigType) –Returns the config for the embedding algorithm.
-
info(str) –Prints info about the embedding algorithm.
Source code in qoolqit/embedding/base_embedder.py
algorithm: Callable
property
Returns the callable to the embedding algorithm.
config: ConfigType
property
Returns the config for the embedding algorithm.
info: str
property
Prints info about the embedding algorithm.
embed(data: InDataType) -> OutDataType
Validates the input, runs the embedding algorithm, and validates the output.
Parameters:
-
(dataInDataType) –the data to embed.
Source code in qoolqit/embedding/base_embedder.py
InteractionEmbedder()
A matrix to graph embedder using the interaction embedding algorithm.
Methods:
-
embed–Validates the input, runs the embedding algorithm, and validates the output.
Attributes:
-
algorithm(Callable) –Returns the callable to the embedding algorithm.
-
config(ConfigType) –Returns the config for the embedding algorithm.
-
info(str) –Prints info about the embedding algorithm.
Source code in qoolqit/embedding/matrix_embedder.py
algorithm: Callable
property
Returns the callable to the embedding algorithm.
config: ConfigType
property
Returns the config for the embedding algorithm.
info: str
property
Prints info about the embedding algorithm.
embed(data: InDataType) -> OutDataType
Validates the input, runs the embedding algorithm, and validates the output.
Parameters:
-
(dataInDataType) –the data to embed.
Source code in qoolqit/embedding/base_embedder.py
InteractionEmbedderConfig(method: str = 'Nelder-Mead', maxiter: int = 200000, tol: float = 1e-08)
dataclass
Configuration parameters for the interaction embedding.
Methods:
-
dict–Returns the dataclass as a dictionary.
MatrixToGraphEmbedder(algorithm: Callable, config: ConfigType)
A family of embedders that map a matrix to a graph.
A custom algorithm and configuration can be set at initialization.
An algorithm should be a standalone function that takes a piece of data of an InDataType and maps it to an OutDataType. Any extra configuration parameters taken as input by the algorithm function should be defined in the config dataclass, inheriting from EmbedderConfig.
Parameters:
-
(algorithmCallable) –a callable to the algorithm function.
-
(configConfigType) –a config dataclass holding parameter values for the algorithm.
Methods:
-
embed–Validates the input, runs the embedding algorithm, and validates the output.
Attributes:
-
algorithm(Callable) –Returns the callable to the embedding algorithm.
-
config(ConfigType) –Returns the config for the embedding algorithm.
-
info(str) –Prints info about the embedding algorithm.
Source code in qoolqit/embedding/base_embedder.py
algorithm: Callable
property
Returns the callable to the embedding algorithm.
config: ConfigType
property
Returns the config for the embedding algorithm.
info: str
property
Prints info about the embedding algorithm.
embed(data: InDataType) -> OutDataType
Validates the input, runs the embedding algorithm, and validates the output.
Parameters:
-
(dataInDataType) –the data to embed.
Source code in qoolqit/embedding/base_embedder.py
SpringLayoutConfig(iterations: int = 100, threshold: float = 0.0001, seed: int | None = None)
dataclass
Configuration parameters for the spring-layout embedding.
Methods:
-
dict–Returns the dataclass as a dictionary.
SpringLayoutEmbedder(config: SpringLayoutConfig = SpringLayoutConfig())
A graph to graph embedder using the spring layout algorithm.
Methods:
-
embed–Validates the input, runs the embedding algorithm, and validates the output.
Attributes:
-
algorithm(Callable) –Returns the callable to the embedding algorithm.
-
config(ConfigType) –Returns the config for the embedding algorithm.
-
info(str) –Prints info about the embedding algorithm.
Source code in qoolqit/embedding/graph_embedder.py
algorithm: Callable
property
Returns the callable to the embedding algorithm.
config: ConfigType
property
Returns the config for the embedding algorithm.
info: str
property
Prints info about the embedding algorithm.
embed(data: InDataType) -> OutDataType
Validates the input, runs the embedding algorithm, and validates the output.
Parameters:
-
(dataInDataType) –the data to embed.
Source code in qoolqit/embedding/base_embedder.py
algorithms
Modules:
Classes:
-
BladeConfig–Configuration parameters to embed with BLaDE.
-
InteractionEmbedderConfig–Configuration parameters for the interaction embedding.
-
SpringLayoutConfig–Configuration parameters for the spring-layout embedding.
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)
dataclass
Configuration parameters to embed with BLaDE.
Methods:
-
__post_init__–Post initialization of the
BladeConfigdataclass. -
dict–Returns the dataclass as a dictionary.
__post_init__(device: Device | None) -> None
Post initialization of the BladeConfig dataclass.
Set the max_min_dist_ratio argument of the blade_embedding algorithm
based on the specification of the selected device.
Parameters:
-
(deviceDevice) –the QoolQit device to use to set the maximum ratio between the maximum radial distance and the minimum pairwise distance between atoms.
Source code in qoolqit/embedding/algorithms/blade/blade.py
InteractionEmbedderConfig(method: str = 'Nelder-Mead', maxiter: int = 200000, tol: float = 1e-08)
dataclass
Configuration parameters for the interaction embedding.
Methods:
-
dict–Returns the dataclass as a dictionary.
SpringLayoutConfig(iterations: int = 100, threshold: float = 0.0001, seed: int | None = None)
dataclass
Configuration parameters for the spring-layout embedding.
Methods:
-
dict–Returns the dataclass as a dictionary.
blade
Modules:
Classes:
-
BladeConfig–Configuration parameters to embed with BLaDE.
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)
dataclass
Configuration parameters to embed with BLaDE.
Methods:
-
__post_init__–Post initialization of the
BladeConfigdataclass. -
dict–Returns the dataclass as a dictionary.
__post_init__(device: Device | None) -> None
Post initialization of the BladeConfig dataclass.
Set the max_min_dist_ratio argument of the blade_embedding algorithm
based on the specification of the selected device.
Parameters:
-
(deviceDevice) –the QoolQit device to use to set the maximum ratio between the maximum radial distance and the minimum pairwise distance between atoms.
Source code in qoolqit/embedding/algorithms/blade/blade.py
blade
Classes:
-
BladeConfig–Configuration parameters to embed with BLaDE.
Functions:
-
blade–Embed an interaction matrix or QUBO with the BLaDE algorithm.
-
default_compute_max_distance_to_walk–Default function with rapid then slow decrease to zero of the walking distance.
-
default_compute_ratio_step_factors–Default function to decrease the ratio slightly too low and then increase.
-
update_positions–Compute vector moves to adjust node positions toward target interactions.
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)
dataclass
Configuration parameters to embed with BLaDE.
Methods:
-
__post_init__–Post initialization of the
BladeConfigdataclass. -
dict–Returns the dataclass as a dictionary.
__post_init__(device: Device | None) -> None
Post initialization of the BladeConfig dataclass.
Set the max_min_dist_ratio argument of the blade_embedding algorithm
based on the specification of the selected device.
Parameters:
-
(deviceDevice) –the QoolQit device to use to set the maximum ratio between the maximum radial distance and the minimum pairwise distance between atoms.
Source code in qoolqit/embedding/algorithms/blade/blade.py
blade(matrix: np.ndarray, *, 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]] = default_compute_max_distance_to_walk, compute_regulation_cursor: Callable[[float], float] = lambda _: 0.1, compute_ratio_step_factors: Callable[[float], float] = default_compute_ratio_step_factors, ratio_rerun: int = 2, draw_steps: bool | list[int] = False, draw_weighted_graph: bool = False, draw_differences: bool = False) -> np.ndarray
Embed an interaction matrix or QUBO with the BLaDE algorithm.
BLaDE stands for Balanced Latently Dimensional Embedder. It compute positions for nodes so that their interactions approach the desired values. The interactions assume that the interaction coefficient of the device is set to 1. Its typical target is on interaction matrices or QUBOs, but it can also be used for MIS with limitations if the adjacency matrix is converted into a QUBO. The general principle is based on the Fruchterman-Reingold algorithm.
An objective interaction matrix or QUBO between the nodes. It must
be either symmetrical or triangular.
max_min_dist_ratio: If present, set the maximum ratio between
the maximum radial distance and the minimum pairwise distances.
dimensions: List of numbers of dimensions to explore one
after the other. A list with one value is equivalent to a list containing
twice the same value. For a 2D embedding, the last value should be 2.
Increasing the number of intermediate dimensions can help to escape
from local minima.
starting_positions: If provided, initial positions to start from. Otherwise,
random positions will be generated. The number of dimensions of the
starting positions must be lower than or equal to the first dimension
to explore. If it is lower, it is added dimensions filled with
random values.
pca: Whether to apply Principal Component Analysis to prioritize dimensions
to keep when transitioning from a space to a space with fewer dimensions.
It is disabled by default because it can raise an error when there are
too many dimensions compared to the number of nodes.
steps_per_round: Number of elementary steps to perform for each dimension
transition, where at each step move vectors are computed and applied
on the nodes.
compute_weight_relative_threshold: Function that is called at each step.
It takes a float number between 0 and 1 that represents the progress
on the steps. It must return a float number between 0 and 1 that gives
a threshold determining which weights are significant (see
update_positions to learn more).
compute_max_distance_to_walk: Function that is called at each step.
It takes a float number between 0 and 1 that represents the progress
on the steps, and takes another argument that is set to None when
max_min_dist_ratio is not enabled, otherwise, it is set to
the maximum radial distance for the current step.
It must return a float number that limits the distances
nodes can move at one step (see update_positions to learn more).
compute_regulation_cursor: Function that is called at each step.
It takes a float number between 0 and 1 that represents the progress
on the steps. It must return a float number between 0 (no regulation)
and 1 (full regulation) that uniformizes the ability for the forces
to achieve their objectives at each step by changing priorities.
ratio_rerun: When the distance ratio constraint is not met, it defines
the maximum number of times the algorithm applies additional
computation steps putting the priority on the constraint.
compute_ratio_step_factors: Function that is called at the boundaries of
the rounds. It defines the target ratio the enforce during the
evolution. It acts as a multiplying factor on the target ratio.
draw_steps: If it is a boolean, it defines whether to globally enable
drawing and traces for nodes and forces (for all steps). If it is a
list of integers, it defines a subset of steps to enable such drawing.
Requires installing the seaborn library.
draw_weighted_graph: For each step with drawing enabled, defines whether
to draw a weighted graph representing interactions.
draw_differences: For each step with drawing enabled, defines whether
to draw the differences between current and target interactions.
Source code in qoolqit/embedding/algorithms/blade/blade.py
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | |
default_compute_max_distance_to_walk(progress: float, max_radial_dist: float | None) -> float
Default function with rapid then slow decrease to zero of the walking distance.
Source code in qoolqit/embedding/algorithms/blade/blade.py
default_compute_ratio_step_factors(progress: float) -> float
Default function to decrease the ratio slightly too low and then increase.
update_positions(*, positions: np.ndarray, target_interactions: np.ndarray, weight_relative_threshold: float = 0.0, min_dist: float | None = None, max_radius: float | None = None, max_distance_to_walk: float | tuple[float, float, float] = np.inf, regulation_cursor: float = 0.0, draw_step: bool = False, step: int | None = None, draw_weighted_graph: bool = False) -> np.ndarray
Compute vector moves to adjust node positions toward target interactions.
positions: Starting positions of the nodes. target_interactions: Desired interactions. weight_relative_threshold: It is used to compute a weight difference threshold defining which weights differences are significant and should be considered. For this purpose, it is multiplied by the higher weight difference. It is also used to reduce the precision when targeting the objective weights. min_dist: If set, defined the minimum distance that should be met, and creates forces to enforce the constraint. max_radius: If set, defined the maximum radius that should be met, and creates forces to enforce the constraint. max_distance_to_walk: It set, limits the distance that nodes can walk when the forces are applied. It impacts the priorities of the forces because they only consider the slope of the differences in weights that can be targeting with this ceiling. regulation_cursor: A cursor between 0 (no regulation) and 1 (full regulation) to uniformize the ability of the forces to achieve their interaction targets. draw_step: Whether to draw the nodes and the forces. step: Step number.
Source code in qoolqit/embedding/algorithms/blade/blade.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 | |
drawing
Functions:
-
as_2d–Return the first two coordinates; expects last dim >= 2.
-
draw_set_graph_coords–Coords are positions in numerical order of the nodes.
as_2d(a: np.ndarray) -> np.ndarray
draw_set_graph_coords(graph: nx.Graph, coords: np.ndarray, edge_labels: dict | None = None) -> None
Coords are positions in numerical order of the nodes.
Source code in qoolqit/embedding/algorithms/blade/drawing.py
interaction_embedding
Classes:
-
InteractionEmbedderConfig–Configuration parameters for the interaction embedding.
Functions:
-
interaction_embedding–Matrix embedding into the interaction term of the Rydberg Analog Model.
InteractionEmbedderConfig(method: str = 'Nelder-Mead', maxiter: int = 200000, tol: float = 1e-08)
dataclass
Configuration parameters for the interaction embedding.
Methods:
-
dict–Returns the dataclass as a dictionary.
interaction_embedding(matrix: np.ndarray, method: str, maxiter: int, tol: float) -> DataGraph
Matrix embedding into the interaction term of the Rydberg Analog Model.
Uses scipy.minimize to find the optimal set of node coordinates such that the matrix of values 1/(r_ij)^6 approximate the off-diagonal terms of the input matrix.
Check the documentation for scipy.minimize for more information about each parameter: https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.minimize.html
Parameters:
-
(matrixndarray) –the matrix to embed.
-
(methodstr) –the method used by scipy.minimize.
-
(maxiterint) –maximum number of iterations.
-
(tolfloat) –tolerance for termination.
Source code in qoolqit/embedding/algorithms/interaction_embedding.py
spring_layout_embedding
Classes:
-
SpringLayoutConfig–Configuration parameters for the spring-layout embedding.
Functions:
-
spring_layout_embedding–Force-directed embedding, wrapping
nx.spring_layout.
SpringLayoutConfig(iterations: int = 100, threshold: float = 0.0001, seed: int | None = None)
dataclass
Configuration parameters for the spring-layout embedding.
Methods:
-
dict–Returns the dataclass as a dictionary.
spring_layout_embedding(graph: DataGraph, iterations: int, threshold: float, seed: int | None) -> DataGraph
Force-directed embedding, wrapping nx.spring_layout.
Generates a new graph with the same nodes and edges as the original graph, but with node coordinates set to embed edge weights into pairwise distances as wᵢⱼ=1/rᵢⱼ^6.
The positions are generated by nx.spring_layout.
Since nx.spring_layout embeds edge weights as wᵢⱼ = (k/rᵢⱼ)^3, we set:
- k=1 and scale=None to disable global rescaling of positions.
- rescale weights wᵢⱼ -> wᵢⱼ^1/2
to achieve our target embedding wᵢⱼ=1/rᵢⱼ^6.
Check the documentation for nx.spring_layout for more information about each parameter:
https://networkx.org/documentation/stable/reference/generated/networkx.drawing.layout.spring_layout.html
Parameters:
-
(graphDataGraph) –the graph to embed according to its edge weights.
-
(iterationsint) –maximum number of iterations to take.
-
(thresholdfloat) –Threshold for relative error in node position changes. The iteration stops if force-displacement is below this threshold.
-
(seedint | None) –random seed for reproducibility.
Returns:
-
DataGraph(DataGraph) –graph with the node coordinates set according to the spring-layout embedding.
Source code in qoolqit/embedding/algorithms/spring_layout_embedding.py
base_embedder
Classes:
-
BaseEmbedder–Abstract base class for all embedders.
-
EmbedderConfig–Base abstract dataclass for all embedding algorithm configurations.
BaseEmbedder(algorithm: Callable, config: ConfigType)
Abstract base class for all embedders.
An embedder is a function that maps a InDataType to an OutDataType through an embedding algorithm. Parameters of the embedding algorithm can be customized through the EmbedderConfig.
An algorithm should be a standalone function that takes a piece of data of an InDataType and maps it to an OutDataType. Any extra configuration parameters taken as input by the algorithm function should be defined in the config dataclass, inheriting from EmbedderConfig.
Parameters:
-
(algorithmCallable) –a callable to the algorithm function.
-
(configConfigType) –a config dataclass holding parameter values for the algorithm.
Methods:
-
embed–Validates the input, runs the embedding algorithm, and validates the output.
-
validate_input–Checks if the given data is compatible with the embedder.
-
validate_output–Checks if the resulting output is expected by the embedder.
Attributes:
-
algorithm(Callable) –Returns the callable to the embedding algorithm.
-
config(ConfigType) –Returns the config for the embedding algorithm.
-
info(str) –Prints info about the embedding algorithm.
Source code in qoolqit/embedding/base_embedder.py
algorithm: Callable
property
Returns the callable to the embedding algorithm.
config: ConfigType
property
Returns the config for the embedding algorithm.
info: str
property
Prints info about the embedding algorithm.
embed(data: InDataType) -> OutDataType
Validates the input, runs the embedding algorithm, and validates the output.
Parameters:
-
(dataInDataType) –the data to embed.
Source code in qoolqit/embedding/base_embedder.py
validate_input(data: InDataType) -> None
abstractmethod
Checks if the given data is compatible with the embedder.
Each embedder should write its own data validator. If the data is not of the supported type or in the specific supported format for that embedder, an error should be raised.
Parameters:
-
(dataInDataType) –the data to validate.
Raises:
-
TypeError–if the data is not of the supported type.
-
SomeError–some other error if other constraints are not met.
Source code in qoolqit/embedding/base_embedder.py
validate_output(result: OutDataType) -> None
abstractmethod
Checks if the resulting output is expected by the embedder.
Each embedder should write its own output validator. If the result is not of the supported type or in the specific supported format for that embedder, an error should be raised.
Parameters:
-
(resultOutDataType) –the output to validate.
Raises:
-
TypeError–if the output is not of the supported type.
-
SomeError–some other error if other constraints are not met.
Source code in qoolqit/embedding/base_embedder.py
EmbedderConfig()
dataclass
Base abstract dataclass for all embedding algorithm configurations.
Subclasses define parameters specific to their algorithms. Each config should define fields that directly translate to arguments in the respective embedding function it configures.
Methods:
-
dict–Returns the dataclass as a dictionary.
graph_embedder
Classes:
-
GraphToGraphEmbedder–A family of embedders that map a graph to a graph.
-
SpringLayoutEmbedder–A graph to graph embedder using the spring layout algorithm.
GraphToGraphEmbedder(algorithm: Callable, config: ConfigType)
A family of embedders that map a graph to a graph.
Focused on unit-disk graph embedding, where the goal is to find a set of coordinates for a graph that has no coordinates, such that the final unit-disk edges matches the set of edges in the original graph.
A custom algorithm and configuration can be set at initialization.
An algorithm should be a standalone function that takes a piece of data of an InDataType and maps it to an OutDataType. Any extra configuration parameters taken as input by the algorithm function should be defined in the config dataclass, inheriting from EmbedderConfig.
Parameters:
-
(algorithmCallable) –a callable to the algorithm function.
-
(configConfigType) –a config dataclass holding parameter values for the algorithm.
Methods:
-
embed–Validates the input, runs the embedding algorithm, and validates the output.
Attributes:
-
algorithm(Callable) –Returns the callable to the embedding algorithm.
-
config(ConfigType) –Returns the config for the embedding algorithm.
-
info(str) –Prints info about the embedding algorithm.
Source code in qoolqit/embedding/base_embedder.py
algorithm: Callable
property
Returns the callable to the embedding algorithm.
config: ConfigType
property
Returns the config for the embedding algorithm.
info: str
property
Prints info about the embedding algorithm.
embed(data: InDataType) -> OutDataType
Validates the input, runs the embedding algorithm, and validates the output.
Parameters:
-
(dataInDataType) –the data to embed.
Source code in qoolqit/embedding/base_embedder.py
SpringLayoutEmbedder(config: SpringLayoutConfig = SpringLayoutConfig())
A graph to graph embedder using the spring layout algorithm.
Methods:
-
embed–Validates the input, runs the embedding algorithm, and validates the output.
Attributes:
-
algorithm(Callable) –Returns the callable to the embedding algorithm.
-
config(ConfigType) –Returns the config for the embedding algorithm.
-
info(str) –Prints info about the embedding algorithm.
Source code in qoolqit/embedding/graph_embedder.py
algorithm: Callable
property
Returns the callable to the embedding algorithm.
config: ConfigType
property
Returns the config for the embedding algorithm.
info: str
property
Prints info about the embedding algorithm.
embed(data: InDataType) -> OutDataType
Validates the input, runs the embedding algorithm, and validates the output.
Parameters:
-
(dataInDataType) –the data to embed.
Source code in qoolqit/embedding/base_embedder.py
matrix_embedder
Classes:
-
Blade–A matrix to graph embedder using the BLaDE algorithm.
-
InteractionEmbedder–A matrix to graph embedder using the interaction embedding algorithm.
-
MatrixToGraphEmbedder–A family of embedders that map a matrix to a graph.
Blade(config: BladeConfig = BladeConfig())
A matrix to graph embedder using the BLaDE algorithm.
Parameters:
-
(configBladeConfig, default:BladeConfig()) –configuration object for the BLaDE algorithm.
Methods:
-
embed–Return a DataGraph with coordinates that embeds the input matrix.
Attributes:
-
algorithm(Callable) –Returns the callable to the embedding algorithm.
-
config(ConfigType) –Returns the config for the embedding algorithm.
-
info(str) –Prints info about the embedding algorithm.
Source code in qoolqit/embedding/matrix_embedder.py
algorithm: Callable
property
Returns the callable to the embedding algorithm.
config: ConfigType
property
Returns the config for the embedding algorithm.
info: str
property
Prints info about the embedding algorithm.
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:
-
(datandarray) –the matrix to embed into a DataGraph with coordinates.
Source code in qoolqit/embedding/matrix_embedder.py
InteractionEmbedder()
A matrix to graph embedder using the interaction embedding algorithm.
Methods:
-
embed–Validates the input, runs the embedding algorithm, and validates the output.
Attributes:
-
algorithm(Callable) –Returns the callable to the embedding algorithm.
-
config(ConfigType) –Returns the config for the embedding algorithm.
-
info(str) –Prints info about the embedding algorithm.
Source code in qoolqit/embedding/matrix_embedder.py
algorithm: Callable
property
Returns the callable to the embedding algorithm.
config: ConfigType
property
Returns the config for the embedding algorithm.
info: str
property
Prints info about the embedding algorithm.
embed(data: InDataType) -> OutDataType
Validates the input, runs the embedding algorithm, and validates the output.
Parameters:
-
(dataInDataType) –the data to embed.
Source code in qoolqit/embedding/base_embedder.py
MatrixToGraphEmbedder(algorithm: Callable, config: ConfigType)
A family of embedders that map a matrix to a graph.
A custom algorithm and configuration can be set at initialization.
An algorithm should be a standalone function that takes a piece of data of an InDataType and maps it to an OutDataType. Any extra configuration parameters taken as input by the algorithm function should be defined in the config dataclass, inheriting from EmbedderConfig.
Parameters:
-
(algorithmCallable) –a callable to the algorithm function.
-
(configConfigType) –a config dataclass holding parameter values for the algorithm.
Methods:
-
embed–Validates the input, runs the embedding algorithm, and validates the output.
Attributes:
-
algorithm(Callable) –Returns the callable to the embedding algorithm.
-
config(ConfigType) –Returns the config for the embedding algorithm.
-
info(str) –Prints info about the embedding algorithm.
Source code in qoolqit/embedding/base_embedder.py
algorithm: Callable
property
Returns the callable to the embedding algorithm.
config: ConfigType
property
Returns the config for the embedding algorithm.
info: str
property
Prints info about the embedding algorithm.
embed(data: InDataType) -> OutDataType
Validates the input, runs the embedding algorithm, and validates the output.
Parameters:
-
(dataInDataType) –the data to embed.
Source code in qoolqit/embedding/base_embedder.py
exceptions
Classes:
-
CompilationError–An error raised when attempting to compile a program into a Pulser Sequence.
CompilationError
An error raised when attempting to compile a program into a Pulser Sequence.
execution
QoolQit module to execute quantum programs on QPUs or local/remote emulators.
Modules:
Classes:
-
LocalEmulator–Run QoolQit
QuantumPrograms on a Pasqal local emulator backends. -
QPU–Execute QoolQit QuantumPrograms on Pasqal quantum processing units.
-
RemoteEmulator–Run QoolQit
QuantumPrograms on a Pasqal remote emulator backends. -
SequenceCompiler–Compiles a QoolQit Register and Drive to a Device.
LocalEmulator(*, backend_type: type[EmulatorBackend] = QutipBackendV2, emulation_config: EmulationConfig | None = None, num_shots: int | None = None)
Run QoolQit QuantumPrograms on a Pasqal local emulator backends.
This class serves as a primary interface between tools written using QoolQit (including solvers) and local emulator backends.
Parameters:
-
(backend_typetype, default:QutipBackendV2) –backend type. Must be a subtype of
pulser.backend.EmulatorBackend. -
(emulation_configEmulationConfig, default:None) –optional configuration object emulators.
-
(num_shotsint, default:None) –number of bitstring samples to collect from the final quantum state.
Examples:
from qoolqit.execution import LocalEmulator, BackendType
backend = LocalEmulator(backend_type=BackendType.QutipBackendV2)
result = backend.run(program)
Methods:
-
default_emulation_config–Return a unique emulation config for all emulators.
-
run–Run a compiled QuantumProgram and return the results.
-
validate_emulation_config–Returns a valid config for emulator backends, if needed.
Source code in qoolqit/execution/backends.py
default_emulation_config() -> EmulationConfig
Return a unique emulation config for all emulators.
Defaults to a configuration that asks for the final bitstring, sampled num_shots times.
Source code in qoolqit/execution/backends.py
run(program: QuantumProgram) -> Sequence[Results]
Run a compiled QuantumProgram and return the results.
Source code in qoolqit/execution/backends.py
validate_emulation_config(emulation_config: EmulationConfig | None) -> EmulationConfig
Returns a valid config for emulator backends, if needed.
Parameters:
-
(emulation_configEmulationConfig | None) –optional base configuration class for all emulators backends. If no config is provided to an emulator backend, the backend default will used.
Source code in qoolqit/execution/backends.py
QPU(*, connection: RemoteConnection, num_shots: int | None = None)
Execute QoolQit QuantumPrograms on Pasqal quantum processing units.
This class provides the primary interface for running quantum programs on actual QPU hardware. It requires authenticated credentials through a connection object to submit and execute programs on remote quantum processors.
Parameters:
-
(connectionRemoteConnection) –Authenticated connection to the remote QPU backend.
-
(num_shotsint | None, default:None) –Number of bitstring samples to collect from the final quantum state.
Examples:
Using Pasqal Cloud:
from pulser_pasqal import PasqalCloud
from qoolqit.execution import QPU
connection = PasqalCloud(
username="your_username",
password="your_password",
project_id="your_project_id"
)
backend = QPU(connection=connection)
remote_results = backend.submit(program)
Using Atos MyQML:
from pulser_myqlm import PulserQLMConnection
from qoolqit.execution import QPU
connection = PulserQLMConnection()
backend = QPU(connection=connection)
results = backend.run(program)
Note
Contact your quantum computing provider for credentials and connection setup: - Pasqal Cloud Documentation - Atos MyQML Framework
Methods:
-
run–Execute a compiled quantum program on the QPU and return the results.
-
submit–Submit a compiled quantum program to the QPU and return a result handler.
-
validate_connection–Validate the required connection to instantiate a RemoteBackend.
Source code in qoolqit/execution/backends.py
run(program: QuantumProgram) -> Sequence[Results]
Execute a compiled quantum program on the QPU and return the results.
This method submits the program and waits for completion before returning the final results.
Parameters:
-
(programQuantumProgram) –The compiled quantum program to execute on the QPU.
Returns:
-
Sequence[Results]–The execution results from the QPU.
Source code in qoolqit/execution/backends.py
submit(program: QuantumProgram, wait: bool = False) -> RemoteResults
Submit a compiled quantum program to the QPU and return a result handler.
Parameters:
-
(programQuantumProgram) –The compiled quantum program to execute on the QPU.
-
(waitbool, default:False) –Whether to wait for the QPU to complete execution before returning.
Returns:
-
RemoteResults–A remote result handler for monitoring job status and retrieving results.
Note
The returned RemoteResults object provides:
- Job status monitoring via get_batch_status()
- Result retrieval via the results property (when job is complete)
Source code in qoolqit/execution/backends.py
validate_connection(connection: RemoteConnection) -> RemoteConnection
staticmethod
Validate the required connection to instantiate a RemoteBackend.
Remote emulators and QPUs require a pulser.backend.remote.RemoteConnection or derived
to send jobs. Validation also happens inside the backend. Early validation just makes the
error easier to understand.
Source code in qoolqit/execution/backends.py
RemoteEmulator(*, backend_type: type[RemoteEmulatorBackend] = EmuFreeBackendV2, connection: RemoteConnection, emulation_config: EmulationConfig | None = None, num_shots: int | None = None)
Run QoolQit QuantumPrograms on a Pasqal remote emulator backends.
This class serves as a primary interface between tools written using QoolQit (including solvers)
and remote emulator backends.
The behavior is similar to LocalEmulator, but here, requires credentials through
a connection to submit/run a program.
To get your credentials and to create a connection object, please refer to the Pasqal Cloud
interface documentation.
Parameters:
-
(backend_typetype, default:EmuFreeBackendV2) –backend type. Must be a subtype of
pulser_pasqal.backends.RemoteEmulatorBackend. -
(connectionRemoteConnection) –connection to execute the program on remote backends.
-
(emulation_configEmulationConfig, default:None) –optional configuration object emulators.
-
(num_shotsint, default:None) –number of bitstring samples to collect from the final quantum state.
Examples:
from pulser_pasqal import PasqalCloud
from qoolqit.execution import RemoteEmulator, BackendType
connection = PasqalCloud(username=..., password=..., project_id=...)
backend = RemoteEmulator(backend_type=BackendType.EmuFreeBackendV2, connection=connection)
Methods:
-
default_emulation_config–Return a unique emulation config for all emulators.
-
run–Run a compiled QuantumProgram remotely and return the results.
-
submit–Submit a compiled QuantumProgram and return a remote handler of the results.
-
validate_connection–Validate the required connection to instantiate a RemoteBackend.
-
validate_emulation_config–Returns a valid config for emulator backends, if needed.
Source code in qoolqit/execution/backends.py
default_emulation_config() -> EmulationConfig
Return a unique emulation config for all emulators.
Defaults to a configuration that asks for the final bitstring, sampled num_shots times.
Source code in qoolqit/execution/backends.py
run(program: QuantumProgram) -> Sequence[Results]
Run a compiled QuantumProgram remotely and return the results.
Source code in qoolqit/execution/backends.py
submit(program: QuantumProgram, wait: bool = False) -> RemoteResults
Submit a compiled QuantumProgram and return a remote handler of the results.
The returned handler RemoteResults can be used to:
- query the job status with remote_results.get_batch_status()
- when DONE, retrieve results with remote_results.results
Parameters:
-
(programQuantumProgram) –the compiled quantum program to run.
-
(waitbool, default:False) –Wait for remote backend to complete the job.
Source code in qoolqit/execution/backends.py
validate_connection(connection: RemoteConnection) -> RemoteConnection
staticmethod
Validate the required connection to instantiate a RemoteBackend.
Remote emulators and QPUs require a pulser.backend.remote.RemoteConnection or derived
to send jobs. Validation also happens inside the backend. Early validation just makes the
error easier to understand.
Source code in qoolqit/execution/backends.py
validate_emulation_config(emulation_config: EmulationConfig | None) -> EmulationConfig
Returns a valid config for emulator backends, if needed.
Parameters:
-
(emulation_configEmulationConfig | None) –optional base configuration class for all emulators backends. If no config is provided to an emulator backend, the backend default will used.
Source code in qoolqit/execution/backends.py
SequenceCompiler(register: Register, drive: Drive, device: Device, profile: CompilerProfile, device_max_duration_ratio: float | None = None)
Compiles a QoolQit Register and Drive to a Device.
Parameters:
-
(registerRegister) –the QoolQit Register.
-
(driveDrive) –the QoolQit Drive.
-
(deviceDevice) –the QoolQit Device.
-
(profileCompilerProfile) –the CompilerProfile to use.
-
(device_max_duration_ratiofloat | None, default:None) –optionally set the program duration to a fraction of the device's maximum allowed duration.
Source code in qoolqit/execution/sequence_compiler.py
backends
Classes:
-
LocalEmulator–Run QoolQit
QuantumPrograms on a Pasqal local emulator backends. -
PulserEmulatorBackend–Base Emulator class.
-
PulserRemoteBackend– -
QPU–Execute QoolQit QuantumPrograms on Pasqal quantum processing units.
-
RemoteEmulator–Run QoolQit
QuantumPrograms on a Pasqal remote emulator backends.
LocalEmulator(*, backend_type: type[EmulatorBackend] = QutipBackendV2, emulation_config: EmulationConfig | None = None, num_shots: int | None = None)
Run QoolQit QuantumPrograms on a Pasqal local emulator backends.
This class serves as a primary interface between tools written using QoolQit (including solvers) and local emulator backends.
Parameters:
-
(backend_typetype, default:QutipBackendV2) –backend type. Must be a subtype of
pulser.backend.EmulatorBackend. -
(emulation_configEmulationConfig, default:None) –optional configuration object emulators.
-
(num_shotsint, default:None) –number of bitstring samples to collect from the final quantum state.
Examples:
from qoolqit.execution import LocalEmulator, BackendType
backend = LocalEmulator(backend_type=BackendType.QutipBackendV2)
result = backend.run(program)
Methods:
-
default_emulation_config–Return a unique emulation config for all emulators.
-
run–Run a compiled QuantumProgram and return the results.
-
validate_emulation_config–Returns a valid config for emulator backends, if needed.
Source code in qoolqit/execution/backends.py
default_emulation_config() -> EmulationConfig
Return a unique emulation config for all emulators.
Defaults to a configuration that asks for the final bitstring, sampled num_shots times.
Source code in qoolqit/execution/backends.py
run(program: QuantumProgram) -> Sequence[Results]
Run a compiled QuantumProgram and return the results.
Source code in qoolqit/execution/backends.py
validate_emulation_config(emulation_config: EmulationConfig | None) -> EmulationConfig
Returns a valid config for emulator backends, if needed.
Parameters:
-
(emulation_configEmulationConfig | None) –optional base configuration class for all emulators backends. If no config is provided to an emulator backend, the backend default will used.
Source code in qoolqit/execution/backends.py
PulserEmulatorBackend(num_shots: int | None = None)
Base Emulator class.
Parameters:
-
(num_shotsint | None, default:None) –run the program
num_shotstimes to collect bitstrings statistics. On QPU this represents the actual number of runs of the program. On emulators, the bitstring are sampled from the quantum statenum_shotstimes.
Methods:
-
default_emulation_config–Return a unique emulation config for all emulators.
-
validate_emulation_config–Returns a valid config for emulator backends, if needed.
Source code in qoolqit/execution/backends.py
default_emulation_config() -> EmulationConfig
Return a unique emulation config for all emulators.
Defaults to a configuration that asks for the final bitstring, sampled num_shots times.
Source code in qoolqit/execution/backends.py
validate_emulation_config(emulation_config: EmulationConfig | None) -> EmulationConfig
Returns a valid config for emulator backends, if needed.
Parameters:
-
(emulation_configEmulationConfig | None) –optional base configuration class for all emulators backends. If no config is provided to an emulator backend, the backend default will used.
Source code in qoolqit/execution/backends.py
PulserRemoteBackend
Methods:
-
validate_connection–Validate the required connection to instantiate a RemoteBackend.
validate_connection(connection: RemoteConnection) -> RemoteConnection
staticmethod
Validate the required connection to instantiate a RemoteBackend.
Remote emulators and QPUs require a pulser.backend.remote.RemoteConnection or derived
to send jobs. Validation also happens inside the backend. Early validation just makes the
error easier to understand.
Source code in qoolqit/execution/backends.py
QPU(*, connection: RemoteConnection, num_shots: int | None = None)
Execute QoolQit QuantumPrograms on Pasqal quantum processing units.
This class provides the primary interface for running quantum programs on actual QPU hardware. It requires authenticated credentials through a connection object to submit and execute programs on remote quantum processors.
Parameters:
-
(connectionRemoteConnection) –Authenticated connection to the remote QPU backend.
-
(num_shotsint | None, default:None) –Number of bitstring samples to collect from the final quantum state.
Examples:
Using Pasqal Cloud:
from pulser_pasqal import PasqalCloud
from qoolqit.execution import QPU
connection = PasqalCloud(
username="your_username",
password="your_password",
project_id="your_project_id"
)
backend = QPU(connection=connection)
remote_results = backend.submit(program)
Using Atos MyQML:
from pulser_myqlm import PulserQLMConnection
from qoolqit.execution import QPU
connection = PulserQLMConnection()
backend = QPU(connection=connection)
results = backend.run(program)
Note
Contact your quantum computing provider for credentials and connection setup: - Pasqal Cloud Documentation - Atos MyQML Framework
Methods:
-
run–Execute a compiled quantum program on the QPU and return the results.
-
submit–Submit a compiled quantum program to the QPU and return a result handler.
-
validate_connection–Validate the required connection to instantiate a RemoteBackend.
Source code in qoolqit/execution/backends.py
run(program: QuantumProgram) -> Sequence[Results]
Execute a compiled quantum program on the QPU and return the results.
This method submits the program and waits for completion before returning the final results.
Parameters:
-
(programQuantumProgram) –The compiled quantum program to execute on the QPU.
Returns:
-
Sequence[Results]–The execution results from the QPU.
Source code in qoolqit/execution/backends.py
submit(program: QuantumProgram, wait: bool = False) -> RemoteResults
Submit a compiled quantum program to the QPU and return a result handler.
Parameters:
-
(programQuantumProgram) –The compiled quantum program to execute on the QPU.
-
(waitbool, default:False) –Whether to wait for the QPU to complete execution before returning.
Returns:
-
RemoteResults–A remote result handler for monitoring job status and retrieving results.
Note
The returned RemoteResults object provides:
- Job status monitoring via get_batch_status()
- Result retrieval via the results property (when job is complete)
Source code in qoolqit/execution/backends.py
validate_connection(connection: RemoteConnection) -> RemoteConnection
staticmethod
Validate the required connection to instantiate a RemoteBackend.
Remote emulators and QPUs require a pulser.backend.remote.RemoteConnection or derived
to send jobs. Validation also happens inside the backend. Early validation just makes the
error easier to understand.
Source code in qoolqit/execution/backends.py
RemoteEmulator(*, backend_type: type[RemoteEmulatorBackend] = EmuFreeBackendV2, connection: RemoteConnection, emulation_config: EmulationConfig | None = None, num_shots: int | None = None)
Run QoolQit QuantumPrograms on a Pasqal remote emulator backends.
This class serves as a primary interface between tools written using QoolQit (including solvers)
and remote emulator backends.
The behavior is similar to LocalEmulator, but here, requires credentials through
a connection to submit/run a program.
To get your credentials and to create a connection object, please refer to the Pasqal Cloud
interface documentation.
Parameters:
-
(backend_typetype, default:EmuFreeBackendV2) –backend type. Must be a subtype of
pulser_pasqal.backends.RemoteEmulatorBackend. -
(connectionRemoteConnection) –connection to execute the program on remote backends.
-
(emulation_configEmulationConfig, default:None) –optional configuration object emulators.
-
(num_shotsint, default:None) –number of bitstring samples to collect from the final quantum state.
Examples:
from pulser_pasqal import PasqalCloud
from qoolqit.execution import RemoteEmulator, BackendType
connection = PasqalCloud(username=..., password=..., project_id=...)
backend = RemoteEmulator(backend_type=BackendType.EmuFreeBackendV2, connection=connection)
Methods:
-
default_emulation_config–Return a unique emulation config for all emulators.
-
run–Run a compiled QuantumProgram remotely and return the results.
-
submit–Submit a compiled QuantumProgram and return a remote handler of the results.
-
validate_connection–Validate the required connection to instantiate a RemoteBackend.
-
validate_emulation_config–Returns a valid config for emulator backends, if needed.
Source code in qoolqit/execution/backends.py
default_emulation_config() -> EmulationConfig
Return a unique emulation config for all emulators.
Defaults to a configuration that asks for the final bitstring, sampled num_shots times.
Source code in qoolqit/execution/backends.py
run(program: QuantumProgram) -> Sequence[Results]
Run a compiled QuantumProgram remotely and return the results.
Source code in qoolqit/execution/backends.py
submit(program: QuantumProgram, wait: bool = False) -> RemoteResults
Submit a compiled QuantumProgram and return a remote handler of the results.
The returned handler RemoteResults can be used to:
- query the job status with remote_results.get_batch_status()
- when DONE, retrieve results with remote_results.results
Parameters:
-
(programQuantumProgram) –the compiled quantum program to run.
-
(waitbool, default:False) –Wait for remote backend to complete the job.
Source code in qoolqit/execution/backends.py
validate_connection(connection: RemoteConnection) -> RemoteConnection
staticmethod
Validate the required connection to instantiate a RemoteBackend.
Remote emulators and QPUs require a pulser.backend.remote.RemoteConnection or derived
to send jobs. Validation also happens inside the backend. Early validation just makes the
error easier to understand.
Source code in qoolqit/execution/backends.py
validate_emulation_config(emulation_config: EmulationConfig | None) -> EmulationConfig
Returns a valid config for emulator backends, if needed.
Parameters:
-
(emulation_configEmulationConfig | None) –optional base configuration class for all emulators backends. If no config is provided to an emulator backend, the backend default will used.
Source code in qoolqit/execution/backends.py
compilation_functions
Classes:
-
CompilerProfile–Enum for the different compilation profiles.
-
WaveformConverter–Convert a QoolQit waveform into a equivalent Pulser waveform.
Functions:
-
basic_compilation–Compiles a QoolQit program to a PulserSequence.
CompilerProfile
Enum for the different compilation profiles.
WaveformConverter(device: Device, time: float, energy: float)
Convert a QoolQit waveform into a equivalent Pulser waveform.
Requires the new time and energy scales set by the compilation. Additionally, requires the clock period of the device to round the duration.
Methods:
-
convert–Convert a QoolQit waveform into a equivalent Pulser waveform.
Source code in qoolqit/execution/compilation_functions.py
convert(waveform: Waveform) -> ParamObj | PulserWaveform
Convert a QoolQit waveform into a equivalent Pulser waveform.
Source code in qoolqit/execution/compilation_functions.py
basic_compilation(register: Register, drive: Drive, device: Device, profile: CompilerProfile = CompilerProfile.MAX_ENERGY, device_max_duration_ratio: float | None = None) -> PulserSequence
Compiles a QoolQit program to a PulserSequence.
Defines: - program_energy_ratio: the ratio between the maximum amplitude in the drive and the maximum interaction energy. - device_energy_ratio: the ratio between the device's maximum allowed amplitude in the drive and the maximum possible interaction energy.
If program_energy_ratio > device_energy_ratio the program is scaled to match the device's maximum allowed amplitude. Otherwise, the program is scaled to match the device's minimum allowed pairwise distance.
If the device requires a layout, it is automatically generated.
Parameters:
-
(registerRegister) –QoolQit Register.
-
(driveDrive) –QoolQit Drive.
-
(deviceDevice) –QoolQit Device.
-
(device_max_duration_ratiofloat | None, default:None) –optionally set the program duration to a fraction of the device's maximum allowed duration.
Returns:
-
PulserSequence(Sequence) –The compiled program as a pulser.Sequence object.
Source code in qoolqit/execution/compilation_functions.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | |
sequence_compiler
Classes:
-
SequenceCompiler–Compiles a QoolQit Register and Drive to a Device.
SequenceCompiler(register: Register, drive: Drive, device: Device, profile: CompilerProfile, device_max_duration_ratio: float | None = None)
Compiles a QoolQit Register and Drive to a Device.
Parameters:
-
(registerRegister) –the QoolQit Register.
-
(driveDrive) –the QoolQit Drive.
-
(deviceDevice) –the QoolQit Device.
-
(profileCompilerProfile) –the CompilerProfile to use.
-
(device_max_duration_ratiofloat | None, default:None) –optionally set the program duration to a fraction of the device's maximum allowed duration.
Source code in qoolqit/execution/sequence_compiler.py
graphs
Graph creation and manipulation in QoolQit.
Modules:
-
base_graph– -
data_graph– -
utils–
Classes:
-
BaseGraph–The BaseGraph in QoolQit, directly inheriting from the NetworkX Graph.
-
DataGraph–The main graph structure to represent problem data.
Functions:
-
all_node_pairs–Return all pairs of nodes (u, v) where u < v.
-
distances–Return a dictionary of edge distances.
-
random_coords–Generate a random set of node coordinates on a square of side L.
-
random_edge_list–Generates a random set of k edges linkings items from a set of nodes.
-
scale_coords–Scale the coordinates by a given value.
-
space_coords–Spaces the coordinates so the minimum distance is equal to a set spacing.
BaseGraph(edges: Iterable = [])
The BaseGraph in QoolQit, directly inheriting from the NetworkX Graph.
Defines basic functionalities for graphs within the Rydberg Analog, such as instantiating from a set of node coordinates, directly accessing node distances, and checking if the graph is unit-disk.
Parameters:
-
(edgesIterable, default:[]) –set of edge tuples (i, j)
Methods:
-
distances–Returns a dictionary of distances for a given set of edges.
-
draw–Draw the graph.
-
from_coordinates–Construct a base graph from a set of coordinates.
-
from_nodes–Construct a base graph from a set of nodes.
-
from_nx–Convert a NetworkX Graph object into a QoolQit graph instance.
-
interactions–Rydberg model interaction 1/r^6 between pair of nodes.
-
is_ud_graph–Check if the graph is unit-disk.
-
max_distance–Returns the maximum distance in the graph.
-
min_distance–Returns the minimum distance in the graph.
-
rescale_coords–Rescales the node coordinates by a factor.
-
set_ud_edges–Reset the set of edges to be equal to the set of unit-disk edges.
-
ud_edges–Returns the set of edges given by the intersection of circles of a given radius.
-
ud_radius_range–Return the range (R_min, R_max) where the graph is unit-disk.
Attributes:
-
all_node_pairs(set) –Return a list of all possible node pairs in the graph.
-
coords(dict) –Return the dictionary of node coordinates.
-
has_coords(bool) –Check if the graph has coordinates.
-
has_edge_weights(bool) –Check if the graph has edge weights.
-
has_edges(bool) –Check if the graph has edges.
-
has_node_weights(bool) –Check if the graph has node weights.
-
sorted_edges(set) –Returns the set of edges (u, v) such that (u < v).
Source code in qoolqit/graphs/base_graph.py
all_node_pairs: set
property
Return a list of all possible node pairs in the graph.
coords: dict
property
writable
Return the dictionary of node coordinates.
has_coords: bool
property
Check if the graph has coordinates.
Requires all nodes to have coordinates.
has_edge_weights: bool
property
Check if the graph has edge weights.
Requires all edges to have a weight.
has_edges: bool
property
Check if the graph has edges.
has_node_weights: bool
property
Check if the graph has node weights.
Requires all nodes to have a weight.
sorted_edges: set
property
Returns the set of edges (u, v) such that (u < v).
distances(edge_list: Iterable | None = None) -> dict
Returns a dictionary of distances for a given set of edges.
Distances are calculated directly from the coordinates. Raises an error if there are no coordinates on the graph.
Parameters:
-
(edge_listIterable | None, default:None) –set of edges.
Source code in qoolqit/graphs/base_graph.py
draw(ax: Axes | None = None, **kwargs: Any) -> None
Draw the graph.
Uses the draw_networkx function from NetworkX.
Parameters:
-
(axAxes | None, default:None) –Axes object to draw on. If None, uses the current Axes.
-
(**kwargsAny, default:{}) –keyword-arguments to pass to draw_networkx.
Source code in qoolqit/graphs/base_graph.py
from_coordinates(coords: list | dict) -> BaseGraph
classmethod
Construct a base graph from a set of coordinates.
Parameters:
-
(coordslist | dict) –list or dictionary of coordinate pairs.
Source code in qoolqit/graphs/base_graph.py
from_nodes(nodes: Iterable) -> BaseGraph
classmethod
Construct a base graph from a set of nodes.
Parameters:
-
(nodesIterable) –set of nodes.
Source code in qoolqit/graphs/base_graph.py
from_nx(g: nx.Graph) -> BaseGraph
classmethod
Convert a NetworkX Graph object into a QoolQit graph instance.
The input networkx.Graph graph must be defined only with the following allowed
Node attributes
pos (tuple): represents the node 2D position. Must be a list/tuple of real numbers. weight: represents the node weight. Must be a real number.
Edge attributes: weight: represents the edge weight. Must be a real number.
Returns an instance of the class with following attributes
- _node_weights : dict[node, float or None]
- _edge_weights : dict[(u,v), float or None]
- _coords : dict[node, (float,float) or None]
Source code in qoolqit/graphs/base_graph.py
interactions() -> dict
is_ud_graph() -> bool
max_distance(connected: bool | None = None) -> float
Returns the maximum distance in the graph.
Parameters:
-
(connectedbool | None, default:None) –if True/False, computes only over connected/disconnected nodes.
Source code in qoolqit/graphs/base_graph.py
min_distance(connected: bool | None = None) -> float
Returns the minimum distance in the graph.
Parameters:
-
(connectedbool | None, default:None) –if True/False, computes only over connected/disconnected nodes.
Source code in qoolqit/graphs/base_graph.py
rescale_coords(*args: Any, scaling: float | None = None, spacing: float | None = None) -> None
Rescales the node coordinates by a factor.
Accepts either a scaling or a spacing factor.
Parameters:
-
(scalingfloat | None, default:None) –value to scale by.
-
(spacingfloat | None, default:None) –value to set as the minimum distance in the graph.
Source code in qoolqit/graphs/base_graph.py
set_ud_edges(radius: float) -> None
Reset the set of edges to be equal to the set of unit-disk edges.
Parameters:
-
(radiusfloat) –the radius to use in determining the set of unit-disk edges.
Source code in qoolqit/graphs/base_graph.py
ud_edges(radius: float) -> set
Returns the set of edges given by the intersection of circles of a given radius.
Parameters:
-
(radiusfloat) –the value
Source code in qoolqit/graphs/base_graph.py
ud_radius_range() -> tuple
Return the range (R_min, R_max) where the graph is unit-disk.
The graph is unit-disk if the maximum distance between all connected nodes is smaller than the minimum distance between disconnected nodes. This means that for any value R in that interval, the following condition is true:
graph.ud_edges(radius = R) == graph.sorted edges
Source code in qoolqit/graphs/base_graph.py
DataGraph(edges: Iterable = [])
The main graph structure to represent problem data.
Parameters:
-
(edgesIterable, default:[]) –set of edge tuples (i, j)
Methods:
-
circle–Constructs a circle graph, with the respective coordinates.
-
distances–Returns a dictionary of distances for a given set of edges.
-
draw–Draw the graph.
-
from_coordinates–Construct a base graph from a set of coordinates.
-
from_matrix–Constructs a graph from a symmetric square matrix.
-
from_nodes–Construct a base graph from a set of nodes.
-
from_nx–Convert a NetworkX Graph object into a QoolQit graph instance.
-
from_pyg–Convert a PyTorch Geometric Data object into a DataGraph instance.
-
heavy_hexagonal–Constructs a heavy-hexagonal lattice graph, with respective coordinates.
-
hexagonal–Constructs a hexagonal lattice graph, with respective coordinates.
-
interactions–Rydberg model interaction 1/r^6 between pair of nodes.
-
is_ud_graph–Check if the graph is unit-disk.
-
line–Constructs a line graph, with the respective coordinates.
-
max_distance–Returns the maximum distance in the graph.
-
min_distance–Returns the minimum distance in the graph.
-
random_er–Constructs an Erdős–Rényi random graph.
-
random_ud–Constructs a random unit-disk graph.
-
rescale_coords–Rescales the node coordinates by a factor.
-
set_ud_edges–Reset the set of edges to be equal to the set of unit-disk edges.
-
square–Constructs a square lattice graph, with respective coordinates.
-
to_pyg–Convert the DataGraph to a PyTorch Geometric Data object.
-
triangular–Constructs a triangular lattice graph, with respective coordinates.
-
ud_edges–Returns the set of edges given by the intersection of circles of a given radius.
-
ud_radius_range–Return the range (R_min, R_max) where the graph is unit-disk.
Attributes:
-
all_node_pairs(set) –Return a list of all possible node pairs in the graph.
-
coords(dict) –Return the dictionary of node coordinates.
-
edge_weights(dict) –Return the dictionary of edge weights.
-
has_coords(bool) –Check if the graph has coordinates.
-
has_edge_weights(bool) –Check if the graph has edge weights.
-
has_edges(bool) –Check if the graph has edges.
-
has_node_weights(bool) –Check if the graph has node weights.
-
node_weights(dict) –Return the dictionary of node weights.
-
sorted_edges(set) –Returns the set of edges (u, v) such that (u < v).
Source code in qoolqit/graphs/data_graph.py
all_node_pairs: set
property
Return a list of all possible node pairs in the graph.
coords: dict
property
writable
Return the dictionary of node coordinates.
edge_weights: dict
property
writable
Return the dictionary of edge weights.
has_coords: bool
property
Check if the graph has coordinates.
Requires all nodes to have coordinates.
has_edge_weights: bool
property
Check if the graph has edge weights.
Requires all edges to have a weight.
has_edges: bool
property
Check if the graph has edges.
has_node_weights: bool
property
Check if the graph has node weights.
Requires all nodes to have a weight.
node_weights: dict
property
writable
Return the dictionary of node weights.
sorted_edges: set
property
Returns the set of edges (u, v) such that (u < v).
circle(n: int, spacing: float = 1.0, center: tuple = (0.0, 0.0)) -> DataGraph
classmethod
Constructs a circle graph, with the respective coordinates.
Parameters:
-
(nint) –number of nodes.
-
(spacingfloat, default:1.0) –distance between each node.
-
(centertuple, default:(0.0, 0.0)) –point (x, y) to set as the center of the graph.
Source code in qoolqit/graphs/data_graph.py
distances(edge_list: Iterable | None = None) -> dict
Returns a dictionary of distances for a given set of edges.
Distances are calculated directly from the coordinates. Raises an error if there are no coordinates on the graph.
Parameters:
-
(edge_listIterable | None, default:None) –set of edges.
Source code in qoolqit/graphs/base_graph.py
draw(ax: Axes | None = None, **kwargs: Any) -> None
Draw the graph.
Uses the draw_networkx function from NetworkX.
Parameters:
-
(axAxes | None, default:None) –Axes object to draw on. If None, uses the current Axes.
-
(**kwargsAny, default:{}) –keyword-arguments to pass to draw_networkx.
Source code in qoolqit/graphs/base_graph.py
from_coordinates(coords: list | dict) -> BaseGraph
classmethod
Construct a base graph from a set of coordinates.
Parameters:
-
(coordslist | dict) –list or dictionary of coordinate pairs.
Source code in qoolqit/graphs/base_graph.py
from_matrix(data: ArrayLike) -> DataGraph
classmethod
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:
-
(dataArrayLike) –symmetric square matrix.
Source code in qoolqit/graphs/data_graph.py
from_nodes(nodes: Iterable) -> BaseGraph
classmethod
Construct a base graph from a set of nodes.
Parameters:
-
(nodesIterable) –set of nodes.
Source code in qoolqit/graphs/base_graph.py
from_nx(g: nx.Graph) -> BaseGraph
classmethod
Convert a NetworkX Graph object into a QoolQit graph instance.
The input networkx.Graph graph must be defined only with the following allowed
Node attributes
pos (tuple): represents the node 2D position. Must be a list/tuple of real numbers. weight: represents the node weight. Must be a real number.
Edge attributes: weight: represents the edge weight. Must be a real number.
Returns an instance of the class with following attributes
- _node_weights : dict[node, float or None]
- _edge_weights : dict[(u,v), float or None]
- _coords : dict[node, (float,float) or None]
Source code in qoolqit/graphs/base_graph.py
from_pyg(data: torch_geometric.data.Data, node_attrs: Iterable[str] | None = None, edge_attrs: Iterable[str] | None = None, graph_attrs: Iterable[str] | None = None, node_weights_attr: str | None = None, edge_weights_attr: str | None = None) -> DataGraph
classmethod
Convert a PyTorch Geometric Data object into a DataGraph instance.
Requires torch_geometric. Uses to_networkx internally.
Default attributes copied (if present on data ):
- Node:
x,pos(posis also stored in_coords) - Edge:
edge_attr - Graph:
y
Use node_attrs, edge_attrs, graph_attrs for extras.
QoolQit weights (_node_weights, _edge_weights) are not
populated automatically — use the explicit parameters:
node_weights_attr: real-valued tensor of shape(N,)or(N, 1). Defaults toNone.edge_weights_attr: real-valued tensor of shape(E,)or(E, 1)whereE = edge_index.shape[1](directed count). Defaults toNone.
The weight attribute is also stored as a regular node/edge attribute.
Parameters:
-
(dataData) –PyTorch Geometric Data object to convert.
-
(node_attrsIterable[str] | None, default:None) –extra node attributes to copy (beyond x and pos).
-
(edge_attrsIterable[str] | None, default:None) –extra edge attributes to copy (beyond edge_attr).
-
(graph_attrsIterable[str] | None, default:None) –extra graph-level attributes to copy (beyond y).
-
(node_weights_attrstr | None, default:None) –Data attribute to use as node weights.
-
(edge_weights_attrstr | None, default:None) –Data attribute to use as edge weights.
Returns:
-
DataGraph–DataGraph with
_coords,_node_weights,_edge_weights -
DataGraph–populated where applicable.
Raises:
-
ImportError–if
torch_geometricis not installed. -
TypeError–if
datais not atorch_geometric.data.Datainstance, or if a weight attribute is not atorch.Tensor. -
AttributeError–if a specified weight attribute is missing.
-
ValueError–if a weight tensor has an incompatible shape or size.
Source code in qoolqit/graphs/data_graph.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | |
heavy_hexagonal(m: int, n: int, spacing: float = 1.0) -> DataGraph
classmethod
Constructs a heavy-hexagonal lattice graph, with respective coordinates.
Parameters:
-
(mint) –Number of rows of hexagons.
-
(nint) –Number of columns of hexagons.
-
(spacingfloat, default:1.0) –The distance between adjacent nodes on the final lattice.
Notes
The heavy-hexagonal lattice is a regular hexagonal lattice where each edge is decorated with an additional lattice site.
Source code in qoolqit/graphs/data_graph.py
hexagonal(m: int, n: int, spacing: float = 1.0) -> DataGraph
classmethod
Constructs a hexagonal lattice graph, with respective coordinates.
Parameters:
-
(mint) –Number of rows of hexagons.
-
(nint) –Number of columns of hexagons.
-
(spacingfloat, default:1.0) –The distance between adjacent nodes on the final lattice.
Source code in qoolqit/graphs/data_graph.py
interactions() -> dict
is_ud_graph() -> bool
line(n: int, spacing: float = 1.0) -> DataGraph
classmethod
Constructs a line graph, with the respective coordinates.
Parameters:
-
(nint) –number of nodes.
-
(spacingfloat, default:1.0) –distance between each node.
Source code in qoolqit/graphs/data_graph.py
max_distance(connected: bool | None = None) -> float
Returns the maximum distance in the graph.
Parameters:
-
(connectedbool | None, default:None) –if True/False, computes only over connected/disconnected nodes.
Source code in qoolqit/graphs/base_graph.py
min_distance(connected: bool | None = None) -> float
Returns the minimum distance in the graph.
Parameters:
-
(connectedbool | None, default:None) –if True/False, computes only over connected/disconnected nodes.
Source code in qoolqit/graphs/base_graph.py
random_er(n: int, p: float, seed: int | None = None) -> DataGraph
classmethod
Constructs an Erdős–Rényi random graph.
Parameters:
-
(nint) –number of nodes.
-
(pfloat) –probability that any two nodes connect.
-
(seedint | None, default:None) –random seed.
Source code in qoolqit/graphs/data_graph.py
random_ud(n: int, radius: float = 1.0, L: float | None = None) -> DataGraph
classmethod
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:
-
(nint) –number of nodes.
-
(radiusfloat, default:1.0) –radius to use for defining the unit-disk edges.
-
(Lfloat | None, default:None) –size of the square on which to sample the node coordinates.
Source code in qoolqit/graphs/data_graph.py
rescale_coords(*args: Any, scaling: float | None = None, spacing: float | None = None) -> None
Rescales the node coordinates by a factor.
Accepts either a scaling or a spacing factor.
Parameters:
-
(scalingfloat | None, default:None) –value to scale by.
-
(spacingfloat | None, default:None) –value to set as the minimum distance in the graph.
Source code in qoolqit/graphs/base_graph.py
set_ud_edges(radius: float) -> None
Reset the set of edges to be equal to the set of unit-disk edges.
square(m: int, n: int, spacing: float = 1.0) -> DataGraph
classmethod
Constructs a square lattice graph, with respective coordinates.
Parameters:
-
(mint) –Number of rows of square.
-
(nint) –Number of columns of square.
-
(spacingfloat, default:1.0) –The distance between adjacent nodes on the final lattice.
Source code in qoolqit/graphs/data_graph.py
to_pyg(node_attrs: Iterable[str] | None = None, edge_attrs: Iterable[str] | None = None, graph_attrs: Iterable[str] | None = None, node_weights_attr: str = 'weight', edge_weights_attr: str = 'edge_weight') -> torch_geometric.data.Data
Convert the DataGraph to a PyTorch Geometric Data object.
Requires torch_geometric. Uses from_networkx internally.
Default attributes exported (if present on the graph):
- Node
"x"→data.x; Edge"edge_attr"→data.edge_attr - Graph
"y"→data.y
Use node_attrs, edge_attrs, graph_attrs for extras.
QoolQit internal dicts exported when populated:
_coords→data.pos(float64, shape(N, 2))_node_weights→data.<node_weights_attr>(float64, shape(N,)). Defaults to"weight"._edge_weights→data.<edge_weights_attr>(float64, shape(2*E,)). Defaults to"edge_weight".
Parameters:
-
(node_attrsIterable[str] | None, default:None) –extra node attributes to export (beyond x).
-
(edge_attrsIterable[str] | None, default:None) –extra edge attributes to export (beyond edge_attr).
-
(graph_attrsIterable[str] | None, default:None) –extra graph-level attributes to export (beyond y).
-
(node_weights_attrstr, default:'weight') –Data attribute name for node weights. Defaults to
"weight". -
(edge_weights_attrstr, default:'edge_weight') –Data attribute name for edge weights. Defaults to
"edge_weight".
Returns:
-
Data–PyTorch Geometric Data object.
Raises:
-
ImportError–if
torch_geometricis not installed.
Source code in qoolqit/graphs/data_graph.py
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 | |
triangular(m: int, n: int, spacing: float = 1.0) -> DataGraph
classmethod
Constructs a triangular lattice graph, with respective coordinates.
Parameters:
-
(mint) –Number of rows of triangles.
-
(nint) –Number of columns of triangles.
-
(spacingfloat, default:1.0) –The distance between adjacent nodes on the final lattice.
Source code in qoolqit/graphs/data_graph.py
ud_edges(radius: float) -> set
Returns the set of edges given by the intersection of circles of a given radius.
Parameters:
-
(radiusfloat) –the value
Source code in qoolqit/graphs/base_graph.py
ud_radius_range() -> tuple
Return the range (R_min, R_max) where the graph is unit-disk.
The graph is unit-disk if the maximum distance between all connected nodes is smaller than the minimum distance between disconnected nodes. This means that for any value R in that interval, the following condition is true:
graph.ud_edges(radius = R) == graph.sorted edges
Source code in qoolqit/graphs/base_graph.py
all_node_pairs(nodes: Iterable) -> set
Return all pairs of nodes (u, v) where u < v.
Parameters:
-
(nodesIterable) –set of node indices.
distances(coords: dict, edge_list: Iterable) -> dict
Return a dictionary of edge distances.
Parameters:
-
(coordsdict) –dictionary of node coordinates.
-
(edge_listIterable) –edge list to compute the distances for.
Source code in qoolqit/graphs/utils.py
random_coords(n: int, L: float = 1.0) -> list
Generate a random set of node coordinates on a square of side L.
Parameters:
-
(nint) –number of coordinate pairs to generate.
-
(Lfloat, default:1.0) –side of the square.
Source code in qoolqit/graphs/utils.py
random_edge_list(nodes: Iterable, k: int) -> list
Generates a random set of k edges linkings items from a set of nodes.
scale_coords(coords: dict, scaling: float) -> dict
Scale the coordinates by a given value.
Parameters:
-
(coordsdict) –dictionary of node coordinates.
-
(scalingfloat) –value to scale by.
Source code in qoolqit/graphs/utils.py
space_coords(coords: dict, spacing: float) -> dict
Spaces the coordinates so the minimum distance is equal to a set spacing.
Parameters:
-
(coordsdict) –dictionary of node coordinates.
-
(spacingfloat) –value to set as minimum distance.
Source code in qoolqit/graphs/utils.py
base_graph
Classes:
-
BaseGraph–The BaseGraph in QoolQit, directly inheriting from the NetworkX Graph.
BaseGraph(edges: Iterable = [])
The BaseGraph in QoolQit, directly inheriting from the NetworkX Graph.
Defines basic functionalities for graphs within the Rydberg Analog, such as instantiating from a set of node coordinates, directly accessing node distances, and checking if the graph is unit-disk.
Parameters:
-
(edgesIterable, default:[]) –set of edge tuples (i, j)
Methods:
-
distances–Returns a dictionary of distances for a given set of edges.
-
draw–Draw the graph.
-
from_coordinates–Construct a base graph from a set of coordinates.
-
from_nodes–Construct a base graph from a set of nodes.
-
from_nx–Convert a NetworkX Graph object into a QoolQit graph instance.
-
interactions–Rydberg model interaction 1/r^6 between pair of nodes.
-
is_ud_graph–Check if the graph is unit-disk.
-
max_distance–Returns the maximum distance in the graph.
-
min_distance–Returns the minimum distance in the graph.
-
rescale_coords–Rescales the node coordinates by a factor.
-
set_ud_edges–Reset the set of edges to be equal to the set of unit-disk edges.
-
ud_edges–Returns the set of edges given by the intersection of circles of a given radius.
-
ud_radius_range–Return the range (R_min, R_max) where the graph is unit-disk.
Attributes:
-
all_node_pairs(set) –Return a list of all possible node pairs in the graph.
-
coords(dict) –Return the dictionary of node coordinates.
-
has_coords(bool) –Check if the graph has coordinates.
-
has_edge_weights(bool) –Check if the graph has edge weights.
-
has_edges(bool) –Check if the graph has edges.
-
has_node_weights(bool) –Check if the graph has node weights.
-
sorted_edges(set) –Returns the set of edges (u, v) such that (u < v).
Source code in qoolqit/graphs/base_graph.py
all_node_pairs: set
property
Return a list of all possible node pairs in the graph.
coords: dict
property
writable
Return the dictionary of node coordinates.
has_coords: bool
property
Check if the graph has coordinates.
Requires all nodes to have coordinates.
has_edge_weights: bool
property
Check if the graph has edge weights.
Requires all edges to have a weight.
has_edges: bool
property
Check if the graph has edges.
has_node_weights: bool
property
Check if the graph has node weights.
Requires all nodes to have a weight.
sorted_edges: set
property
Returns the set of edges (u, v) such that (u < v).
distances(edge_list: Iterable | None = None) -> dict
Returns a dictionary of distances for a given set of edges.
Distances are calculated directly from the coordinates. Raises an error if there are no coordinates on the graph.
Parameters:
-
(edge_listIterable | None, default:None) –set of edges.
Source code in qoolqit/graphs/base_graph.py
draw(ax: Axes | None = None, **kwargs: Any) -> None
Draw the graph.
Uses the draw_networkx function from NetworkX.
Parameters:
-
(axAxes | None, default:None) –Axes object to draw on. If None, uses the current Axes.
-
(**kwargsAny, default:{}) –keyword-arguments to pass to draw_networkx.
Source code in qoolqit/graphs/base_graph.py
from_coordinates(coords: list | dict) -> BaseGraph
classmethod
Construct a base graph from a set of coordinates.
Parameters:
-
(coordslist | dict) –list or dictionary of coordinate pairs.
Source code in qoolqit/graphs/base_graph.py
from_nodes(nodes: Iterable) -> BaseGraph
classmethod
Construct a base graph from a set of nodes.
Parameters:
-
(nodesIterable) –set of nodes.
Source code in qoolqit/graphs/base_graph.py
from_nx(g: nx.Graph) -> BaseGraph
classmethod
Convert a NetworkX Graph object into a QoolQit graph instance.
The input networkx.Graph graph must be defined only with the following allowed
Node attributes
pos (tuple): represents the node 2D position. Must be a list/tuple of real numbers. weight: represents the node weight. Must be a real number.
Edge attributes: weight: represents the edge weight. Must be a real number.
Returns an instance of the class with following attributes
- _node_weights : dict[node, float or None]
- _edge_weights : dict[(u,v), float or None]
- _coords : dict[node, (float,float) or None]
Source code in qoolqit/graphs/base_graph.py
interactions() -> dict
is_ud_graph() -> bool
max_distance(connected: bool | None = None) -> float
Returns the maximum distance in the graph.
Parameters:
-
(connectedbool | None, default:None) –if True/False, computes only over connected/disconnected nodes.
Source code in qoolqit/graphs/base_graph.py
min_distance(connected: bool | None = None) -> float
Returns the minimum distance in the graph.
Parameters:
-
(connectedbool | None, default:None) –if True/False, computes only over connected/disconnected nodes.
Source code in qoolqit/graphs/base_graph.py
rescale_coords(*args: Any, scaling: float | None = None, spacing: float | None = None) -> None
Rescales the node coordinates by a factor.
Accepts either a scaling or a spacing factor.
Parameters:
-
(scalingfloat | None, default:None) –value to scale by.
-
(spacingfloat | None, default:None) –value to set as the minimum distance in the graph.
Source code in qoolqit/graphs/base_graph.py
set_ud_edges(radius: float) -> None
Reset the set of edges to be equal to the set of unit-disk edges.
Parameters:
-
(radiusfloat) –the radius to use in determining the set of unit-disk edges.
Source code in qoolqit/graphs/base_graph.py
ud_edges(radius: float) -> set
Returns the set of edges given by the intersection of circles of a given radius.
Parameters:
-
(radiusfloat) –the value
Source code in qoolqit/graphs/base_graph.py
ud_radius_range() -> tuple
Return the range (R_min, R_max) where the graph is unit-disk.
The graph is unit-disk if the maximum distance between all connected nodes is smaller than the minimum distance between disconnected nodes. This means that for any value R in that interval, the following condition is true:
graph.ud_edges(radius = R) == graph.sorted edges
Source code in qoolqit/graphs/base_graph.py
data_graph
Classes:
-
DataGraph–The main graph structure to represent problem data.
DataGraph(edges: Iterable = [])
The main graph structure to represent problem data.
Parameters:
-
(edgesIterable, default:[]) –set of edge tuples (i, j)
Methods:
-
circle–Constructs a circle graph, with the respective coordinates.
-
distances–Returns a dictionary of distances for a given set of edges.
-
draw–Draw the graph.
-
from_coordinates–Construct a base graph from a set of coordinates.
-
from_matrix–Constructs a graph from a symmetric square matrix.
-
from_nodes–Construct a base graph from a set of nodes.
-
from_nx–Convert a NetworkX Graph object into a QoolQit graph instance.
-
from_pyg–Convert a PyTorch Geometric Data object into a DataGraph instance.
-
heavy_hexagonal–Constructs a heavy-hexagonal lattice graph, with respective coordinates.
-
hexagonal–Constructs a hexagonal lattice graph, with respective coordinates.
-
interactions–Rydberg model interaction 1/r^6 between pair of nodes.
-
is_ud_graph–Check if the graph is unit-disk.
-
line–Constructs a line graph, with the respective coordinates.
-
max_distance–Returns the maximum distance in the graph.
-
min_distance–Returns the minimum distance in the graph.
-
random_er–Constructs an Erdős–Rényi random graph.
-
random_ud–Constructs a random unit-disk graph.
-
rescale_coords–Rescales the node coordinates by a factor.
-
set_ud_edges–Reset the set of edges to be equal to the set of unit-disk edges.
-
square–Constructs a square lattice graph, with respective coordinates.
-
to_pyg–Convert the DataGraph to a PyTorch Geometric Data object.
-
triangular–Constructs a triangular lattice graph, with respective coordinates.
-
ud_edges–Returns the set of edges given by the intersection of circles of a given radius.
-
ud_radius_range–Return the range (R_min, R_max) where the graph is unit-disk.
Attributes:
-
all_node_pairs(set) –Return a list of all possible node pairs in the graph.
-
coords(dict) –Return the dictionary of node coordinates.
-
edge_weights(dict) –Return the dictionary of edge weights.
-
has_coords(bool) –Check if the graph has coordinates.
-
has_edge_weights(bool) –Check if the graph has edge weights.
-
has_edges(bool) –Check if the graph has edges.
-
has_node_weights(bool) –Check if the graph has node weights.
-
node_weights(dict) –Return the dictionary of node weights.
-
sorted_edges(set) –Returns the set of edges (u, v) such that (u < v).
Source code in qoolqit/graphs/data_graph.py
all_node_pairs: set
property
Return a list of all possible node pairs in the graph.
coords: dict
property
writable
Return the dictionary of node coordinates.
edge_weights: dict
property
writable
Return the dictionary of edge weights.
has_coords: bool
property
Check if the graph has coordinates.
Requires all nodes to have coordinates.
has_edge_weights: bool
property
Check if the graph has edge weights.
Requires all edges to have a weight.
has_edges: bool
property
Check if the graph has edges.
has_node_weights: bool
property
Check if the graph has node weights.
Requires all nodes to have a weight.
node_weights: dict
property
writable
Return the dictionary of node weights.
sorted_edges: set
property
Returns the set of edges (u, v) such that (u < v).
circle(n: int, spacing: float = 1.0, center: tuple = (0.0, 0.0)) -> DataGraph
classmethod
Constructs a circle graph, with the respective coordinates.
Parameters:
-
(nint) –number of nodes.
-
(spacingfloat, default:1.0) –distance between each node.
-
(centertuple, default:(0.0, 0.0)) –point (x, y) to set as the center of the graph.
Source code in qoolqit/graphs/data_graph.py
distances(edge_list: Iterable | None = None) -> dict
Returns a dictionary of distances for a given set of edges.
Distances are calculated directly from the coordinates. Raises an error if there are no coordinates on the graph.
Parameters:
-
(edge_listIterable | None, default:None) –set of edges.
Source code in qoolqit/graphs/base_graph.py
draw(ax: Axes | None = None, **kwargs: Any) -> None
Draw the graph.
Uses the draw_networkx function from NetworkX.
Parameters:
-
(axAxes | None, default:None) –Axes object to draw on. If None, uses the current Axes.
-
(**kwargsAny, default:{}) –keyword-arguments to pass to draw_networkx.
Source code in qoolqit/graphs/base_graph.py
from_coordinates(coords: list | dict) -> BaseGraph
classmethod
Construct a base graph from a set of coordinates.
Parameters:
-
(coordslist | dict) –list or dictionary of coordinate pairs.
Source code in qoolqit/graphs/base_graph.py
from_matrix(data: ArrayLike) -> DataGraph
classmethod
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:
-
(dataArrayLike) –symmetric square matrix.
Source code in qoolqit/graphs/data_graph.py
from_nodes(nodes: Iterable) -> BaseGraph
classmethod
Construct a base graph from a set of nodes.
Parameters:
-
(nodesIterable) –set of nodes.
Source code in qoolqit/graphs/base_graph.py
from_nx(g: nx.Graph) -> BaseGraph
classmethod
Convert a NetworkX Graph object into a QoolQit graph instance.
The input networkx.Graph graph must be defined only with the following allowed
Node attributes
pos (tuple): represents the node 2D position. Must be a list/tuple of real numbers. weight: represents the node weight. Must be a real number.
Edge attributes: weight: represents the edge weight. Must be a real number.
Returns an instance of the class with following attributes
- _node_weights : dict[node, float or None]
- _edge_weights : dict[(u,v), float or None]
- _coords : dict[node, (float,float) or None]
Source code in qoolqit/graphs/base_graph.py
from_pyg(data: torch_geometric.data.Data, node_attrs: Iterable[str] | None = None, edge_attrs: Iterable[str] | None = None, graph_attrs: Iterable[str] | None = None, node_weights_attr: str | None = None, edge_weights_attr: str | None = None) -> DataGraph
classmethod
Convert a PyTorch Geometric Data object into a DataGraph instance.
Requires torch_geometric. Uses to_networkx internally.
Default attributes copied (if present on data ):
- Node:
x,pos(posis also stored in_coords) - Edge:
edge_attr - Graph:
y
Use node_attrs, edge_attrs, graph_attrs for extras.
QoolQit weights (_node_weights, _edge_weights) are not
populated automatically — use the explicit parameters:
node_weights_attr: real-valued tensor of shape(N,)or(N, 1). Defaults toNone.edge_weights_attr: real-valued tensor of shape(E,)or(E, 1)whereE = edge_index.shape[1](directed count). Defaults toNone.
The weight attribute is also stored as a regular node/edge attribute.
Parameters:
-
(dataData) –PyTorch Geometric Data object to convert.
-
(node_attrsIterable[str] | None, default:None) –extra node attributes to copy (beyond x and pos).
-
(edge_attrsIterable[str] | None, default:None) –extra edge attributes to copy (beyond edge_attr).
-
(graph_attrsIterable[str] | None, default:None) –extra graph-level attributes to copy (beyond y).
-
(node_weights_attrstr | None, default:None) –Data attribute to use as node weights.
-
(edge_weights_attrstr | None, default:None) –Data attribute to use as edge weights.
Returns:
-
DataGraph–DataGraph with
_coords,_node_weights,_edge_weights -
DataGraph–populated where applicable.
Raises:
-
ImportError–if
torch_geometricis not installed. -
TypeError–if
datais not atorch_geometric.data.Datainstance, or if a weight attribute is not atorch.Tensor. -
AttributeError–if a specified weight attribute is missing.
-
ValueError–if a weight tensor has an incompatible shape or size.
Source code in qoolqit/graphs/data_graph.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 | |
heavy_hexagonal(m: int, n: int, spacing: float = 1.0) -> DataGraph
classmethod
Constructs a heavy-hexagonal lattice graph, with respective coordinates.
Parameters:
-
(mint) –Number of rows of hexagons.
-
(nint) –Number of columns of hexagons.
-
(spacingfloat, default:1.0) –The distance between adjacent nodes on the final lattice.
Notes
The heavy-hexagonal lattice is a regular hexagonal lattice where each edge is decorated with an additional lattice site.
Source code in qoolqit/graphs/data_graph.py
hexagonal(m: int, n: int, spacing: float = 1.0) -> DataGraph
classmethod
Constructs a hexagonal lattice graph, with respective coordinates.
Parameters:
-
(mint) –Number of rows of hexagons.
-
(nint) –Number of columns of hexagons.
-
(spacingfloat, default:1.0) –The distance between adjacent nodes on the final lattice.
Source code in qoolqit/graphs/data_graph.py
interactions() -> dict
is_ud_graph() -> bool
line(n: int, spacing: float = 1.0) -> DataGraph
classmethod
Constructs a line graph, with the respective coordinates.
Parameters:
-
(nint) –number of nodes.
-
(spacingfloat, default:1.0) –distance between each node.
Source code in qoolqit/graphs/data_graph.py
max_distance(connected: bool | None = None) -> float
Returns the maximum distance in the graph.
Parameters:
-
(connectedbool | None, default:None) –if True/False, computes only over connected/disconnected nodes.
Source code in qoolqit/graphs/base_graph.py
min_distance(connected: bool | None = None) -> float
Returns the minimum distance in the graph.
Parameters:
-
(connectedbool | None, default:None) –if True/False, computes only over connected/disconnected nodes.
Source code in qoolqit/graphs/base_graph.py
random_er(n: int, p: float, seed: int | None = None) -> DataGraph
classmethod
Constructs an Erdős–Rényi random graph.
Parameters:
-
(nint) –number of nodes.
-
(pfloat) –probability that any two nodes connect.
-
(seedint | None, default:None) –random seed.
Source code in qoolqit/graphs/data_graph.py
random_ud(n: int, radius: float = 1.0, L: float | None = None) -> DataGraph
classmethod
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:
-
(nint) –number of nodes.
-
(radiusfloat, default:1.0) –radius to use for defining the unit-disk edges.
-
(Lfloat | None, default:None) –size of the square on which to sample the node coordinates.
Source code in qoolqit/graphs/data_graph.py
rescale_coords(*args: Any, scaling: float | None = None, spacing: float | None = None) -> None
Rescales the node coordinates by a factor.
Accepts either a scaling or a spacing factor.
Parameters:
-
(scalingfloat | None, default:None) –value to scale by.
-
(spacingfloat | None, default:None) –value to set as the minimum distance in the graph.
Source code in qoolqit/graphs/base_graph.py
set_ud_edges(radius: float) -> None
Reset the set of edges to be equal to the set of unit-disk edges.
square(m: int, n: int, spacing: float = 1.0) -> DataGraph
classmethod
Constructs a square lattice graph, with respective coordinates.
Parameters:
-
(mint) –Number of rows of square.
-
(nint) –Number of columns of square.
-
(spacingfloat, default:1.0) –The distance between adjacent nodes on the final lattice.
Source code in qoolqit/graphs/data_graph.py
to_pyg(node_attrs: Iterable[str] | None = None, edge_attrs: Iterable[str] | None = None, graph_attrs: Iterable[str] | None = None, node_weights_attr: str = 'weight', edge_weights_attr: str = 'edge_weight') -> torch_geometric.data.Data
Convert the DataGraph to a PyTorch Geometric Data object.
Requires torch_geometric. Uses from_networkx internally.
Default attributes exported (if present on the graph):
- Node
"x"→data.x; Edge"edge_attr"→data.edge_attr - Graph
"y"→data.y
Use node_attrs, edge_attrs, graph_attrs for extras.
QoolQit internal dicts exported when populated:
_coords→data.pos(float64, shape(N, 2))_node_weights→data.<node_weights_attr>(float64, shape(N,)). Defaults to"weight"._edge_weights→data.<edge_weights_attr>(float64, shape(2*E,)). Defaults to"edge_weight".
Parameters:
-
(node_attrsIterable[str] | None, default:None) –extra node attributes to export (beyond x).
-
(edge_attrsIterable[str] | None, default:None) –extra edge attributes to export (beyond edge_attr).
-
(graph_attrsIterable[str] | None, default:None) –extra graph-level attributes to export (beyond y).
-
(node_weights_attrstr, default:'weight') –Data attribute name for node weights. Defaults to
"weight". -
(edge_weights_attrstr, default:'edge_weight') –Data attribute name for edge weights. Defaults to
"edge_weight".
Returns:
-
Data–PyTorch Geometric Data object.
Raises:
-
ImportError–if
torch_geometricis not installed.
Source code in qoolqit/graphs/data_graph.py
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 | |
triangular(m: int, n: int, spacing: float = 1.0) -> DataGraph
classmethod
Constructs a triangular lattice graph, with respective coordinates.
Parameters:
-
(mint) –Number of rows of triangles.
-
(nint) –Number of columns of triangles.
-
(spacingfloat, default:1.0) –The distance between adjacent nodes on the final lattice.
Source code in qoolqit/graphs/data_graph.py
ud_edges(radius: float) -> set
Returns the set of edges given by the intersection of circles of a given radius.
Parameters:
-
(radiusfloat) –the value
Source code in qoolqit/graphs/base_graph.py
ud_radius_range() -> tuple
Return the range (R_min, R_max) where the graph is unit-disk.
The graph is unit-disk if the maximum distance between all connected nodes is smaller than the minimum distance between disconnected nodes. This means that for any value R in that interval, the following condition is true:
graph.ud_edges(radius = R) == graph.sorted edges
Source code in qoolqit/graphs/base_graph.py
utils
Functions:
-
all_node_pairs–Return all pairs of nodes (u, v) where u < v.
-
distances–Return a dictionary of edge distances.
-
less_or_equal–Less or approximately equal.
-
radial_distances–Return a dictionary of node distances from the origin.
-
random_coords–Generate a random set of node coordinates on a square of side L.
-
random_edge_list–Generates a random set of k edges linkings items from a set of nodes.
-
scale_coords–Scale the coordinates by a given value.
-
space_coords–Spaces the coordinates so the minimum distance is equal to a set spacing.
all_node_pairs(nodes: Iterable) -> set
Return all pairs of nodes (u, v) where u < v.
Parameters:
-
(nodesIterable) –set of node indices.
distances(coords: dict, edge_list: Iterable) -> dict
Return a dictionary of edge distances.
Parameters:
-
(coordsdict) –dictionary of node coordinates.
-
(edge_listIterable) –edge list to compute the distances for.
Source code in qoolqit/graphs/utils.py
less_or_equal(a: float, b: float, rel_tol: float = 0.0, abs_tol: float = ATOL_32) -> bool
radial_distances(coords: dict) -> dict
Return a dictionary of node distances from the origin.
Parameters:
-
(coordsdict) –dictionary of node coordinates.
random_coords(n: int, L: float = 1.0) -> list
Generate a random set of node coordinates on a square of side L.
Parameters:
-
(nint) –number of coordinate pairs to generate.
-
(Lfloat, default:1.0) –side of the square.
Source code in qoolqit/graphs/utils.py
random_edge_list(nodes: Iterable, k: int) -> list
Generates a random set of k edges linkings items from a set of nodes.
scale_coords(coords: dict, scaling: float) -> dict
Scale the coordinates by a given value.
Parameters:
-
(coordsdict) –dictionary of node coordinates.
-
(scalingfloat) –value to scale by.
Source code in qoolqit/graphs/utils.py
space_coords(coords: dict, spacing: float) -> dict
Spaces the coordinates so the minimum distance is equal to a set spacing.
Parameters:
-
(coordsdict) –dictionary of node coordinates.
-
(spacingfloat) –value to set as minimum distance.
Source code in qoolqit/graphs/utils.py
program
Classes:
-
QuantumProgram–A program representing a Sequence acting on a Register of qubits.
QuantumProgram(register: Register, drive: Drive)
A program representing a Sequence acting on a Register of qubits.
Parameters:
-
(registerRegister) –the register of qubits, defining their positions.
-
(driveDrive) –the drive acting on qubits, defining amplitude, detuning and phase.
Methods:
-
compile_to–Compiles the quantum program for execution on a specific device.
Attributes:
-
compiled_sequence(Sequence) –The Pulser sequence compiled to a specific device.
-
drive(Drive) –The driving waveforms.
-
is_compiled(bool) –Check if the program has been compiled.
-
register(Register) –The register of qubits.
Source code in qoolqit/program.py
compiled_sequence: PulserSequence
property
The Pulser sequence compiled to a specific device.
drive: Drive
property
The driving waveforms.
is_compiled: bool
property
Check if the program has been compiled.
register: Register
property
The register of qubits.
compile_to(device: Device, profile: CompilerProfile = CompilerProfile.MAX_ENERGY, device_max_duration_ratio: float | None = None) -> None
Compiles the quantum program for execution on a specific device.
The compilation process adapts the program to the device's constraints while preserving the relative ratios of the original program parameters. Different compilation profiles optimize for specific objectives:
- CompilerProfile.MAX_ENERGY (default): Scales the program to utilize the device's maximum capabilities. The drive amplitude and the register positions are rescaled to achieve respectively the maximum amplitude and the minimum pairwise distance compatible with the input program and the device's constraints.
- CompilerProfile.WORKING_POINT: .
Further options DO NOT preserve the input program, but rather adapts the program to the device's constraint. Programs compiled this way are not guaranteed to be portable across devices.
- device_max_duration_ratio: Rescale the drive duration to a fraction of the device's maximum allowed duration. This option is useful in adiabatic protocols where one simply seek to minimize the time derivative of the drive's amplitude.
Parameters:
-
(deviceDevice) –The target device for compilation.
-
(profileCompilerProfile, default:MAX_ENERGY) –The compilation strategy to optimize the program. Defaults to CompilerProfile.MAX_ENERGY.
-
(device_max_duration_ratiofloat | None, default:None) –Whether to set the program duration to a fraction of the device's maximum allowed duration. Must be a number in the range (0, 1]. Can only be set if the device has a maximum allowed duration.
Raises:
-
CompilationError–If the compilation fails due to device constraints.
Source code in qoolqit/program.py
register
Classes:
-
Register–The Register in QoolQit, representing a set of qubits with coordinates.
Register(qubits: dict)
The Register in QoolQit, representing a set of qubits with coordinates.
Parameters:
-
(qubitsdict) –a dictionary of qubits and respective coordinates {q: (x, y), ...}.
Methods:
-
distances–Distance between each qubit pair.
-
draw–Draw the register.
-
from_coordinates–Initializes a Register from a list of coordinates.
-
from_graph–Initializes a Register from a graph that has coordinates.
-
interactions–Interaction 1/r^6 between each qubit pair.
-
max_radial_distance–Maximum radial distance between all qubits.
-
min_distance–Minimum distance between all qubit pairs.
-
radial_distances–Radial distance of each qubit from the origin.
Attributes:
-
n_qubits(int) –Number of qubits in the Register.
-
qubits(dict) –Returns the dictionary of qubits and respective coordinates.
-
qubits_ids(list) –Returns the qubit keys.
Source code in qoolqit/register.py
n_qubits: int
property
Number of qubits in the Register.
qubits: dict
property
Returns the dictionary of qubits and respective coordinates.
qubits_ids: list
property
Returns the qubit keys.
distances() -> dict
draw(return_fig: bool = False) -> Figure | None
Draw the register.
Parameters:
-
(return_figbool, default:False) –boolean argument to return the matplotlib figure.
Source code in qoolqit/register.py
from_coordinates(coords: list) -> Register
classmethod
Initializes a Register from a list of coordinates.
Parameters:
-
(coordslist) –a list of coordinates [(x, y), ...]
Source code in qoolqit/register.py
from_graph(graph: DataGraph) -> Register
classmethod
Initializes a Register from a graph that has coordinates.
Parameters:
-
(graphDataGraph) –a DataGraph instance.
Source code in qoolqit/register.py
interactions() -> dict
max_radial_distance() -> float
min_distance() -> float
waveforms
Modules:
-
base_waveforms– -
utils– -
waveforms–
Classes:
-
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.
Blackman(duration: float, area: float)
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
See: https://en.wikipedia.org/wiki/Window_function#:~:text=Blackman%20window
Parameters:
-
(durationfloat) –The waveform duration.
-
(areafloat) –The integral of the waveform.
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
Source code in qoolqit/waveforms/waveforms.py
duration: float
property
Returns the duration of the waveform.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
Constant(duration: float, value: float)
A constant waveform over a given duration.
Parameters:
-
(durationfloat) –the total duration.
-
(valuefloat) –the value to take during the duration.
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
Source code in qoolqit/waveforms/waveforms.py
duration: float
property
Returns the duration of the waveform.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
Delay(duration: float, *args: float, **kwargs: float | np.ndarray)
An empty waveform.
Parameters:
-
(durationfloat) –the total duration of the waveform.
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
Source code in qoolqit/waveforms/base_waveforms.py
duration: float
property
Returns the duration of the waveform.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
Interpolated(duration: float, values: ArrayLike, times: Optional[ArrayLike] = None, interpolator: str = 'PchipInterpolator', **interpolator_kwargs: Any)
A waveform created from interpolation of a set of data points.
Parameters:
-
(durationint) –The waveform duration (in ns).
-
(valuesArrayLike) –Values of the interpolation points. Must be a list of castable to float or a parametrized object.
-
(timesArrayLike, default:None) –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.
-
(interpolatorstr, default:'PchipInterpolator') –The SciPy interpolation class to use. Supports "PchipInterpolator" and "interp1d".
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
Source code in qoolqit/waveforms/waveforms.py
duration: float
property
Returns the duration of the waveform.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
PiecewiseLinear(durations: list | tuple, values: list | tuple)
A piecewise linear waveform.
Creates a composite waveform of N ramps that linearly interpolate through the given N+1 values.
Parameters:
-
(durationslist | tuple) –list or tuple of N duration values.
-
(valueslist | tuple) –list or tuple of N+1 waveform values.
Methods:
-
function–Identifies the right waveform in the composition and evaluates it at time t.
-
max–Get the maximum value of the waveform.
-
min–Get the approximate minimum value of the waveform.
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
durations(list[float]) –Returns the list of durations of each individual waveform.
-
n_waveforms(int) –Returns the number of waveforms.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
-
times(list[float]) –Returns the list of times when each individual waveform starts.
-
waveforms(list[Waveform]) –Returns a list of the individual waveforms.
Source code in qoolqit/waveforms/waveforms.py
duration: float
property
Returns the duration of the waveform.
durations: list[float]
property
Returns the list of durations of each individual waveform.
n_waveforms: int
property
Returns the number of waveforms.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
times: list[float]
property
Returns the list of times when each individual waveform starts.
waveforms: list[Waveform]
property
Returns a list of the individual waveforms.
function(t: float) -> float
Identifies the right waveform in the composition and evaluates it at time t.
Source code in qoolqit/waveforms/base_waveforms.py
max() -> float
min() -> float
Get the approximate minimum value of the waveform.
This is a brute-force method that samples the waveform over a pre-defined number of points to find the minimum value in the duration. Custom waveforms that have an easy to compute maximum value should override this method.
Source code in qoolqit/waveforms/base_waveforms.py
Ramp(duration: float, initial_value: float, final_value: float)
A ramp that linearly interpolates between an initial and final value.
Parameters:
-
(durationfloat) –the total duration.
-
(initial_valuefloat) –the initial value at t = 0.
-
(final_valuefloat) –the final value at t = duration.
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
Source code in qoolqit/waveforms/waveforms.py
duration: float
property
Returns the duration of the waveform.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
Sin(duration: float, amplitude: float = 1.0, omega: float = 1.0, phi: float = 0.0, shift: float = 0.0)
An arbitrary sine over a given duration.
Parameters:
-
(durationfloat) –the total duration.
-
(amplitudefloat, default:1.0) –the amplitude of the sine wave.
-
(omegafloat, default:1.0) –the frequency of the sine wave.
-
(phifloat, default:0.0) –the phase of the sine wave.
-
(shiftfloat, default:0.0) –the vertical shift of the sine wave.
Methods:
-
max–Get the approximate maximum value of the waveform.
-
min–Get the approximate minimum value of the waveform.
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
Source code in qoolqit/waveforms/waveforms.py
duration: float
property
Returns the duration of the waveform.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
max() -> float
Get the approximate maximum value of the waveform.
This is a brute-force method that samples the waveform over a pre-defined number of points to find the maximum value in the duration. Custom waveforms that have an easy to compute maximum value should override this method.
Source code in qoolqit/waveforms/base_waveforms.py
min() -> float
Get the approximate minimum value of the waveform.
This is a brute-force method that samples the waveform over a pre-defined number of points to find the minimum value in the duration. Custom waveforms that have an easy to compute maximum value should override this method.
Source code in qoolqit/waveforms/base_waveforms.py
base_waveforms
Classes:
-
CompositeWaveform–Base class for composite waveforms.
-
Waveform–Base class for waveforms.
CompositeWaveform(*waveforms: Waveform)
Base class for composite waveforms.
A CompositeWaveform stores a sequence of waveforms occurring one after the other by the order given. When it is evaluated at time t, the corresponding waveform from the sequence is identified depending on the duration of each one, and it is then evaluated for a time t' = t minus the duration of all previous waveforms.
Parameters:
-
(waveformsWaveform, default:()) –an iterator over waveforms.
Methods:
-
function–Identifies the right waveform in the composition and evaluates it at time t.
-
max–Get the maximum value of the waveform.
-
min–Get the approximate minimum value of the waveform.
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
durations(list[float]) –Returns the list of durations of each individual waveform.
-
n_waveforms(int) –Returns the number of waveforms.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
-
times(list[float]) –Returns the list of times when each individual waveform starts.
-
waveforms(list[Waveform]) –Returns a list of the individual waveforms.
Source code in qoolqit/waveforms/base_waveforms.py
duration: float
property
Returns the duration of the waveform.
durations: list[float]
property
Returns the list of durations of each individual waveform.
n_waveforms: int
property
Returns the number of waveforms.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
times: list[float]
property
Returns the list of times when each individual waveform starts.
waveforms: list[Waveform]
property
Returns a list of the individual waveforms.
function(t: float) -> float
Identifies the right waveform in the composition and evaluates it at time t.
Source code in qoolqit/waveforms/base_waveforms.py
max() -> float
min() -> float
Get the approximate minimum value of the waveform.
This is a brute-force method that samples the waveform over a pre-defined number of points to find the minimum value in the duration. Custom waveforms that have an easy to compute maximum value should override this method.
Source code in qoolqit/waveforms/base_waveforms.py
Waveform(duration: float, *args: float, **kwargs: float | np.ndarray)
Base class for waveforms.
A Waveform is a function of time for t >= 0. Custom waveforms can be defined by
inheriting from the base class and overriding the function method corresponding
to the function f(t) that returns the value of the waveform evaluated at time t.
A waveform is always a 1D function, so if it includes other parameters, these should be
passed and saved at initialization for usage within the function method.
Parameters:
-
(durationfloat) –the total duration of the waveform.
Methods:
-
function–Evaluates the waveform function at a given time t.
-
max–Get the approximate maximum value of the waveform.
-
min–Get the approximate minimum value of the waveform.
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
Source code in qoolqit/waveforms/base_waveforms.py
duration: float
property
Returns the duration of the waveform.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
function(t: float) -> float
abstractmethod
max() -> float
Get the approximate maximum value of the waveform.
This is a brute-force method that samples the waveform over a pre-defined number of points to find the maximum value in the duration. Custom waveforms that have an easy to compute maximum value should override this method.
Source code in qoolqit/waveforms/base_waveforms.py
min() -> float
Get the approximate minimum value of the waveform.
This is a brute-force method that samples the waveform over a pre-defined number of points to find the minimum value in the duration. Custom waveforms that have an easy to compute maximum value should override this method.
Source code in qoolqit/waveforms/base_waveforms.py
utils
Functions:
-
round_to_sum–Round a list of numbers such that their sum is the rounded sum.
round_to_sum(values: list[float]) -> list[int]
Round a list of numbers such that their sum is the rounded sum.
Σᵢround(aᵢ) = round(Σᵢaᵢ)
Source code in qoolqit/waveforms/utils.py
waveforms
Classes:
-
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.
Blackman(duration: float, area: float)
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
See: https://en.wikipedia.org/wiki/Window_function#:~:text=Blackman%20window
Parameters:
-
(durationfloat) –The waveform duration.
-
(areafloat) –The integral of the waveform.
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
Source code in qoolqit/waveforms/waveforms.py
duration: float
property
Returns the duration of the waveform.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
Constant(duration: float, value: float)
A constant waveform over a given duration.
Parameters:
-
(durationfloat) –the total duration.
-
(valuefloat) –the value to take during the duration.
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
Source code in qoolqit/waveforms/waveforms.py
duration: float
property
Returns the duration of the waveform.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
Delay(duration: float, *args: float, **kwargs: float | np.ndarray)
An empty waveform.
Parameters:
-
(durationfloat) –the total duration of the waveform.
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
Source code in qoolqit/waveforms/base_waveforms.py
duration: float
property
Returns the duration of the waveform.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
Interpolated(duration: float, values: ArrayLike, times: Optional[ArrayLike] = None, interpolator: str = 'PchipInterpolator', **interpolator_kwargs: Any)
A waveform created from interpolation of a set of data points.
Parameters:
-
(durationint) –The waveform duration (in ns).
-
(valuesArrayLike) –Values of the interpolation points. Must be a list of castable to float or a parametrized object.
-
(timesArrayLike, default:None) –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.
-
(interpolatorstr, default:'PchipInterpolator') –The SciPy interpolation class to use. Supports "PchipInterpolator" and "interp1d".
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
Source code in qoolqit/waveforms/waveforms.py
duration: float
property
Returns the duration of the waveform.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
PiecewiseLinear(durations: list | tuple, values: list | tuple)
A piecewise linear waveform.
Creates a composite waveform of N ramps that linearly interpolate through the given N+1 values.
Parameters:
-
(durationslist | tuple) –list or tuple of N duration values.
-
(valueslist | tuple) –list or tuple of N+1 waveform values.
Methods:
-
function–Identifies the right waveform in the composition and evaluates it at time t.
-
max–Get the maximum value of the waveform.
-
min–Get the approximate minimum value of the waveform.
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
durations(list[float]) –Returns the list of durations of each individual waveform.
-
n_waveforms(int) –Returns the number of waveforms.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
-
times(list[float]) –Returns the list of times when each individual waveform starts.
-
waveforms(list[Waveform]) –Returns a list of the individual waveforms.
Source code in qoolqit/waveforms/waveforms.py
duration: float
property
Returns the duration of the waveform.
durations: list[float]
property
Returns the list of durations of each individual waveform.
n_waveforms: int
property
Returns the number of waveforms.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
times: list[float]
property
Returns the list of times when each individual waveform starts.
waveforms: list[Waveform]
property
Returns a list of the individual waveforms.
function(t: float) -> float
Identifies the right waveform in the composition and evaluates it at time t.
Source code in qoolqit/waveforms/base_waveforms.py
max() -> float
min() -> float
Get the approximate minimum value of the waveform.
This is a brute-force method that samples the waveform over a pre-defined number of points to find the minimum value in the duration. Custom waveforms that have an easy to compute maximum value should override this method.
Source code in qoolqit/waveforms/base_waveforms.py
Ramp(duration: float, initial_value: float, final_value: float)
A ramp that linearly interpolates between an initial and final value.
Parameters:
-
(durationfloat) –the total duration.
-
(initial_valuefloat) –the initial value at t = 0.
-
(final_valuefloat) –the final value at t = duration.
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
Source code in qoolqit/waveforms/waveforms.py
duration: float
property
Returns the duration of the waveform.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
Sin(duration: float, amplitude: float = 1.0, omega: float = 1.0, phi: float = 0.0, shift: float = 0.0)
An arbitrary sine over a given duration.
Parameters:
-
(durationfloat) –the total duration.
-
(amplitudefloat, default:1.0) –the amplitude of the sine wave.
-
(omegafloat, default:1.0) –the frequency of the sine wave.
-
(phifloat, default:0.0) –the phase of the sine wave.
-
(shiftfloat, default:0.0) –the vertical shift of the sine wave.
Methods:
-
max–Get the approximate maximum value of the waveform.
-
min–Get the approximate minimum value of the waveform.
Attributes:
-
duration(float) –Returns the duration of the waveform.
-
params(dict[str, float | ndarray]) –Dictionary of parameters used by the waveform.
Source code in qoolqit/waveforms/waveforms.py
duration: float
property
Returns the duration of the waveform.
params: dict[str, float | np.ndarray]
property
Dictionary of parameters used by the waveform.
max() -> float
Get the approximate maximum value of the waveform.
This is a brute-force method that samples the waveform over a pre-defined number of points to find the maximum value in the duration. Custom waveforms that have an easy to compute maximum value should override this method.
Source code in qoolqit/waveforms/base_waveforms.py
min() -> float
Get the approximate minimum value of the waveform.
This is a brute-force method that samples the waveform over a pre-defined number of points to find the minimum value in the duration. Custom waveforms that have an easy to compute maximum value should override this method.