Noisy Simulator Backends
Three different engines answer three different noise questions: trajectory sampling for scale, the density matrix for exactness, and the stabilizer simulator for very large Clifford circuits. This page is about choosing the backend; for building the noise model itself see Noisy Simulation.
1. Trajectory (Monte-Carlo) simulation
A pure-state method: each shot samples one stochastic "trajectory" through the noise channels, so memory
stays that of a single state vector (2N amplitudes) while the ensemble reproduces the noisy
distribution. The statistical error on an expectation value falls as
1/√N in the number of trajectories. The planned targets for
this method are gpu, tensornet and tensornet-mps — none ships in the
open reference build yet.
import qalgora
# Planned — trajectory noise on the GPU state-vector backend
# (spec interface, not in the open reference build):
# qalgora.set_target("gpu")
# result = qalgora.sample(kernel, noise_model=noise, num_trajectories=1000)
Batched trajectory execution amortises kernel launches across shots; tune it with
QALGORA_BATCH_SIZE, QALGORA_BATCHED_SIM_MAX_BRANCHES (16) and
QALGORA_BATCHED_SIM_MAX_QUBITS (20).
2. Density matrix — the density-matrix-cpu target
Propagates the full 2N×2N = 4N density matrix, giving the exact noisy state with no sampling error. That squaring of the dimension limits it to small circuits (roughly 14 qubits), but there it is the ground truth other backends are checked against. This target runs on the open reference build.
import qalgora
qalgora.set_target("density-matrix-cpu") # runnable today
3. Stabilizer — the stim target (planned)
A Clifford-only stabilizer simulator that scales to large qubit counts — ideal for syndrome extraction
and error-correction experiments. It supports H, S, CNOT and Pauli gates and measurement, but not
non-Clifford gates such as T or Toffoli. The explicit_measurements option returns the full
per-shot measurement record for bulk sampling.
# Planned — Clifford/stabilizer backend
# (spec interface, not in the open reference build):
# qalgora.set_target("stim")
| Backend | Exact? | Scales to | Use for | Status |
|---|---|---|---|---|
trajectory (gpu) | sampled | memory ≈ statevector (2N) | large noisy circuits, expectation values | Planned |
density-matrix-cpu | exact | ~14 qubits (4N memory) | small-circuit ground truth | Available in reference build |
stim | exact (Clifford) | large Clifford circuits | QEC / stabilizer circuits | Planned |
含噪模拟器后端
三种引擎分别回答三类不同的噪声问题:用轨迹采样应对规模,用密度矩阵保证精确,用稳定子模拟器处理超大规模的 Clifford 电路。 本页讨论的是如何选择后端;若要了解如何构建噪声模型本身,请参阅 含噪模拟。
1. 轨迹(蒙特卡洛)模拟
一种纯态方法:每一次采样都在噪声信道中抽取一条随机“轨迹”,因此内存占用与单个态矢量相当(2N 个振幅),而整个系综则重现了含噪分布。期望值的统计误差随轨迹数
N 以 1/√N 的速度下降。该方法规划中的目标后端为 gpu、tensornet 与 tensornet-mps——目前均未包含在开放参考实现中。
import qalgora
# 规划中——在 GPU 态矢量后端上做轨迹噪声模拟
#(规范接口,参考实现暂未包含):
# qalgora.set_target("gpu")
# result = qalgora.sample(kernel, noise_model=noise, num_trajectories=1000)
批量轨迹执行可在多次采样间摊销内核启动开销;可通过
QALGORA_BATCH_SIZE、QALGORA_BATCHED_SIM_MAX_BRANCHES(16)和
QALGORA_BATCHED_SIM_MAX_QUBITS(20)进行调优。
2. 密度矩阵 density-matrix-cpu 目标
传播完整的 2N×2N = 4N 密度矩阵,给出精确的含噪态且不引入采样误差。维度的平方使其只能处理小型电路(大致 14 个量子比特),但在这一范围内它正是用来校验其他后端的基准真值。该目标可在开放参考实现上运行。
import qalgora
qalgora.set_target("density-matrix-cpu") # 当前可运行
3. 稳定子 stim 目标(规划中)
一个仅支持 Clifford 的稳定子模拟器,可扩展到很大的量子比特规模,非常适合做校验子提取和纠错实验。它支持 H、S、CNOT 和 Pauli 门以及测量,但不支持 T、Toffoli 等非 Clifford 门。explicit_measurements 选项会返回每次采样的完整测量记录,适用于批量采样。
# 规划中——Clifford / 稳定子后端
#(规范接口,参考实现暂未包含):
# qalgora.set_target("stim")
| 后端 | 是否精确 | 可扩展至 | 适用场景 | 当前状态 |
|---|---|---|---|---|
轨迹(gpu) | 采样 | 内存 ≈ 态矢量(2N) | 大型含噪电路、期望值 | 规划中 |
density-matrix-cpu | 精确 | 约 14 量子比特(4N 内存) | 小型电路的基准真值 | 参考实现可用 |
stim | 精确(Clifford) | 大规模 Clifford 电路 | QEC / 稳定子电路 | 规划中 |