dense-evolution 8.1.6__tar.gz → 8.1.7__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.
- dense_evolution-8.1.7/PKG-INFO +513 -0
- dense_evolution-8.1.7/README.md +468 -0
- {dense_evolution-8.1.6 → dense_evolution-8.1.7}/dash.py +3515 -3515
- {dense_evolution-8.1.6 → dense_evolution-8.1.7}/dense_evolution/__init__.py +11 -11
- {dense_evolution-8.1.6 → dense_evolution-8.1.7}/dense_evolution/chunk.py +367 -372
- {dense_evolution-8.1.6 → dense_evolution-8.1.7}/dense_evolution/compiler.py +311 -316
- {dense_evolution-8.1.6 → dense_evolution-8.1.7}/dense_evolution/gates.py +50 -55
- {dense_evolution-8.1.6 → dense_evolution-8.1.7}/dense_evolution/healing.py +139 -143
- {dense_evolution-8.1.6 → dense_evolution-8.1.7}/dense_evolution/parser.py +424 -429
- {dense_evolution-8.1.6 → dense_evolution-8.1.7}/dense_evolution/registry.py +372 -377
- {dense_evolution-8.1.6 → dense_evolution-8.1.7}/dense_evolution/simulator.py +0 -3
- {dense_evolution-8.1.6 → dense_evolution-8.1.7}/dense_evolution/stress_test.py +76 -76
- dense_evolution-8.1.7/dense_evolution/test2.py +76 -0
- dense_evolution-8.1.7/dense_evolution.egg-info/PKG-INFO +513 -0
- {dense_evolution-8.1.6 → dense_evolution-8.1.7}/dense_evolution.egg-info/SOURCES.txt +4 -1
- {dense_evolution-8.1.6 → dense_evolution-8.1.7}/dense_evolution.egg-info/requires.txt +1 -0
- {dense_evolution-8.1.6 → dense_evolution-8.1.7}/dense_evolution.egg-info/top_level.txt +1 -0
- dense_evolution-8.1.7/ia_utils/__init__.py +0 -0
- dense_evolution-8.1.7/ia_utils/vector_healing.py +171 -0
- dense_evolution-8.1.7/license.md +58 -0
- {dense_evolution-8.1.6 → dense_evolution-8.1.7}/pyproject.toml +85 -83
- dense_evolution-8.1.6/PKG-INFO +0 -366
- dense_evolution-8.1.6/README.md +0 -322
- dense_evolution-8.1.6/dense_evolution.egg-info/PKG-INFO +0 -366
- dense_evolution-8.1.6/license.md +0 -58
- {dense_evolution-8.1.6 → dense_evolution-8.1.7}/dense_evolution.egg-info/dependency_links.txt +0 -0
- {dense_evolution-8.1.6 → dense_evolution-8.1.7}/setup.cfg +0 -0
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: dense-evolution
|
|
3
|
+
Version: 8.1.7
|
|
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/README.md
|
|
9
|
+
Project-URL: Repository, https://github.com/tatopenn-cell/Dense-Evolution
|
|
10
|
+
Project-URL: Bug Tracker, https://github.com/tatopenn-cell/Dense-Evolution/issues
|
|
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
|
+
Requires-Dist: scipy>=1.9.0
|
|
30
|
+
Provides-Extra: jax
|
|
31
|
+
Requires-Dist: jax>=0.4.0; extra == "jax"
|
|
32
|
+
Requires-Dist: jaxlib>=0.4.0; extra == "jax"
|
|
33
|
+
Provides-Extra: gpu
|
|
34
|
+
Requires-Dist: cupy-cuda12x>=12.0.0; extra == "gpu"
|
|
35
|
+
Provides-Extra: dashboard
|
|
36
|
+
Requires-Dist: dash>=2.0.0; extra == "dashboard"
|
|
37
|
+
Requires-Dist: plotly>=5.0.0; extra == "dashboard"
|
|
38
|
+
Provides-Extra: full
|
|
39
|
+
Requires-Dist: jax>=0.4.0; extra == "full"
|
|
40
|
+
Requires-Dist: jaxlib>=0.4.0; extra == "full"
|
|
41
|
+
Requires-Dist: cupy-cuda12x>=12.0.0; extra == "full"
|
|
42
|
+
Requires-Dist: dash>=2.0.0; extra == "full"
|
|
43
|
+
Requires-Dist: plotly>=5.0.0; extra == "full"
|
|
44
|
+
Dynamic: license-file
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
██████╗ ███████╗███╗ ██╗███████╗███████╗
|
|
48
|
+
██╔══██╗██╔════╝████╗ ██║██╔════╝██╔════╝
|
|
49
|
+
██║ ██║█████╗ ██╔██╗ ██║███████╗█████╗
|
|
50
|
+
██║ ██║██╔══╝ ██║╚██╗██║╚════██║██╔══╝
|
|
51
|
+
██████╔╝███████╗██║ ╚████║███████║███████╗
|
|
52
|
+
╚═════╝ ╚══════╝╚═╝ ╚═══╝╚══════╝╚══════╝
|
|
53
|
+
███████╗██╗ ██╗ ██████╗ ██╗ ██╗ ██╗████████╗██╗ ██████╗ ███╗ ██╗
|
|
54
|
+
██╔════╝██║ ██║██╔═══██╗██║ ██║ ██║╚══██╔══╝██║██╔═══██╗████╗ ██║
|
|
55
|
+
█████╗ ██║ ██║██║ ██║██║ ██║ ██║ ██║ ██║██║ ██║██╔██╗ ██║
|
|
56
|
+
██╔══╝ ╚██╗ ██╔╝██║ ██║██║ ██║ ██║ ██║ ██║██║ ██║██║╚██╗██║
|
|
57
|
+
███████╗ ╚████╔╝ ╚██████╔╝███████╗╚██████╔╝ ██║ ██║╚██████╔╝██║ ╚████║
|
|
58
|
+
╚══════╝ ╚═══╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
**Dense Statevector Quantum Simulator · JAX XLA · NISQ · VQE · QML**
|
|
63
|
+
|
|
64
|
+
[](https://github.com/tatopenn-cell/Dense-Evolution/actions/workflows/ci.yml)
|
|
65
|
+
[](https://pypi.org/project/dense-evolution/)
|
|
66
|
+
[](https://www.python.org/)
|
|
67
|
+
[](LICENSE.md)
|
|
68
|
+
[](https://github.com/tatopenn-cell/Dense-Evolution/actions)
|
|
69
|
+
[](https://github.com/tatopenn-cell/Dense-Evolution-Ising-Tests/actions/workflows/ci.yml)
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## ▍ What It Is
|
|
74
|
+
|
|
75
|
+
**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`.
|
|
76
|
+
|
|
77
|
+
The integrated `dash.py` dashboard provides live ipywidgets telemetry across 8 panels per simulation run, directly inside Google Colab or Jupyter.
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## ▍ Install
|
|
82
|
+
|
|
83
|
+
```bash
|
|
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
|
+
|
|
96
|
+
```python
|
|
97
|
+
!git clone https://github.com/tatopenn-cell/Dense-Evolution.git
|
|
98
|
+
%cd Dense-Evolution
|
|
99
|
+
!pip install -e .
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## ▍ Quick Start
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from dense_evolution import DenseSVSimulator, QASMParser
|
|
108
|
+
|
|
109
|
+
# parse any OpenQASM 2.0 / 3.0 string
|
|
110
|
+
qasm = """
|
|
111
|
+
OPENQASM 2.0;
|
|
112
|
+
include "qelib1.inc";
|
|
113
|
+
qreg q[3];
|
|
114
|
+
h q[0];
|
|
115
|
+
cx q[0], q[1];
|
|
116
|
+
cx q[1], q[2];
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
parser = QASMParser()
|
|
120
|
+
circuit = parser.parse(qasm)
|
|
121
|
+
|
|
122
|
+
sim = DenseSVSimulator(n_qubits=3)
|
|
123
|
+
sim.run_circuit_jit_beast_mode(circuit.ops)
|
|
124
|
+
|
|
125
|
+
probs = sim.get_probabilities()
|
|
126
|
+
sv = sim.get_statevector()
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Dashboard (Colab / Jupyter):**
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
import dash
|
|
133
|
+
from IPython.display import display, clear_output
|
|
134
|
+
|
|
135
|
+
clear_output()
|
|
136
|
+
display(dash.dashboard_unificata)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
**Anti-OOM for large circuits:**
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
from dense_evolution import Chunk
|
|
143
|
+
|
|
144
|
+
sim = Chunk(27) # logical 27 qubits
|
|
145
|
+
circuit_ops = [['h', i] for i in range(27)]
|
|
146
|
+
sim.run_chunk(circuit_ops, chunk_size_gates=500) # SafeMemoryGuard active
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## ▍ Architecture
|
|
152
|
+
|
|
153
|
+
```
|
|
154
|
+
dense_evolution/
|
|
155
|
+
├── registry.py hardware detection · JAX/CuPy/NumPy flags · NoiseModel (Kraus channels)
|
|
156
|
+
├── gates.py GATES{} · PARAMETRIC_GATES{} · GATE_IDS{}
|
|
157
|
+
├── healing.py predictive state engine · Phi_AB · vettore dinamico · MemoryReflectionEngine
|
|
158
|
+
├── parser.py QASMParser · QASMCircuit · OpenQASM 2.0 / 3.0
|
|
159
|
+
├── compiler.py QuantumTranspiler · _apply_gate_fast_step (jit) · gate decomposition
|
|
160
|
+
├── chunk.py SafeMemoryGuard · MemoryChunker · CircuitChunker · Chunk (Anti-OOM)
|
|
161
|
+
├── simulator.py DenseSVSimulator · run_parametric_batch_jit · vmap batch VQE
|
|
162
|
+
└── dash.py ipywidgets dashboard · VQE engine · QM/MM · MD simulation · 3D wavefunction
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Data flow per run:**
|
|
166
|
+
|
|
167
|
+
```
|
|
168
|
+
▶ Run
|
|
169
|
+
└─ core_calcolo_quantistico() parse → JIT execute → apply noise
|
|
170
|
+
├─ ottimizza_vqe() Hellmann-Feynman AD → ADAM → df_vqe_telemetry
|
|
171
|
+
├─ run_md_simulation_dummy() QM/MM dynamics → df_md_telemetry + Pearson matrix
|
|
172
|
+
└─ build_panel_*(res) matplotlib figure → display()
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
|
|
177
|
+
## ▍ Core Features
|
|
178
|
+
|
|
179
|
+
| Feature | Detail |
|
|
180
|
+
|---|---|
|
|
181
|
+
| **Linear Kernel Fusion** | Stride-sliced tensor ops via JAX XLA — zero Kronecker matrices |
|
|
182
|
+
| **Parametric Batch JIT** | `run_parametric_batch_jit()` evaluates full parameter grids in one `jax.vmap` + `jax.jit` call |
|
|
183
|
+
| **Circuit Chunking** | Fixed-size JIT blocks eliminate tracer overhead on 1000+ gate circuits |
|
|
184
|
+
| **Kraus Noise Channels** | `depolarizing` `amplitude_damping` `phase_damping` `bitflip` `combined` — stochastic, O(2ⁿ) cost |
|
|
185
|
+
| **VQE + ADAM** | Hellmann-Feynman gradient · positional parameter injection into any OpenQASM 2.0 circuit |
|
|
186
|
+
| **Anti-OOM Engine** | `SafeMemoryGuard` blocks execution before JAX raises `RESOURCE_EXHAUSTED` |
|
|
187
|
+
| **Predictive Healing** | `healing.py` — Φ_AB alignment, dynamic vector, Σ-sync, `MemoryReflectionEngine` |
|
|
188
|
+
| **Backend Agnostic** | NumPy CPU · JAX XLA CPU/TPU · CuPy CUDA — runtime selection, zero code changes |
|
|
189
|
+
| **Live Dashboard** | 8-panel ipywidgets telemetry: probability, VQE energy, entropy, purity, gradient, noise, θ-correction, Pearson heatmap |
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## ▍ Scientific Validation & Applications
|
|
194
|
+
|
|
195
|
+
To demonstrate the numerical accuracy and stability of **Dense Evolution**, the simulator was stress-tested across 3,500 continuous spatial sampling points to compute the **Silicon Dimer (Si2) Dissociation Curve** via Variational Quantum Eigensolver (VQE).
|
|
196
|
+
|
|
197
|
+
* Physical Accuracy: The simulation successfully maps the exact Born-Oppenheimer Potential Energy Curve (PEC), capturing the deep quantum ground state bound minimum at ~3.55 Å with negative total energy, before converging asymptotically toward full molecular dissociation.
|
|
198
|
+
* Numerical Precision: Calculations are locked at Double Precision (float64), proving the simulator's resilience against cumulative machine epsilon errors (~ 1.11 × 10⁻¹⁶) across thousands of sequential circuit executions.
|
|
199
|
+
* Run this molecular experiment instantly on Google Colab Free Tier:
|
|
200
|
+
[Open Notebook on Google Colab](https://colab.research.google.com/drive/1cX7vYsVaxO29677ltgDTbh3pqUi0NYC5#scrollTo=Qg_lqX-Iw_UM)
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
```text
|
|
205
|
+
============================================================
|
|
206
|
+
🔬 MOLECULAR VQE: EXACT POTENTIAL ENERGY CURVE (PEC)
|
|
207
|
+
============================================================
|
|
208
|
+
Distanza R: 1.200 Å | Energia Totale Molecola: +155.761158 eV
|
|
209
|
+
Distanza R: 1.671 Å | Energia Totale Molecola: +34.372692 eV
|
|
210
|
+
Distanza R: 2.142 Å | Energia Totale Molecola: +6.583098 eV
|
|
211
|
+
Distanza R: 2.614 Å | Energia Totale Molecola: +0.727422 eV
|
|
212
|
+
Distanza R: 3.085 Å | Energia Totale Molecola: -0.253226 eV
|
|
213
|
+
Distanza R: 3.557 Å | Energia Totale Molecola: -0.273498 eV
|
|
214
|
+
Distanza R: 4.028 Å | Energia Totale Molecola: -0.170948 eV
|
|
215
|
+
Distanza R: 4.500 Å | Energia Totale Molecola: -0.093048 eV
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
#### Variational Quantum Chemistry Plot
|
|
219
|
+
Below is the physical validation plot showing the Born-Oppenheimer potential energy curve:
|
|
220
|
+
|
|
221
|
+
<img width="993" height="593" alt="image" src="https://github.com/user-attachments/assets/5fe57865-40f2-4930-9e8d-63959ea93a22" />
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
👉 *For the full suite of physical benchmarks, including the Transverse Field Ising Model (TFIM) and Phase Transition mappings, visit the main [Dense-Evolution-Ising-Tests](https://github.com/tatopenn-cell/Dense-Evolution-Ising-Tests) repository. You can also view the raw script for this specific molecular run [here](https://github.com/tatopenn-cell/Dense-Evolution-Ising-Tests/blob/main/vqe_silicon_molecular.py).*
|
|
225
|
+
|
|
226
|
+
---
|
|
227
|
+
|
|
228
|
+
## ▍ API Reference
|
|
229
|
+
|
|
230
|
+
### `DenseSVSimulator`
|
|
231
|
+
|
|
232
|
+
```python
|
|
233
|
+
sim = DenseSVSimulator(
|
|
234
|
+
n_qubits : int,
|
|
235
|
+
use_gpu : bool = False,
|
|
236
|
+
use_float32: bool = False,
|
|
237
|
+
)
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
| Method | Description |
|
|
241
|
+
|---|---|
|
|
242
|
+
| `set_initial_state(state=None)` | Reset to `\|0⟩ⁿ` or inject custom statevector |
|
|
243
|
+
| `run_circuit_jit_beast_mode(circuit)` | JIT-compiled gate execution — primary execution path |
|
|
244
|
+
| `run_circuit_with_chunking(circuit, chunk_size=500)` | Chunked execution for long circuits |
|
|
245
|
+
| `run_parametric_batch_jit(base_circuit, parameter_batch)` | `vmap` over parameter grid — returns full batch of statevectors |
|
|
246
|
+
| `get_probabilities()` → `np.ndarray` | `\|ψ_i\|²` for all basis states |
|
|
247
|
+
| `get_statevector()` → `np.ndarray` | Full complex statevector |
|
|
248
|
+
| `measure(qubit_idx)` → `int` | Projective measurement with state collapse |
|
|
249
|
+
| `memory_mb()` → `float` | Current RAM usage in MB |
|
|
250
|
+
| `apply_gate_1q(gate, qubit)` | Apply arbitrary 2×2 unitary |
|
|
251
|
+
| `apply_gate_2q(gate, q1, q2)` | Apply arbitrary 4×4 unitary |
|
|
252
|
+
|
|
253
|
+
### `QASMParser`
|
|
254
|
+
|
|
255
|
+
```python
|
|
256
|
+
parser = QASMParser()
|
|
257
|
+
circuit = parser.parse(qasm_str) # → QASMCircuit
|
|
258
|
+
valid, msg = parser.validate(circuit)
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
`QASMCircuit` fields: `n_qubits`, `n_cbits`, `ops` (list of gate tuples).
|
|
262
|
+
|
|
263
|
+
### `NoiseModel`
|
|
264
|
+
|
|
265
|
+
```python
|
|
266
|
+
noise = NoiseModel()
|
|
267
|
+
noise.apply(sv, model='depolarizing', p=0.01, n_qubits=4, rng=rng)
|
|
268
|
+
desc = NoiseModel.kraus_description('amplitude_damping')
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### `Chunk` (Anti-OOM)
|
|
272
|
+
|
|
273
|
+
```python
|
|
274
|
+
sim = Chunk(
|
|
275
|
+
n_qubits : int,
|
|
276
|
+
chunk_size_gates : int = 500,
|
|
277
|
+
memory_threshold : float = 0.15, # block below 15% free RAM
|
|
278
|
+
use_gpu : bool = False,
|
|
279
|
+
use_float32 : bool = False,
|
|
280
|
+
)
|
|
281
|
+
sim.run_chunk(circuit, chunk_size_gates=500)
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
Backward-compatibility aliases: `chunk1 = MemoryChunker`, `chunk2 = Chunk`, `Chunk2Incrociato = Chunk`.
|
|
285
|
+
|
|
286
|
+
---
|
|
287
|
+
|
|
288
|
+
## ▍ Gate Library
|
|
289
|
+
|
|
290
|
+
**Fixed gates** (no parameters):
|
|
291
|
+
|
|
292
|
+
| Gate | Symbol | Gate | Symbol |
|
|
293
|
+
|---|---|---|---|
|
|
294
|
+
| `h` | Hadamard | `x` | Pauli-X |
|
|
295
|
+
| `y` | Pauli-Y | `z` | Pauli-Z |
|
|
296
|
+
| `s` | S gate | `sdg` | S† gate |
|
|
297
|
+
| `t` | T gate | `tdg` | T† gate |
|
|
298
|
+
| `sx` | √X gate | `id` | Identity |
|
|
299
|
+
| `cx` | CNOT | `cz` | CZ |
|
|
300
|
+
| `cy` | CY | `swap` | SWAP |
|
|
301
|
+
| `iswap` | iSWAP | `ecr` | ECR |
|
|
302
|
+
| `ccx` | Toffoli | | |
|
|
303
|
+
|
|
304
|
+
**Parametric gates**:
|
|
305
|
+
|
|
306
|
+
| Gate | Parameters | Description |
|
|
307
|
+
|---|---|---|
|
|
308
|
+
| `rx(θ)` | θ | X-rotation |
|
|
309
|
+
| `ry(θ)` | θ | Y-rotation |
|
|
310
|
+
| `rz(θ)` | θ | Z-rotation |
|
|
311
|
+
| `p(λ)` | λ | Phase gate |
|
|
312
|
+
| `u1(λ)` | λ | U1 (≡ p) |
|
|
313
|
+
| `u2(φ, λ)` | φ, λ | U2 rotation |
|
|
314
|
+
| `u3(θ, φ, λ)` | θ, φ, λ | Generic single-qubit |
|
|
315
|
+
| `cp(λ, ctrl, tgt)` | λ | Controlled-Phase |
|
|
316
|
+
| `crz(λ, ctrl, tgt)` | λ | Controlled-RZ |
|
|
317
|
+
|
|
318
|
+
---
|
|
319
|
+
|
|
320
|
+
## ▍ Noise Models
|
|
321
|
+
|
|
322
|
+
All channels applied as post-circuit stochastic Kraus operations on the full statevector.
|
|
323
|
+
|
|
324
|
+
| Model | Kraus operators | Physical process |
|
|
325
|
+
|---|---|---|
|
|
326
|
+
| `ideal` | `I` | Noiseless |
|
|
327
|
+
| `depolarizing` | `{√(1−p)I, √(p/3)X, √(p/3)Y, √(p/3)Z}` | Isotropic Pauli error |
|
|
328
|
+
| `amplitude_damping` | `{K₀=diag(1,√(1−γ)), K₁=[[0,√γ],[0,0]]}` | T₁ energy relaxation |
|
|
329
|
+
| `phase_damping` | `{K₀, K₁}` | T₂ dephasing |
|
|
330
|
+
| `bitflip` | `{√(1−p)I, √p·X}` | Bit flip σₓ |
|
|
331
|
+
| `combined` | depolarizing(p/2) ∘ amplitude_damping(p/3) | Worst-case NISQ |
|
|
332
|
+
|
|
333
|
+
Fidelity metrics computed on every noisy run: Bhattacharyya `F = Σᵢ √(pᵢqᵢ)` and TVD `= ½Σᵢ|pᵢ−qᵢ|`.
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
## ▍ Mitigation & Predictive Healing
|
|
338
|
+
|
|
339
|
+
Active error tracking and stabilization integrated natively into the simulation runtime via `healing.py`.
|
|
340
|
+
|
|
341
|
+
| Model | Operators | Description |
|
|
342
|
+
|---|---|---|
|
|
343
|
+
| `dephasing_tracking` | `Δ_pre_emp ∘ Σ` | Predictive deviation vs ideal eigenstate |
|
|
344
|
+
| `phi_ab_alignment` | `Φ_AB(state_A, state_B, ipg)` | Semantic + coherence alignment between two quantum states |
|
|
345
|
+
| `vettore_dinamico` | `V_din = K · log(E_B/E_A) · Φ_AB` | Log-differential energetic evolution vector |
|
|
346
|
+
| `kappa_stabilization` | `κ-strength routine` | Proactive statevector profile shielding |
|
|
347
|
+
| `richardson_integration` | `{λ₁=1.0, λ₂=2.0}` | Dual-point zero-noise trajectory approximation |
|
|
348
|
+
|
|
349
|
+
All core functions compiled via `@jax.jit`. Event history managed by `MemoryReflectionEngine` with JAX Zero-Drift spectral aggregation.
|
|
350
|
+
|
|
351
|
+
---
|
|
352
|
+
|
|
353
|
+
## ▍ Anti-OOM Chunk Engine
|
|
354
|
+
|
|
355
|
+
All operations parcellized dynamically using a 4-layer architectural shield.
|
|
356
|
+
|
|
357
|
+
| Layer | Class | Role |
|
|
358
|
+
|---|---|---|
|
|
359
|
+
| 1 | `SafeMemoryGuard` | Pre-allocation RAM check — blocks before JAX raises `RESOURCE_EXHAUSTED` |
|
|
360
|
+
| 2 | `MemoryChunker` | Geometry calculator — computes `num_chunks`, `chunk_dim`, `chunk_size_bits` from available RAM without any JAX allocation |
|
|
361
|
+
| 3 | `CircuitChunker` | Per-slice execution — `SafeMemoryGuard` fires before every gate-slice dispatch |
|
|
362
|
+
| 4 | `Chunk` | Top-level wrapper — logical n_qubits decoupled from physical allocation at `safe_qubits` |
|
|
363
|
+
|
|
364
|
+
### Benchmark vs PennyLane — Windows CPU (8 GB RAM)
|
|
365
|
+
|
|
366
|
+
> Dense Evolution maintains constant ~2 GB RAM at any qubit count via dynamic chunking.
|
|
367
|
+
> PennyLane allocates the full statevector — OOM beyond 26q.
|
|
368
|
+
|
|
369
|
+
| Qubits | Hilbert Space | PennyLane | PennyLane RAM | Dense Evolution | Dense RAM | Chunk Geometry |
|
|
370
|
+
|:------:|:-------------:|:---------:|:-------------:|:---------------:|:---------:|:--------------:|
|
|
371
|
+
| 24 | 16,777,216 | ✅ | 307 MB | ✅ | 516 MB | 1× (2²⁷) |
|
|
372
|
+
| 26 | 67,108,864 | ✅ | 1,074 MB | ✅ | 2,050 MB | 1× (2²⁷) |
|
|
373
|
+
| 28 | 268,435,456 | ❌ OOM | — | ✅ | 2,050 MB | 2× (2²⁷) |
|
|
374
|
+
| 30 | 1,073,741,824 | ❌ OOM | — | ✅ | 2,048 MB | 8× (2²⁷) |
|
|
375
|
+
| 32 | 4,294,967,296 | ❌ OOM | — | ✅ | 2,048 MB | 32× (2²⁷) |
|
|
376
|
+
|
|
377
|
+
```python
|
|
378
|
+
from dense_evolution import Chunk
|
|
379
|
+
|
|
380
|
+
sim = Chunk(27)
|
|
381
|
+
sim.run_chunk([['h', i] for i in range(27)], chunk_size_gates=500)
|
|
382
|
+
|
|
383
|
+
print(sim)
|
|
384
|
+
# Chunk(n_qubits=27, safe_qubits=27, num_chunks=1,
|
|
385
|
+
# chunk_size_bits=27, mem_per_chunk=2048.0 MB, ram_free=42.3%, has_jax=True)
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
---
|
|
389
|
+
|
|
390
|
+
## ▍ Benchmarks
|
|
391
|
+
|
|
392
|
+
> Measured on Google Colab Free Tier (CPU runtime)
|
|
393
|
+
|
|
394
|
+
| Metric | Value |
|
|
395
|
+
|---|---|
|
|
396
|
+
| Numerical drift (30-layer Ansatz, 1360 gates) | `Δ = 1.11 × 10⁻¹⁶` |
|
|
397
|
+
| Memory footprint @ 20q | `32 MB` (float64) · `16 MB` (float32) |
|
|
398
|
+
| JIT compile overhead (first run) | `< 400 ms` |
|
|
399
|
+
| Gate throughput after warm-up | `> 10⁶ gates/s` (CPU) |
|
|
400
|
+
| Maximum tested qubits (Colab Free) | `24q` stable · `33q` high-RAM runtime |
|
|
401
|
+
| Anti-OOM latency reduction (static JIT cache) | `−86.47%` |
|
|
402
|
+
|
|
403
|
+
---
|
|
404
|
+
|
|
405
|
+
## ▍ Dashboard Panels
|
|
406
|
+
|
|
407
|
+
| Panel | Contents |
|
|
408
|
+
|---|---|
|
|
409
|
+
| **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 ×3 · R7 Pearson heatmap |
|
|
410
|
+
| **Fisica Stato** | Bloch projection · Schmidt rank · coherence vector |
|
|
411
|
+
| **Mosaico** | 2D probability density map up to 1008 qubits |
|
|
412
|
+
| **VQE Results** | 6-subplot: energy convergence, entropy, purity, ‖∇L‖, noise factor, θ-correction |
|
|
413
|
+
| **MD Results** | 6-subplot MD telemetry + masked Pearson correlation heatmap |
|
|
414
|
+
| **Performance** | Gate throughput · JIT compile time · RAM usage |
|
|
415
|
+
|
|
416
|
+
---
|
|
417
|
+
|
|
418
|
+
## ▍ VQE Engine
|
|
419
|
+
|
|
420
|
+
**Positional parameter injection** — `QASMParser` tokenizes all literals to `0.0` for JIT speed. VQE recovers parameters by:
|
|
421
|
+
1. Counting parametric gates (`rx ry rz p u1 cp crz`) → `n_params`
|
|
422
|
+
2. Initializing `θ ∈ ℝⁿ` uniform in `[−π, π]`
|
|
423
|
+
3. Injecting `θ[i]` sequentially by gate order in the AST via `risolvi_qasm()`
|
|
424
|
+
|
|
425
|
+
Compatible with any custom OpenQASM 2.0 string without pre-labelling.
|
|
426
|
+
|
|
427
|
+
**Gradient & update rule:**
|
|
428
|
+
|
|
429
|
+
$$\frac{\partial E}{\partial \theta_i} = \left\langle\psi(\theta)\left|\frac{\partial H}{\partial \theta_i}\right|\psi(\theta)\right\rangle \qquad \theta \leftarrow \theta - \frac{\alpha\,\hat{m}_t}{\sqrt{\hat{v}_t}+\varepsilon}$$
|
|
430
|
+
|
|
431
|
+
**Telemetry columns** (→ `df_vqe_telemetry`):
|
|
432
|
+
|
|
433
|
+
| Column | Unit | Description |
|
|
434
|
+
|---|---|---|
|
|
435
|
+
| `VQE_Energy` | Ha | ⟨ψ\|H\|ψ⟩ |
|
|
436
|
+
| `Entropy` | bit | −Tr(ρ log₂ ρ) |
|
|
437
|
+
| `Purity` | — | Tr(ρ²) ∈ [1/d, 1] |
|
|
438
|
+
| `Gradient` | — | ‖∇L‖ — barren plateau detection |
|
|
439
|
+
| `Noise_Factor` | — | Fidelity-derived noise proxy |
|
|
440
|
+
| `Theta_Correction` | rad | ADAM step norm |
|
|
441
|
+
|
|
442
|
+
---
|
|
443
|
+
|
|
444
|
+
## ▍ Hamiltonian Library
|
|
445
|
+
|
|
446
|
+
Auto-filtered by qubit count to prevent shape mismatch.
|
|
447
|
+
|
|
448
|
+
| Molecule | Qubits | Bond length | E₀ (Ha) |
|
|
449
|
+
|---|:---:|:---:|:---:|
|
|
450
|
+
| H₂ | 2 | 0.74 Å | −1.13 |
|
|
451
|
+
| H₃⁺ | 3 | 0.85 Å | −1.28 |
|
|
452
|
+
| LiH | 4 | 1.40 Å | −2.31 |
|
|
453
|
+
| H₂O | 5 | 0.96 Å | −4.12 |
|
|
454
|
+
|
|
455
|
+
Custom: JSON array of diagonal eigenvalues, length `2^n_qubits`.
|
|
456
|
+
|
|
457
|
+
---
|
|
458
|
+
|
|
459
|
+
## ▍ Circuit Library (30+ presets)
|
|
460
|
+
|
|
461
|
+
All circuits stored as OpenQASM 2.0 strings in `QASM_LIBRARY`.
|
|
462
|
+
|
|
463
|
+
**Standard** — Bell Φ⁺, QFT 4q/8q, Toffoli, Adder 2-bit, Deutsch-Jozsa, Bernstein-Vazirani
|
|
464
|
+
|
|
465
|
+
**Algorithms** — Grover 3q/4q, Simon 4q, Shor 15, HHL, QAOA Max-Cut 4q, QPE 5q, Quantum Walk, Teleportation, BB84
|
|
466
|
+
|
|
467
|
+
---
|
|
468
|
+
|
|
469
|
+
## ▍ Changelog
|
|
470
|
+
|
|
471
|
+
### v8.1.7
|
|
472
|
+
- `ia_utils/` — new package: `median_healing`, `enhanced_dense_healing_hybrid` for vector sequence healing (NaN/Inf-safe)
|
|
473
|
+
- `jax` import in `ia_utils.vector_healing` made lazy — importable without the `[jax]` extra
|
|
474
|
+
- Fixed `reconstruction_error` telemetry returning `NaN` when input contained `NaN`/`Inf`
|
|
475
|
+
- Added `scipy` to core dependencies (was used but undeclared)
|
|
476
|
+
|
|
477
|
+
### v8.1.6
|
|
478
|
+
- Modular package structure (`dense_evolution/` directory)
|
|
479
|
+
- Split `registry.py`, `gates.py`, `healing.py`, `chunk.py` into dedicated modules
|
|
480
|
+
|
|
481
|
+
### v8.1.5
|
|
482
|
+
- `chunk.py` — `SafeMemoryGuard`: hard block at configurable free-RAM threshold (default 15%), soft warning at 2× threshold, `gc.collect()` before every check
|
|
483
|
+
- `chunk.py` — `Chunk` no longer subclasses `DenseSVSimulator`; inner simulator allocated at `safe_qubits` only — eliminates `RESOURCE_EXHAUSTED` on 28q–34q circuits
|
|
484
|
+
- `chunk.py` — `CircuitChunker.split_circuit` RAM-checks every gate-slice before dispatch
|
|
485
|
+
- `chunk.py` — `MemoryChunker` attributes (`num_chunks`, `chunk_size_bits`, `dtype`) forwarded as `@property` on `Chunk` for benchmark compatibility
|
|
486
|
+
|
|
487
|
+
### v8.1.0
|
|
488
|
+
- `healing.py` — Predictive State Engine: `calculate_phi_ab`, `calculate_vettore_dinamico`, `calculate_delta_preemp`, `evaluate_phi_trigger`, `calculate_jax_reflection` — all `@jax.jit`
|
|
489
|
+
- `MemoryReflectionEngine` — event logging + JAX Zero-Drift spectral aggregation
|
|
490
|
+
|
|
491
|
+
### v8.0.x
|
|
492
|
+
- `run_parametric_batch_jit()` — `jax.vmap` over full parameter grids in single XLA call
|
|
493
|
+
- `run_circuit_jit_beast_mode()` — static JIT compilation with QuantumTranspiler
|
|
494
|
+
- OpenQASM 2.0/3.0 dual-mode parser with paren-depth-aware expression splitting
|
|
495
|
+
- `NoiseModel` Kraus channels in `registry.py`
|
|
496
|
+
|
|
497
|
+
---
|
|
498
|
+
|
|
499
|
+
## ▍ License
|
|
500
|
+
|
|
501
|
+
**Business Source License 1.1** — converts automatically to **Apache 2.0** on **1 June 2029**.
|
|
502
|
+
|
|
503
|
+
- Non-commercial use: unrestricted
|
|
504
|
+
- Commercial use: ≤ 24 allocated qubits · ≤ 1,000 circuits/day · ≤ 10,000 shots/circuit
|
|
505
|
+
- Attribution required: `© 2026 Salvatore Pennacchio <jtatopenn@libero.it> — Dense Evolution`
|
|
506
|
+
|
|
507
|
+
Full text: [LICENSE.md](LICENSE.md)
|
|
508
|
+
|
|
509
|
+
---
|
|
510
|
+
|
|
511
|
+
<div align="center">
|
|
512
|
+
<sub>© 2026 Salvatore Pennacchio — Dense Evolution</sub>
|
|
513
|
+
</div>
|