dense-evolution 8.0.7__tar.gz → 8.0.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. dense_evolution-8.0.8/PKG-INFO +311 -0
  2. dense_evolution-8.0.8/README.md +267 -0
  3. {dense_evolution-8.0.7 → dense_evolution-8.0.8}/dash.py +461 -1011
  4. dense_evolution-8.0.8/dense_evolution/gates.py +50 -0
  5. {dense_evolution-8.0.7 → dense_evolution-8.0.8}/dense_evolution/simulator.py +467 -488
  6. dense_evolution-8.0.8/dense_evolution.egg-info/PKG-INFO +311 -0
  7. {dense_evolution-8.0.7 → dense_evolution-8.0.8}/pyproject.toml +1 -1
  8. dense_evolution-8.0.7/PKG-INFO +0 -2956
  9. dense_evolution-8.0.7/README.md +0 -2912
  10. dense_evolution-8.0.7/dense_evolution/gates.py +0 -61
  11. dense_evolution-8.0.7/dense_evolution.egg-info/PKG-INFO +0 -2956
  12. {dense_evolution-8.0.7 → dense_evolution-8.0.8}/dense_evolution/__init__.py +0 -0
  13. {dense_evolution-8.0.7 → dense_evolution-8.0.8}/dense_evolution/compiler.py +0 -0
  14. {dense_evolution-8.0.7 → dense_evolution-8.0.8}/dense_evolution/mega_stress_test.py +0 -0
  15. {dense_evolution-8.0.7 → dense_evolution-8.0.8}/dense_evolution/parser.py +0 -0
  16. {dense_evolution-8.0.7 → dense_evolution-8.0.8}/dense_evolution/registry.py +0 -0
  17. {dense_evolution-8.0.7 → dense_evolution-8.0.8}/dense_evolution/stress_test.py +0 -0
  18. {dense_evolution-8.0.7 → dense_evolution-8.0.8}/dense_evolution/stress_test_quantum.py +0 -0
  19. {dense_evolution-8.0.7 → dense_evolution-8.0.8}/dense_evolution/test_library.py +0 -0
  20. {dense_evolution-8.0.7 → dense_evolution-8.0.8}/dense_evolution.egg-info/SOURCES.txt +0 -0
  21. {dense_evolution-8.0.7 → dense_evolution-8.0.8}/dense_evolution.egg-info/dependency_links.txt +0 -0
  22. {dense_evolution-8.0.7 → dense_evolution-8.0.8}/dense_evolution.egg-info/requires.txt +0 -0
  23. {dense_evolution-8.0.7 → dense_evolution-8.0.8}/dense_evolution.egg-info/top_level.txt +0 -0
  24. {dense_evolution-8.0.7 → dense_evolution-8.0.8}/license.md +0 -0
  25. {dense_evolution-8.0.7 → dense_evolution-8.0.8}/setup.cfg +0 -0
