How apayne185/qatabasis works
Purpose and Entry Points
Qatabasis is hybrid quantum-classical VQE middleware for molecular ground-state estimation across local CPU simulation, NVIDIA GPU simulation, MPI ranks, and IBM Quantum QPUs. Main programmatic entry is QatabasisStack; user-facing runs begin through Makefile, benchmark runners, or the walkthrough.
• src/api/interface.py
• benchmarks/local_test_run.py
• benchmarks/ibm_test_run.py
Problem Construction
ChemistryProblem converts registered or resolved molecular input into an electronic-structure problem using PySCF, then applies Jordan–Wigner mapping to produce a Pauli Hamiltonian and selects a hardware-efficient ansatz. Molecule resolution accepts registry names, geometries, SMILES, and optionally PubChem lookup.
• src/api/problems.py
• src/api/molecule_resolver.py
• MOLECULES.md
Hardware Policy and Backend Routing
Startup hardware discovery determines CPU/GPU availability, GPU class and memory fit, precision policy, MPI rank count, output hardware slug, and preferred simulator backend. Environment variables can force backend, GPU use, precision, molecules, iterations, seed, and IBM credentials. Production routing selects GPU-capable Qiskit Aer/cuStateVec when available, otherwise CPU statevector; IBM mode selects the Qiskit Runtime path.
• src/api/hardware.py
• src/api/interface.py
• .env.example
Primary VQE Control Flow
Rank 0 owns SPSA state. For each iteration it creates two perturbed parameter vectors, evaluates their energies, estimates a gradient, updates parameters, detects convergence, and periodically checkpoints optimizer state. In simulator mode, ranks independently build the full statevector and evaluate partitions of Pauli terms; collective reduction produces total energies. This boundary is important: only observable evaluation is distributed, while per-rank statevector construction remains exponential and redundant.
• src/api/interface.py
• src/api/problems.py
• src/api/results.py
IBM QPU Boundary
For BACKEND=ibm_cloud, the Python path submits both SPSA perturbation evaluations together as EstimatorV2 PUBs, reducing cloud round trips. It depends on IBM Quantum Runtime credentials and backend selection. The native C++ client is a separate REST-oriented implementation, not the documented production route.
• src/api/interface.py
• src/dispatcher/qpu_client.cpp
• .env.example
Native MPI/CUDA Dispatch Path
A separately built hpc_core module exposes C++ execution to Python through pybind11. The dispatcher uses nonblocking MPI broadcast and all-reduce around CPU/CUDA local work; shared workload/result/Pauli contracts are defined in C++ headers. Its CUDA kernel uses a mixed-precision mean-field Pauli evaluation and is diagnostic-only, explicitly not validated for production chemical accuracy. CPU-only builds use a stub fallback.
• src/dispatcher/bridge.cpp
• src/dispatcher/dispatcher.cpp
• src/classical/cuda/kernel.cu
• src/classical/cpu/kernel_stub.cpp
• include/stack_types.h
Execution, Deployment, and Persistence
Docker provides CUDA, OpenMPI, and Python; native deployment uses Conda/CMake and Slurm scripts for HPC scheduling. Results are timestamped structured JSON organized by detected hardware and run category, then consumed by aggregation/plotting scripts. Material external dependencies are Qiskit/Qiskit Nature, PySCF, mpi4py/OpenMPI, NVIDIA CUDA/cuQuantum/Qiskit Aer, and IBM Quantum Runtime.
• Dockerfile
• CMakeLists.txt
• scripts/install_native.sh
• scripts/slurm_scaling.sh
• benchmarks/aggregate_scaling.py
Components 17
Python VQE stack
- QatabasisStack · Owns routing, SPSA control, and checkpointing.
src/api/interface.py - Hardware policy · Selects CPU, GPU, MPI, precision, and simulator policy.
src/api/hardware.py - Molecule resolver · Resolves registry names, geometry, SMILES, and optional PubChem input.
src/api/molecule_resolver.py - ChemistryProblem · Builds PySCF problems, Jordan–Wigner Pauli Hamiltonians, and ansatzes.
src/api/problems.py - SPSA optimizer · Creates perturbations, estimates gradients, updates parameters, and converges.
src/api/interface.py - Distributed observable evaluation · Each rank builds a full statevector; ranks partition Pauli terms then reduce energies.
src/api/interface.py - Result persistence · Stores timestamped runs by detected hardware and category.
src/api/results.py - IBM Runtime EstimatorV2 · Batches both SPSA perturbation evaluations as PUBs.
src/api/interface.py
Native MPI/CUDA path
- hpc_core bridge · Exposes native dispatch to Python.
src/dispatcher/bridge.cpp - MPI dispatcher · Uses nonblocking broadcast and all-reduce around local work.
src/dispatcher/dispatcher.cpp - Shared execution contracts · Defines workload, result, and Pauli data contracts.
include/stack_types.h - CUDA Pauli kernel · Mixed-precision mean-field evaluation; not production-accuracy validated.
src/classical/cuda/kernel.cu - CPU stub kernel · Supports CPU-only native builds.
src/classical/cpu/kernel_stub.cpp
Execution and results
- Run entry points
benchmarks/local_test_run.py - Native build and image · Packages CUDA, OpenMPI, Python, and the native module.
CMakeLists.txt - Slurm scaling runs
scripts/slurm_scaling.sh - Scaling aggregation
benchmarks/aggregate_scaling.py
Connections 20
- Run entry points → QatabasisStack: starts
- QatabasisStack → Hardware policy: discovers policy
- QatabasisStack → Molecule resolver: resolves input
- Molecule resolver → ChemistryProblem: molecular input
- ChemistryProblem → SPSA optimizer: Hamiltonian and ansatz
- Hardware policy → Distributed observable evaluation: CPU/GPU simulator route
- Hardware policy → IBM Runtime EstimatorV2: ibm_cloud route
- SPSA optimizer → Distributed observable evaluation: perturbed energies
- SPSA optimizer → IBM Runtime EstimatorV2: paired PUB evaluations
- Distributed observable evaluation → SPSA optimizer: reduced energies
- IBM Runtime EstimatorV2 → SPSA optimizer: Estimator results
- SPSA optimizer → Result persistence: checkpoints and final run
- Distributed observable evaluation → hpc_core bridge: optional native execution
- hpc_core bridge → MPI dispatcher: calls
- MPI dispatcher → Shared execution contracts: uses contracts
- MPI dispatcher → CUDA Pauli kernel: CUDA local work
- MPI dispatcher → CPU stub kernel: CPU-only fallback
- Native build and image → hpc_core bridge: builds module
- Slurm scaling runs → Run entry points: schedules runs
- Result persistence → Scaling aggregation: consumed for plots