qalgora-Q Docs Hub量子文档 ✦ Ask AI✦ 问问文档

Stim Interop

◐ Design-level API
This page documents qalgora-Q API design, architecture, or adaptation workflows. Code examples illustrate intended usage and are not guaranteed to run in the current reference implementation.

Stim is an ultra-fast stabilizer simulator for Clifford circuits — the engine behind modern quantum-error-correction research. qalgora-Q exposes a planned Stim-class target and Stim-circuit import (specification interface).

Fast Clifford simulation

import qalgora

qalgora.set_target("qpp-cpu")         # runnable default in the open reference implementation
# Planned optional Stim backend:
# qalgora.set_target("stim")          # Clifford / stabilizer circuits only; optional adapter (planned)
# counts = qalgora.sample(surface_code_round, shots_count=100000)
Specification — not in the open reference build
The Stim-class stabilizer target shown here is part of the specification. For pure Clifford stabilizer circuits, a dedicated simulator can scale far beyond a state-vector simulator; the actual scale depends on circuit structure, the number of detectors, the sampled outputs, and memory. The open reference build is a pure-NumPy CPU state-vector simulator and does not bundle a dedicated stabilizer engine, so it cannot reach those sizes — this section documents the intended interface.

Importing a Stim circuit

# Planned Stim adapter:
# kernel = qalgora.from_stim(stim_circuit)
# detector samples for a decoder (see Detector Error Models)
# samples = qalgora.sample(kernel, shots_count=1_000_000)
Specification API — not in the open reference build yet
This example shows a qalgora-Q specification API (or a third-party library) that the open reference build does not bundle today. It documents the intended interface; to run code now, use the reference build’s supported core API.
For QEC
Clifford-only circuits simulate in polynomial time, so a stabilizer simulator scales to large codes. Pair it with Detector Error Models and the QEC library.
Notes
Clifford / stabilizer circuits only. Non-Clifford gates (for example T and Toffoli) are out of scope for a stabilizer simulator and need a different backend.

References

  • C. Gidney, "Stim: a fast stabilizer circuit simulator," Quantum 5, 497 (2021). quantum-journal.org

Stim 互操作

◐ 设计接口
本页描述的是 qalgora-Q 的接口设计、架构设计或适配工作流。相关代码用于说明预期用法,当前参考实现不保证可以直接运行。

Stim 是专为 Clifford 电路设计的超高速稳定子模拟器,是现代量子纠错研究的核心引擎。qalgora-Q 提供 Stim 类目标后端(规划中),并支持导入 Stim 电路(规划接口)。

快速 Clifford 模拟

import qalgora

qalgora.set_target("qpp-cpu")         # 开放参考实现中可运行的默认目标
# 规划中的可选 Stim 后端:
# qalgora.set_target("stim")          # 仅限 Clifford / 稳定子电路;可选适配器(规划中)
# counts = qalgora.sample(surface_code_round, shots_count=100000)
规范——开源参考实现暂未包含
此处展示的 Stim 类稳定子目标后端属于规范。对纯 Clifford 稳定子电路,专用模拟器可扩展到远大于态矢量模拟器的规模;实际规模取决于电路结构、探测器数量、采样输出和内存。开源参考实现是纯 NumPy 的 CPU 态矢量模拟器,并未内置专用的稳定子引擎,因此无法达到这种规模——本节描述的是预期接口。

导入 Stim 电路

# 规划中的 Stim 适配器:
# kernel = qalgora.from_stim(stim_circuit)
# detector samples for a decoder (see Detector Error Models)
# samples = qalgora.sample(kernel, shots_count=1_000_000)
规范接口 · 参考实现暂未包含
此示例展示的是 qalgora-Q 规范中的接口(或第三方库),开放参考实现目前尚未内置,仅用于说明预期用法;如需立即运行,请使用参考实现已支持的核心 API。
面向量子纠错
纯 Clifford 电路可在多项式时间内完成模拟,因此稳定子模拟器可扩展至大规模码。可与 探测器错误模型量子纠错库配合使用。
注意事项
仅限 Clifford / 稳定子电路。非 Clifford 门(例如 TToffoli)超出稳定子模拟器的范围,需使用其他后端。

参考文献

  • C. Gidney, "Stim: a fast stabilizer circuit simulator," Quantum 5, 497 (2021). quantum-journal.org