@@ -0,0 +1,311 @@
1
+ Metadata-Version: 2.4
2
+ Name: dense-evolution
3
+ Version: 8.0.8
4
+ Summary: 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)
5
+ Author-email: Salvatore Pennacchio <jtatopenn@libero.it>
6
+ License: Business Source License 1.1
7
+ Project-URL: Homepage, https://github.com/tatopenn-cell/Dense-Evolution
8
+ Project-URL: Documentation, https://github.com/tatopenn-cell/Dense-Evolution/blob/main/LICENSE
9
+ Project-URL: Repository, https://github.com/tatopenn-cell/Dense-Evolution
10
+ Project-URL: Bug Tracker, https://github.com/tatopenn-cell/Dense-Evolution/blob/main/dense_evolution.py
11
+ Keywords: quantum-computing,quantum-simulation,statevector,jax,cupy,cuda-acceleration,openqasm,nisq-noise,hpc,linear-kernel-fusion,dashboard,visualization
12
+ Classifier: Development Status :: 5 - Production/Stable
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: Other/Proprietary License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Scientific/Engineering :: Physics
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: >=3.9
24
+ Description-Content-Type: text/markdown
25
+ License-File: license.md
26
+ Requires-Dist: numpy>=1.22.0
27
+ Requires-Dist: matplotlib>=3.5.0
28
+ Requires-Dist: psutil>=5.9.0
29
+ Provides-Extra: jax
30
+ Requires-Dist: jax>=0.4.0; extra == "jax"
31
+ Requires-Dist: jaxlib>=0.4.0; extra == "jax"
32
+ Provides-Extra: gpu
33
+ Requires-Dist: cupy-cuda12x>=12.0.0; extra == "gpu"
34
+ Provides-Extra: dashboard
35
+ Requires-Dist: dash>=2.0.0; extra == "dashboard"
36
+ Requires-Dist: plotly>=5.0.0; extra == "dashboard"
37
+ Provides-Extra: full
38
+ Requires-Dist: jax>=0.4.0; extra == "full"
39
+ Requires-Dist: jaxlib>=0.4.0; extra == "full"
40
+ Requires-Dist: cupy-cuda12x>=12.0.0; extra == "full"
41
+ Requires-Dist: dash>=2.0.0; extra == "full"
42
+ Requires-Dist: plotly>=5.0.0; extra == "full"
43
+ Dynamic: license-file
44
+
45
+ ```
46
+ ██████╗ ███████╗███╗ ██╗███████╗███████╗
47
+ ██╔══██╗██╔════╝████╗ ██║██╔════╝██╔════╝
48
+ ██║ ██║█████╗ ██╔██╗ ██║███████╗█████╗
49
+ ██║ ██║██╔══╝ ██║╚██╗██║╚════██║██╔══╝
50
+ ██████╔╝███████╗██║ ╚████║███████║███████╗
51
+ ╚═════╝ ╚══════╝╚═╝ ╚═══╝╚══════╝╚══════╝
52
+ ███████╗██╗ ██╗ ██████╗ ██╗
53
+ ██╔════╝██║ ██║██╔═══██╗██║
54
+ █████╗ ██║ ██║██║ ██║██║
55
+ ██╔══╝ ╚██╗ ██╔╝██║ ██║██║
56
+ ███████╗ ╚████╔╝ ╚██████╔╝███████╗
57
+ ╚══════╝ ╚═══╝ ╚═════╝ ╚══════╝
58
+ ```
59
+
60
+ **Dense Statevector Quantum Simulator · JAX XLA · NISQ · VQE · QML**
61
+
62
+ [![CI](https://github.com/tatopenn-cell/Dense-Evolution/actions/workflows/ci.yml/badge.svg)](https://github.com/tatopenn-cell/Dense-Evolution/actions/workflows/ci.yml)
63
+ [![PyPI](https://img.shields.io/pypi/v/dense-evolution?style=flat-square&color=00e5ff)](https://pypi.org/project/dense-evolution/)
64
+ [![Python](https://img.shields.io/badge/Python-3.9+-blue?style=flat-square&logo=python&logoColor=white)](https://www.python.org/)
65
+ [![License](https://img.shields.io/badge/License-BSL_1.1-orange?style=flat-square)](LICENSE.md)
66
+ [![Build](https://img.shields.io/badge/Build-Passing-00ff9d?style=flat-square)](https://github.com/tatopenn-cell/Dense-Evolution/actions)
67
+
68
+ </div>
69
+
70
+ ---
71
+
72
+ ## ▍ What It Is
73
+
74
+ **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`.
75
+
76
+ The integrated `dash.py` dashboard provides live ipywidgets telemetry across 6 quantum observables per simulation run, directly inside Google Colab or Jupyter.
77
+
78
+ ---
79
+
80
+ ## ▍ Install
81
+
82
+ ```bash
83
+ # core engine
84
+ pip install dense-evolution
85
+
86
+ # full stack: JAX · GPU · dashboard
87
+ pip install dense-evolution[full]
88
+
89
+ # development
90
+ git clone https://github.com/tatopenn-cell/Dense-Evolution.git
91
+ cd Dense-Evolution && pip install -e .[full]
92
+ ```
93
+
94
+ **Google Colab (3 lines):**
95
+ ```python
96
+ !git clone https://github.com/tatopenn-cell/Dense-Evolution.git
97
+ %cd Dense-Evolution
98
+ !pip install -e .
99
+ ```
100
+
101
+ ---
102
+
103
+ ## ▍ Quick Start
104
+
105
+ ```python
106
+ from dense_evolution import DenseSVSimulator, QASMParser
107
+
108
+ # parse any OpenQASM 2.0 string
109
+ qasm = """
110
+ OPENQASM 2.0;
111
+ include "qelib1.inc";
112
+ qreg q[3];
113
+ h q[0];
114
+ cx q[0], q[1];
115
+ cx q[1], q[2];
116
+ """
117
+
118
+ parser = QASMParser()
119
+ circuit = parser.parse(qasm)
120
+
121
+ sim = DenseSVSimulator(n_qubits=3)
122
+ sim.run_circuit_jit_beast_mode(circuit.ops)
123
+
124
+ print(sim.get_probabilities()) # [0.5, 0, 0, 0, 0, 0, 0, 0.5] — GHZ state
125
+ print(sim.memory_mb()) # 0.000128 MB
126
+ ```
127
+
128
+ **Dashboard (Colab / Jupyter):**
129
+ ```python
130
+ import dash
131
+ from IPython.display import display, clear_output
132
+
133
+ clear_output()
134
+ display(dash.dashboard_unificata)
135
+ ```
136
+
137
+ ---
138
+
139
+ ## ▍ Architecture
140
+
141
+ ```
142
+ dense_evolution/
143
+ ├── registry.py hardware detection · JAX / CuPy / NumPy capability flags
144
+ ├── gates.py GATES{} · PARAMETRIC_GATES{} · GATE_IDS{}
145
+ ├── noise_model.py Kraus channels · stochastic trajectory engine
146
+ ├── parser.py QASMParser · QASMCircuit · OpenQASM 2.0 / 3.0
147
+ ├── compiler.py _apply_gate_fast_step (jit) · _compile_and_run_circuit_jit
148
+ ├── simulator.py DenseSVSimulator · vmap batch VQE · chunked execution
149
+ └── dash.py ipywidgets dashboard · VQE engine · MD simulation
150
+ ```
151
+
152
+ **Data flow per run:**
153
+ ```
154
+ ▶ Run
155
+ └─ core_calcolo_quantistico() parse → JIT execute → apply noise
156
+ ├─ ottimizza_vqe() Hellmann-Feynman AD → ADAM → df_vqe_telemetry
157
+ ├─ run_md_simulation_dummy() QM/MM dynamics → df_md_telemetry + Pearson matrix
158
+ └─ build_panel_*(res) matplotlib figure → display()
159
+ ```
160
+
161
+ ---
162
+
163
+ ## ▍ Core Features
164
+
165
+ | Feature | Detail |
166
+ |---|---|
167
+ | **Linear Kernel Fusion** | Stride-sliced tensor ops via JAX XLA — zero Kronecker matrices |
168
+ | **Circuit Chunking** | Fixed-size JIT blocks eliminate tracer overhead on 1000+ gate circuits |
169
+ | **Kraus Noise Channels** | `depolarizing` `amplitude_damping` `phase_damping` `bitflip` `combined` — stochastic, O(2ⁿ) cost |
170
+ | **VQE + ADAM** | Hellmann-Feynman gradient via JAX AD · positional parameter injection into any QASM 2.0 |
171
+ | **vmap Batch Sweep** | `run_parametric_batch_jit()` evaluates full parameter grids in one JIT call |
172
+ | **Backend Agnostic** | NumPy CPU · JAX XLA CPU/TPU · CuPy CUDA — runtime selection, zero code changes |
173
+ | **Live Dashboard** | 8-panel ipywidgets telemetry: probability, VQE energy, entropy, purity, gradient, noise, θ-correction, Pearson heatmap |
174
+
175
+ ---
176
+
177
+ ## ▍ Benchmarks
178
+
179
+ > Measured on Google Colab Free Tier (CPU runtime)
180
+
181
+ | Metric | Value |
182
+ |---|---|
183
+ | Numerical drift (80-layer Ansatz, 1360 gates) | `Δ = 1.11 × 10⁻¹⁶` |
184
+ | Memory footprint @ 20q | `32 MB` (float64) · `16 MB` (float32) |
185
+ | JIT compile overhead (first run) | `< 400 ms` |
186
+ | Gate throughput after warm-up | `> 10⁶ gates/s` (CPU) |
187
+ | Maximum tested qubits (Colab Free) | `24q` stable · `33q` high-RAM runtime |
188
+
189
+ ---
190
+
191
+ ## ▍ Dashboard Panels
192
+
193
+ | Panel | Contents |
194
+ |---|---|
195
+ | **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 |
196
+ | **Fisica Stato** | Bloch projection · Schmidt rank · coherence vector |
197
+ | **Mosaico 1008q** | 2D probability density map up to 1008 qubits |
198
+ | **VQE Results** | 6-subplot telemetry: energy convergence, entropy, purity, ‖∇L‖, noise factor, θ-correction |
199
+ | **MD Results** | 6-subplot MD telemetry + masked Pearson correlation heatmap |
200
+ | **Performance** | Gate throughput · JIT compile time · RAM usage |
201
+
202
+ ---
203
+
204
+ ## ▍ Circuit Library (80+ presets)
205
+
206
+ All circuits are stored as OpenQASM 2.0 strings in `QASM_LIBRARY`.
207
+
208
+ **Standard** — Bell Φ⁺, QFT 4q/8q, Toffoli, Adder 2-bit, Deutsch-Jozsa, Bernstein-Vazirani
209
+ **Algorithms** — Grover 3q/4q, Simon 4q, Shor 15, HHL, QAOA Max-Cut 4q, QPE 5q, Quantum Walk, Teleportation, BB84
210
+ **Topological** — Anyonic Braiding 6q, Charge Pump 8q, DiamondPhi 12q, Omega Phase Lock 8q, Arecibo DeepField 16q, ARECIBO v11.3 SINGULARITY
211
+ **Peptide / Biological** — Furin RRAR 8q, Hemoglobin MVLSPADK 8q, Spike 8q/16q, p53 Guardian 24q, WormholeTriplePeptide 24q
212
+ **Stress Tests** — Hardware Stress, Quantum Supremacy, Interference Stress, BGQ 32q, Twin Shield Full Resonance 32q, Nuovo Circuito 33q
213
+
214
+ **Proprietary phase constants used in topological circuits:**
215
+
216
+ | Constant | Value (rad) | Physical origin |
217
+ |---|:---:|---|
218
+ | φ (Golden Ratio) | 1.6180 | Tatopenn φ-resonance |
219
+ | sp³ diamond angle | 1.9106 | Carbon tetrahedral bond |
220
+ | Topological lock | 3.0718 | Near-π translocation phase |
221
+ | Omega / Fe₂S₂ | 6.1574 | Iron-sulfur cluster phase lock |
222
+ | BGQ wormhole kick | 0.7000 | BGQ wormhole kickback amplitude |
223
+
224
+ ---
225
+
226
+ ## ▍ VQE Engine
227
+
228
+ **Positional parameter injection** — `QASMParser` tokenizes all literals to `0.0` for JIT speed. VQE recovers parameters by:
229
+ 1. counting parametric gates (`rx ry rz p u1 cp crz`) → `n_params`
230
+ 2. initializing `θ ∈ ℝⁿ` uniform in `[−π, π]`
231
+ 3. injecting `θ[i]` sequentially by gate order in the AST via `risolvi_qasm()`
232
+
233
+ Compatible with any custom OpenQASM 2.0 string without pre-labelling.
234
+
235
+ **Gradient & update rule:**
236
+
237
+ $$\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}$$
238
+
239
+ **Telemetry columns** (→ `df_vqe_telemetry`):
240
+
241
+ | Column | Unit | Description |
242
+ |---|---|---|
243
+ | `VQE_Energy` | Ha | ⟨ψ\|H\|ψ⟩ |
244
+ | `Entropy` | bit | −Tr(ρ log₂ ρ) |
245
+ | `Purity` | — | Tr(ρ²) ∈ [1/d, 1] |
246
+ | `Gradient` | — | ‖∇L‖ — barren plateau detection |
247
+ | `Noise_Factor` | — | fidelity-derived noise proxy |
248
+ | `Theta_Correction` | rad | ADAM step norm |
249
+
250
+ ---
251
+
252
+ ## ▍ Hamiltonian Library
253
+
254
+ Auto-filtered by qubit count to prevent shape mismatch.
255
+
256
+ | Molecule | Qubits | Bond length | E₀ (Ha) |
257
+ |---|:---:|:---:|:---:|
258
+ | H₂ | 2 | 0.74 Å | −1.13 |
259
+ | H₃⁺ | 3 | 0.85 Å | −1.28 |
260
+ | LiH | 4 | 1.40 Å | −2.31 |
261
+ | H₂O | 5 | 0.96 Å | −4.12 |
262
+
263
+ Custom: JSON array of diagonal eigenvalues, length `2^n_qubits`.
264
+
265
+ ---
266
+
267
+ ## ▍ Noise Models
268
+
269
+ All channels applied as post-circuit Kraus operations on the full statevector.
270
+
271
+ | Model | Kraus operators | Physical process |
272
+ |---|---|---|
273
+ | `ideal` | I | noiseless |
274
+ | `depolarizing` | {√(1−p)I, √(p/3)X,Y,Z} | isotropic Pauli error |
275
+ | `amplitude_damping` | {K₀, K₁} | T₁ energy relaxation |
276
+ | `phase_damping` | {K₀, K₁} | T₂ dephasing |
277
+ | `bitflip` | {√(1−p)I, √p·X} | bit flip σₓ |
278
+ | `combined` | depolarizing(p/2) ∘ amp_damp(p/3) | worst-case NISQ |
279
+
280
+ Fidelity: Bhattacharyya `F = Σᵢ √(pᵢqᵢ)` and TVD `= ½Σᵢ|pᵢ−qᵢ|` computed on every noisy run.
281
+
282
+ ---
283
+
284
+ ## ▍ Troubleshooting
285
+
286
+ | Error | Cause | Fix |
287
+ |---|---|---|
288
+ | `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 |
289
+ | VQE telemetry empty | VQE disabled or no parametric gates | Enable **VQE Settings** checkbox; use circuits with `rx/ry/rz` gates |
290
+ | Hamiltonian shape mismatch | JSON array length ≠ 2^n_qubits | Supply exactly `2^n` values (e.g. 16 for 4q) |
291
+ | Barren plateau span not visible | < 3 consecutive epochs with ‖g‖ < 0.01·max‖g‖ | Increase epochs or reduce learning rate |
292
+ | Dashboard blank in JupyterLab | Extension missing | `jupyter labextension install @jupyter-widgets/jupyterlab-manager` |
293
+ | 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 |
294
+
295
+ ---
296
+
297
+ ## ▍ License
298
+
299
+ **Business Source License 1.1** — converts automatically to **Apache 2.0** on **1 June 2029**.
300
+
301
+ - Non-commercial use: unrestricted
302
+ - Commercial use: ≤ 24 allocated qubits · ≤ 1000 circuits/day · ≤ 10,000 shots/circuit
303
+ - Attribution required on all copies: `© 2026 Salvatore Pennacchio <jtatopenn@libero.it> — Dense Evolution`
304
+
305
+ Full text: [LICENSE.md](LICENSE.md)
306
+
307
+ ---
308
+
309
+ <div align="center">
310
+ <sub>© 2026 Salvatore Pennacchio — Dense Evolution v8.0.7</sub>
311
+
@@ -0,0 +1,267 @@
1
+ ```
2
+ ██████╗ ███████╗███╗ ██╗███████╗███████╗
3
+ ██╔══██╗██╔════╝████╗ ██║██╔════╝██╔════╝
4
+ ██║ ██║█████╗ ██╔██╗ ██║███████╗█████╗
5
+ ██║ ██║██╔══╝ ██║╚██╗██║╚════██║██╔══╝
6
+ ██████╔╝███████╗██║ ╚████║███████║███████╗
7
+ ╚═════╝ ╚══════╝╚═╝ ╚═══╝╚══════╝╚══════╝
8
+ ███████╗██╗ ██╗ ██████╗ ██╗
9
+ ██╔════╝██║ ██║██╔═══██╗██║
10
+ █████╗ ██║ ██║██║ ██║██║
11
+ ██╔══╝ ╚██╗ ██╔╝██║ ██║██║
12
+ ███████╗ ╚████╔╝ ╚██████╔╝███████╗
13
+ ╚══════╝ ╚═══╝ ╚═════╝ ╚══════╝
14
+ ```
15
+
16
+ **Dense Statevector Quantum Simulator · JAX XLA · NISQ · VQE · QML**
17
+
18
+ [![CI](https://github.com/tatopenn-cell/Dense-Evolution/actions/workflows/ci.yml/badge.svg)](https://github.com/tatopenn-cell/Dense-Evolution/actions/workflows/ci.yml)
19
+ [![PyPI](https://img.shields.io/pypi/v/dense-evolution?style=flat-square&color=00e5ff)](https://pypi.org/project/dense-evolution/)
20
+ [![Python](https://img.shields.io/badge/Python-3.9+-blue?style=flat-square&logo=python&logoColor=white)](https://www.python.org/)
21
+ [![License](https://img.shields.io/badge/License-BSL_1.1-orange?style=flat-square)](LICENSE.md)
22
+ [![Build](https://img.shields.io/badge/Build-Passing-00ff9d?style=flat-square)](https://github.com/tatopenn-cell/Dense-Evolution/actions)
23
+
24
+ </div>
25
+
26
+ ---
27
+
28
+ ## ▍ What It Is
29
+
30
+ **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`.
31
+
32
+ The integrated `dash.py` dashboard provides live ipywidgets telemetry across 6 quantum observables per simulation run, directly inside Google Colab or Jupyter.
33
+
34
+ ---
35
+
36
+ ## ▍ Install
37
+
38
+ ```bash
39
+ # core engine
40
+ pip install dense-evolution
41
+
42
+ # full stack: JAX · GPU · dashboard
43
+ pip install dense-evolution[full]
44
+
45
+ # development
46
+ git clone https://github.com/tatopenn-cell/Dense-Evolution.git
47
+ cd Dense-Evolution && pip install -e .[full]
48
+ ```
49
+
50
+ **Google Colab (3 lines):**
51
+ ```python
52
+ !git clone https://github.com/tatopenn-cell/Dense-Evolution.git
53
+ %cd Dense-Evolution
54
+ !pip install -e .
55
+ ```
56
+
57
+ ---
58
+
59
+ ## ▍ Quick Start
60
+
61
+ ```python
62
+ from dense_evolution import DenseSVSimulator, QASMParser
63
+
64
+ # parse any OpenQASM 2.0 string
65
+ qasm = """
66
+ OPENQASM 2.0;
67
+ include "qelib1.inc";
68
+ qreg q[3];
69
+ h q[0];
70
+ cx q[0], q[1];
71
+ cx q[1], q[2];
72
+ """
73
+
74
+ parser = QASMParser()
75
+ circuit = parser.parse(qasm)
76
+
77
+ sim = DenseSVSimulator(n_qubits=3)
78
+ sim.run_circuit_jit_beast_mode(circuit.ops)
79
+
80
+ print(sim.get_probabilities()) # [0.5, 0, 0, 0, 0, 0, 0, 0.5] — GHZ state
81
+ print(sim.memory_mb()) # 0.000128 MB
82
+ ```
83
+
84
+ **Dashboard (Colab / Jupyter):**
85
+ ```python
86
+ import dash
87
+ from IPython.display import display, clear_output
88
+
89
+ clear_output()
90
+ display(dash.dashboard_unificata)
91
+ ```
92
+
93
+ ---
94
+
95
+ ## ▍ Architecture
96
+
97
+ ```
98
+ dense_evolution/
99
+ ├── registry.py hardware detection · JAX / CuPy / NumPy capability flags
100
+ ├── gates.py GATES{} · PARAMETRIC_GATES{} · GATE_IDS{}
101
+ ├── noise_model.py Kraus channels · stochastic trajectory engine
102
+ ├── parser.py QASMParser · QASMCircuit · OpenQASM 2.0 / 3.0
103
+ ├── compiler.py _apply_gate_fast_step (jit) · _compile_and_run_circuit_jit
104
+ ├── simulator.py DenseSVSimulator · vmap batch VQE · chunked execution
105
+ └── dash.py ipywidgets dashboard · VQE engine · MD simulation
106
+ ```
107
+
108
+ **Data flow per run:**
109
+ ```
110
+ ▶ Run
111
+ └─ core_calcolo_quantistico() parse → JIT execute → apply noise
112
+ ├─ ottimizza_vqe() Hellmann-Feynman AD → ADAM → df_vqe_telemetry
113
+ ├─ run_md_simulation_dummy() QM/MM dynamics → df_md_telemetry + Pearson matrix
114
+ └─ build_panel_*(res) matplotlib figure → display()
115
+ ```
116
+
117
+ ---
118
+
119
+ ## ▍ Core Features
120
+
121
+ | Feature | Detail |
122
+ |---|---|
123
+ | **Linear Kernel Fusion** | Stride-sliced tensor ops via JAX XLA — zero Kronecker matrices |
124
+ | **Circuit Chunking** | Fixed-size JIT blocks eliminate tracer overhead on 1000+ gate circuits |
125
+ | **Kraus Noise Channels** | `depolarizing` `amplitude_damping` `phase_damping` `bitflip` `combined` — stochastic, O(2ⁿ) cost |
126
+ | **VQE + ADAM** | Hellmann-Feynman gradient via JAX AD · positional parameter injection into any QASM 2.0 |
127
+ | **vmap Batch Sweep** | `run_parametric_batch_jit()` evaluates full parameter grids in one JIT call |
128
+ | **Backend Agnostic** | NumPy CPU · JAX XLA CPU/TPU · CuPy CUDA — runtime selection, zero code changes |
129
+ | **Live Dashboard** | 8-panel ipywidgets telemetry: probability, VQE energy, entropy, purity, gradient, noise, θ-correction, Pearson heatmap |
130
+
131
+ ---
132
+
133
+ ## ▍ Benchmarks
134
+
135
+ > Measured on Google Colab Free Tier (CPU runtime)
136
+
137
+ | Metric | Value |
138
+ |---|---|
139
+ | Numerical drift (80-layer Ansatz, 1360 gates) | `Δ = 1.11 × 10⁻¹⁶` |
140
+ | Memory footprint @ 20q | `32 MB` (float64) · `16 MB` (float32) |
141
+ | JIT compile overhead (first run) | `< 400 ms` |
142
+ | Gate throughput after warm-up | `> 10⁶ gates/s` (CPU) |
143
+ | Maximum tested qubits (Colab Free) | `24q` stable · `33q` high-RAM runtime |
144
+
145
+ ---
146
+
147
+ ## ▍ Dashboard Panels
148
+
149
+ | Panel | Contents |
150
+ |---|---|
151
+ | **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 |
152
+ | **Fisica Stato** | Bloch projection · Schmidt rank · coherence vector |
153
+ | **Mosaico 1008q** | 2D probability density map up to 1008 qubits |
154
+ | **VQE Results** | 6-subplot telemetry: energy convergence, entropy, purity, ‖∇L‖, noise factor, θ-correction |
155
+ | **MD Results** | 6-subplot MD telemetry + masked Pearson correlation heatmap |
156
+ | **Performance** | Gate throughput · JIT compile time · RAM usage |
157
+
158
+ ---
159
+
160
+ ## ▍ Circuit Library (80+ presets)
161
+
162
+ All circuits are stored as OpenQASM 2.0 strings in `QASM_LIBRARY`.
163
+
164
+ **Standard** — Bell Φ⁺, QFT 4q/8q, Toffoli, Adder 2-bit, Deutsch-Jozsa, Bernstein-Vazirani
165
+ **Algorithms** — Grover 3q/4q, Simon 4q, Shor 15, HHL, QAOA Max-Cut 4q, QPE 5q, Quantum Walk, Teleportation, BB84
166
+ **Topological** — Anyonic Braiding 6q, Charge Pump 8q, DiamondPhi 12q, Omega Phase Lock 8q, Arecibo DeepField 16q, ARECIBO v11.3 SINGULARITY
167
+ **Peptide / Biological** — Furin RRAR 8q, Hemoglobin MVLSPADK 8q, Spike 8q/16q, p53 Guardian 24q, WormholeTriplePeptide 24q
168
+ **Stress Tests** — Hardware Stress, Quantum Supremacy, Interference Stress, BGQ 32q, Twin Shield Full Resonance 32q, Nuovo Circuito 33q
169
+
170
+ **Proprietary phase constants used in topological circuits:**
171
+
172
+ | Constant | Value (rad) | Physical origin |
173
+ |---|:---:|---|
174
+ | φ (Golden Ratio) | 1.6180 | Tatopenn φ-resonance |
175
+ | sp³ diamond angle | 1.9106 | Carbon tetrahedral bond |
176
+ | Topological lock | 3.0718 | Near-π translocation phase |
177
+ | Omega / Fe₂S₂ | 6.1574 | Iron-sulfur cluster phase lock |
178
+ | BGQ wormhole kick | 0.7000 | BGQ wormhole kickback amplitude |
179
+
180
+ ---
181
+
182
+ ## ▍ VQE Engine
183
+
184
+ **Positional parameter injection** — `QASMParser` tokenizes all literals to `0.0` for JIT speed. VQE recovers parameters by:
185
+ 1. counting parametric gates (`rx ry rz p u1 cp crz`) → `n_params`
186
+ 2. initializing `θ ∈ ℝⁿ` uniform in `[−π, π]`
187
+ 3. injecting `θ[i]` sequentially by gate order in the AST via `risolvi_qasm()`
188
+
189
+ Compatible with any custom OpenQASM 2.0 string without pre-labelling.
190
+
191
+ **Gradient & update rule:**
192
+
193
+ $$\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}$$
194
+
195
+ **Telemetry columns** (→ `df_vqe_telemetry`):
196
+
197
+ | Column | Unit | Description |
198
+ |---|---|---|
199
+ | `VQE_Energy` | Ha | ⟨ψ\|H\|ψ⟩ |
200
+ | `Entropy` | bit | −Tr(ρ log₂ ρ) |
201
+ | `Purity` | — | Tr(ρ²) ∈ [1/d, 1] |
202
+ | `Gradient` | — | ‖∇L‖ — barren plateau detection |
203
+ | `Noise_Factor` | — | fidelity-derived noise proxy |
204
+ | `Theta_Correction` | rad | ADAM step norm |
205
+
206
+ ---
207
+
208
+ ## ▍ Hamiltonian Library
209
+
210
+ Auto-filtered by qubit count to prevent shape mismatch.
211
+
212
+ | Molecule | Qubits | Bond length | E₀ (Ha) |
213
+ |---|:---:|:---:|:---:|
214
+ | H₂ | 2 | 0.74 Å | −1.13 |
215
+ | H₃⁺ | 3 | 0.85 Å | −1.28 |
216
+ | LiH | 4 | 1.40 Å | −2.31 |
217
+ | H₂O | 5 | 0.96 Å | −4.12 |
218
+
219
+ Custom: JSON array of diagonal eigenvalues, length `2^n_qubits`.
220
+
221
+ ---
222
+
223
+ ## ▍ Noise Models
224
+
225
+ All channels applied as post-circuit Kraus operations on the full statevector.
226
+
227
+ | Model | Kraus operators | Physical process |
228
+ |---|---|---|
229
+ | `ideal` | I | noiseless |
230
+ | `depolarizing` | {√(1−p)I, √(p/3)X,Y,Z} | isotropic Pauli error |
231
+ | `amplitude_damping` | {K₀, K₁} | T₁ energy relaxation |
232
+ | `phase_damping` | {K₀, K₁} | T₂ dephasing |
233
+ | `bitflip` | {√(1−p)I, √p·X} | bit flip σₓ |
234
+ | `combined` | depolarizing(p/2) ∘ amp_damp(p/3) | worst-case NISQ |
235
+
236
+ Fidelity: Bhattacharyya `F = Σᵢ √(pᵢqᵢ)` and TVD `= ½Σᵢ|pᵢ−qᵢ|` computed on every noisy run.
237
+
238
+ ---
239
+
240
+ ## ▍ Troubleshooting
241
+
242
+ | Error | Cause | Fix |
243
+ |---|---|---|
244
+ | `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 |
245
+ | VQE telemetry empty | VQE disabled or no parametric gates | Enable **VQE Settings** checkbox; use circuits with `rx/ry/rz` gates |
246
+ | Hamiltonian shape mismatch | JSON array length ≠ 2^n_qubits | Supply exactly `2^n` values (e.g. 16 for 4q) |
247
+ | Barren plateau span not visible | < 3 consecutive epochs with ‖g‖ < 0.01·max‖g‖ | Increase epochs or reduce learning rate |
248
+ | Dashboard blank in JupyterLab | Extension missing | `jupyter labextension install @jupyter-widgets/jupyterlab-manager` |
249
+ | 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 |
250
+
251
+ ---
252
+
253
+ ## ▍ License
254
+
255
+ **Business Source License 1.1** — converts automatically to **Apache 2.0** on **1 June 2029**.
256
+
257
+ - Non-commercial use: unrestricted
258
+ - Commercial use: ≤ 24 allocated qubits · ≤ 1000 circuits/day · ≤ 10,000 shots/circuit
259
+ - Attribution required on all copies: `© 2026 Salvatore Pennacchio <jtatopenn@libero.it> — Dense Evolution`
260
+
261
+ Full text: [LICENSE.md](LICENSE.md)
262
+
263
+ ---
264
+
265
+ <div align="center">
266
+ <sub>© 2026 Salvatore Pennacchio — Dense Evolution v8.0.7</sub>
267
+