Skip to main content

bbqram-state-preparation-finance

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.

Ir a la instalación

Datos de origen

Repositorio
hiyenwong/ai_collection
Última actividad en el origen
8 de junio de 2026 a las 08:11
Idioma detectado de SKILL.md
inglés
Estrellas
2
Forks
0

Opciones de instalación

De forma predeterminada está seleccionado el prompt que primero revisa el origen. Puedes cambiar a un comando directo o descargar una copia local.

Revisa los archivos de origen

Lee SKILL.md y los archivos complementarios que muestra SkillsMP antes de decidir si quieres instalarlo.

Mostrando SKILL.md

SKILL.md
Instrucciones de origen · Vista previa de solo lectura
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: 1. Arrange MN data elements as leaves of a binary segment tree 2. Each internal node stores the sum (or partial sum) of its children 3. Tree depth: O(log(MN)) 4. 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: 1. **Precompute classically**: Calculate all rotation angles from the segment tree structure 2. **Store in QRAM cells**: Load precomputed fixed-point angles directly into BBQRAM 3. **Trade-off**: BBQRAM stores precomputed angles instead of raw subtree weights 4. **Benefit**: QPU procedure reduces to simple BBQRAM retrievals + controlled-rotation cascades 5. **No reversible arithmetic needed on QPU** ### Step 3: Magnitude-Then-Phase Procedure (Complex-Valued Extension) For complex-valued matrices A ∈ ℂ^(M×N): 1. **Magnitude step**: Encode |A_ij| using the segment tree + precomputed angles 2. **Phase step**: Apply stored leaf phases to each element 3. **Two-step procedure**: - First prepare the state with correct magnitudes - Then apply phase corrections via controlled phase gates 4. **Real signed case**: Natural specialization using one-bit phase (sign bit) ### Step 4: Query Execution The QPU performs: 1. BBQRAM query to retrieve precomputed data: O(log²(MN)) time 2. Apply controlled-rotation cascade based on retrieved angles 3. Apply phase corrections for complex values 4. No reversible arithmetic on QPU ## Implementation Patterns ### Pattern 1: Segment Tree + BBQRAM Data Structure ```python 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))) # Build segment tree self.tree = self._build_tree(data) # Precompute rotation angles self.angles = self._precompute_angles() # Extract leaf phases for complex values 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 # Leaf weights 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 ```python 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) # BBQRAM routing (hardware-specific) # Routes to correct leaf based on index_bits # Apply precomputed rotation qc.ry(angle, n_target_qubits - 1) # Apply phase correction for complex values if abs(phase) > 1e-10: qc.rz(phase, n_target_qubits - 1) return qc ``` ### Pattern 3: Full State Preparation Pipeline ```python 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() # Build BBQRAM segment tree bbqram = BBQRAMSegmentTree(data) # Qubit counts n_addr = int(np.ceil(np.log2(M * N))) n_data = int(np.ceil(np.log2(M * N))) # Amplitude qubits qc = QuantumCircuit(n_addr + n_data) # Superposition over address space for i in range(n_addr): qc.h(i) # BBQRAM queries + controlled rotations for idx in range(len(data)): angle, phase = bbqram.query(idx) # Controlled rotation cascade # (Simplified - actual implementation uses BBQRAM routing) 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 1. **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. 2. **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. 3. **Query complexity unchanged**: O(log²(MN)) BBQRAM query time is maintained despite the architectural improvement. 4. **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 5. **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: 1. Increase bit-width of stored angles 2. Use adaptive precision (more bits for critical rotations) 3. Apply error mitigation (zero-noise extrapolation on rotation gates) ### BBQRAM Routing Errors Hardware imperfections in bucket brigade routing: 1. Add error-correcting codes to QRAM address lines 2. Use redundant routing paths 3. Apply post-selection on query success ### Phase Wrapping Issues For complex-valued data with phases outside [0, 2π): 1. Normalize phases to principal range 2. Use phase unwrapping before storage 3. 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 - **Primary Paper**: https://arxiv.org/abs/2604.25644 - **Qiskit**: https://qiskit.org/ (for circuit simulation) - **BBQRAM implementations**: Check latest quantum hardware SDKs
Ver en GitHub