qnetbench.api¶
The portable API shim. This package and qnetbench.trace are the two
frozen contracts of the suite — applications import from here and nowhere else, and
a backend is free to implement the surface however it likes.
Narrative guide: Applications and Extending the suite.
qnetbench.api
¶
qnetbench.api — the portable API shim.
This package and qnetbench.trace are the two frozen contracts of the suite.
Applications import only from here.
ViolationKind
module-attribute
¶
Application
¶
Bases: Protocol
A benchmark application.
roles() names the participants (e.g. ["alice", "bob"]); the harness maps
each role onto a node and calls run once per role, concurrently.
ClassicalSocket
¶
EntanglementHandle
dataclass
¶
EntanglementHandle(
req_id: int,
fidelity: float,
latency: Duration,
pair_age: Duration,
qubit: Qubit | None = None,
outcome: int | None = None,
violations: list[ViolationKind] = list(),
)
The result of one delivered entangled pair, from the local host's side.
For purpose="keep", qubit is the live local half. For purpose="measure",
the backend measured on delivery and outcome holds the bit (qubit is None).
violations is non-empty when the delivery broke its Demand contract; the
handle is still returned so applications can decide how to degrade.
violations
class-attribute
instance-attribute
¶
violations: list[ViolationKind] = field(
default_factory=list
)
EPRSocket
¶
Bases: Protocol
Requests entanglement with one peer, under a demand contract.
request
¶
request(n: int, demand: Demand) -> list[EntanglementHandle]
Source code in qnetbench/api/host.py
Host
¶
Bases: Protocol
Everything an application role can do. Bound to one node for one run.
epr_socket
¶
Source code in qnetbench/api/host.py
classical_socket
¶
classical_socket(peer: NodeId) -> ClassicalSocket
Source code in qnetbench/api/host.py
qsend
¶
Source code in qnetbench/api/host.py
qrecv
¶
Source code in qnetbench/api/host.py
Qubit
¶
Bases: Protocol
A local qubit handle. Physics lives in the backend; the app only sees ops.
AppOutcome
¶
Bases: BaseModel
What an application role reports when it finishes.
utility is application-defined in [0, 1] and is the quantity the
staleness/fidelity curves are plotted against.
Basis
¶
Demand
¶
Bases: BaseModel
The contract attached to a request for entanglement.
This is what makes the suite discriminative: schedulers read it, the trace records requested-vs-delivered against it, and the characterizer mines its distribution across an application's run.
Gate
¶
Bases: str, Enum
Single-qubit gates. Two-qubit gates are methods on Qubit (cnot/cz).
Value types¶
qnetbench.api.types
¶
Core value types for the portable API shim.
This module has no dependencies inside qnetbench, so both qnetbench.api and
qnetbench.trace can build on it without a cycle.
ViolationKind
module-attribute
¶
Basis
¶
Gate
¶
Bases: str, Enum
Single-qubit gates. Two-qubit gates are methods on Qubit (cnot/cz).
Demand
¶
Bases: BaseModel
The contract attached to a request for entanglement.
This is what makes the suite discriminative: schedulers read it, the trace records requested-vs-delivered against it, and the characterizer mines its distribution across an application's run.
AppOutcome
¶
Bases: BaseModel
What an application role reports when it finishes.
utility is application-defined in [0, 1] and is the quantity the
staleness/fidelity curves are plotted against.
The runtime surface¶
qnetbench.api.host
¶
The runtime surface an application sees. Applications program against these Protocols and never import a backend or a simulator.
Qubit
¶
Bases: Protocol
A local qubit handle. Physics lives in the backend; the app only sees ops.
EntanglementHandle
dataclass
¶
EntanglementHandle(
req_id: int,
fidelity: float,
latency: Duration,
pair_age: Duration,
qubit: Qubit | None = None,
outcome: int | None = None,
violations: list[ViolationKind] = list(),
)
The result of one delivered entangled pair, from the local host's side.
For purpose="keep", qubit is the live local half. For purpose="measure",
the backend measured on delivery and outcome holds the bit (qubit is None).
violations is non-empty when the delivery broke its Demand contract; the
handle is still returned so applications can decide how to degrade.
violations
class-attribute
instance-attribute
¶
violations: list[ViolationKind] = field(
default_factory=list
)
EPRSocket
¶
Bases: Protocol
Requests entanglement with one peer, under a demand contract.
request
¶
request(n: int, demand: Demand) -> list[EntanglementHandle]
Source code in qnetbench/api/host.py
ClassicalSocket
¶
Host
¶
Bases: Protocol
Everything an application role can do. Bound to one node for one run.
epr_socket
¶
Source code in qnetbench/api/host.py
classical_socket
¶
classical_socket(peer: NodeId) -> ClassicalSocket
Source code in qnetbench/api/host.py
qsend
¶
Source code in qnetbench/api/host.py
qrecv
¶
Source code in qnetbench/api/host.py
The application contract¶
qnetbench.api.application
¶
The application contract. An application is written once here and runs on any backend, under any arbitration mode.
Application
¶
Bases: Protocol
A benchmark application.
roles() names the participants (e.g. ["alice", "bob"]); the harness maps
each role onto a node and calls run once per role, concurrently.