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

Circuit Simulation

◐ 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.

qalgora-Q bundles several simulator families. Pick one with set_target based on qubit count, entanglement, and noise needs.

State-vector simulators

TargetUse caseStatus
qpp-cpuCPU statevector — small circuits, no GPUAvailable in reference build
gpuSingle-GPU statevectorPlanned
gpu (mgpu)Statevector pooled across multiple GPUs/nodesPlanned

Tensor-network simulators

TargetUse caseStatus
tensornetLarge, low-entanglement circuitsPlanned
tensornet-mpsMatrix-product-state ansätze, 1D systemsPlanned

Noisy & photonic

TargetUse caseStatus
density-matrix-cpuExact noisy simulation (2N×2N = 4N memory)Available in reference build
stimFast Clifford / stabilizer circuits (QEC)Planned
photonicsQudit / photonic operations (beam splitter, phase shift)Planned

Only qpp-cpu (alias cpu) and density-matrix-cpu run on the open reference build today; the GPU, tensor-network, Stim and photonic targets are the specified interface and are not included yet.

import qalgora
qalgora.set_target("qpp-cpu")          # runnable today
print(qalgora.sample(small_kernel))

# Planned (spec interface — not in the open reference build):
# qalgora.set_target("tensornet-mps")
# print(qalgora.sample(large_1d_kernel))

How each method scales

MethodMemoryBest whenStatus
Statevector2N complex amplitudesAny entanglement; reachable qubit count is set by RAM/VRAM and precision (a 30-qubit complex64 statevector ≈ 8 GB, complex128 ≈ 16 GB)qpp-cpu available; GPU statevector planned
Tensor networkDepends on bond dimensionLow entanglement / shallow circuits, 100s of qubitsPlanned
Matrix product stateLinear in N · bond²1D, low-entanglement systemsPlanned
Density matrix2N×2N = 4NExact noise, small Ndensity-matrix-cpu available
Stabilizer (Stim)N² (Clifford only)QEC, very large Clifford circuitsClifford-only; planned

Precision

The reference CPU statevector runs in double precision (complex128). Single (fp32) vs. double (fp64) selection is a GPU-backend option (planned): fp32 halves memory and is faster; fp64 is safer for tight-tolerance chemistry.

import qalgora
qalgora.set_target("qpp-cpu")                    # reference build runs double precision

# Planned (GPU backend, spec interface — not in the open reference build):
# qalgora.set_target("gpu", option="fp64")       # double precision
# data = np.array([...], dtype=qalgora.complex())  # match the target's width
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.
Choosing a simulator
Start on the CPU statevector (the open reference build runs qpp-cpu today; gpu is a planned backend). Hit a memory wall? The planned options are pooling with mgpu, or switching to tensornet/tensornet-mps when entanglement is low. Need noise? Use density-matrix-cpu (small); trajectory sampling on gpu (large) is planned. Pure Clifford? stim (planned).

电路模拟

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

qalgora-Q 内置了多套模拟器,可以根据量子比特数、纠缠程度和是否需要噪声,用 set_target 挑选合适的后端。

态矢量模拟器

目标后端适用场景当前状态
qpp-cpuCPU 态矢量——适合小规模电路,无需 GPU参考实现可用
gpu单 GPU 态矢量规划中
gpu (mgpu)把态矢量摊到多块 GPU 或多个节点上规划中

张量网络模拟器

目标后端适用场景当前状态
tensornet大规模低纠缠电路规划中
tensornet-mps矩阵乘积态拟设、一维系统规划中

噪声与光子

目标后端适用场景当前状态
density-matrix-cpu精确噪声模拟(2N×2N = 4N 内存)参考实现可用
stim快速 Clifford / 稳定子电路(QEC)规划中
photonics多能级量子位(qudit)与光子操作(分束器、移相)规划中

当前只有 qpp-cpu(别名 cpu)与 density-matrix-cpu 能在开放参考实现上运行;GPU、张量网络、Stim 与光子目标属于规范接口,参考实现暂未包含。

import qalgora
qalgora.set_target("qpp-cpu")          # 当前可运行
print(qalgora.sample(small_kernel))

# 规划中(规范接口——参考实现暂未包含):
# qalgora.set_target("tensornet-mps")
# print(qalgora.sample(large_1d_kernel))

各方法能撑多大规模

方法内存适用条件当前状态
态矢量2N 个复振幅任意纠缠度;可达的量子比特数取决于内存/显存与精度(30 量子比特 complex64 态矢量约 8 GB,complex128 约 16 GB)qpp-cpu 可用;GPU 态矢量规划中
张量网络取决于键维数低纠缠 / 浅层电路,数百量子比特规划中
矩阵乘积态随 N · 键维数² 线性增长一维低纠缠系统规划中
密度矩阵2N×2N = 4NN 较小时的精确噪声模拟density-matrix-cpu 可用
稳定子(Stim)N²(仅限 Clifford)QEC、超大规模 Clifford 电路仅限 Clifford;规划中

精度

参考实现的 CPU 态矢量采用双精度(complex128)。单精度(fp32)与双精度(fp64)的切换是 GPU 后端的选项(规划中):fp32 内存减半、速度更快;fp64 更稳,适合对容差要求严格的化学计算。

import qalgora
qalgora.set_target("qpp-cpu")                    # 参考实现以双精度运行

# 规划中(GPU 后端,规范接口——参考实现暂未包含):
# qalgora.set_target("gpu", option="fp64")       # double precision
# data = np.array([...], dtype=qalgora.complex())
规范接口 · 参考实现暂未包含
此示例展示的是 qalgora-Q 规范中的接口(或第三方库),开放参考实现目前尚未内置,仅用于说明预期用法;如需立即运行,请使用参考实现已支持的核心 API。
如何选择模拟器
先从 CPU 态矢量起步(参考实现当前运行 qpp-cpugpu 为规划中后端)。内存不够了?规划中的方案是用 mgpu 摊到多卡,或者趁纠缠度低切到 tensornet/tensornet-mps。要做噪声模拟?规模小就用 density-matrix-cpu;规模大时在 gpu 上做轨迹采样(规划中)。纯 Clifford 电路?用 stim(规划中)。