QRAM-Simulator Architecture¶
This document describes the overall architecture, design philosophy, and core modules of the QRAM-Simulator repository.
Repository split: this repository is the pure C++ QRAM simulation foundation (with a thin pybind11 binding and the
qram-simulatorPyPI package); the sparse-state simulator framework (SparQ), the higher-level algorithms, and the richpysparqbindings live in the SparQSim repository, which consumes this repository as a git submodule (extern/qram-simulator).
1. Overview¶
1.1 Project Goals¶
QRAM-Simulator is a high-performance C++ core for simulating quantum random access memory (QRAM) loading circuits:
Dual qubit / qutrit architectures: two QRAM implementations — a physical qubit tree and a three-level node tree
Noise aware: bit-flip / phase-flip / combined-flip / depolarizing / amplitude-damping noise injected per time slice
Branch pruning: good/bad branch pruning shrinks the simulation to “all bad branches computed + one good branch as the baseline”
Python bindings: a thin pybind11 layer (
pip install qram-simulator) exports every core workhorse classThe optional CUDA backend is enabled with
QRAM_ENABLE_CUDA=ON; CPU remains the default
1.2 Design Philosophy¶
Sparse state first: the tree state records only non-basis-state nodes, so complexity is on the order of the number of nonzero elements rather than 2^n
Branch as trajectory: the (address, bus_input) input branch is the unit of simulation, and noise accumulates on the trajectory amplitudes
Performance and usability together: the C++ core (OpenMP/TBB parallelism) provides performance, the Python bindings provide usability
Self-contained build: Eigen / fmt / argparse are all vendored under
ThirdParty/; the build needs no network access
2. Directory Layout and Modules¶
QRAM-Simulator/
├── Common/ # shared infrastructure (static library SparQ_Common)
│ ├── include/ # full-amplitude bridge, matrices, random engine, logging, iteration utilities…
│ └── src/
├── QRAM/ # QRAM circuit core (static library SparQ_QRAMSimulator)
│ ├── include/ # qubit/qutrit circuits, branch structures, time-step scheduling
│ └── src/
├── bindings/python/ # thin pybind11 bindings (qram-simulator PyPI package)
├── Experiments/ # QRAM paper experiment executables
├── test/ # C++ tests (in-house TEST macro framework)
├── docs/ # this documentation (Sphinx) + Doxygen configuration
└── ThirdParty/ # eigen / fmt / argparse / googletest (vendored)
2.2 QRAM/ — QRAM Circuit Core¶
File |
Contents |
|---|---|
|
|
|
|
|
|
|
|
|
Both architectures share the same TimeStep scheduler (distinguished by the arch_qubit / arch_qutrit constants); their interface shapes are identical, so they can be used interchangeably:
qram_simulator::qram_qubit::QRAMCircuit qram_q(4, 2); // qubit architecture
qram_simulator::qram_qutrit::QRAMCircuit qram_t(4, 2); // qutrit architecture
2.3 bindings/python/ — Python Binding Layer¶
core_binding.cpp exports the core workhorse classes through pybind11, and scikit-build-core handles the packaging:
C++ Class |
Python Name |
Description |
|---|---|---|
|
qubit-architecture circuit |
|
|
qutrit-architecture circuit |
|
|
full-amplitude state-vector bridge (entry point for external library integration) |
|
same names |
time-step and noise scheduling |
|
same names |
noise-model keys and architecture constants |
|
|
global random seed control |
The QRAM_BUILD_PYTHON_BINDINGS build toggle (OFF by default) keeps embedding consumers (SparQSim’s add_subdirectory) and the pure C++ CI unaffected.
2.4 Experiments/ — Paper Experiments¶
Experiment |
Description |
|---|---|
CI regression cross-check: QRAM circuit-level noise ↔ operator-level channels (registered with ctest) |
|
figure reproduction for the arXiv:2503.13832 paper (PRA version) |
|
audit of the correspondence between noise models and circuit-level channels |
|
fidelity simulator comparison |
|
verification of the bad-branch range theory |
3. Data Flow¶
3.1 Sparse Tree-State Representation¶
┌──────────────────────────────────────────────────────────────┐
│ State (qubit) QRAMState (qutrit) │
├──────────────────────────────────────────────────────────────┤
│ std::set<size_t> nz_elements std::map<size_t,QRAMNode> │
│ ├ records only |1> node ├ records only nodes not │
│ │ positions │ in state (W,0) │
│ └ everything else implied |0> └ node carries (addr,data) │
│ │
│ complete binary tree, level-order numbering: │
│ left = 2i+1, right = 2i+2 │
└──────────────────────────────────────────────────────────────┘
Both memory and compute complexity are on the order of the number of nonzero (non-basis-state) nodes, not 2^n.
3.2 QRAM Loading Workflow¶
construct QRAMCircuit(addr_size, data_size[, memory])
│
▼
set_noise_models({OperationType: probability}) ← optional; probability ∈ [0,1],
│ Damping requires γ < 1
▼
set_input_random/uniform(n) ← sample n (addr, bus) input branches
│
▼
initialize_system() ← TimeStep::generate builds noisy TimeSlices
│
▼
run_normal() / run_full() / run(version)
├ run_normal: all bad branches computed + one good branch as the baseline
│ (remaining good branches predicted by XOR mirroring)
└ run_full : every branch evolved, unpruned ground truth
│
▼
sample_and_get_fidelity() ← sample output branches, |<ideal|actual>|²
3.3 Noise Injection¶
TimeStep::noise_one_step inserts noise operations after each time slice according to the noise model:
Noise |
Effect |
|
|---|---|---|
Bit flip |
|
trajectory splitting: flip / no-flip, amplitudes weighted by √p |
Phase flip |
|
trajectory amplitude multiplied by −1 (with probability p) |
Combined flip |
|
flips bit and phase simultaneously |
Depolarizing |
|
random Pauli mixture |
Amplitude damping |
|
relative good-branch multiplier (1−γ)^Δn; two injection granularities, |
Set to zero |
|
node reset to the basis state |
3.4 Full-Amplitude Bridge (QRAMFullAmp)¶
full-amplitude state vector ──_set_branches──▶ input branch set (split by addr/data bits)
│ │
│ qutrit QRAMCircuit::run
│ (requires a non-empty noise model)
│ │
│ sample_output (trajectory sampling)
▼ ▼
new state vector ◀──_reconstruct──────── branch trajectories mapped back onto the state vector
(good branches predicted by XOR mirroring + Damping multipliers; renormalization check after reconstruction)
4. Key Design Decisions¶
4.1 Qutrit-based vs Qubit-based QRAM¶
Qutrit architecture: every tree node is a three-level system (addr ∈ {W,L,R}, data ∈ {0,1}); routing is performed by A1/A2 rotation gates (carrying a w phase). The tree structure matches the schedule naturally, with fewer gates and lower noise accumulation.
Qubit architecture: nodes are standard two-level bits, with better hardware compatibility and a more mature theoretical toolkit. Combined with good/bad branch pruning — bad-branch address ranges are derived from TimeStep::get_bad_range_*, so the branch group of a good address materializes only one baseline trajectory and predicts the rest by XOR mirroring — this is the core speedup of the qubit architecture for large-scale simulation (see qubit QRAM pruning theory).
The two implementations share the same TimeStep scheduler and noise-model format, and their interface shapes are identical.
4.2 Versioned Run Entry Points¶
run(version) accepts strings such as "full" / "normal" / "fast". The qutrit architecture requires a non-empty noise model before run(version) may be used (noise-free scenarios should be handled directly outside the circuit), while run_normal() / run_full() carry no such constraint.
4.3 CUDA Integration (Retained Code)¶
QRAM/include/cuda/qram_circuit_qutrit.cuh (CuQRAMCircuit, a thrust device_vector memory mirror) is retained in the code base; the optional CUDA targets are built with QRAM_ENABLE_CUDA=ON. CPU remains the default (OpenMP required, TBB optional), and unfinished production CondRot kernels still use CPU fallbacks. The actively developed GPU path — the CUDA sparse-state simulator — lives in the sister repository SparQSim, verified on an 8×A800 server with CUDA 12.8 (v1c verification record).
5. References¶
Quickstart: quickstart.md
Installation guide: installation.md
Paper 1: arXiv:2503.13832
Paper 2: arXiv:2503.15118
Quantum Arithmetic Operator Constraints — operator semantics and unitary guarantees
Paper Reproduction Documentation — paper list and experiment overview