qoolqit
Classes
-
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.
source 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.
source classmethod DataGraph.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.
source classmethod DataGraph.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.
source classmethod DataGraph.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.
source classmethod DataGraph.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.
source classmethod DataGraph.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.
source classmethod DataGraph.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.
Notes
The heavy-hexagonal lattice is a regular hexagonal lattice where each edge is decorated with an additional lattice site.
source classmethod DataGraph.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.
source classmethod DataGraph.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
source classmethod DataGraph.from_pyg(data) → DataGraph
Create a graph from a pyg data object.
Raises
-
NotImplementedError
source property DataGraph.node_weights: dict
Return the dictionary of node weights.
source property DataGraph.edge_weights: dict
Return the dictionary of edge weights.
source property DataGraph.has_node_weights: bool
Check if the graph has node weights.
Requires all nodes to have a weight.
source property DataGraph.has_edge_weights: bool
Check if the graph has edge weights.
Requires all edges to have a weight.
source method DataGraph.set_ud_edges(radius: float) → None
Reset the set of edges to be equal to the set of unit-disk edges.
source 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
source property Drive.amplitude: Waveform
The amplitude waveform in the drive.
source property Drive.detuning: Waveform
The detuning waveform in the drive.
source property Drive.phase: float
The phase value in the drive.
source property Drive.duration: float
source method Drive.draw(n_points: int = 500, return_fig: bool = False) → plt.Figure | None
source class MockDevice()
Bases : Device
An ideal device without constraints.
source class AnalogDevice()
Bases : Device
A realistic device with constraints mimicking a real QPU.
source class TestAnalogDevice()
Bases : Device
A realistic device with constraints mimicking a real QPU.
source enum AvailableDevices()
source 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
source method Ramp.function(t: float) → float
source method Ramp.max() → float
source method Ramp.min() → float
source 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
source method Constant.function(t: float) → float
source method Constant.max() → float
source method Constant.min() → float
source 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.
source 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
source method Delay.function(t: float) → float
source method Delay.max() → float
source method Delay.min() → float
source 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
source method Sin.function(t: float) → float
source 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.
source classmethod Register.from_graph(graph: DataGraph) → Register
Initializes a Register from a graph that has coordinates.
Parameters
-
graph : DataGraph — a DataGraph instance.
Raises
-
ValueError
source classmethod Register.from_coordinates(coords: list) → Register
Initializes a Register from a list of coordinates.
Parameters
-
coords : list — a list of coordinates [(x, y), ...]
Raises
-
TypeError
source property Register.qubits: dict
Returns the dictionary of qubits and respective coordinates.
source property Register.n_qubits: int
Number of qubits in the Register.
source method Register.distances() → dict
Distance between each qubit pair.
source method Register.min_distance() → float
Minimum distance between all qubit pairs.
source method Register.interactions() → dict
Interaction 1/r^6 between each qubit pair.
source method Register.draw(return_fig: bool = False) → plt.Figure | None
Draw the register.
Parameters
-
return_fig : bool — boolean argument to return the plt.Figure instance.
source 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.
source property QuantumProgram.register: Register
The register of qubits.
source property QuantumProgram.drive: Drive
The driving waveforms.
source property QuantumProgram.is_compiled: bool
Check if the program has been compiled.
source property QuantumProgram.compiled_sequence: PulserSequence
The Pulser sequence compiled to a specific device.
source method QuantumProgram.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.
source method QuantumProgram.draw(n_points: int = 500, compiled: bool = False, return_fig: bool = False) → plt.Figure | None
Raises
-
ValueError
source method QuantumProgram.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
source 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
source property SequenceCompiler.register: Register
source property SequenceCompiler.drive: Drive
source property SequenceCompiler.device: Device
source property SequenceCompiler.profile: CompilerProfile
The compiler profile to use.
source method SequenceCompiler.compile_sequence() → PulserSequence
Raises
-
ValueError
source enum CompilerProfile()
source enum ResultType()
source enum BackendName()
source class QutipBackend(seq: PulserSequence, result_type: ResultType = ResultType.STATEVECTOR, **backend_params: Any)
source method QutipBackend.run(runs: int = 100, evaluation_times: list[float] = [1.0]) → OutputType
source 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.
source 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.