Complete API Reference
Generated file
Generated from the installed package. Every signature, type
and default below is read from the release it documents, so
this page matches the API you are calling.
Conventions used throughout:
- Import is the path to prefer. Where a package re-exports a
name, the short package-level path is shown rather than the
module it happens to be defined in.
- Raises lists exceptions a function raises itself. It does
not include exceptions propagating from deeper calls.
- A type column reading
<qndk> is an elided absolute path to the
installed package.
qndk.circuit
Public API: CircuitLoader, GF2mField, QiskitCircuit, default_irreducible_polynomial, new_gf2m, new_grover, new_tfim
-
CircuitLoader
- Kind: class
- Import:
from qndk.circuit.circuit_loader import CircuitLoader
- Signature:
CircuitLoader(module_name: str = 'qiskit_circuits', dict_name: str = 'CIRCUIT_DEFINITIONS')
Load and manage circuits from a Python module.
| Parameter |
Type |
Default |
Required |
module_name |
str |
'qiskit_circuits' |
optional |
dict_name |
str |
'CIRCUIT_DEFINITIONS' |
optional |
| Member |
Kind |
Signature |
Summary |
get_circuit |
method |
(self, name: str) -> Optional[qiskit.circuit.quantumcircuit.QuantumCircuit] |
|
list_circuits |
method |
(self) -> List[str] |
|
GF2mField
- Kind: class
- Import:
from qndk.circuit.gf2m import GF2mField
- Signature:
GF2mField(m: 'int', poly: 'int | None' = None) -> None
GF(2^m): m-bit field elements, reduced modulo poly -- a degree-m irreducible polynomial over GF(2), packed as an (m+1)-bit int (bit i is the coefficient of x^i, bit m is always 1). Addition needs none of this (it's plain bitwise XOR); squaring, multiplication, and inversion are all defined with respect to this specific field.
| Parameter |
Type |
Default |
Required |
m |
int |
`` |
required |
poly |
int \| None |
None |
optional |
| Member |
Kind |
Signature |
Summary |
multiply_table |
method |
(self) -> 'dict[tuple[int, int], int]' |
{(i, j): x^(i+j) mod poly} for every 0 <= i, j < m -- which output bits the term a_i * b_j contributes to. Thi |
square_matrix |
method |
(self) -> 'list[int]' |
column[i] = x^(2i) mod poly, as an m-bit mask. Squaring is linear over GF(2) (the Frobenius map), so this alon |
QiskitCircuit
- Kind: class
- Import:
from qndk.circuit.qiskit_circuits import QiskitCircuit
- Signature:
QiskitCircuit(circuit_type: str, num_qubits: int = None, **kwargs)
Class for creating a Qiskit Quantum Circuit Types of Qiskit Circuits available MCMTV - MCMT implementation using the CCX V-chain QFT - Quantum Frouier Transform QAOA - QAOA quantum circuit QV - Quantum volume model circuit. RCA - Ripple-carry circuit TFIM - Trotterized transverse-field Ising model circuit GF2M - GF(2^m) arithmetic circuit (add/square/multiply/inverse) Inputs: num_qubits : Number of qubits Output: Qiskit QuantumCircuit object
| Parameter |
Type |
Default |
Required |
circuit_type |
str |
`` |
required |
num_qubits |
int |
None |
optional |
**kwargs |
| |
kwargs |
|
| Member |
Kind |
Signature |
Summary |
MCMTV |
method |
(self, target, control, gate) -> qiskit.circuit.quantumcircuit.QuantumCircuit |
|
QAOA |
method |
(self, prob_edge_creation) -> qiskit.circuit.quantumcircuit.QuantumCircuit |
|
QV |
method |
(self) -> qiskit.circuit.quantumcircuit.QuantumCircuit |
|
RCA |
method |
(self) -> qiskit.circuit.quantumcircuit.QuantumCircuit |
|
build_circuit |
method |
(self, **kwargs) -> qiskit.circuit.quantumcircuit.QuantumCircuit |
|
draw |
method |
(self, block: bool = False, **kwargs) |
|
draw_qiskit_dag |
method |
(self, block: bool = False, figsize: tuple[float, float] | None = None, dpi: float | None = None) |
|
get_operator |
method |
(self, weight_matrix) |
Generate Hamiltonian for the graph partitioning Notes: Goals: 1 Separate the vertices into two set of the same |
qasm2 |
method |
(self) -> str |
|
qasm3 |
method |
(self) -> str |
|
qft |
method |
(self, num_qubits: int) -> qiskit.circuit.quantumcircuit.QuantumCircuit |
|
simple |
method |
(self, num_qubits: int) -> qiskit.circuit.quantumcircuit.QuantumCircuit |
|
default_irreducible_polynomial
- Kind: function
- Import:
from qndk.circuit.gf2m import default_irreducible_polynomial
- Signature:
default_irreducible_polynomial(m: 'int') -> 'int'
- Raises:
RuntimeError, ValueError
The smallest-value degree-m irreducible polynomial over GF(2), packed as an (m+1)-bit int (bit i is x^i's coefficient, bit m is always 1).
| Parameter |
Type |
Default |
Required |
m |
int |
`` |
required |
new_gf2m
- Kind: function
- Import:
from qndk.circuit.gf2m import new_gf2m
- Signature:
new_gf2m(m: 'int', operation: 'str' = 'multiply', poly: 'int | None' = None) -> 'QuantumCircuit'
- Raises:
ValueError
Builds a GF(2^m) arithmetic circuit by name.
| Parameter |
Type |
Default |
Required |
m |
int |
`` |
required |
operation |
str |
'multiply' |
optional |
poly |
int \| None |
None |
optional |
new_grover
- Kind: function
- Import:
from qndk.circuit.grover import new_grover
- Signature:
new_grover(target_bitstring: str) -> qiskit.circuit.quantumcircuit.QuantumCircuit
| Parameter |
Type |
Default |
Required |
target_bitstring |
str |
`` |
required |
new_tfim
- Kind: function
- Import:
from qndk.circuit.tfim import new_tfim
- Signature:
new_tfim(num_qubits: int, num_trotter_steps: int = 1, j_coupling: float = 1.0, h_field: float = 1.0, dt: float = 0.2, clifford_t_synthesis: bool = False) -> qiskit.circuit.quantumcircuit.QuantumCircuit
- Raises:
ValueError
Trotterized time evolution of the 1D transverse-field Ising model.
| Parameter |
Type |
Default |
Required |
num_qubits |
int |
`` |
required |
num_trotter_steps |
int |
1 |
optional |
j_coupling |
float |
1.0 |
optional |
h_field |
float |
1.0 |
optional |
dt |
float |
0.2 |
optional |
clifford_t_synthesis |
bool |
False |
optional |
qndk.transpile
Public API: TranspiledCircuit, global_clbit_id, global_qubit_id
-
TranspiledCircuit
- Kind: class
- Import:
from qndk.transpile.transpile import TranspiledCircuit
- Signature:
TranspiledCircuit(circuit: 'Union[QuantumCircuit, QiskitCircuit]', optimization_level: 'int' = 0, decompose: 'bool' = True, basis_gates: 'List[str]' = None)
- Raises:
TypeError
Wraps a Qiskit QuantumCircuit and prepares it for the qndk pipeline: - decompose and transpile to a given basis, - derive a DAG and interaction graph, - provide plotting helpers, and return a new TranspiledCircuit of the augmented circuit.
| Parameter |
Type |
Default |
Required |
circuit |
Union[QuantumCircuit, QiskitCircuit] |
`` |
required |
optimization_level |
int |
0 |
optional |
decompose |
bool |
True |
optional |
basis_gates |
List[str] |
None |
optional |
| Member |
Kind |
Signature |
Summary |
copy |
method |
(self) |
|
dag_copy |
method |
(self) -> 'DAGCircuit' |
|
draw |
method |
(self, block: 'bool' = False, **kwargs) |
|
draw_qiskit_dag |
method |
(self, block: 'bool' = False, figsize: 'Tuple[float, float] | None' = None, dpi: 'float | None' = None) |
|
enough_physical_qubits |
method |
(self, network: 'QuantumNetwork') -> 'Tuple[bool, int]' |
|
networkx_dag |
method |
(self) -> 'nx.DiGraph' |
|
plot_dag |
method |
(self, block: 'bool' = False, qubit_tracker=None) |
|
plot_unpartitioned_interactions |
method |
(self, circuit_to_partition_qubit: 'Dict[str, str]' = {}, block: 'bool' = False) |
|
qasm2 |
method |
(self) -> 'str' |
|
qasm3 |
method |
(self) -> 'str' |
|
qubit_interaction_graph |
method |
(self) -> 'nx.Graph' |
|
save |
method |
(self, filepath: 'str') |
|
global_clbit_id
- Kind: function
- Import:
from qndk.transpile.ids import global_clbit_id
- Signature:
global_clbit_id(c: qiskit.circuit.Clbit) -> str
| Parameter |
Type |
Default |
Required |
c |
Clbit |
`` |
required |
global_qubit_id
- Kind: function
- Import:
from qndk.transpile.ids import global_qubit_id
- Signature:
global_qubit_id(q: qiskit.circuit.Qubit) -> str
- Raises:
TypeError
| Parameter |
Type |
Default |
Required |
q |
Qubit |
`` |
required |
qndk.quantum_network
Public API: Link, LinkSpec, MagicFactory, MagicFactorySpec, QPU, QPUSpec, QuantumNetwork, Qubit, QubitLayout, QubitSpec, Switch, SwitchSpec, build_bcube, build_clos, build_fattree, build_network, build_qfly, build_rack
Link
- Kind: class
- Import:
from qndk.quantum_network import Link
- Signature:
Link(*, bandwidth: 'float' = 1.0, loss_db_km: 'float' = 0.2, length_m: 'float' = 1.0, latency_ms: 'float' = 0.001, src: 'str', dst: 'str') -> None
- Inherits:
LinkSpec
| Parameter |
Type |
Default |
Required |
bandwidth |
float |
1.0 |
optional |
loss_db_km |
float |
0.2 |
optional |
length_m |
float |
1.0 |
optional |
latency_ms |
float |
0.001 |
optional |
src |
str |
`` |
required |
dst |
str |
`` |
required |
| Member |
Kind |
Signature |
Summary |
from_dict |
classmethod |
(cls, d: 'dict') -> 'Link' |
|
loss_db |
method |
(self) -> 'float' |
|
make_id |
staticmethod |
(src: 'str', dst: 'str') -> 'str' |
|
search_weight |
method |
(self) -> 'float' |
|
to_dict |
method |
(self) -> 'dict' |
|
LinkSpec
- Kind: class
- Import:
from qndk.quantum_network import LinkSpec
- Signature:
LinkSpec(*, bandwidth: 'float' = 1.0, loss_db_km: 'float' = 0.2, length_m: 'float' = 1.0, latency_ms: 'float' = 0.001) -> None
| Parameter |
Type |
Default |
Required |
bandwidth |
float |
1.0 |
optional |
loss_db_km |
float |
0.2 |
optional |
length_m |
float |
1.0 |
optional |
latency_ms |
float |
0.001 |
optional |
MagicFactory
- Kind: class
- Import:
from qndk.quantum_network import MagicFactory
- Signature:
MagicFactory(*, index: 'int', connectivity: "Literal['grid4', 'all2all', 'block']" = 'all2all', qubits: 'dict[str, Qubit]' = <factory>, comm_qubit_coherence_time_ms: 'float' = 1000.0, distill_rounds: 'int' = 2, distillation_level_time_ms: 'float' = 0.1, magic_state_injection_time_ms: 'float | None' = None) -> None
- Inherits:
QPU
A QPU that holds distilled magic states and nothing else.
| Parameter |
Type |
Default |
Required |
index |
int |
`` |
required |
connectivity |
Literal['grid4', 'all2all', 'block'] |
'all2all' |
optional |
qubits |
dict[str, Qubit] |
<factory> |
optional |
comm_qubit_coherence_time_ms |
float |
1000.0 |
optional |
distill_rounds |
int |
2 |
optional |
distillation_level_time_ms |
float |
0.1 |
optional |
magic_state_injection_time_ms |
float \| None |
None |
optional |
| Member |
Kind |
Signature |
Summary |
is_magic_state_factory |
property |
|
|
to_dict |
method |
(self) -> 'dict' |
|
MagicFactorySpec
- Kind: class
- Import:
from qndk.quantum_network import MagicFactorySpec
- Signature:
MagicFactorySpec(*, distill_rounds: 'int' = 2, distillation_level_time_ms: 'float' = 0.1, magic_state_injection_time_ms: 'float | None' = None, magic_qubits: 'int' = 1, qubit: 'QubitSpec' = <factory>, comm_qubit_coherence_time_ms: 'float' = 1000.0) -> None
How QuantumNetwork.add_magic_factory builds a magic state factory.
| Parameter |
Type |
Default |
Required |
distill_rounds |
int |
2 |
optional |
distillation_level_time_ms |
float |
0.1 |
optional |
magic_state_injection_time_ms |
float \| None |
None |
optional |
magic_qubits |
int |
1 |
optional |
qubit |
QubitSpec |
<factory> |
optional |
comm_qubit_coherence_time_ms |
float |
1000.0 |
optional |
QPU
- Kind: class
- Import:
from qndk.quantum_network import QPU
- Signature:
QPU(*, index: 'int', connectivity: "Literal['grid4', 'all2all', 'block']", qubits: 'dict[str, Qubit]' = <factory>, comm_qubit_coherence_time_ms: 'float' = 1000.0) -> None
| Parameter |
Type |
Default |
Required |
index |
int |
`` |
required |
connectivity |
Literal['grid4', 'all2all', 'block'] |
`` |
required |
qubits |
dict[str, Qubit] |
<factory> |
optional |
comm_qubit_coherence_time_ms |
float |
1000.0 |
optional |
| Member |
Kind |
Signature |
Summary |
available_comm_qubit_ids |
property |
|
Qubits free to hold one half of an entangled pair. |
from_dict |
classmethod |
(cls, d: 'dict') -> 'QPU' |
|
is_magic_state_factory |
property |
|
|
make_id |
classmethod |
(cls, index: 'int') -> 'str' |
|
num_comm_qubits |
property |
|
|
num_comp_qubits |
property |
|
|
to_dict |
method |
(self) -> 'dict' |
|
QPUSpec
- Kind: class
- Import:
from qndk.quantum_network import QPUSpec
- Signature:
QPUSpec(*, comp_qubits: 'int' = 4, comm_qubits: 'int | None' = None, connectivity: "Literal['grid4', 'all2all', 'block']" = 'all2all', layout: 'QubitLayout | None' = None, qubit: 'QubitSpec' = <factory>, comm_qubit_coherence_time_ms: 'float' = 1000.0) -> None
How QuantumNetwork.add_qpu builds a compute QPU and its qubits.
| Parameter |
Type |
Default |
Required |
comp_qubits |
int |
4 |
optional |
comm_qubits |
int \| None |
None |
optional |
connectivity |
Literal['grid4', 'all2all', 'block'] |
'all2all' |
optional |
layout |
QubitLayout \| None |
None |
optional |
qubit |
QubitSpec |
<factory> |
optional |
comm_qubit_coherence_time_ms |
float |
1000.0 |
optional |
QuantumNetwork
- Kind: class
- Import:
from qndk.quantum_network import QuantumNetwork
- Signature:
QuantumNetwork(directed: 'bool' = False)
A network of QPUs, switches and links.
| Parameter |
Type |
Default |
Required |
directed |
bool |
False |
optional |
| Member |
Kind |
Signature |
Summary |
add_device |
method |
(self, device: 'QPU | Switch | Link') -> 'QPU | Switch | Link' |
Adds an already built device as-is. A qpu added this way has no qubits until they are added with add_qubit / a |
add_link |
method |
(self, src: 'str', dst: 'str', spec: 'LinkSpec | None' = None) -> 'Link' |
|
add_magic_factory |
method |
(self, spec: 'MagicFactorySpec | None' = None, index: 'int | None' = None) -> 'MagicFactory' |
Adds a magic state factory built to spec, and its magic qubits. |
add_qpu |
method |
(self, spec: 'QPUSpec | None' = None, index: 'int | None' = None) -> 'QPU' |
Adds a compute qpu built to spec, together with its qubits and the intra-qpu edges its connectivity implies. |
add_qubit |
method |
(self, qubit: 'Qubit', qpu_id: 'str') -> 'Qubit' |
|
add_qubit_edge |
method |
(self, src_id: 'str', dst_id: 'str') -> 'None' |
Wires two qubits inside the same qpu. |
add_switch |
method |
(self, level: 'int', subtype: "Literal['nir', 'tel']", num_ports: 'int', spec: 'SwitchSpec | None' = None, index: 'int | None' = None) -> 'Switch' |
Adds a switch built to spec. index defaults to the next one no switch on this level has taken yet. |
all_comm_qubit_ids |
method |
(self) -> 'list[str]' |
|
all_comp_qubit_ids |
method |
(self) -> 'list[str]' |
|
all_magic_qubit_ids |
method |
(self) -> 'list[str]' |
|
all_shortest_paths |
method |
(self, src: 'str', dst: 'str') -> 'list[list[str]]' |
|
allocate_qubit |
method |
(self, qubit_id: 'str', job_id: 'str') -> 'None' |
|
allocated_qubit_ids |
method |
(self) -> 'list[str]' |
|
available_qubit_ids |
method |
(self) -> 'list[str]' |
|
boundary_type |
method |
(self, qubit_a: 'str', qubit_b: 'str') -> 'str' |
|
calculate_path_latency |
method |
(self, path: 'list[str]') -> 'float' |
|
copy |
method |
(self) -> 'QuantumNetwork' |
|
from_json |
classmethod |
(cls, data: 'dict') -> 'QuantumNetwork' |
|
get_link |
method |
(self, link_id: 'str') -> 'Link' |
|
get_link_between |
method |
(self, u: 'str', v: 'str') -> 'Link' |
|
get_qpu |
method |
(self, qpu_id: 'str') -> 'QPU' |
|
get_qubit |
method |
(self, qubit_id: 'str') -> 'Qubit' |
|
get_switch |
method |
(self, switch_id: 'str') -> 'Switch' |
|
is_directed |
method |
(self) -> 'bool' |
|
is_qubit_available |
method |
(self, qubit_id: 'str') -> 'bool' |
|
link_id_between |
method |
(self, u: 'str', v: 'str') -> 'str | None' |
The id of the link joining two devices, or None when the edge is intra-qpu qubit wiring, which carries no link |
link_ids |
method |
(self) -> 'list[str]' |
|
min_comp_qubits_across_qpus |
method |
(self) -> 'int' |
|
name |
method |
(self) -> 'str' |
|
neighbors |
method |
(self, node_id: 'str') -> 'list[str]' |
|
nir_switch_ids |
method |
(self) -> 'list[str]' |
|
nir_switches |
property |
|
|
path_boundary_type |
method |
(self, path: 'list[str]') -> 'str' |
|
plot |
method |
(self, qubits: 'bool' = True, block: 'bool' = False, ax=None, partition_result=None, finalize: 'bool' = True, qubit_spread: 'float' = 1.0, qpu_gap_cols: 'float' = 1.0, level_spacing_scale: 'float' = 1.0, qubit_share: 'Optional[float]' = None) |
|
pop_comm_qubit |
method |
(self, qpu_id: 'str', job_id: 'str' = 'in-use') -> 'str' |
Atomically picks one free comm qubit on qpu_id, marks it allocated, and returns its ID. Raises KeyError if no |
qpu_ids |
method |
(self) -> 'list[str]' |
|
qpu_of_qubit |
method |
(self, qubit_id: 'str') -> 'str' |
|
qpus |
property |
|
|
qubit_ids |
method |
(self) -> 'list[str]' |
|
qubits_by_qpu |
method |
(self) -> 'dict[str, list[str]]' |
|
release_qubit |
method |
(self, qubit_id: 'str') -> 'None' |
|
set_name |
method |
(self, name: 'str') -> 'None' |
|
shortest_path |
method |
(self, src: 'str', dst: 'str') -> 'list[str]' |
|
shortest_simple_paths |
method |
(self, src: 'str', dst: 'str') |
|
switch_ids |
method |
(self) -> 'list[str]' |
|
switch_levels |
method |
(self) -> 'dict[str, int]' |
Assigns every switch a tier, counted in hops away from the qpus. |
tel_switch_ids |
method |
(self) -> 'list[str]' |
|
tel_switches |
property |
|
|
to_json |
method |
(self) -> 'dict' |
|
total_comm_qubits |
method |
(self) -> 'int' |
|
total_comp_qubits |
method |
(self) -> 'int' |
|
update_link |
method |
(self, link_id: 'str', **kwargs) -> 'None' |
|
update_qubit |
method |
(self, qubit_id: 'str', **kwargs) -> 'None' |
|
update_switch |
method |
(self, switch_id: 'str', **kwargs) -> 'None' |
|
validate |
method |
(self) -> 'None' |
Asserts the network can actually host a circuit. |
without_magic_factories |
method |
(self) -> 'QuantumNetwork' |
This same network if it has no magic state factories (the common case -- returned as-is, no copy), otherwise a |
Qubit
- Kind: class
- Import:
from qndk.quantum_network import Qubit
- Signature:
Qubit(*, t1_time_ms: 'float' = 1000.0, t2_time_ms: 'float' = 1000.0, reset_time_ms: 'float' = 0.0, gate_fidelity: 'float' = 0.999, measurement_fidelity: 'float' = 0.999, qpu_id: 'str', type: "Literal['comp', 'comm', 'ancilla', 'magic']", row: 'int', col: 'int', allocated_to: 'str | None' = None) -> None
- Inherits:
QubitSpec
| Parameter |
Type |
Default |
Required |
t1_time_ms |
float |
1000.0 |
optional |
t2_time_ms |
float |
1000.0 |
optional |
reset_time_ms |
float |
0.0 |
optional |
gate_fidelity |
float |
0.999 |
optional |
measurement_fidelity |
float |
0.999 |
optional |
qpu_id |
str |
`` |
required |
type |
Literal['comp', 'comm', 'ancilla', 'magic'] |
`` |
required |
row |
int |
`` |
required |
col |
int |
`` |
required |
allocated_to |
str \| None |
None |
optional |
| Member |
Kind |
Signature |
Summary |
from_dict |
classmethod |
(cls, d: 'dict') -> 'Qubit' |
|
make_id |
staticmethod |
(qpu_id: 'str', type: 'str', row: 'int', col: 'int') -> 'str' |
|
to_dict |
method |
(self) -> 'dict' |
|
QubitLayout
- Kind: class
- Import:
from qndk.quantum_network import QubitLayout
- Signature:
QubitLayout(comp_rows: 'int | None' = None, comp_cols: 'int | None' = None, flatten: 'bool' = False, grid_rows: 'int | None' = None, grid_cols: 'int | None' = None) -> None
Placement layout for a QPU's qubits, shared by every connectivity type.
| Parameter |
Type |
Default |
Required |
comp_rows |
int \| None |
None |
optional |
comp_cols |
int \| None |
None |
optional |
flatten |
bool |
False |
optional |
grid_rows |
int \| None |
None |
optional |
grid_cols |
int \| None |
None |
optional |
QubitSpec
- Kind: class
- Import:
from qndk.quantum_network import QubitSpec
- Signature:
QubitSpec(*, t1_time_ms: 'float' = 1000.0, t2_time_ms: 'float' = 1000.0, reset_time_ms: 'float' = 0.0, gate_fidelity: 'float' = 0.999, measurement_fidelity: 'float' = 0.999) -> None
| Parameter |
Type |
Default |
Required |
t1_time_ms |
float |
1000.0 |
optional |
t2_time_ms |
float |
1000.0 |
optional |
reset_time_ms |
float |
0.0 |
optional |
gate_fidelity |
float |
0.999 |
optional |
measurement_fidelity |
float |
0.999 |
optional |
Switch
- Kind: class
- Import:
from qndk.quantum_network import Switch
- Signature:
Switch(*, bsm_count: 'int' = 2, pd_count: 'int' = 0, bs_count: 'int' = 0, es_count: 'int' = 0, model: "Literal['generic', 'cisco']" = 'generic', reconfig_delay_ms: 'float' = 0.01, fidelity: 'float' = 0.999, purity: 'float' = 0.999, loss: 'float' = 0.0, gen_rate_hz: 'float' = 1000000.0, level: 'int', index: 'int', subtype: "Literal['nir', 'tel']", num_ports: 'int') -> None
- Inherits:
SwitchSpec
| Parameter |
Type |
Default |
Required |
bsm_count |
int |
2 |
optional |
pd_count |
int |
0 |
optional |
bs_count |
int |
0 |
optional |
es_count |
int |
0 |
optional |
model |
Literal['generic', 'cisco'] |
'generic' |
optional |
reconfig_delay_ms |
float |
0.01 |
optional |
fidelity |
float |
0.999 |
optional |
purity |
float |
0.999 |
optional |
loss |
float |
0.0 |
optional |
gen_rate_hz |
float |
1000000.0 |
optional |
level |
int |
`` |
required |
index |
int |
`` |
required |
subtype |
Literal['nir', 'tel'] |
`` |
required |
num_ports |
int |
`` |
required |
| Member |
Kind |
Signature |
Summary |
from_dict |
classmethod |
(cls, d: 'dict') -> 'Switch' |
|
make_id |
staticmethod |
(level: 'int', index: 'int') -> 'str' |
|
to_dict |
method |
(self) -> 'dict' |
|
SwitchSpec
- Kind: class
- Import:
from qndk.quantum_network import SwitchSpec
- Signature:
SwitchSpec(*, bsm_count: 'int' = 2, pd_count: 'int' = 0, bs_count: 'int' = 0, es_count: 'int' = 0, model: "Literal['generic', 'cisco']" = 'generic', reconfig_delay_ms: 'float' = 0.01, fidelity: 'float' = 0.999, purity: 'float' = 0.999, loss: 'float' = 0.0, gen_rate_hz: 'float' = 1000000.0) -> None
| Parameter |
Type |
Default |
Required |
bsm_count |
int |
2 |
optional |
pd_count |
int |
0 |
optional |
bs_count |
int |
0 |
optional |
es_count |
int |
0 |
optional |
model |
Literal['generic', 'cisco'] |
'generic' |
optional |
reconfig_delay_ms |
float |
0.01 |
optional |
fidelity |
float |
0.999 |
optional |
purity |
float |
0.999 |
optional |
loss |
float |
0.0 |
optional |
gen_rate_hz |
float |
1000000.0 |
optional |
build_bcube
- Kind: function
- Import:
from qndk.quantum_network import build_bcube
- Signature:
build_bcube(num_qpus: 'int' = None, switch_layers: 'int' = None, ports_per_switch: 'int' = None, qpu_spec: 'QPUSpec | None' = None, switch_spec: 'SwitchSpec | None' = None, link_spec: 'LinkSpec | None' = None, magic_factory_spec: 'MagicFactorySpec | None' = None, num_magic_factories: 'int' = 0, qpu_specs: 'dict[int, QPUSpec] | None' = None) -> 'QuantumNetwork'
qpu_specs replaces qpu_spec for specific QPUs by index -- any index not in it still uses qpu_spec, so a mostly-uniform network with a few exceptions costs one dict entry per exception. Switches and links stay uniform at construction time; use QuantumNetwork.update_switch / update_link to vary those afterward.
| Parameter |
Type |
Default |
Required |
num_qpus |
int |
None |
optional |
switch_layers |
int |
None |
optional |
ports_per_switch |
int |
None |
optional |
qpu_spec |
QPUSpec \| None |
None |
optional |
switch_spec |
SwitchSpec \| None |
None |
optional |
link_spec |
LinkSpec \| None |
None |
optional |
magic_factory_spec |
MagicFactorySpec \| None |
None |
optional |
num_magic_factories |
int |
0 |
optional |
qpu_specs |
dict[int, QPUSpec] \| None |
None |
optional |
build_clos
- Kind: function
- Import:
from qndk.quantum_network import build_clos
- Signature:
build_clos(num_levels: 'int' = 2, qpus_per_rack: 'int' = 1, ports_per_switch: 'int' = 4, qpu_spec: 'QPUSpec | None' = None, switch_spec: 'SwitchSpec | None' = None, link_spec: 'LinkSpec | None' = None, magic_factory_spec: 'MagicFactorySpec | None' = None, num_magic_factories: 'int' = 0, qpu_specs: 'dict[int, QPUSpec] | None' = None) -> 'QuantumNetwork'
- Raises:
ValueError
num_levels is how many switch tiers stack between the qpus and the top of the fabric, and is the main knob on the shape of the fabric. ports_per_switch (k below) sets how wide each tier is:
| Parameter |
Type |
Default |
Required |
num_levels |
int |
2 |
optional |
qpus_per_rack |
int |
1 |
optional |
ports_per_switch |
int |
4 |
optional |
qpu_spec |
QPUSpec \| None |
None |
optional |
switch_spec |
SwitchSpec \| None |
None |
optional |
link_spec |
LinkSpec \| None |
None |
optional |
magic_factory_spec |
MagicFactorySpec \| None |
None |
optional |
num_magic_factories |
int |
0 |
optional |
qpu_specs |
dict[int, QPUSpec] \| None |
None |
optional |
build_fattree
- Kind: function
- Import:
from qndk.quantum_network import build_fattree
- Signature:
build_fattree(num_pods: 'int' = None, num_qpus: 'int' = None, qpu_spec: 'QPUSpec | None' = None, switch_spec: 'SwitchSpec | None' = None, link_spec: 'LinkSpec | None' = None, magic_factory_spec: 'MagicFactorySpec | None' = None, num_magic_factories: 'int' = 0, qpu_specs: 'dict[int, QPUSpec] | None' = None) -> 'QuantumNetwork'
- Raises:
ValueError
qpu_specs replaces qpu_spec for specific QPUs by index -- any index not in it still uses qpu_spec, so a mostly-uniform network with a few exceptions costs one dict entry per exception. Switches and links stay uniform at construction time; use QuantumNetwork.update_switch / update_link to vary those afterward.
| Parameter |
Type |
Default |
Required |
num_pods |
int |
None |
optional |
num_qpus |
int |
None |
optional |
qpu_spec |
QPUSpec \| None |
None |
optional |
switch_spec |
SwitchSpec \| None |
None |
optional |
link_spec |
LinkSpec \| None |
None |
optional |
magic_factory_spec |
MagicFactorySpec \| None |
None |
optional |
num_magic_factories |
int |
0 |
optional |
qpu_specs |
dict[int, QPUSpec] \| None |
None |
optional |
build_network
- Kind: function
- Import:
from qndk.quantum_network import build_network
- Signature:
build_network(topology: 'str', **kwargs) -> 'QuantumNetwork'
- Raises:
ValueError
| Parameter |
Type |
Default |
Required |
topology |
str |
`` |
required |
**kwargs |
| |
kwargs |
|
build_qfly
- Kind: function
- Import:
from qndk.quantum_network import build_qfly
- Signature:
build_qfly(num_switches: 'int', k_ring: 'int' = 1, qpus_per_switch: 'int' = 1, qpu_spec: 'QPUSpec | None' = None, switch_spec: 'SwitchSpec | None' = None, link_spec: 'LinkSpec | None' = None, magic_factory_spec: 'MagicFactorySpec | None' = None, num_magic_factories: 'int' = 0, qpu_specs: 'dict[int, QPUSpec] | None' = None) -> 'QuantumNetwork'
qpu_specs replaces qpu_spec for specific QPUs by index -- any index not in it still uses qpu_spec, so a mostly-uniform network with a few exceptions costs one dict entry per exception. Switches and links stay uniform at construction time; use QuantumNetwork.update_switch / update_link to vary those afterward.
| Parameter |
Type |
Default |
Required |
num_switches |
int |
`` |
required |
k_ring |
int |
1 |
optional |
qpus_per_switch |
int |
1 |
optional |
qpu_spec |
QPUSpec \| None |
None |
optional |
switch_spec |
SwitchSpec \| None |
None |
optional |
link_spec |
LinkSpec \| None |
None |
optional |
magic_factory_spec |
MagicFactorySpec \| None |
None |
optional |
num_magic_factories |
int |
0 |
optional |
qpu_specs |
dict[int, QPUSpec] \| None |
None |
optional |
build_rack
- Kind: function
- Import:
from qndk.quantum_network import build_rack
- Signature:
build_rack(num_qpus: 'int', qpu_spec: 'QPUSpec | None' = None, switch_spec: 'SwitchSpec | None' = None, link_spec: 'LinkSpec | None' = None, magic_factory_spec: 'MagicFactorySpec | None' = None, num_magic_factories: 'int' = 0, qpu_specs: 'dict[int, QPUSpec] | None' = None) -> 'QuantumNetwork'
- Raises:
ValueError
A single rack: one nir switch with num_qpus qpus hanging off it.
| Parameter |
Type |
Default |
Required |
num_qpus |
int |
`` |
required |
qpu_spec |
QPUSpec \| None |
None |
optional |
switch_spec |
SwitchSpec \| None |
None |
optional |
link_spec |
LinkSpec \| None |
None |
optional |
magic_factory_spec |
MagicFactorySpec \| None |
None |
optional |
num_magic_factories |
int |
0 |
optional |
qpu_specs |
dict[int, QPUSpec] \| None |
None |
optional |
qndk.partition
Public API: KernighanLinPartitioner, MetisPartitioner, PartitionEvent, PartitionResult, Partitioner, QubitPartitionTracker, WindowBasedCircuitPartitioner, comp_qubits_by_qpu_desc, new_partition_result, qubit_tracker_from_groups
-
KernighanLinPartitioner
- Kind: class
- Import:
from qndk.partition.kl import KernighanLinPartitioner
- Signature:
KernighanLinPartitioner(circuit, network, seed: int = 20250101, restarts: int = 8, exhaustive_split_search: bool = False)
- Inherits:
Partitioner
- Raises:
ValueError
| Parameter |
Type |
Default |
Required |
circuit |
| |
required |
|
network |
| |
required |
|
seed |
int |
20250101 |
optional |
restarts |
int |
8 |
optional |
exhaustive_split_search |
bool |
False |
optional |
| Member |
Kind |
Signature |
Summary |
kernighan_lin_bisection |
method |
(self, circuit_nx_graph, balance, partition=None, max_iter=10, weight='weight', raw_adjacency=None) |
Partition the graph into two parts, best of self.restarts runs. |
recursive_kernighan_lin_extended |
method |
(self, circuit_nx_graph, coefficient, nodes_partition=None, prior_placement=None, offset: int = 0) -> List[Set[networkx.classes.reportviews.NodeView]] |
Recursively apply the Kernighan-Lin algorithm to partition the graph into 'coefficient' parts. |
MetisPartitioner
- Kind: class
- Import:
from qndk.partition.metis import MetisPartitioner
- Signature:
MetisPartitioner(circuit: TranspiledCircuit, network: QuantumNetwork, seed: int = 20250101)
- Inherits:
Partitioner
- Raises:
Exception
| Parameter |
Type |
Default |
Required |
circuit |
TranspiledCircuit |
`` |
required |
network |
QuantumNetwork |
`` |
required |
seed |
int |
20250101 |
optional |
PartitionEvent
- Kind: class
- Import:
from qndk.partition.partition import PartitionEvent
- Signature:
PartitionEvent(event_type: str, qubits: Tuple[str, ...], from_qpu: int | None = None, to_qpu: int | None = None, node_ids: Tuple[int, ...] = (), action: str | None = None) -> None
Describes an optimization or execution-planning action tied to DAG node ids.
| Parameter |
Type |
Default |
Required |
event_type |
str |
`` |
required |
qubits |
typing.Tuple[str, ...] |
`` |
required |
from_qpu |
int \| None |
None |
optional |
to_qpu |
int \| None |
None |
optional |
node_ids |
typing.Tuple[int, ...] |
() |
optional |
action |
str \| None |
None |
optional |
PartitionResult
- Kind: class
- Import:
from qndk.partition.partition import PartitionResult
- Signature:
PartitionResult(transpiled_circuit: TranspiledCircuit, network: QuantumNetwork, qubit_tracker: QubitPartitionTracker, total_epr_count: int = 0, partition_events: List[PartitionEvent] = None)
| Parameter |
Type |
Default |
Required |
transpiled_circuit |
TranspiledCircuit |
`` |
required |
network |
QuantumNetwork |
`` |
required |
qubit_tracker |
QubitPartitionTracker |
`` |
required |
total_epr_count |
int |
0 |
optional |
partition_events |
typing.List[PartitionEvent] |
None |
optional |
| Member |
Kind |
Signature |
Summary |
calculate_partition_edge_weights |
method |
(self, window_index: int = None) -> dict |
|
circuit_qubit_groups |
method |
(self, window_index: int = None) -> List[List[str]] |
|
plot |
method |
(self, title_prefix='', block=False) |
|
plot_encoded_network |
method |
(self, **kwargs) |
Plots this partition's network with each logical qubit's own surface-code patch inset in place of its plain do |
plot_network |
method |
(self, **kwargs) |
Plots this partition's network. Delegates to plot_encoded_network() -- each logical qubit's own surface-code p |
remap_qubits |
method |
(self, optimization_level: str = 'ilp', F_intra: float = 0.9, F_inter: float = 0.85, ilp_time_limit_ms: int | None = None) -> Dict[str, Any] |
High-level: Recompute the logical→physical mapping using the original rack-placement ILP while keeping the net |
total_operation_dag |
method |
(self) -> networkx.classes.digraph.DiGraph |
|
Partitioner
- Kind: class
- Import:
from qndk.partition.partition import Partitioner
- Signature:
Partitioner(circuit: Union[TranspiledCircuit, QiskitCircuit, qiskit.circuit.quantumcircuit.QuantumCircuit], network: QuantumNetwork, seed: int = 20250101)
- Inherits:
ABC
- Raises:
Exception, TypeError
| Parameter |
Type |
Default |
Required |
circuit |
typing.Union[TranspiledCircuit, QiskitCircuit, qiskit.circuit.quantumcircuit.QuantumCircuit] |
`` |
required |
network |
QuantumNetwork |
`` |
required |
seed |
int |
20250101 |
optional |
| Member |
Kind |
Signature |
Summary |
partition |
method |
(self) -> PartitionResult |
|
QubitPartitionTracker
- Kind: class
- Import:
from qndk.partition.partition import QubitPartitionTracker
- Signature:
QubitPartitionTracker(network: QuantumNetwork)
Builds a mapping from dag_node_id to window to circuit_mapping
| Parameter |
Type |
Default |
Required |
network |
QuantumNetwork |
`` |
required |
| Member |
Kind |
Signature |
Summary |
add_partition_window_for_dag_node_ids |
method |
(self, dag_node_ids: list, windowed_partition: dict, from_qec: bool = False) |
|
circuit_to_network |
method |
(self, dag_node_id: int) -> dict |
|
is_dynamic |
method |
(self) -> bool |
|
is_empty |
method |
(self) -> bool |
|
is_static |
method |
(self) -> bool |
|
last_circuit_to_network |
method |
(self) -> dict |
|
last_window |
method |
(self) -> dict |
|
partitions_at_window |
method |
(self, window_index: int = None) -> dict |
|
replace_last_window_mapping |
method |
(self, circuit_to_network: dict, network_to_circuit: dict) |
|
teleportation_events |
method |
(self) -> dict |
returns a dict that identifies which qubits need to be teleported at each dag_node. this will be used to help |
WindowBasedCircuitPartitioner
- Kind: class
- Import:
from qndk.partition.wbcp import WindowBasedCircuitPartitioner
- Signature:
WindowBasedCircuitPartitioner(circuit: TranspiledCircuit, network: QuantumNetwork, window_size: int = None, seed: int = 20250101, kl_restarts: int = 8)
- Inherits:
Partitioner
- Raises:
ValueError
Implements the Window-Based Circuit Partitioning (WBCP) algorithm for a Qiskit QuantumCircuit.
| Parameter |
Type |
Default |
Required |
circuit |
TranspiledCircuit |
`` |
required |
network |
QuantumNetwork |
`` |
required |
window_size |
int |
None |
optional |
seed |
int |
20250101 |
optional |
kl_restarts |
int |
8 |
optional |
comp_qubits_by_qpu_desc
- Kind: function
- Import:
from qndk.partition.partition import comp_qubits_by_qpu_desc
- Signature:
comp_qubits_by_qpu_desc(network: QuantumNetwork) -> List[Tuple[str, List[str]]]
(qpu_id, comp_qubit_ids) for every QPU with comp qubits, biggest QPU first (ties broken by qpu_id for a deterministic order). QPUs are not assumed to share a qubit count -- this is the canonical ordering used to match a partition group to a specific QPU with room for it, both while a partitioner is still building groups (see WindowBasedCircuitPartitioner) and in QubitPartitionTracker.add_partition_window_for_dag_node_ids, which does the actual group-to-QPU assignment.
| Parameter |
Type |
Default |
Required |
network |
QuantumNetwork |
`` |
required |
new_partition_result
- Kind: function
- Import:
from qndk.partition.partition import new_partition_result
- Signature:
new_partition_result(qc: qiskit.circuit.quantumcircuit.QuantumCircuit, network: QuantumNetwork, manual_qubit_groups: list, from_qec: bool = False) -> PartitionResult
| Parameter |
Type |
Default |
Required |
qc |
QuantumCircuit |
`` |
required |
network |
QuantumNetwork |
`` |
required |
manual_qubit_groups |
list |
`` |
required |
from_qec |
bool |
False |
optional |
qubit_tracker_from_groups
- Kind: function
- Import:
from qndk.partition.partition import qubit_tracker_from_groups
- Signature:
qubit_tracker_from_groups(tc: TranspiledCircuit, network: QuantumNetwork, manual_qubit_groups: list, from_qec: bool = False) -> tuple[QubitPartitionTracker, int]
Build a single-window tracker from an explicit qubit-to-partition grouping.
| Parameter |
Type |
Default |
Required |
tc |
TranspiledCircuit |
`` |
required |
network |
QuantumNetwork |
`` |
required |
manual_qubit_groups |
list |
`` |
required |
from_qec |
bool |
False |
optional |
qndk.simulator
Public API: DQCScheduler, DynamicScheduler, LocalGateTiming, SimulationResult, Simulator, StaticScheduler
DQCScheduler
- Kind: class
- Import:
from qndk.simulator.dqc import DQCScheduler
- Signature:
DQCScheduler(pr: PartitionResult)
- Inherits:
Simulator
| Parameter |
Type |
Default |
Required |
pr |
PartitionResult |
`` |
required |
| Member |
Kind |
Signature |
Summary |
name |
method |
(self) -> str |
|
run_simulation |
method |
(self) -> SimulationResult |
Runs the Discrete Event Simulation for DQC scheduling. Supports both NISQ and Fault-Tolerant modes via self._f |
DynamicScheduler
- Kind: class
- Import:
from qndk.simulator.dynamic import DynamicScheduler
- Signature:
DynamicScheduler(pr: PartitionResult)
- Inherits:
Simulator
| Parameter |
Type |
Default |
Required |
pr |
PartitionResult |
`` |
required |
| Member |
Kind |
Signature |
Summary |
name |
method |
(self) -> str |
|
run_simulation |
method |
(self) -> SimulationResult |
|
LocalGateTiming
- Kind: class
- Import:
from qndk.simulator.dqc import LocalGateTiming
- Signature:
LocalGateTiming(swap_ms: float = None, single_qubit_ms: float = 0.01, remote_ms: float = 1.0, two_qubit_ms: float = 0.1, gate_durations_ms: Dict[str, float] = <factory>) -> None
Configuration for local gate durations, in milliseconds.
| Parameter |
Type |
Default |
Required |
swap_ms |
float |
None |
optional |
single_qubit_ms |
float |
0.01 |
optional |
remote_ms |
float |
1.0 |
optional |
two_qubit_ms |
float |
0.1 |
optional |
gate_durations_ms |
typing.Dict[str, float] |
<factory> |
optional |
| Member |
Kind |
Signature |
Summary |
duration_ms |
method |
(self, gate: qiskit._accelerate.circuit.DAGNode) -> float |
|
SimulationResult
- Kind: class
- Import:
from qndk.simulator.simulator import SimulationResult
- Signature:
SimulationResult(network: QuantumNetwork, qiskit_dag: qiskit._accelerate.circuit.DAGCircuit, qubit_tracker: QubitPartitionTracker, partition_events: List[PartitionEvent] = None, sim_type: str = '')
| Parameter |
Type |
Default |
Required |
network |
QuantumNetwork |
`` |
required |
qiskit_dag |
DAGCircuit |
`` |
required |
qubit_tracker |
QubitPartitionTracker |
`` |
required |
partition_events |
typing.List[PartitionEvent] |
None |
optional |
sim_type |
str |
'' |
optional |
| Member |
Kind |
Signature |
Summary |
add_event |
method |
(self, timestep: float, **kwargs) |
|
bsm_usage_per_step |
method |
(self, include_empties=False) -> List[Dict] |
calculates eprs generated and used in the execution log |
compute_idle_time |
method |
(self) -> float |
Total qubit idle time across all qubits. |
dag_nodes_per_timestep |
method |
(self, graph_with_eprgen: networkx.classes.graph.Graph) -> Dict[float, List[str]] |
Returns a dict mapping each timestep to the list of all dag_nodes executing at that timestep. |
dag_timestep_animation |
method |
(self, fps: float = 2.0, scale: float = 0.5, hold_last: int = 3, **kwargs) |
Render the plot_dag_with_timesteps slider sweep to an animated GIF in memory -- nothing touches the filesystem |
devices_per_timestep |
method |
(self) -> Dict[float, List[str]] |
Returns a dict mapping each timestep to the list of all device_ids involved in that timestep. Duplicate device |
epr_cost |
method |
(self) -> int |
reports the number of eprs pairs consumed |
epr_gens |
method |
(self) -> int |
reports the number of eprs pairs generated |
epr_lifecycle_counts |
method |
(self) -> Dict[str, int] |
How many EPR pairs went through each lifecycle event, keyed by event type: generated and used on demand (epr-o |
events_by_qubit |
method |
(self) -> Dict[str, List[Dict]] |
Every timed event in the execution log, keyed by each physical or comm qubit it touches. An event on two qubit |
execution_log_summary_table |
method |
(self) -> str |
The execution log as fixed-width rows, for reading at a terminal. |
gate_counts |
method |
(self) -> dict |
Returns num_local, num_remote, num_magic, num_gates from the execution log. |
plot |
method |
(self, title_prefix='', block=False) |
|
plot_bsms_used_per_timestep |
method |
(self, title_prefix='', block=False) |
|
plot_dag_with_timesteps |
method |
(self, show_qubits=False, title_prefix='', block=False) |
|
plot_epr_lifecycle |
method |
(self, ax=None, title: str = None, save_as: str = None, show: bool = True, block: bool = False) |
Bar chart of EPR pair lifecycle event counts: pre-generated ahead of demand (lookahead), generated on demand, |
plot_gantt |
method |
(self, title='Execution Log Gantt Chart', figsize=(16, 8), block=False) |
|
plot_gantt_by_device |
method |
(self, title='Execution Gantt Chart by Device', figsize: Optional[Tuple[float, float]] = None, block: bool = False) |
Gantt chart with one row per qubit, rows grouped by their QPU. |
plot_latency_distribution |
method |
(self, title_prefix='', block=False) |
|
save_dag_timestep_animation |
method |
(self, path: str, fps: float = 2.0, scale: float = 0.5, hold_last: int = 3, **kwargs) -> str |
Render the plot_dag_with_timesteps slider sweep to an animated GIF file. |
switch_sequence |
method |
(self) -> List[Tuple[int, int]] |
|
total_operation_dag |
method |
(self) -> networkx.classes.digraph.DiGraph |
returns a DAG of the circuit with the synthetic SimulationResult nodes and synthetic PartitionEvent nodes inje |
Simulator
- Kind: class
- Import:
from qndk.simulator.simulator import Simulator
- Signature:
Simulator(pr: PartitionResult)
- Inherits:
ABC
- Raises:
TypeError
| Parameter |
Type |
Default |
Required |
pr |
PartitionResult |
`` |
required |
| Member |
Kind |
Signature |
Summary |
name |
method |
(self) -> str |
|
run_simulation |
method |
(self) -> SimulationResult |
|
StaticScheduler
- Kind: class
- Import:
from qndk.simulator.static import StaticScheduler
- Signature:
StaticScheduler(pr: PartitionResult)
- Inherits:
Simulator
| Parameter |
Type |
Default |
Required |
pr |
PartitionResult |
`` |
required |
| Member |
Kind |
Signature |
Summary |
name |
method |
(self) -> str |
|
run_simulation |
method |
(self) -> SimulationResult |
|
qndk.quantum_error_correction
Public API: EprDelivery, FixedIdleEpr, PoissonEpr, SurfaceCode, TlerConfig, TlerResult, TlerSweep, build_distributed_dag, fault_tolerant_encode, plot_comparison, plot_error_vs_latency_pareto, plot_ler_vs_distance_by_p, plot_min_distill_rounds_vs_distance, plot_threshold_grid, plot_threshold_vs_k, plot_vs_distance, tler
Quantum error correction: fault-tolerant layout and logical error budgets.
EprDelivery
- Kind: class
- Import:
from qndk.quantum_error_correction import EprDelivery
- Signature:
EprDelivery()
- Inherits:
ABC
An EPR delivery model.
| Member |
Kind |
Signature |
Summary |
label |
property |
|
Short form for plot legends and titles. |
predictor |
method |
(self) |
The threshold table this model's key indexes into. |
threshold_key |
method |
(self) -> tuple |
The key identifying this model's row in its threshold table. |
FixedIdleEpr
- Kind: class
- Import:
from qndk.quantum_error_correction import FixedIdleEpr
- Signature:
FixedIdleEpr(k_idle: int = 4, lam_seam: int = 4, threshold_csv: str = '<bundled data file>') -> None
- Inherits:
EprDelivery
Waiting for a pair is charged as idle noise, k_idle times the base rate. The circuit is untouched — this is a fudge factor, not a mechanism.
| Parameter |
Type |
Default |
Required |
k_idle |
int |
4 |
optional |
lam_seam |
int |
4 |
optional |
threshold_csv |
str |
'<bundled data file>' |
optional |
| Member |
Kind |
Signature |
Summary |
label |
property |
|
|
predictor |
method |
(self) -> ThresholdCache |
The threshold table this model's key indexes into. |
threshold_key |
method |
(self) -> tuple[int, int] |
The key identifying this model's row in its threshold table. |
PoissonEpr
- Kind: class
- Import:
from qndk.quantum_error_correction import PoissonEpr
- Signature:
PoissonEpr(mu: float, lam_seam: int = 1, policy: str = 'sync', threshold_csv: str = '<bundled data file>') -> None
- Inherits:
EprDelivery
Pairs arrive as a Poisson process at rate mu per syndrome round.
| Parameter |
Type |
Default |
Required |
mu |
float |
`` |
required |
lam_seam |
int |
1 |
optional |
policy |
str |
'sync' |
optional |
threshold_csv |
str |
'<bundled data file>' |
optional |
| Member |
Kind |
Signature |
Summary |
arrival_probability |
method |
(self, t_cyc: float = 1.0) -> float |
Probability at least one pair arrives during one syndrome round. |
label |
property |
|
|
predictor |
method |
(self) -> PoissonThresholds |
The threshold table this model's key indexes into. |
threshold_key |
method |
(self) -> tuple[str, float, int] |
The key identifying this model's row in its threshold table. |
SurfaceCode
- Kind: class
- Import:
from qndk.quantum_error_correction import SurfaceCode
- Signature:
SurfaceCode(d: 'int')
- Raises:
ValueError
Square-lattice surface code.
| Parameter |
Type |
Default |
Required |
d |
int |
`` |
required |
| Member |
Kind |
Signature |
Summary |
apply_decoder_circuit |
method |
(self, circuit=None) |
|
register_qiskit |
method |
(self, name: 'str' = 'sc') |
|
TlerConfig
- Kind: class
- Import:
from qndk.quantum_error_correction import TlerConfig
- Signature:
TlerConfig(p_min: float = 0.0001, p_max: float = 0.01, n_p_points: int = 200, approx_threshold: float = 0.1, per_gate_threshold: float = 0.001, magic_budget_fraction: float = 0.1) -> None
The analysis side of a Total Logical Error Rate calculation: the p sweep and the validity bounds. The seam physics lives on the EprDelivery model, and the factory on the network. tler() takes these fields as flat keywords.
| Parameter |
Type |
Default |
Required |
p_min |
float |
0.0001 |
optional |
p_max |
float |
0.01 |
optional |
n_p_points |
int |
200 |
optional |
approx_threshold |
float |
0.1 |
optional |
per_gate_threshold |
float |
0.001 |
optional |
magic_budget_fraction |
float |
0.1 |
optional |
| Member |
Kind |
Signature |
Summary |
p_array |
method |
(self) -> numpy.ndarray |
The physical error rate sweep this config describes. |
TlerResult
- Kind: class
- Import:
from qndk.quantum_error_correction import TlerResult
- Signature:
TlerResult(p_array: numpy.ndarray, local: numpy.ndarray, remote: numpy.ndarray, mem: numpy.ndarray, magic: numpy.ndarray, total: numpy.ndarray, num_local: int, num_remote: int, num_magic: int, distill_rounds: numpy.ndarray, idle_time: float, d: int, epr: object, config: TlerConfig = <factory>, code: object = None) -> None
Total Logical Error Rate breakdown over a physical error rate sweep.
| Parameter |
Type |
Default |
Required |
p_array |
ndarray |
`` |
required |
local |
ndarray |
`` |
required |
remote |
ndarray |
`` |
required |
mem |
ndarray |
`` |
required |
magic |
ndarray |
`` |
required |
total |
ndarray |
`` |
required |
num_local |
int |
`` |
required |
num_remote |
int |
`` |
required |
num_magic |
int |
`` |
required |
distill_rounds |
ndarray |
`` |
required |
idle_time |
float |
`` |
required |
d |
int |
`` |
required |
epr |
object |
`` |
required |
config |
TlerConfig |
<factory> |
optional |
code |
object |
None |
optional |
| Member |
Kind |
Signature |
Summary |
label |
property |
|
Short description of what was priced, for plots. |
num_mem |
property |
|
Number of idle syndrome rounds. |
plot |
method |
(self, **kwargs) |
Plot this result's component breakdown. See _plot for keyword args. |
validity |
method |
(self) -> dict |
Where the additive TLER proxy holds. See check_approximation_validity for the returned keys. |
TlerSweep
- Kind: class
- Import:
from qndk.quantum_error_correction import TlerSweep
- Signature:
TlerSweep(result: 'SimulationResult', *, code: Sequence[ForwardRef('SurfaceCode')], epr: Sequence[EprDelivery], **tler_kwargs)
- Raises:
ValueError
Runs tler() over the grid of codes x EPR delivery models, and groups the plots that compare across that grid onto one object instead of three standalone functions each needing the same list built and passed in by hand:
| Parameter |
Type |
Default |
Required |
result |
SimulationResult |
`` |
required |
code |
typing.Sequence[ForwardRef('SurfaceCode')] |
`` |
required |
epr |
typing.Sequence[EprDelivery] |
`` |
required |
**tler_kwargs |
| |
kwargs |
|
| Member |
Kind |
Signature |
Summary |
plot_comparison |
method |
(self, **kwargs) |
See plot_comparison. |
plot_threshold_grid |
method |
(self, **kwargs) |
See plot_threshold_grid. |
plot_threshold_vs_k |
method |
(self, **kwargs) |
See plot_threshold_vs_k. |
plot_vs_distance |
method |
(self, **kwargs) |
See plot_vs_distance. |
build_distributed_dag
- Kind: function
- Import:
from qndk.quantum_error_correction import build_distributed_dag
- Signature:
build_distributed_dag(circuit: qiskit.circuit.quantumcircuit.QuantumCircuit, network: QuantumNetwork, ancilla_config=None, verbose=False, rng=None, logical_to_physical_partitioning: dict = None)
- Raises:
Exception
Build the distributed DAG for a given circuit and hardware configuration.
| Parameter |
Type |
Default |
Required |
circuit |
QuantumCircuit |
`` |
required |
network |
QuantumNetwork |
`` |
required |
ancilla_config |
`` |
None |
optional |
verbose |
`` |
False |
optional |
rng |
`` |
None |
optional |
logical_to_physical_partitioning |
dict |
None |
optional |
fault_tolerant_encode
- Kind: function
- Import:
from qndk.quantum_error_correction import fault_tolerant_encode
- Signature:
fault_tolerant_encode(circuit, network: QuantumNetwork, partitioner: Type[Partitioner] = None, code: SurfaceCode = None, num_ancilla: int = None, seed: int = None) -> PartitionResult
- Raises:
Exception
Fault-tolerant QEC layout on all-to-all or grid-connected QPUs.
| Parameter |
Type |
Default |
Required |
circuit |
| |
required |
|
network |
QuantumNetwork |
`` |
required |
partitioner |
typing.Type[Partitioner] |
None |
optional |
code |
SurfaceCode |
None |
optional |
num_ancilla |
int |
None |
optional |
seed |
int |
None |
optional |
plot_comparison
- Kind: function
- Import:
from qndk.quantum_error_correction import plot_comparison
- Signature:
plot_comparison(results, label_fn=None, save_as: str = None, show: bool = True, block: bool = False, ax=None)
- Raises:
ValueError
Plot LER_total for several TlerResults on shared axes.
| Parameter |
Type |
Default |
Required |
results |
| |
required |
|
label_fn |
`` |
None |
optional |
save_as |
str |
None |
optional |
show |
bool |
True |
optional |
block |
bool |
False |
optional |
ax |
`` |
None |
optional |
plot_error_vs_latency_pareto
- Kind: function
- Import:
from qndk.quantum_error_correction import plot_error_vs_latency_pareto
- Signature:
plot_error_vs_latency_pareto(results, latencies, label_fn=None, p: float = None, save_as: str = None, show: bool = True, block: bool = False, ax=None)
- Raises:
ValueError
Scatter TLER against wall-clock latency for several (rounds, d) choices -- the tradeoff frontier a single-axis d-sweep or rounds-sweep cannot show, since each of those varies one knob at a time.
| Parameter |
Type |
Default |
Required |
results |
| |
required |
|
latencies |
| |
required |
|
label_fn |
`` |
None |
optional |
p |
float |
None |
optional |
save_as |
str |
None |
optional |
show |
bool |
True |
optional |
block |
bool |
False |
optional |
ax |
`` |
None |
optional |
plot_ler_vs_distance_by_p
- Kind: function
- Import:
from qndk.quantum_error_correction import plot_ler_vs_distance_by_p
- Signature:
plot_ler_vs_distance_by_p(results, mark_probability_ceiling: bool = False, save_as: str = None, show: bool = True, block: bool = False, ax=None)
- Raises:
ValueError
Plot LER_total vs code distance d, one line per physical error rate p.
| Parameter |
Type |
Default |
Required |
results |
| |
required |
|
mark_probability_ceiling |
bool |
False |
optional |
save_as |
str |
None |
optional |
show |
bool |
True |
optional |
block |
bool |
False |
optional |
ax |
`` |
None |
optional |
plot_min_distill_rounds_vs_distance
- Kind: function
- Import:
from qndk.quantum_error_correction import plot_min_distill_rounds_vs_distance
- Signature:
plot_min_distill_rounds_vs_distance(p: float, distances, num_magic: int, num_local: int, fraction: float = 0.1, max_rounds: int = 10, save_as: str = None, show: bool = True, block: bool = False, ax=None)
Plot how many 15-to-1 distillation rounds a factory needs at each code distance to keep magic-state failure within fraction of LER_local.
| Parameter |
Type |
Default |
Required |
p |
float |
`` |
required |
distances |
| |
required |
|
num_magic |
int |
`` |
required |
num_local |
int |
`` |
required |
fraction |
float |
0.1 |
optional |
max_rounds |
int |
10 |
optional |
save_as |
str |
None |
optional |
show |
bool |
True |
optional |
block |
bool |
False |
optional |
ax |
`` |
None |
optional |
plot_threshold_grid
- Kind: function
- Import:
from qndk.quantum_error_correction import plot_threshold_grid
- Signature:
plot_threshold_grid(predictor=None, k_values=None, lam_seam: int = 1, distances=(5, 9, 15, 21), p_values=None, save_as: str = None, show: bool = True, block: bool = False)
- Raises:
ValueError
Per-k_idle panel grid: fitted LER vs p at several code distances, with the fitted threshold p_th marked. Reproduces the TLER paper's Fig. 11 full grid — plot_threshold_vs_k already draws the top-level p_th-vs-k curve this is the per-distance detail underneath.
| Parameter |
Type |
Default |
Required |
predictor |
`` |
None |
optional |
k_values |
`` |
None |
optional |
lam_seam |
int |
1 |
optional |
distances |
`` |
(5, 9, 15, 21) |
optional |
p_values |
`` |
None |
optional |
save_as |
str |
None |
optional |
show |
bool |
True |
optional |
block |
bool |
False |
optional |
plot_threshold_vs_k
- Kind: function
- Import:
from qndk.quantum_error_correction import plot_threshold_vs_k
- Signature:
plot_threshold_vs_k(predictor=None, save_as: str = None, show: bool = True, block: bool = False, ax=None)
Plot the fitted remote threshold p_th vs k_idle, one line per lam_seam.
| Parameter |
Type |
Default |
Required |
predictor |
`` |
None |
optional |
save_as |
str |
None |
optional |
show |
bool |
True |
optional |
block |
bool |
False |
optional |
ax |
`` |
None |
optional |
plot_vs_distance
- Kind: function
- Import:
from qndk.quantum_error_correction import plot_vs_distance
- Signature:
plot_vs_distance(results, p: float = None, save_as: str = None, show: bool = True, block: bool = False, ax=None)
- Raises:
ValueError
Plot LER_total vs code distance d, one line per EPR delivery model.
| Parameter |
Type |
Default |
Required |
results |
| |
required |
|
p |
float |
None |
optional |
save_as |
str |
None |
optional |
show |
bool |
True |
optional |
block |
bool |
False |
optional |
ax |
`` |
None |
optional |
tler
- Kind: function
- Import:
from qndk.quantum_error_correction import tler
- Signature:
tler(result: 'SimulationResult', *, code: SurfaceCode, epr: EprDelivery, distill_rounds: int = None, **sweep) -> TlerResult
- Raises:
ValueError
Compute the Total Logical Error Rate breakdown for a SimulationResult.
| Parameter |
Type |
Default |
Required |
result |
SimulationResult |
`` |
required |
code |
SurfaceCode |
`` |
required |
epr |
EprDelivery |
`` |
required |
distill_rounds |
int |
None |
optional |
**sweep |
| |
kwargs |
|
qndk.batchscheduler
Public API: QuantumBatchScheduler, job_schedule_adapter
QuantumBatchScheduler
- Kind: class
- Import:
from qndk.batchscheduler.batch_scheduler import QuantumBatchScheduler
- Signature:
QuantumBatchScheduler(network: QuantumNetwork, partitioner_fn: Callable[[Any, Any], Any], non_local_multiplier: float = 10.0, job_schedule_fn: Optional[Callable[[Any, Any, Dict[str, Any]], Dict[str, Any]]] = None, schedule_context: Optional[Dict[str, Any]] = None)
Scheduler with two algorithms: 1) Strict FIFO, continuous admission (head-of-line blocking). 2) Heuristic reordering + continuous admission (non-strict).
| Parameter |
Type |
Default |
Required |
network |
QuantumNetwork |
`` |
required |
partitioner_fn |
typing.Callable[[typing.Any, typing.Any], typing.Any] |
`` |
required |
non_local_multiplier |
float |
10.0 |
optional |
job_schedule_fn |
typing.Optional[typing.Callable[[typing.Any, typing.Any, typing.Dict[str, typing.Any]], typing.Dict[str, typing.Any]]] |
None |
optional |
schedule_context |
typing.Optional[typing.Dict[str, typing.Any]] |
None |
optional |
| Member |
Kind |
Signature |
Summary |
run_batch_optimized |
method |
(self, jobs: List[Dict[str, Any]], heuristic: str = 'hybrid') -> Dict[str, Any] |
|
run_fifo_strict |
method |
(self, jobs: List[Dict[str, Any]]) -> Dict[str, Any] |
FIFO (preserve arrival order), but admit as many circuits as possible at the current time before advancing. Co |
run_fifo_strict_old |
method |
(self, jobs: List[Dict[str, Any]]) -> Dict[str, Any] |
|
job_schedule_adapter
- Kind: function
- Import:
from qndk.batchscheduler.job_schedule_adapter import job_schedule_adapter
- Signature:
job_schedule_adapter(transpiled_circuit: Any, partition_result: Any, context: Optional[Dict[str, Any]] = None) -> Dict[str, Any]
Adapter that runs the StaticScheduler simulator and returns metrics for the scheduler.
| Parameter |
Type |
Default |
Required |
transpiled_circuit |
typing.Any |
`` |
required |
partition_result |
typing.Any |
`` |
required |
context |
typing.Optional[typing.Dict[str, typing.Any]] |
None |
optional |
qndk.analysis
Public API: Analyzer
Analyzer
- Kind: class
- Import:
from qndk.analysis.analyzer import Analyzer
- Signature:
Analyzer(run_id: 'Optional[str]' = None, base_dir: 'str' = 'runs')
Orchestrates recording, querying, plotting, and serialization of pipeline metrics.
| Parameter |
Type |
Default |
Required |
run_id |
Optional[str] |
None |
optional |
base_dir |
str |
'runs' |
optional |
| Member |
Kind |
Signature |
Summary |
find_run_keys |
method |
(self, *, topology_type: 'Optional[str]' = None, topology_id: 'Optional[str]' = None, algorithm: 'Optional[str]' = None, heuristic: 'Optional[str]' = None) -> 'List[str]' |
|
get_job_rows |
method |
(self, job_id: 'str', run_key: 'Optional[str]' = None) |
Return all per-circuit (job) rows matching job_id (optionally filtered by run_key). |
get_jobs_df |
method |
(self, filters: 'Optional[Dict[str, Any]]' = None) |
|
get_runs_df |
method |
(self, filters: 'Optional[Dict[str, Any]]' = None) |
|
job_specifics |
method |
(self, job_id: 'str', run_key: 'Optional[str]' = None, return_df: 'bool' = False) |
Print a compact summary for a circuit (job) and optionally return the matching rows as a DataFrame. |
plot_avg_latency_by_algo_topo |
method |
(self, df=None, *, title='Average Latency by Topology and Algorithm', block: 'bool' = False) |
|
plot_circuit_timeline |
method |
(self, run_key: 'str', *, title_prefix: 'str' = 'Circuit Timeline') |
Interactive Gantt-like chart (Plotly) of circuit start/finish times using horizontal bars. |
plot_circuit_timeline_old |
method |
(self, run_key: 'str', *, title_prefix: 'str' = 'Circuit Timeline') |
Interactive Gantt-like chart (Plotly) of circuit start/finish times using horizontal bars. |
plot_latency_per_job |
method |
(self, run_key: 'str', *, title_prefix='Per-Circuit Latency') |
Interactive bar chart (Plotly) of per-circuit average latency, sorted by start_time. |
plot_levels_utilization |
method |
(self, run_key: 'str', *, total_qubits: 'int | None' = None, title_prefix: 'str' = 'QDC Qubit Utilization') |
Interactive per-level utilization overlay (Plotly). Prefers recorded levels; otherwise derives from rows (requ |
plot_levels_utilization_smooth |
method |
(self, run_key: 'str', *, total_qubits: 'int | None' = None, title_prefix: 'str' = 'Per-Level Utilization', grid_points: 'int' = 400, smooth: 'str' = 'ema', smooth_window_frac: 'float' = 0.1) |
Per-level utilization with a smooth overlay (EMA/Gaussian/Rolling) to reduce spikiness. |
plot_levels_wastage_interactive |
method |
(self, run_key: 'str', *, total_qubits: 'Optional[int]' = None, title_prefix='Per-Level Wastage') |
Interactive per-level wastage bars (Plotly). Prefers recorded levels; otherwise derives from rows (requires to |
plot_makespan_by_algo_topo |
method |
(self, df=None, *, title='Makespan by Topology and Algorithm', block: 'bool' = False) |
|
plot_switch_events_per_job_stacked |
method |
(self, run_key: 'str', *, normalize: 'bool' = False, title_prefix='Per-Circuit Switch Events') |
Interactive stacked (TEL+NIR) Plotly chart of per-circuit switch events, sorted by start_time. |
plot_switch_events_per_job_stacked_old |
method |
(self, run_key: 'str', *, normalize: 'bool' = False, title_prefix='Per-Circuit Switch Events') |
Interactive stacked (TEL+NIR) Plotly chart of per-circuit switch events, sorted by start_time. |
plot_switch_events_stacked_by_algo_topo |
method |
(self, df=None, *, title='Switch Events (NIR+TEL) by Topology and Algorithm', block: 'bool' = False) |
|
plot_wastage_by_algo_topo |
method |
(self, df=None, *, title='Wastage per Qubit by Topology and Algorithm', block: 'bool' = False) |
|
record_circuit |
method |
(self, circuit_obj: 'Any', *, name: 'Optional[str]' = None) -> 'None' |
|
record_network |
method |
(self, network_obj: 'Any') -> 'None' |
|
record_partition |
method |
(self, algorithm: 'str', partition_result: 'Any', *, include_mappings: 'bool' = False) -> 'None' |
|
record_run_global |
method |
(self, run_key: 'str', *, topology_type: 'str', topology_id: 'str', algorithm: 'str', heuristic: 'Optional[str]' = None, shape: 'Optional[Dict[str, Any]]' = None, makespan: 'Optional[float]' = None, wastage_per_qubit: 'Optional[float]' = None, avg_latency_over_jobs: 'Optional[float]' = None, switch_events_sum: 'Optional[float]' = None, nir_switch_events_sum: 'Optional[float]' = None, tel_switch_events_sum: 'Optional[float]' = None, jobs_started: 'Optional[int]' = None, total_jobs: 'Optional[int]' = None, extras: 'Optional[Dict[str, Any]]' = None) -> 'None' |
|
record_run_jobs |
method |
(self, run_key: 'str', per_job_rows: 'List[Dict[str, Any]]') -> 'None' |
|
record_schedule |
method |
(self, algorithm: 'str', schedule_obj: 'Any', *, makespan: 'Optional[float]' = None, wastage_per_qubit: 'Optional[float]' = None, job_results: 'Optional[List[Dict[str, Any]]]' = None) -> 'None' |
|
record_topology |
method |
(self, topology_obj: 'Any', *, topology_type: 'Optional[str]' = None, topology_id: 'Optional[str]' = None) -> 'None' |
|
record_transpile |
method |
(self, transpiled_obj: 'Any') -> 'None' |
|
save_json |
method |
(self, filename: 'str' = '<bundled data file>') -> 'str' |
|
summarize_runs |
method |
(self, by: 'Tuple[str, ...]' = ('topology_type', 'topology_id', 'algorithm'), metrics: 'Tuple[str, ...]' = ('makespan', 'wastage_per_qubit', 'avg_latency_over_jobs', 'switch_events_sum'), agg: 'str' = 'mean') |
|
to_dict |
method |
(self) -> 'Dict[str, Any]' |
Return a sanitized dict containing: session record, multi-run tables, artifacts, errors, run_id. |
qndk.compile
Public API: ExecutionPlan, OpCounts, RoundRobinPool, new_exec_plan, simulate_circuit
ExecutionPlan
- Kind: class
- Import:
from qndk.compile.distributed import ExecutionPlan
- Signature:
ExecutionPlan(circuit: qiskit.circuit.quantumcircuit.QuantumCircuit, partition_result: PartitionResult, stats: Optional[OpCounts] = None)
| Parameter |
Type |
Default |
Required |
circuit |
QuantumCircuit |
`` |
required |
partition_result |
PartitionResult |
`` |
required |
stats |
typing.Optional[OpCounts] |
None |
optional |
| Member |
Kind |
Signature |
Summary |
draw_qiskit_dag |
method |
(self, block: bool = False, figsize: Optional[tuple[float, float]] = None, dpi: Optional[float] = None) |
|
simulate |
method |
(self, shots: int = 128) -> qiskit.primitives.containers.bit_array.BitArray |
|
to_json |
method |
(self) -> str |
|
OpCounts
- Kind: class
- Import:
from qndk.compile.distributed import OpCounts
- Signature:
OpCounts(entanglements: int = 0, two_qubit_gates: int = 0, one_qubit_gates: int = 0, measurements: int = 0, unique_op_types: set = <factory>) -> None
| Parameter |
Type |
Default |
Required |
entanglements |
int |
0 |
optional |
two_qubit_gates |
int |
0 |
optional |
one_qubit_gates |
int |
0 |
optional |
measurements |
int |
0 |
optional |
unique_op_types |
set |
<factory> |
optional |
| Member |
Kind |
Signature |
Summary |
to_json_obj |
method |
(self) -> dict |
|
RoundRobinPool
- Kind: class
- Import:
from qndk.compile.distributed import RoundRobinPool
- Signature:
RoundRobinPool()
Maps QPU IDs to a list of resources and tracks a per-QPU round-robin index for sequential allocation. Calling next() advances the index and wraps around, so resources are reused evenly across requests.
| Member |
Kind |
Signature |
Summary |
add |
method |
(self, qpu: str, item) -> None |
|
all_for_qpu |
method |
(self, qpu: str) -> list |
|
next |
method |
(self, qpu: str) |
|
per_qpu_items |
method |
(self) |
|
new_exec_plan
- Kind: function
- Import:
from qndk.compile.distributed import new_exec_plan
- Signature:
new_exec_plan(partition: PartitionResult) -> ExecutionPlan
- Raises:
Exception, ValueError
| Parameter |
Type |
Default |
Required |
partition |
PartitionResult |
`` |
required |
simulate_circuit
- Kind: function
- Import:
from qndk.compile.distributed import simulate_circuit
- Signature:
simulate_circuit(qc: Union[qiskit.circuit.quantumcircuit.QuantumCircuit, QiskitCircuit, TranspiledCircuit], shots: int = 128) -> qiskit.primitives.containers.bit_array.BitArray
- Raises:
Exception, TypeError
| Parameter |
Type |
Default |
Required |
qc |
typing.Union[qiskit.circuit.quantumcircuit.QuantumCircuit, QiskitCircuit, TranspiledCircuit] |
`` |
required |
shots |
int |
128 |
optional |
qndk.encoders
Public API: dag_encoder, encode_circuit, encode_network, load_dag_encoder, load_network_encoder, network_encoder, preload_encoders
qndk.encoders — learned representations for quantum circuits and network states.
dag_encoder
- Kind: function
- Import:
from qndk.encoders import dag_encoder
- Signature:
dag_encoder(circuit, device='cpu', return_full=False)
Qiskit circuit -> frozen embeddings dict.
| Parameter |
Type |
Default |
Required |
circuit |
| |
required |
|
device |
`` |
'cpu' |
optional |
return_full |
`` |
False |
optional |
encode_circuit
- Kind: function
- Import:
from qndk.encoders import encode_circuit
- Signature:
encode_circuit(circuit, *, device='cpu', return_full=False)
- Raises:
TypeError
Embed a quantum circuit's DAG structure into a learned representation.
| Parameter |
Type |
Default |
Required |
circuit |
| |
required |
|
device |
`` |
'cpu' |
optional |
return_full |
`` |
False |
optional |
encode_network
- Kind: function
- Import:
from qndk.encoders import encode_network
- Signature:
encode_network(network, *, device='cpu', which='graph')
Embed a quantum datacenter network state into a learned representation.
| Parameter |
Type |
Default |
Required |
network |
| |
required |
|
device |
`` |
'cpu' |
optional |
which |
`` |
'graph' |
optional |
load_dag_encoder
- Kind: function
- Import:
from qndk.encoders import load_dag_encoder
- Signature:
load_dag_encoder(path='<bundled data file>', device='cpu')
| Parameter |
Type |
Default |
Required |
path |
`` |
'<bundled data file>' |
optional |
device |
`` |
'cpu' |
optional |
load_network_encoder
- Kind: function
- Import:
from qndk.encoders import load_network_encoder
- Signature:
load_network_encoder(path='<bundled data file>', device='cpu')
| Parameter |
Type |
Default |
Required |
path |
`` |
'<bundled data file>' |
optional |
device |
`` |
'cpu' |
optional |
network_encoder
- Kind: function
- Import:
from qndk.encoders import network_encoder
- Signature:
network_encoder(net, device='cpu', which='graph')
qndk Network -> frozen embedding. which: 'graph'|'graph_proj'|'rl'.
| Parameter |
Type |
Default |
Required |
net |
| |
required |
|
device |
`` |
'cpu' |
optional |
which |
`` |
'graph' |
optional |
preload_encoders
- Kind: function
- Import:
from qndk.encoders import preload_encoders
- Signature:
preload_encoders(device='cpu', dag=True, network=True)
Eagerly load encoder checkpoints so the first encode_* call in a hot loop (e.g. per-gate visualization) doesn't pay one-time model-load cost.
| Parameter |
Type |
Default |
Required |
device |
`` |
'cpu' |
optional |
dag |
`` |
True |
optional |
network |
`` |
True |
optional |
qndk.optimizers
Public API: RackILP, RackILPResult
RackILP
- Kind: class
- Import:
from qndk.optimizers.placement_ilp import RackILP
- Signature:
RackILP(F_intra: 'float' = 0.9, F_inter: 'float' = 0.85, time_limit_ms: 'Optional[int]' = None, solver_name: 'str' = 'CBC_MIXED_INTEGER_PROGRAMMING', alpha: 'float' = 1.0, beta: 'float' = 1.0, prune_percentile: 'float' = 0.0, num_starts: 'int' = 4, local_refine: 'bool' = True, refine_moves_limit: 'int' = 200, random_seed: 'int' = 1)
- Raises:
ValueError
Latency-aware rack placement with: - Multi-start greedy warm-starts (different heuristics). - Optional local refinement (fast swap/move hill-climb). - Hotspot balancing via max rack-pair load term. - Pruning of pair variables for faster MIP.
| Parameter |
Type |
Default |
Required |
F_intra |
float |
0.9 |
optional |
F_inter |
float |
0.85 |
optional |
time_limit_ms |
Optional[int] |
None |
optional |
solver_name |
str |
'CBC_MIXED_INTEGER_PROGRAMMING' |
optional |
alpha |
float |
1.0 |
optional |
beta |
float |
1.0 |
optional |
prune_percentile |
float |
0.0 |
optional |
num_starts |
int |
4 |
optional |
local_refine |
bool |
True |
optional |
refine_moves_limit |
int |
200 |
optional |
random_seed |
int |
1 |
optional |
| Member |
Kind |
Signature |
Summary |
solve |
method |
(self, epr: 'List[List[float]]', num_ToR: 'List[int]') -> 'RackILPResult' |
|
RackILPResult
- Kind: class
- Import:
from qndk.optimizers.placement_ilp import RackILPResult
- Signature:
RackILPResult(part_to_rack: 'Dict[int, int]', x_opt: 'List[List[int]]', objective_value: 'float', status: 'str')
| Parameter |
Type |
Default |
Required |
part_to_rack |
Dict[int, int] |
`` |
required |
x_opt |
List[List[int]] |
`` |
required |
objective_value |
float |
`` |
required |
status |
str |
`` |
required |
qndk.utils
Public API: ordered_key
ordered_key
- Kind: function
- Import:
from qndk.utils import ordered_key
- Signature:
ordered_key(a: Any, b: Any) -> tuple
Avoids str conversion, sorted(), and f-string formatting that
| Parameter |
Type |
Default |
Required |
a |
typing.Any |
`` |
required |
b |
typing.Any |
`` |
required |