Skip to main content

Micro-optimized High-Performance NISQ Statevector Quantum Circuit Simulator (Hardware-Adaptive Integration of Native NumPy, CUDA-Accelerated CuPy, and Linear Kernel Fusion via JAX JIT/XLA Compilation)

Project description

██████╗ ███████╗███╗   ██╗███████╗███████╗
██╔══██╗██╔════╝████╗  ██║██╔════╝██╔════╝
██║  ██║█████╗  ██╔██╗ ██║███████╗█████╗  
██║  ██║██╔══╝  ██║╚██╗██║╚════██║██╔══╝  
██████╔╝███████╗██║ ╚████║███████║███████╗
╚═════╝ ╚══════╝╚═╝  ╚═══╝╚══════╝╚══════╝
███████╗██╗   ██╗ ██████╗ ██╗     
██╔════╝██║   ██║██╔═══██╗██║     
█████╗  ██║   ██║██║   ██║██║     
██╔══╝  ╚██╗ ██╔╝██║   ██║██║     
███████╗ ╚████╔╝ ╚██████╔╝███████╗
╚══════╝  ╚═══╝   ╚═════╝ ╚══════╝

Dense Statevector Quantum Simulator · JAX XLA · NISQ · VQE · QML

![CI](https://github.com/tatopenn-cell/Dense-Evolution/actions/workflows/ci.yml) ![PyPI](https://pypi.org/project/dense-evolution/) ![Python](https://www.python.org/) ![License](LICENSE.md) ![Build](https://github.com/tatopenn-cell/Dense-Evolution/actions)

---

▍ What It Is

Dense Evolution is a high-performance statevector simulator engineered for deep NISQ circuits, VQE pipelines, and QML workloads. It eliminates Kronecker product overhead entirely via stride-sliced linear kernel fusion compiled through JAX XLA — keeping memory at the theoretical minimum of 2ⁿ × 16 bytes.

The integrated dash.py dashboard provides live ipywidgets telemetry across 6 quantum observables per simulation run, directly inside Google Colab or Jupyter.

---

▍ Install

# core engine
pip install dense-evolution

# full stack: JAX · GPU · dashboard
pip install dense-evolution\\\[full]

# development
git clone https://github.com/tatopenn-cell/Dense-Evolution.git
cd Dense-Evolution \\\&\\\& pip install -e .\\\[full]

Google Colab (3 lines):

!git clone https://github.com/tatopenn-cell/Dense-Evolution.git
%cd Dense-Evolution
!pip install -e .

---

▍ Quick Start

from dense\\\_evolution import DenseSVSimulator, QASMParser

# parse any OpenQASM 2.0 string
qasm = """
OPENQASM 2.0;
include "qelib1.inc";
qreg q\\\[3];
h q\\\[0];
cx q\\\[0], q\\\[1];
cx q\\\[1], q\\\[2];
"""

parser = QASMParser()
circuit = parser.parse(qasm)

sim = DenseSVSimulator(n\\\_qubits=3)
sim.run\\\_circuit\\\_jit\\\_beast\\\_mode(circuit.ops)

print(sim.get\\\_probabilities())   # \\\[0.5, 0, 0, 0, 0, 0, 0, 0.5]  — GHZ state
print(sim.memory\\\_mb())           # 0.000128 MB

Dashboard (Colab / Jupyter):

import dash
from IPython.display import display, clear\\\_output

clear\\\_output()
display(dash.dashboard\\\_unificata)

---

▍ Architecture

dense\\\_evolution/
├── registry.py       hardware detection · JAX / CuPy / NumPy capability flags
├── gates.py          GATES{} · PARAMETRIC\\\_GATES{} · GATE\\\_IDS{}
├── noise\\\_model.py    Kraus channels · stochastic trajectory engine
├── parser.py         QASMParser · QASMCircuit · OpenQASM 2.0 / 3.0
├── compiler.py       \\\_apply\\\_gate\\\_fast\\\_step (jit) · \\\_compile\\\_and\\\_run\\\_circuit\\\_jit
├── simulator.py      DenseSVSimulator · vmap batch VQE · chunked execution
└── dash.py           ipywidgets dashboard · VQE engine · MD simulation

Data flow per run:

▶ Run
 └─ core\\\_calcolo\\\_quantistico()          parse → JIT execute → apply noise
     ├─ ottimizza\\\_vqe()                 Hellmann-Feynman AD → ADAM → df\\\_vqe\\\_telemetry
     ├─ run\\\_md\\\_simulation\\\_dummy()       QM/MM dynamics → df\\\_md\\\_telemetry + Pearson matrix
     └─ build\\\_panel\\\_\\\*(res)              matplotlib figure → display()

---

▍ Core Features

Feature Detail
Linear Kernel Fusion Stride-sliced tensor ops via JAX XLA — zero Kronecker matrices
Circuit Chunking Fixed-size JIT blocks eliminate tracer overhead on 1000+ gate circuits
Kraus Noise Channels depolarizing amplitude\\\_damping phase\\\_damping bitflip combined — stochastic, O(2ⁿ) cost
VQE + ADAM Hellmann-Feynman gradient via JAX AD · positional parameter injection into any QASM 2.0
vmap Batch Sweep run\\\_parametric\\\_batch\\\_jit() evaluates full parameter grids in one JIT call
Backend Agnostic NumPy CPU · JAX XLA CPU/TPU · CuPy CUDA — runtime selection, zero code changes
Live Dashboard 8-panel ipywidgets telemetry: probability, VQE energy, entropy, purity, gradient, noise, θ-correction, Pearson heatmap

---

▍ Benchmarks

Measured on Google Colab Free Tier (CPU runtime)

Metric Value
Numerical drift (80-layer Ansatz, 1360 gates) Δ = 1.11 × 10⁻¹⁶
Memory footprint @ 20q 32 MB (float64) · 16 MB (float32)
JIT compile overhead (first run) < 400 ms
Gate throughput after warm-up > 10⁶ gates/s (CPU)
Maximum tested qubits (Colab Free) 24q stable · 33q high-RAM runtime

---

▍ Dashboard Panels

Panel Contents
Overview R0 header · R1 P(|n⟩) histogram + Top-12 states · R2 wavefunction helix 3D + metrics table · R3 noise analysis + shot histogram · R4–R6 VQE telemetry × 6 · R7 Pearson heatmap
Fisica Stato Bloch projection · Schmidt rank · coherence vector
Mosaico 1008q 2D probability density map up to 1008 qubits
VQE Results 6-subplot telemetry: energy convergence, entropy, purity, ‖∇L‖, noise factor, θ-correction
MD Results 6-subplot MD telemetry + masked Pearson correlation heatmap
Performance Gate throughput · JIT compile time · RAM usage

---

▍ Circuit Library (30+ presets)

All circuits are stored as OpenQASM 2.0 strings in QASM\\\_LIBRARY.

Standard — Bell Φ⁺, QFT 4q/8q, Toffoli, Adder 2-bit, Deutsch-Jozsa, Bernstein-Vazirani
Algorithms — Grover 3q/4q, Simon 4q, Shor 15, HHL, QAOA Max-Cut 4q, QPE 5q, Quantum Walk, Teleportation, BB84
Topological — Anyonic Braiding 6q, Charge Pump 8q, Arecibo DeepField 16q Peptide / Biological — Furin RRAR 8q, Hemoglobin MVLSPADK 8q, Stress Tests — Hardware Stress, Quantum Supremacy, Interference Stress,

▍ VQE Engine

Positional parameter injectionQASMParser tokenizes all literals to 0.0 for JIT speed. VQE recovers parameters by:

  1. counting parametric gates (rx ry rz p u1 cp crz) → n\\\_params
  2. initializing θ ∈ ℝⁿ uniform in \\\[−π, π]
  3. injecting θ\\\[i] sequentially by gate order in the AST via risolvi\\\_qasm()

Compatible with any custom OpenQASM 2.0 string without pre-labelling.

Gradient & update rule:

$$\frac{\partial E}{\partial \theta_i} = \langle\psi(\theta)|,\frac{\partial H}{\partial \theta_i},|\psi(\theta)\rangle \qquad \theta \leftarrow \theta - \frac{\alpha,\hat{m}_t}{\sqrt{\hat{v}_t}+\varepsilon}$$

Telemetry columns (→ df\\\_vqe\\\_telemetry):

Column Unit Description
VQE\\\_Energy Ha ⟨ψ|H|ψ⟩
Entropy bit −Tr(ρ log₂ ρ)
Purity Tr(ρ²) ∈ [1/d, 1]
Gradient ‖∇L‖ — barren plateau detection
Noise\\\_Factor fidelity-derived noise proxy
Theta\\\_Correction rad ADAM step norm

---

▍ Hamiltonian Library

Auto-filtered by qubit count to prevent shape mismatch.

Molecule Qubits Bond length E₀ (Ha)
H₂ 2 0.74 Å −1.13
H₃⁺ 3 0.85 Å −1.28
LiH 4 1.40 Å −2.31
H₂O 5 0.96 Å −4.12

Custom: JSON array of diagonal eigenvalues, length 2^n\\\_qubits.

---

▍ Noise Models

All channels applied as post-circuit Kraus operations on the full statevector.

Model Kraus operators Physical process
ideal I noiseless
depolarizing {√(1−p)I, √(p/3)X,Y,Z} isotropic Pauli error
amplitude\\\_damping {K₀, K₁} T₁ energy relaxation
phase\\\_damping {K₀, K₁} T₂ dephasing
bitflip {√(1−p)I, √p·X} bit flip σₓ
combined depolarizing(p/2) ∘ amp_damp(p/3) worst-case NISQ

Fidelity: Bhattacharyya F = Σᵢ √(pᵢqᵢ) and TVD = ½Σᵢ|pᵢ−qᵢ| computed on every noisy run.

---

▍ Troubleshooting

Error Cause Fix
TypeError: cond branches must have equal output types JAX dtype mismatch between 1q/2q branches de.patch\\\_dense\\\_parametric(de.DenseSVSimulator) — runs automatically on import
VQE telemetry empty VQE disabled or no parametric gates Enable VQE Settings checkbox; use circuits with rx/ry/rz gates
Hamiltonian shape mismatch JSON array length ≠ 2^n_qubits Supply exactly 2^n values (e.g. 16 for 4q)
Barren plateau span not visible < 3 consecutive epochs with ‖g‖ < 0.01·max‖g‖ Increase epochs or reduce learning rate
Dashboard blank in JupyterLab Extension missing jupyter labextension install @jupyter-widgets/jupyterlab-manager
Memory error on high-qubit circuits 2ⁿ × 16 bytes: 24q = 268 MB, 30q = 16 GB Use use\\\_float32=True to halve; cap at 24q on standard runtimes

---

### 🚀 Quantum Error Mitigation & Predictive Healing Engine

To significantly suppress non-unitary quantum noise and phase dephasing channels without the massive physical hardware overhead of standard Error Correction, this release introduces a high-performance, JAX-accelerated **Predictive Healing Engine** natively integrated into the simulation runtime.

Unlike static Zero-Noise Extrapolation (ZNE) protocols that can compound errors over deep variational quantum circuits, the new framework implements an active predictive mitigation topology controlled via a dynamic, multi-variable stabilization parameter ($\kappa$):

* ** Dephasing Tracking:** The engine monitors phase drift by calculating the predictive deviation ($$\Delta_{pre\_emp}$$) of the synchronization function ($\Sigma$) relative to the ideal target eigenstate.

* **Hardware-Adaptive $\kappa$-Stabilization:** Upon reaching the critical dephasing threshold, a calibrated learning routine dynamically scales the coherence strength ($\kappa$). This proactively shields the statevector profile *prior* to Richardson extrapolation.

* **Coupled Richardson Integration:** The healed quantum energy values are subsequently mapped to dual-point stretched noise density thresholds ($\lambda_1 = 1.0, \lambda_2 = 2.0$), stabilizing the final zero-noise trajectory approximation without creating non-linear numerical artifacts.

All computational cores—including spatial alignment tensors ($\Phi_{AB}$) and life-vector dynamics ($V_{vita}$)—are decorated with @jax.jit, triggering full **XLA Kernel Fusion** to execute mass-parallelized trajectory sweeps (over 10,000+ simultaneous simulation tracks) under a fraction of a second.

▍ License

Business Source License 1.1 — converts automatically to Apache 2.0 on 1 June 2029.

  • Non-commercial use: unrestricted
  • Commercial use: ≤ 24 allocated qubits · ≤ 1000 circuits/day · ≤ 10,000 shots/circuit
  • Attribution required on all copies: © 2026 Salvatore Pennacchio <jtatopenn@libero.it> — Dense Evolution

Full text: LICENSE.md

---

© 2026 Salvatore Pennacchio — Dense Evolution v8.0.9

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dense_evolution-8.0.9.tar.gz (82.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dense_evolution-8.0.9-py3-none-any.whl (80.7 kB view details)

Uploaded Python 3

File details

Details for the file dense_evolution-8.0.9.tar.gz.

File metadata

  • Download URL: dense_evolution-8.0.9.tar.gz
  • Upload date:
  • Size: 82.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.7

File hashes

Hashes for dense_evolution-8.0.9.tar.gz
Algorithm Hash digest
SHA256 aeee25a49e0eb140a512668142344a188bf8d25b2d1c9eaa749387b2ee1b9524
MD5 52112518a642f6cd69f7ebbdc172a4f0
BLAKE2b-256 9ac0ccf4648501ce4c8cfc69c568db3f4313795ff943145bae2ecaca80cf982c

See more details on using hashes here.

File details

Details for the file dense_evolution-8.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for dense_evolution-8.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 40b7b8192cf7b7704e839d7e1e3e36788ffe092c69c779ab788831ef22b4fa40
MD5 613e16916165c0d93aa043cffa85c66d
BLAKE2b-256 d37523f24af720c87848270d0fc401561270197701966c292e6dc6f72592fc35

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page