MIMIQ TensorKeeper¶
A Clifford-augmented Matrix Product State (CAMPS) quantum circuit simulator for MIMIQ.
part of MIMIQ, by
TensorKeeper simulates quantum circuits by splitting the state in two:
\(C\) is a Clifford unitary kept as a stabilizer tableau, and \(|\varphi\rangle\) is a Matrix Product State. Clifford gates go into \(C\) at \(O(n)\) and cost no bond dimension, so the MPS only ever has to represent the non-Clifford content of the circuit.
That is the whole point. A Clifford circuit is classically easy by Gottesman-Knill, yet it can be maximally entangled, so a plain MPS simulator pays exponentially for it. TensorKeeper pays nothing. What it pays for instead is magic: \(T\) gates and other non-Clifford operations. On a circuit that is mostly Clifford with bounded magic, it stays cheap at any width and any depth.
It plugs into MIMIQ: you build
circuits with mimiqcircuits, run them with TkSimulator, and receive the same
QCSResults object MIMIQ uses elsewhere.
New to this? Read Concepts first. It is short, and every tuning knob in the simulator follows from it.
Quick start¶
from mimiqcircuits import Circuit, GateH, GateCX
from tensorkeeper import TkSimulator
# Build a Bell-state circuit.
c = Circuit()
c.push(GateH(), 0)
c.push(GateCX(), 0, 1)
sim = TkSimulator(bonddim=64)
results = sim.execute(c, nsamples=1000, seed=1)
print(results.histogram()) # {bs"00": ~500, bs"11": ~500}
Both gates are Clifford, so the frame absorbed the entire circuit and the MPS never moved:
state = sim.build_state(2)
state, fidelity = sim.evolve(state, sim.compile(c))
print(state.bond_dim) # 1
print(fidelity) # ExactFidelity()
A Bell pair is entangled, and the residual MPS is still a product state, because all of that entanglement is stabilizer entanglement and lives in the frame.
Add a \(T\) gate and the MPS finally has something to hold, because \(T\) is not Clifford:
from mimiqcircuits import BitString, GateT
c.push(GateT(), 1)
state = sim.build_state(2)
state, _ = sim.evolve(state, sim.compile(c))
print(abs(state.amplitude(BitString("00"))) ** 2) # 0.5
Features¶
- CAMPS core written in Rust, exposed through PyO3. Shared with the Julia binding, so the two agree to machine precision.
- A conformant
mimiqcircuits.backends.LocalBackend: drop-in with the rest of MIMIQ. - Clifford gates, Pauli noise, mid-circuit measurement, reset, feed-forward.
- Expectation values of Pauli strings and of general one- and two-qubit operators, evaluated through the frame without collapsing the state.
- Amplitudes, bitstring probabilities and sampling.
- Accuracy reporting that distinguishes an exact run from a truncated one, and never claims exactness it cannot back.
Installation¶
pip install mimiq-tensorkeeper --index-url https://mimiq:<your-token>@license.qperfect.io/pypi/simple
The platforms, the linear algebra engines and the cuda extra are covered in
Getting Started.
From a source checkout:
When to use it¶
TensorKeeper is not a better MPS simulator in general. Reach for it when the circuit's difficulty is concentrated:
| Workload | Use TensorKeeper? |
|---|---|
| Clifford, any depth | Yes. Free. |
| Clifford + bounded \(T\) count | Yes. This is the design point. |
| Magic state cultivation, error correction | Yes. |
| Rotation-dense, magic everywhere | No advantage; use TensorWeaver. |
| Small and exact | Use a state-vector simulator. |
Where to go next¶
- Concepts: what CAMPS is and why it works. Start here.
- Getting Started: install, first circuit, both API paths.
- Circuit Execution: measurement, noise, observables, results.
- Accuracy and Tuning:
bonddim,sv_cutoff, the disentangler. - Examples: a curriculum of runnable scripts.
- API Reference: every public class and method.
Components¶
| Piece | What it is |
|---|---|
tensorkeeper |
this Python package |
tensorkeeper-rs |
the Rust CAMPS core |
TensorKeeper.jl |
the Julia binding onto the same core |
tensorweaver-rs |
the MPS engine underneath |