| name | bbqram-state-preparation-finance |
| description | Architecture-aware quantum state preparation using Bucket Brigade QRAM (BBQRAM) with segment tree for polylogarithmic query time. Covers complex-valued matrix encoding, classical precomputation of rotation angles, and magnitude-then-phase procedures. Enables efficient data loading for quantum finance applications. Based on arXiv:2604.25644. Use when: designing QRAM-based quantum data loaders, optimizing state preparation for quantum finance, loading complex-valued financial data into quantum circuits, implementing efficient amplitude encoding with BBQRAM. |
BBQRAM State Preparation for Quantum Finance
Description
Efficient quantum state preparation methodology using Bucket Brigade QRAM (BBQRAM) integrated with a segment tree architecture. Achieves O(log²(MN)) BBQRAM query complexity for loading complex-valued matrices A ∈ ℂ^(M×N) into quantum states. Introduces two key improvements over prior work: (1) classical precomputation of rotation angles to eliminate the U_2CR subroutine, and (2) extension to complex-valued matrices via leaf phase storage with a two-step magnitude-then-phase procedure.
Primary Paper: "Efficient Complex-Valued State Preparation on Bucket Brigade QRAM" (arXiv:2604.25644, Berti & Ghisoni, 2026)
Activation Keywords
- BBQRAM state preparation
- bucket brigade QRAM segment tree
- complex-valued quantum state preparation
- quantum finance data loading QRAM
- O(log²(MN)) state preparation
- classical precomputation rotation angles
- magnitude-then-phase quantum encoding
- architecture-aware QRAM
- quantum data loading bucket brigade
Core Methodology
Step 1: Segment Tree Construction
Build a segment tree over the matrix data to enable polylogarithmic access:
- Arrange MN data elements as leaves of a binary segment tree
- Each internal node stores the sum (or partial sum) of its children
- Tree depth: O(log(MN))
- Each BBQRAM cell stores:
- Precomputed rotation angles (magnitude information)
- Leaf phase (for complex-valued extension)
Step 2: Classical Precomputation (Key Improvement)
Instead of computing rotation angles on-the-fly using the U_2CR subroutine:
- Precompute classically: Calculate all rotation angles from the segment tree structure
- Store in QRAM cells: Load precomputed fixed-point angles directly into BBQRAM
- Trade-off: BBQRAM stores precomputed angles instead of raw subtree weights
- Benefit: QPU procedure reduces to simple BBQRAM retrievals + controlled-rotation cascades
- No reversible arithmetic needed on QPU
Step 3: Magnitude-Then-Phase Procedure (Complex-Valued Extension)
For complex-valued matrices A ∈ ℂ^(M×N):
- Magnitude step: Encode |A_ij| using the segment tree + precomputed angles
- Phase step: Apply stored leaf phases to each element
- Two-step procedure:
- First prepare the state with correct magnitudes
- Then apply phase corrections via controlled phase gates
- Real signed case: Natural specialization using one-bit phase (sign bit)
Step 4: Query Execution
The QPU performs:
- BBQRAM query to retrieve precomputed data: O(log²(MN)) time
- Apply controlled-rotation cascade based on retrieved angles
- Apply phase corrections for complex values
- No reversible arithmetic on QPU
Implementation Patterns
Pattern 1: Segment Tree + BBQRAM Data Structure
class BBQRAMSegmentTree:
"""
Bucket Brigade QRAM with segment tree for efficient state preparation.
Each cell stores precomputed rotation angle + optional leaf phase.
"""
def __init__(self, data: np.ndarray):
"""
Args:
data: Complex-valued matrix flattened to 1D array of size MN
"""
self.MN = len(data)
self.n_levels = int(np.ceil(np.log2(self.MN)))
self.tree = self._build_tree(data)
self.angles = self._precompute_angles()
self.phases = np.angle(data)
def _build_tree(self, data):
"""Build segment tree with cumulative weights."""
tree = np.zeros(2 * self.MN)
tree[self.MN:] = np.abs(data)**2
for i in range(self.MN - 1, 0, -1):
tree[i] = tree[2*i] + tree[2*i + 1]
return tree
def _precompute_angles(self):
"""Precompute rotation angles from segment tree."""
angles = []
for i in range(1, self.MN):
left = self.tree[2*i]
right = self.tree[2*i + 1]
total = left + right
if total > 0:
theta = 2 * np.arcsin(np.sqrt(left / total))
else:
theta = 0
angles.append(theta)
return np.array(angles)
def query(self, index: int) -> tuple:
"""Retrieve precomputed angle and phase for given index."""
angle = self.angles[index]
phase = self.phases[index]
return angle, phase
Pattern 2: BBQRAM Query Circuit
from qiskit import QuantumCircuit, QuantumRegister
def bbqram_query_circuit(index_bits, angle, phase, n_target_qubits):
"""
Generate BBQRAM query circuit for a single element.
The actual BBQRAM routing is hardware-dependent.
This shows the logical structure:
Args:
index_bits: Qubits encoding the element index
angle: Precomputed rotation angle (theta)
phase: Leaf phase for complex value
n_target_qubits: Number of target qubits for amplitude encoding
Returns:
QuantumCircuit implementing the query
"""
n_addr = len(index_bits)
qc = QuantumCircuit(n_addr + n_target_qubits)
qc.ry(angle, n_target_qubits - 1)
if abs(phase) > 1e-10:
qc.rz(phase, n_target_qubits - 1)
return qc
Pattern 3: Full State Preparation Pipeline
def prepare_complex_state_bbqram(matrix: np.ndarray) -> QuantumCircuit:
"""
Full pipeline: complex matrix → quantum state via BBQRAM.
Args:
matrix: Complex-valued M×N matrix
Returns:
QuantumCircuit preparing |ψ⟩ = Σ_ij A_ij |i⟩|j⟩
"""
M, N = matrix.shape
data = matrix.flatten()
bbqram = BBQRAMSegmentTree(data)
n_addr = int(np.ceil(np.log2(M * N)))
n_data = int(np.ceil(np.log2(M * N)))
qc = QuantumCircuit(n_addr + n_data)
for i in range(n_addr):
qc.h(i)
for idx in range(len(data)):
angle, phase = bbqram.query(idx)
ctrl_qubits = _index_to_qubits(idx, n_addr)
qc.cry(angle, ctrl_qubits[-1], n_addr)
if abs(phase) > 1e-10:
qc.crz(phase, ctrl_qubits[-1], n_addr)
return qc
Key Insights from arXiv:2604.25644
-
Removing U_2CR: The original approach used a reversible arithmetic subroutine (U_2CR) on the QPU to compute rotation angles. By precomputing classically and storing fixed-point angles in BBQRAM cells, the QPU only needs to retrieve and apply rotations — no arithmetic needed.
-
Memory trade-off: Each BBQRAM cell now stores precomputed angles (fixed-point numbers) rather than raw subtree weights. This uses O(MN) memory cells per matrix — the same asymptotic space.
-
Query complexity unchanged: O(log²(MN)) BBQRAM query time is maintained despite the architectural improvement.
-
Complex-valued extension: The two-step magnitude-then-phase procedure is a clean separation:
- Magnitudes are handled by the segment tree (same as real case)
- Phases are stored as leaf metadata and applied afterward
- Real signed matrices are a natural one-bit phase specialization
-
Architecture-awareness: The design leverages the specific structure of BBQRAM (bucket brigade routing) rather than treating QRAM as a black box.
Complexity Analysis
| Component | Complexity | Notes |
|---|
| Qubit count | O(log(MN)) | For MN elements |
| Query time | O(log²(MN)) | BBQRAM routing depth |
| Classical precomputation | O(MN) | One-time cost |
| Memory per matrix | O(MN) cells | Precomputed angles + phases |
| QPU arithmetic | None | Key improvement over prior work |
When to Use This Approach
- Large-scale quantum finance applications: Portfolio data, covariance matrices, price histories
- Complex-valued data loading: Quantum algorithms requiring complex amplitudes
- BBQRAM hardware available: Bucket brigade QRAM architecture is implemented or simulated
- Polylogarithmic query needed: When O(log²(MN)) access is critical for quantum advantage
- Architecture-aware optimization: When targeting specific QRAM hardware
When NOT to Use
- Small datasets: Classical loading is sufficient for small n
- No QRAM hardware: BBQRAM is still largely theoretical/near-term
- Real-time data updates: Precomputation must be redone for dynamic data
- Extreme precision requirements: Fixed-point angle representation has finite precision
Error Handling
Precision Loss in Fixed-Point Angles
If fixed-point representation causes fidelity loss:
- Increase bit-width of stored angles
- Use adaptive precision (more bits for critical rotations)
- Apply error mitigation (zero-noise extrapolation on rotation gates)
BBQRAM Routing Errors
Hardware imperfections in bucket brigade routing:
- Add error-correcting codes to QRAM address lines
- Use redundant routing paths
- Apply post-selection on query success
Phase Wrapping Issues
For complex-valued data with phases outside [0, 2π):
- Normalize phases to principal range
- Use phase unwrapping before storage
- Apply phase correction gates with bounded rotation angles
Related Papers
- arXiv:2604.25644 — Primary paper (Berti & Ghisoni, 2026)
- arXiv:1307.0411 — Original amplitude encoding motivation
- arXiv:2602.21350 — Inverse Born Rule Fallacy (critique of naive amplitude encoding)
- arXiv:2411.11660 — Tensor network approach for probability loading
Related Skills
quantum-ml-data-loading - General QML data loading techniques
inverse-born-rule-fallacy - Critical analysis of amplitude encoding
dynamical-hamiltonian-encoding - Alternative encoding avoiding phase-locking
quantum-finance-stack-analysis - Evaluating quantum finance approaches
Tools Used
terminal: Run quantum simulation code (Qiskit, PennyLane)
write: Create BBQRAM state preparation implementations
web_search: Find related QRAM and state preparation papers
web_extract: Extract paper content from arXiv
Resources