Backends¶
A Backend is the execution contract. Subclasses
implement run_circuit (raw gate matrices) or run (a bound
QuantumCircuit); the base provides the plan-level
surface:
capabilities— aBackendCapabilitiesdescriptor.validate(plan) -> list[str]— plan/backend compatibility diagnostics.supports(plan) -> bool— quick plan capability check.execute(plan) -> BackendResult— the canonical single-call entry point (validates, binds viaplan.bound(), runs).
Results¶
BackendResult carries the state vector / density
matrix, raw samples, measurement counts / probabilities, labeled
expectations, eigenvalues, a JSON-safe native payload, and the
shots / seed / target_name of the run. counts is a dict
mapping measured bitstrings to shot counts, ordered big-endian;
get_counts() is an equivalent method accessor and state aliases the
state vector. Everything serializes via to_dict() / to_json().
Circuit measurement annotations (qc.measure / qc.measure_all) are
honored by Backend.run: a proper subset restricts the returned counts to
those qubits (see Execution Core).
Built-ins¶
StatevectorBackend— exact state-vector simulation.DensityMatrixBackend— density-matrix (mixed-state) simulation, including noise channels.MPSBackend/TreeTensorNetworkBackend— approximate tensor-network simulators.MockBackend— deterministic stub for tests and pipelines.LocalSimulatorBackend— the reference local simulator.
from microquantum import ExecutionPlan, QuantumCircuit, StatevectorBackend
qc = QuantumCircuit(2).h(0).cx(0, 1)
backend = StatevectorBackend()
result = backend.run(qc, shots=1024, seed=1)
print(result.state)
print(result.counts)
print(result.most_frequent())
plan = ExecutionPlan.from_circuit(qc, backend=backend, shots=512, seed=1)
print(backend.validate(plan)) # []
print(backend.supports(plan)) # True
print(backend.execute(plan).counts == backend.run(qc, shots=512, seed=1).counts) # same data path
Noise¶
NoiseModel and NoiseChannel
attach to density-matrix / tensor-network simulators for noisy execution
studies.
Interoperability¶
Executor and continuous-focused backends stay NumPy-only; GPU acceleration is
opt-in at the array layer (set_array_backend()). Vendor
execution happens through the provider boundary (Providers).