QRAM-Simulator
QRAM 电路模拟核心(C++ 基座仓):Qutrit/Qubit 两种 QRAM 架构、噪声模型、QRAM 论文实验与 pybind11 Python 绑定
仓库分工
本仓库是 C++ 基座:QRAM 电路核心 + 论文实验 + pybind11 薄绑定(qram-simulator
PyPI 包);SparQ 框架(稀疏态模拟器、算法库、pysparq 富绑定、算法类实验)位于
SparQSim 仓库:
| 仓库 | 内容 | PyPI 包 |
|---|---|---|
| QRAM-Simulator(本仓库) | C++ QRAM 电路核心(Common + QRAM)+ QRAM 论文实验 + pybind11 薄绑定 | qram-simulator |
| SparQSim | SparQ 框架(稀疏态模拟器、算法库、pysparq 富绑定、算法类实验) | pysparq |
依赖方向:SparQSim → QRAM-Simulator。SparQSim 以 git submodule
(相对 URL ../QRAM-Simulator.git)方式引用本仓库并编译 C++ 核心;两个仓库各自
独立 tag/发版,SparQSim 发版前将 submodule pin 到本仓库的对应 tag。
核心能力
- QRAM 电路模拟:Qutrit-based(
qram_circuit_qutrit.h)与 Qubit-based (qram_circuit_qubit.h)两种实现 - 噪声模型:退极化(Depolarizing)与振幅阻尼(Damping),含概率参数范围校验
- 架构剪枝:qubit 架构 normal(剪枝)模式与 full(不剪枝)模式逐版本对拍
- 公共组件:稀疏/稠密矩阵、随机引擎、错误处理、state manipulator 等
C++ 快速开始
构建
git clone https://github.com/IAI-USTC-Quantum/QRAM-Simulator.git
cd QRAM-Simulator
mkdir build && cd build
# 配置(CPU 版本;GPU/CUDA 后端当前暂缓,CMake 会构建 CPU-only 版本)
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
构建开关(均可通过 -D...=ON/OFF 控制):
| 开关 | 默认 | 说明 |
|---|---|---|
QRAM_BUILD_TESTS |
ON | 构建 C++ 测试(test/) |
QRAM_BUILD_EXPERIMENTS |
ON | 构建 QRAM 实验程序(Experiments/) |
核心用法
#include "qram_circuit_qubit.h"
using namespace qram_simulator;
using namespace qram_qubit;
// 1. 构造 QRAM 电路(addr_size=4, data_size=2)
QRAMCircuit qram(4, 2);
qram.set_memory_random(); // 随机数据树
// 2. 注入噪声(可选;概率范围校验,Damping 要求 gamma < 1)
qram.set_noise_models({
{ OperationType::Depolarizing, 1e-3 },
{ OperationType::Damping, 1e-4 }
});
// 3. 运行(normal=架构剪枝 / full=不剪枝基准)
qram.set_input_uniform(100);
qram.run_normal();
// 4. 采样保真度
double fidelity = qram.sample_and_get_fidelity();
Python 快速开始
pip install qram-simulator
绑定层(bindings/python/,pybind11)导出核心工作类:QRAMCircuitQubit /
QRAMCircuitQutrit(两套架构电路)、QRAMFullAmp(全振幅桥接)、TimeStep
(时序与噪声调度)、OperationType 与全局随机种子控制,供外部库直接驱动
完整的"构造 → 设噪声 → 运行 → 保真度"工作流:
from qram_simulator import QRAMCircuitQubit, OperationType, set_seed
set_seed(42)
qram = QRAMCircuitQubit(4, 2)
qram.set_memory_random()
qram.set_noise_models({OperationType.Depolarizing: 1e-3,
OperationType.Damping: 1e-4})
qram.set_input_uniform(100)
qram.run_normal()
print(qram.sample_and_get_fidelity())
本地开发:pip install -v .(CMake ≥ 3.18 + C++17 + OpenMP),
测试:pytest bindings/python/test。
作为 CMake 子项目消费(SparQSim 的方式)
# submodule: git submodule add ../QRAM-Simulator.git extern/qram-simulator
set(QRAM_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(QRAM_BUILD_EXPERIMENTS OFF CACHE BOOL "" FORCE)
add_subdirectory(extern/qram-simulator) # 提供 SparQ_QRAMSimulator / SparQ_Common 目标与平铺头文件布局
运行实验
# QRAM 保真度实验(V2)
./build/bin/Experiment_QRAM_FidelityV2 ...
Python 侧(pysparq 全功能绑定与 qram_simulator 薄绑定)见 SparQSim 仓库。
论文与引用
本仓库由两篇论文分别驱动:
Paper 1: QRAM-Simulator — arXiv:2503.13832
Efficient Simulation of Quantum Random Access Memory
- QRAM 电路模拟:Qutrit-based 与 Qubit-based 两种 QRAM 实现(C++ API),支持退极化和振幅阻尼噪声模型
- 稀疏态优化:仅存储非零振幅,可实现 64+ 量子比特的结构化算法模拟
- 错误过滤:针对含噪 QRAM 的错误过滤方案
对应代码:QRAM/、Experiments/QRAM/(错误过滤实验在 SparQSim 仓库)
Paper 2: SparQ — arXiv:2503.15118
SparQ: A Sparse Quantum Circuit Simulator with Register-Level Abstraction
将 Register Level Programming 拓展为通用稀疏态量子模拟器(QFT、Grover、哈密顿量 模拟、QDA、QCNN 等算法与扩展算法库)。
对应代码:SparQ/、SparQ_Algorithm/ 与算法类实验已迁至
SparQSim 仓库。
BibTeX
@article{sun2025sparqsim,
title={SparQSim: Simulating Scalable Quantum Algorithms via Sparse Quantum State Representations},
author={Sun, Tai-Ping and Chen, Zhao-Yun and Wang, Yun-Jie and Xue, Cheng and Liu, Huan-Yu and Zhuang, Xi-Ning and Xu, Xiao-Fan and Wu, Yu-Chun and Guo, Guo-Ping},
journal={arXiv preprint arXiv:2503.15118},
year={2025}
}
@article{wang2025refined,
title={Refined Criteria for QRAM Error Suppression via Efficient Large-Scale QRAM Simulator},
author={Wang, Yun-Jie and Sun, Tai-Ping and Zhuang, Xi-Ning and Xu, Xiao-Fan and Liu, Huan-Yu and Xue, Cheng and Wu, Yu-Chun and Chen, Zhao-Yun and Guo, Guo-Ping},
journal={arXiv preprint arXiv:2503.13832},
year={2025}
}
复现论文结果
详细的实验复现指南见 docs/paper/ 目录:
- docs/paper/README.md - 论文关联文档
- docs/paper/reproduction.md - QRAM-Simulator 实验复现指南
项目结构
QRAM-Simulator/
├── QRAM/ # QRAM 电路实现(Qutrit/Qubit-based)
├── Common/ # 公共组件(矩阵、随机引擎、state manipulator 等)
├── bindings/python/ # pybind11 薄绑定(qram-simulator PyPI 包)
├── Experiments/ # QRAM 论文实验(QRAMFidelityV2、QubitPaper、ChannelCorrespondence 等)
├── test/ # C++ 测试(Common/QRAM 归属部分)
├── ThirdParty/ # vendored 依赖(Eigen、fmt、googletest、argparse)
└── docs/ # Sphinx 文档(breathe 吸入 Doxygen C++ API + autoapi Python API)
发版流程
- 在 Gitea(开发主仓)合并变更到 main;
- 同步到 GitHub 上游
IAI-USTC-Quantum/QRAM-Simulator; - 更新
CHANGELOG.md,打 tag(vX.Y.Z,注意历史上已有 v0.1.x,新系列从 v0.2.0 起); - push tag 或创建 GitHub Release →
pypi-publish.yml自动构建 cp310–cp313 的 manylinux / win_amd64 wheel 与 sdist,经 PyPI trusted publishing 发布qram-simulator包;pysparq仍由 SparQSim 仓库发布。
About Us
本项目由 IAI-USTC Quantum 开发。
- GitHub Organization: IAI-USTC-Quantum — 查看团队的所有开源项目
- Documentation: iai-ustc-quantum.github.io — 团队文档与项目主页
IAI-USTC Quantum 是合肥综合性国家科学中心人工智能研究院(Institute of Artificial Intelligence, Hefei Comprehensive National Science Center)量子人工智能团队。
主要开发者:Agony5757 (chenzhaoyun@iai.ustc.edu.cn)、RichardSun、Itachixc、YunJ1e、cilysad、TMYTiMidlY
相关项目
- SparQSim - SparQ 框架与 Python 生态(pysparq)
- UnifiedQuantum - 统一量子计算框架
许可证
Apache-2.0 License
Release files for qram-simulator 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| qram_simulator-0.2.0.tar.gz | 4.1 MB | Details |
Built distributions (wheels)
Total release size: 9.4 MB
Release files / qram_simulator-0.2.0.tar.gz
| Download URL | qram_simulator-0.2.0.tar.gz |
|---|---|
| Size | 4.1 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
538d23c413c4695880a0f480c83d608bcc24fadf7f590dfca158cb51d068fffa
|
|
BLAKE2b-256 checksum How to use checksums |
af7ef2b13ac311739684928ef85e9bd75e781b029dd48e6245aa1c0910e3c78f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.
Transparency logRelease files / qram_simulator-0.2.0-cp313-cp313-win_amd64.whl
| Download URL | qram_simulator-0.2.0-cp313-cp313-win_amd64.whl |
|---|---|
| Size | 843.3 kB |
| Tags | CPython 3.13 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
2e394133ecdadab0496db0e427d66f4234927bbd6672b3801b536c19c554ad78
|
|
BLAKE2b-256 checksum How to use checksums |
f1df75812851a5d3241e11247c21610826102c0f26f078fc7f35243fe472361c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.
Transparency logRelease files / qram_simulator-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | qram_simulator-0.2.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 475.2 kB |
| Tags | CPython 3.13 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
af9c97ce9c720d455f3eaf1a530326548dab48c7cba7fb7993a46043d5a2b81b
|
|
BLAKE2b-256 checksum How to use checksums |
9ba6d17496c87fa48f49b81cab358275b9da1b779e45eece99917b2bb94275f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.
Transparency logRelease files / qram_simulator-0.2.0-cp312-cp312-win_amd64.whl
| Download URL | qram_simulator-0.2.0-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 843.5 kB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
3d7df3fb7c9aa527a17647f3eb4bdfb3e74f766b5d819cce3df79bacdccb1121
|
|
BLAKE2b-256 checksum How to use checksums |
90d769632b2fb75351cb7ccad723549065ed4c03d609bfdd2507ca652db0dea0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.
Transparency logRelease files / qram_simulator-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | qram_simulator-0.2.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 475.2 kB |
| Tags | CPython 3.12 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
98e94e964238073902dec8c7decfa7ce7721393932284228ccbd4329a28d8323
|
|
BLAKE2b-256 checksum How to use checksums |
d0b2e98fa2e0599b2fe98095580ca5ecbfe79e5a1fdcc9e67c220f85571b71f7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.
Transparency logRelease files / qram_simulator-0.2.0-cp311-cp311-win_amd64.whl
| Download URL | qram_simulator-0.2.0-cp311-cp311-win_amd64.whl |
|---|---|
| Size | 842.2 kB |
| Tags | CPython 3.11 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
948f63ee069de8c3a0c8e5c091335fb1bd8be1e753962ca28a42d10f3959cc69
|
|
BLAKE2b-256 checksum How to use checksums |
21487f721a77f12d7bf78e6bdeb6dcceb86aefd3b092db79856832fdd74df871
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.
Transparency logRelease files / qram_simulator-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | qram_simulator-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 475.6 kB |
| Tags | CPython 3.11 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
e5247ffaed898150327ff53d4b10b1e7971468f1e8f58fda6b427f50fb1818d0
|
|
BLAKE2b-256 checksum How to use checksums |
111980c37b6ab391967bbd0cdb468ce161a07e70d8983b5dbbbf240a8298c12d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.
Transparency logRelease files / qram_simulator-0.2.0-cp310-cp310-win_amd64.whl
| Download URL | qram_simulator-0.2.0-cp310-cp310-win_amd64.whl |
|---|---|
| Size | 840.9 kB |
| Tags | CPython 3.10 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
17b46f74e97f55e79d590c78db404fdee5d1957cc2ca3c7d0ebf802458e08d5c
|
|
BLAKE2b-256 checksum How to use checksums |
66b766cd5527fcf4b37fe48604dc3228af6f523711ac0a9514495b7f936bbbe2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.
Transparency logRelease files / qram_simulator-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
| Download URL | qram_simulator-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl |
|---|---|
| Size | 474.1 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 |
|
SHA-256 checksum How to use checksums |
7ac6d6a2c9ed8acee229b8d565eb8cbb125f6eee759c4f38f777921e129df987
|
|
BLAKE2b-256 checksum How to use checksums |
1e0d43a92103943953fa55407c9dbc7b6ef5b1452f715845ebe8fb72f0f57cd0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 25, 2026.
Transparency log