qubosolver.protocols
qubosolver.protocols
Structural protocols for the QUBO solver, using PEP 544 Protocol typing.
Unlike nominal typing (C++/Java), where a class must explicitly inherit from an
interface, Python's Protocol allows "static duck typing": a class is compatible
with a protocol if it implements the same methods with matching signatures,
regardless of its inheritance tree. mypy validates the full method contract
(argument names, types, and return type); when runtime type checking is enabled,
isinstance checks against the protocol are also supported (see
typing.Protocol).
Example
Classes:
-
Backend–Structural protocol for quantum backends.
Backend
Structural protocol for quantum backends.
Any object that implements run with the expected signature is considered a
Backend, without requiring explicit subclassing. This enables duck-typed
compatibility checks (via isinstance when beartype runtime checking is
active, or static type checking via mypy/pyright).
Typical implementations wrap a remote or local quantum execution engine (e.g. a Qoolqit emulator or a real QPU) and return a handle to the asynchronous computation.
Methods:
-
run–Submit a quantum program for execution.
run
run(program: qoolqit.QuantumProgram) -> job.Job[Results]
Submit a quantum program for execution.
Parameters:
-
program(qoolqit.QuantumProgram) –The compiled quantum program to execute.
Returns:
-
job.Job[Results]–A job wrapping the
qoolqit.execution.Resultsthat will be populated upon completion.