-
DataGraph — The main graph structure to represent problem data.
-
Drive — The drive Hamiltonian acting over a duration.
-
MockDevice — An ideal device without constraints.
-
AnalogDevice — A realistic device with constraints mimicking a real QPU.
-
TestAnalogDevice — A realistic device with constraints mimicking a real QPU.
-
Ramp — A ramp that linearly interpolates between an initial and final value.
-
Constant — A constant waveform over a given duration.
-
PiecewiseLinear — A piecewise linear waveform.
-
Delay — An empty waveform.
-
Sin — An arbitrary sine over a given duration.
-
Register — The Register in QoolQit, representing a set of qubits with coordinates.
-
QuantumProgram — A program representing a Sequence acting on a Register of qubits.
-
SequenceCompiler — Compiles a QoolQit Register and Drive to a Device.
-
QutipBackend — Qutip backend.
-
SpringLayoutEmbedder — A graph to graph embedder using the spring layout algorithm.
-
InteractionEmbedder — A matrix to graph embedder using the interaction embedding algorithm.
qoolqit
Classes
class
DataGraph
(edges: Iterable = [])
Bases : BaseGraph
The main graph structure to represent problem data.
Default constructor for the BaseGraph.
Parameters
-
edges : Iterable — set of edge tuples (i, j)
Attributes
-
adj — Graph adjacency object holding the neighbors of each node.
-
name — String identifier of the graph.
-
nodes — A NodeView of the Graph as G.nodes or G.nodes().
-
edges — An EdgeView of the Graph as G.edges or G.edges().
-
degree — A DegreeView for the Graph as G.degree or G.degree().
-
sorted_edges : set — Returns the set of edges (u, v) such that (u < v).
-
all_node_pairs : set — Return a list of all possible node pairs in the graph.
-
has_coords : bool — Check if the graph has coordinates.
-
has_edges : bool — Check if the graph has edges.
-
coords : dict — Return the dictionary of node coordinates.
-
node_weights : dict — Return the dictionary of node weights.
-
edge_weights : dict — Return the dictionary of edge weights.
-
has_node_weights : bool — Check if the graph has node weights.
-
has_edge_weights : bool — Check if the graph has edge weights.
Methods
-
line — Constructs a line graph, with the respective coordinates.
-
circle — Constructs a circle graph, with the respective coordinates.
-
random_er — Constructs an Erdős–Rényi random graph.
-
triangular — Constructs a triangular lattice graph, with respective coordinates.
-
hexagonal — Constructs a hexagonal lattice graph, with respective coordinates.
-
heavy_hexagonal — Constructs a heavy-hexagonal lattice graph, with respective coordinates.
-
random_ud — Constructs a random unit-disk graph.
-
from_matrix — Constructs a graph from a symmetric square matrix.
-
from_pyg — Create a graph from a pyg data object.
-
set_ud_edges — Reset the set of edges to be equal to the set of unit-disk edges.
classmethod
line
(n: int, spacing: float = 1.0) → DataGraph
Constructs a line graph, with the respective coordinates.
Parameters
-
n : int — number of nodes.
-
spacing : float — distance between each node.
classmethod
circle
(n: int, spacing: float = 1.0, center: tuple = (0.0, 0.0)) → DataGraph
Constructs a circle graph, with the respective coordinates.
Parameters
-
n : int — number of nodes.
-
spacing : float — distance between each node.
-
center : tuple — point (x, y) to set as the center of the graph.
classmethod
random_er
(n: int, p: float, seed: int | None = None) → DataGraph
Constructs an Erdős–Rényi random graph.
Parameters
-
n : int — number of nodes.
-
p : float — probability that any two nodes connect.
-
seed : int | None — random seed.
classmethod
triangular
(m: int, n: int, spacing: float = 1.0) → DataGraph
Constructs a triangular lattice graph, with respective coordinates.
Parameters
-
m : int — Number of rows of triangles.
-
n : int — Number of columns of triangles.
-
spacing : float — The distance between adjacent nodes on the final lattice.
classmethod
hexagonal
(m: int, n: int, spacing: float = 1.0) → DataGraph
Constructs a hexagonal lattice graph, with respective coordinates.
Parameters
-
m : int — Number of rows of hexagons.
-
n : int — Number of columns of hexagons.
-
spacing : float — The distance between adjacent nodes on the final lattice.
classmethod
heavy_hexagonal
(m: int, n: int, spacing: float = 1.0) → DataGraph
Constructs a heavy-hexagonal lattice graph, with respective coordinates.
Parameters
-
m : int — Number of rows of hexagons.
-
n : int — Number of columns of hexagons.
-
spacing : float — The distance between adjacent nodes on the final lattice.
classmethod
random_ud
(n: int, radius: float = 1.0, L: float | None = None) → DataGraph
Constructs a random unit-disk graph.
The nodes are sampled uniformly from a square of size (L x L). If L is not given, it is estimated based on a rough heuristic that of packing N nodes on a square of side L such that the expected minimum distance is R, leading to L ~ (R / 2) * sqrt(π * n).
Parameters
-
n : int — number of nodes.
-
radius : float — radius to use for defining the unit-disk edges.
-
L : float | None — size of the square on which to sample the node coordinates.
classmethod
from_matrix
(data: ArrayLike) → DataGraph
Constructs a graph from a symmetric square matrix.
The diagonal values are set as the node weights. For each entry (i, j) where M[i, j] != 0 an edge (i, j) is added to the graph and the value M[i, j] is set as its weight.
Parameters
-
data : ArrayLike — symmetric square matrix.
Raises
-
ValueError
classmethod
from_pyg
(data) → DataGraph
Create a graph from a pyg data object.
Raises
-
NotImplementedError
property
node_weights
: dict
Return the dictionary of node weights.
property
edge_weights
: dict
Return the dictionary of edge weights.
property
has_node_weights
: bool
Check if the graph has node weights.
Requires all nodes to have a weight.
property
has_edge_weights
: bool
Check if the graph has edge weights.
Requires all edges to have a weight.
method
set_ud_edges
(radius: float) → None
Reset the set of edges to be equal to the set of unit-disk edges.
class
Drive
(*args: Any, amplitude: Waveform | None = None, detuning: Waveform | None = None, phase: float = 0.0)
The drive Hamiltonian acting over a duration.
Default constructor for the Drive.
Must be instantiated with keyword arguments. Accepts either an amplitude waveform, a detuning waveform, or both. A phase value can also be passed.
Parameters
Attributes
Methods
property
amplitude
: Waveform
The amplitude waveform in the drive.
property
detuning
: Waveform
The detuning waveform in the drive.
property
phase
: float
The phase value in the drive.
property
duration
: float
method
draw
(n_points: int = 500, return_fig: bool = False) → plt.Figure | None
class
MockDevice
()
Bases : Device
An ideal device without constraints.
class
AnalogDevice
()
Bases : Device
A realistic device with constraints mimicking a real QPU.
class
TestAnalogDevice
()
Bases : Device
A realistic device with constraints mimicking a real QPU.
enum
AvailableDevices
()
class
Ramp
(duration: float, initial_value: float, final_value: float)
Bases : Waveform
A ramp that linearly interpolates between an initial and final value.
Parameters
-
duration : float — the total duration.
-
initial_value : float — the initial value at t = 0.
-
final_value : float — the final value at t = duration.
Attributes
-
duration : float — Returns the duration of the waveform.
-
params : dict[str, float] — Dictonary of parameters used by the waveform.
Methods
method
function
(t: float) → float
method
max
() → float
method
min
() → float
class
Constant
(duration: float, value: float)
Bases : Waveform
A constant waveform over a given duration.
Parameters
-
duration : float — the total duration.
-
value : float — the value to take during the duration.
Attributes
-
duration : float — Returns the duration of the waveform.
-
params : dict[str, float] — Dictonary of parameters used by the waveform.
Methods
method
function
(t: float) → float
method
max
() → float
method
min
() → float
class
PiecewiseLinear
(durations: list | tuple, values: list | tuple)
Bases : CompositeWaveform
A piecewise linear waveform.
Creates a composite waveform of N ramps that linearly interpolate through the given N+1 values.
Parameters
-
durations : list | tuple — list or tuple of N duration values.
-
values : list | tuple — list or tuple of N+1 waveform values.
Attributes
-
duration : float — Returns the duration of the waveform.
-
params : dict[str, float] — Dictonary of parameters used by the waveform.
-
durations : list[float] — Returns the list of durations of each individual waveform.
-
times : list[float] — Returns the list of times when each individual waveform starts.
-
waveforms : list[Waveform] — Returns a list of the individual waveforms.
-
n_waveforms : int — Returns the number of waveforms.
class
Delay
(duration: float, *args: float, **kwargs: float)
Bases : Waveform
An empty waveform.
Initializes the Waveform.
Parameters
-
duration : float — the total duration of the waveform.
Attributes
-
duration : float — Returns the duration of the waveform.
-
params : dict[str, float] — Dictonary of parameters used by the waveform.
Methods
method
function
(t: float) → float
method
max
() → float
method
min
() → float
class
Sin
(duration: float, amplitude: float = 1.0, omega: float = 1.0, phi: float = 0.0, shift: float = 0.0)
Bases : Waveform
An arbitrary sine over a given duration.
Parameters
-
duration : float — the total duration.
-
amplitude : float — the amplitude of the sine wave.
-
omega : float — the frequency of the sine wave.
-
phi : float — the phase of the sine wave.
-
shift : float — the vertical shift of the sine wave.
Attributes
-
duration : float — Returns the duration of the waveform.
-
params : dict[str, float] — Dictonary of parameters used by the waveform.
Methods
method
function
(t: float) → float
class
Register
(qubits: dict)
The Register in QoolQit, representing a set of qubits with coordinates.
Default constructor for the Register.
Parameters
-
qubits : dict — a dictionary of qubits and respective coordinates {q: (x, y), ...}.
Attributes
-
qubits : dict — Returns the dictionary of qubits and respective coordinates.
-
n_qubits : int — Number of qubits in the Register.
Methods
-
from_graph — Initializes a Register from a graph that has coordinates.
-
from_coordinates — Initializes a Register from a list of coordinates.
-
distances — Distance between each qubit pair.
-
min_distance — Minimum distance between all qubit pairs.
-
interactions — Interaction 1/r^6 between each qubit pair.
-
draw — Draw the register.
classmethod
from_graph
(graph: DataGraph) → Register
Initializes a Register from a graph that has coordinates.
Parameters
-
graph : DataGraph — a DataGraph instance.
Raises
-
ValueError
classmethod
from_coordinates
(coords: list) → Register
Initializes a Register from a list of coordinates.
Parameters
-
coords : list — a list of coordinates [(x, y), ...]
Raises
-
TypeError
property
qubits
: dict
Returns the dictionary of qubits and respective coordinates.
property
n_qubits
: int
Number of qubits in the Register.
method
distances
() → dict
Distance between each qubit pair.
method
min_distance
() → float
Minimum distance between all qubit pairs.
method
interactions
() → dict
Interaction 1/r^6 between each qubit pair.
method
draw
(return_fig: bool = False) → plt.Figure | None
Draw the register.
Parameters
-
return_fig : bool — boolean argument to return the plt.Figure instance.
class
QuantumProgram
(register: Register, drive: Drive)
A program representing a Sequence acting on a Register of qubits.
Parameters
-
register : Register — the Register of qubits.
-
sequence — the Sequence of waveforms.
Attributes
Methods
-
compile_to — Compiles the given program to a device.
-
run — Run the compiled sequence on selected backend.
property
register
: Register
The register of qubits.
property
drive
: Drive
The driving waveforms.
property
is_compiled
: bool
Check if the program has been compiled.
property
compiled_sequence
: PulserSequence
The Pulser sequence compiled to a specific device.
method
compile_to
(device: Device, profile: CompilerProfile = CompilerProfile.DEFAULT) → None
Compiles the given program to a device.
Parameters
-
device : Device — the Device to compile to.
-
profile : CompilerProfile — the compiler profile to use during compilation.
method
draw
(n_points: int = 500, compiled: bool = False, return_fig: bool = False) → plt.Figure | None
Raises
-
ValueError
method
run
(backend_name: BackendName = BackendName.QUTIP, result_type: ResultType = ResultType.STATEVECTOR, runs: int = 100, evaluation_times: list[float] = [1.0], **backend_params: Any) → OutputType
Run the compiled sequence on selected backend.
Raises
-
ValueError
-
NotImplementedError
class
SequenceCompiler
(register: Register, drive: Drive, device: Device)
Compiles a QoolQit Register and Drive to a Device.
Initializes the compiler.
Parameters
Attributes
-
profile : CompilerProfile — The compiler profile to use.
Methods
property
register
: Register
property
drive
: Drive
property
device
: Device
property
profile
: CompilerProfile
The compiler profile to use.
method
compile_sequence
() → PulserSequence
Raises
-
ValueError
enum
CompilerProfile
()
enum
ResultType
()
enum
BackendName
()
class
QutipBackend
(seq: PulserSequence, result_type: ResultType = ResultType.STATEVECTOR, **backend_params: Any)
method
run
(runs: int = 100, evaluation_times: list[float] = [1.0]) → OutputType
class
SpringLayoutEmbedder
()
Bases : GraphToGraphEmbedder[SpringLayoutConfig]
A graph to graph embedder using the spring layout algorithm.
Attributes
-
config : ConfigType — Returns the config for the embedding algorithm.
-
algorithm : Callable — Returns the callable to the embedding algorithm.
-
info : str — Prints info about the embedding algorithm.
class
InteractionEmbedder
()
Bases : MatrixToGraphEmbedder[InteractionEmbeddingConfig]
A matrix to graph embedder using the interaction embedding algorithm.
Attributes
-
config : ConfigType — Returns the config for the embedding algorithm.
-
algorithm : Callable — Returns the callable to the embedding algorithm.
-
info : str — Prints info about the embedding algorithm.