Choosing a Backend
By default PRISM-Q inspects the circuit and picks a backend. Name one when you know something the dispatcher cannot infer, or to benchmark a specific representation.
Let it choose
#![allow(unused)] fn main() { use prism_q::simulate; let result = simulate(&circuit).seed(42).run().unwrap(); // BackendKind::Auto }
Auto reads the circuit's structure and the statevector memory cap. A circuit with no entangling gates runs as a product state and a Clifford circuit on a stabilizer tableau. Past the memory cap, a circuit that keeps few basis states goes to the sparse backend and the rest to MPS at bond 256. Below it, a circuit with partly independent registers runs factored and everything else on the dense statevector. The decision tree draws these steps with their thresholds.
Some routes sit outside the tree:
- A Clifford circuit of 16 or more qubits that splits into independent blocks goes to
FactoredStabilizer. - Shots on a Clifford circuit go to the
CompiledStabilizersampler, which compiles the measurement record once and draws every shot from it. - On a Clifford+T circuit with few T gates, shots can take the stabilizer-rank sampler, and marginals at 12 qubits and above take deterministic Pauli propagation.
- Expectation and marginal queries go to the tensor network when its planned contraction stays inside the peak bound.
Probabilities always come from the tree. The memory cap is half of physical memory,
about 29 qubits on a 16 GiB host, unless PRISM_MAX_SV_QUBITS sets it.
Choose explicitly
#![allow(unused)] fn main() { use prism_q::{simulate, BackendKind}; let result = simulate(&circuit) .backend(BackendKind::Stabilizer) .seed(42) .run() .unwrap(); }
From Python, pass a BackendKind constructor such as BackendKind.stabilizer() to
.backend(...).
Symptom to backend
| If your circuit... | Use | Why |
|---|---|---|
| Is Clifford only (H, S, CX, CZ, ...) | Stabilizer | O(n²), scales to thousands of qubits |
| Is Clifford only and splits into independent blocks | FactoredStabilizer | One tableau per block |
| Has no entangling gates | ProductState | O(n), one state per qubit |
| Is dense and fits the memory cap | Statevector | Exact, fastest for the general case |
| Stays concentrated in few basis states | Sparse | O(k) in nonzero amplitudes |
| Has low entanglement but many qubits | Mps { max_bond_dim } | Polynomial memory in bond dimension |
| Splits into independent registers | Factored | Simulates blocks separately, merges lazily |
| Has low treewidth and you need an expectation or marginal | TensorNetwork | Contracts only what the query reads |
| Needs exact noisy probabilities or expectations | DensityMatrix | Evolves the mixed state once, 4ⁿ entries |
| Is Clifford + a few T gates | See Clifford+T | Beats a dense statevector |
ProductState errors on any entangling gate. Auto selects it only for circuits that
have none; choose it explicitly only for a circuit that stays a product state
throughout.
Scaling
| Backend | Memory | Ceiling |
|---|---|---|
| Statevector | The memory cap: half of physical memory, about 29 qubits on 16 GiB | |
| Stabilizer | Thousands of qubits | |
| Factored Stabilizer | per cluster | Thousands of qubits |
| Sparse | nonzero | Large , small |
| MPS | Large , bounded | |
| Product | Unbounded | |
| Tensor Network | Set by contraction order | Peak intermediate under PRISM_MAX_TN_PEAK_QUBITS; dense readout under PRISM_MAX_PROB_QUBITS |
| Factored | worst case | Largest merged block |
| Density Matrix | Half the statevector cap, about 14 qubits on 16 GiB |
Every cap derives from one detected memory budget.
The distributed feature adds an exact statevector sharded across MPI ranks
(Distributed Statevector and MPI). The
Capability and Support Matrix has CPU and GPU support per
backend, and the architecture reference has the internals.
Next: work through a task end to end in the Tutorials.