Tensor Network Simulators
Tensor-network backends never form the full state vector. They represent the circuit as a network of small tensors and contract it on demand — letting you reach hundreds or thousands of qubits when entanglement stays bounded.
tensornet and tensornet-mps are specified targets; the open reference build (a
pure-NumPy CPU statevector simulator) does not include them yet, so the set_target calls
below are shown commented out.
Exact contraction — the tensornet target (planned)
Backed by a GPU tensor-network engine, tensornet contracts the full network exactly without
ever materialising the 2N state vector, and scales across multiple GPUs and nodes via MPI. It
suits shallow, low-entanglement or structured circuits with many qubits, where a dense state vector would
be impossible. For highly entangled circuits the contraction can become intractable, so the method is not a
universal substitute for statevector simulation.
import qalgora
# Planned tensor-network backend — spec interface, not in the open reference build:
# qalgora.set_target("tensornet") # exact, fp64 by default
# qalgora.set_target("tensornet", option="fp32")
Contraction-path search is the main cost. QALGORA_TENSORNET_NUM_HYPER_SAMPLES (8) trades
search time for a cheaper path, and QALGORA_TENSORNET_OBSERVE_CONTRACT_PATH_REUSE reuses a path
across the terms of an observable.
Approximate MPS — the tensornet-mps target (planned)
The matrix-product-state backend keeps the state in a 1-D chain of tensors whose bond dimension caps how much entanglement can be represented. It is single-GPU and approximate: its accuracy depends on the maximum bond dimension, the singular-value truncation threshold, and how fast entanglement grows in the circuit. Raise the bond dimension for accuracy, lower it for speed — and verify convergence by re-running with a larger bond dimension.
# Planned MPS backend — spec interface, not in the open reference build:
# qalgora.set_target("tensornet-mps")
# qalgora.set_target("tensornet-mps", option="fp32")
| Variable | Default | Meaning |
|---|---|---|
QALGORA_MPS_MAX_BOND | 64 | Maximum bond dimension — the central accuracy/cost dial. |
QALGORA_MPS_ABS_CUTOFF | 1e-5 | Absolute singular-value truncation cutoff. |
QALGORA_MPS_RELATIVE_CUTOFF | 1e-5 | Relative singular-value cutoff. |
QALGORA_MPS_SVD_ALGO | GESVDJ | SVD routine for truncation (GESVD/GESVDJ/GESVDP/GESVDR). |
QALGORA_MPS_MAX_BOND.
For a volume-law (highly entangled) circuit the bond dimension grows exponentially and the result becomes
an approximation — always check convergence by re-running with a larger bond.
张量网络模拟器
张量网络后端从不构造完整的态矢量。它们将线路表示为由小张量组成的网络,并按需进行收缩——当纠缠程度受限时,便能处理数百乃至数千量子比特。
tensornet 与 tensornet-mps 属于规范接口;开放参考实现(纯 NumPy 的 CPU 态矢量模拟器)暂未包含它们,因此下面的 set_target 调用均以注释形式给出。
精确收缩——tensornet 目标(规划中)
基于 GPU 张量网络引擎,tensornet 对整个网络进行精确收缩,全程不构造 2N 态矢量,并可通过 MPI 跨多块 GPU 与多个节点扩展。它适合处理量子比特数众多、深度较浅、低纠缠或具有结构的线路,而在这类场景下稠密态矢量根本无法承载。对于高度纠缠的线路,收缩可能变得不可行,因此该方法并不能普遍替代态矢量模拟。
import qalgora
# 规划中的张量网络后端——规范接口,参考实现暂未包含:
# qalgora.set_target("tensornet") # exact, fp64 by default
# qalgora.set_target("tensornet", option="fp32")
收缩路径搜索是主要开销所在。QALGORA_TENSORNET_NUM_HYPER_SAMPLES(默认 8)以搜索时间换取更廉价的路径,而 QALGORA_TENSORNET_OBSERVE_CONTRACT_PATH_REUSE 则可在可观测量的各项之间复用同一条路径。
近似 MPS——tensornet-mps 目标(规划中)
矩阵乘积态后端将量子态保存为一维张量链,其键维限定了可表示的纠缠上限。它运行于单块 GPU 且为近似方法:其精度取决于最大键维、奇异值截断阈值,以及线路中纠缠增长的快慢。提高键维以换取精度,降低键维以换取速度——并通过加大键维重新运行来检验收敛性。
# 规划中的 MPS 后端——规范接口,参考实现暂未包含:
# qalgora.set_target("tensornet-mps")
# qalgora.set_target("tensornet-mps", option="fp32")
| 变量 | 默认值 | 含义 |
|---|---|---|
QALGORA_MPS_MAX_BOND | 64 | 最大键维——精度与开销之间的核心调节旋钮。 |
QALGORA_MPS_ABS_CUTOFF | 1e-5 | 奇异值的绝对截断阈值。 |
QALGORA_MPS_RELATIVE_CUTOFF | 1e-5 | 奇异值的相对截断阈值。 |
QALGORA_MPS_SVD_ALGO | GESVDJ | 用于截断的 SVD 例程(GESVD/GESVDJ/GESVDP/GESVDR)。 |
QALGORA_MPS_MAX_BOND 时,MPS 运行才是精确的。
对于体积律(高度纠缠)线路,键维会呈指数级增长,结果随之退化为近似值——务必通过加大键维重新运行来检验收敛性。