dense-evolution 8.0.2__tar.gz → 8.0.3__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.0.3/LICENSE.md +61 -0
- {dense_evolution-8.0.2 → dense_evolution-8.0.3}/PKG-INFO +133 -137
- {dense_evolution-8.0.2 → dense_evolution-8.0.3}/README.md +127 -133
- {dense_evolution-8.0.2 → dense_evolution-8.0.3}/dense_evolution.egg-info/PKG-INFO +133 -137
- {dense_evolution-8.0.2 → dense_evolution-8.0.3}/dense_evolution.egg-info/SOURCES.txt +1 -0
- {dense_evolution-8.0.2 → dense_evolution-8.0.3}/dense_evolution.py +42 -8
- {dense_evolution-8.0.2 → dense_evolution-8.0.3}/pyproject.toml +75 -73
- {dense_evolution-8.0.2 → dense_evolution-8.0.3}/dense_evolution.egg-info/dependency_links.txt +0 -0
- {dense_evolution-8.0.2 → dense_evolution-8.0.3}/dense_evolution.egg-info/requires.txt +0 -0
- {dense_evolution-8.0.2 → dense_evolution-8.0.3}/dense_evolution.egg-info/top_level.txt +0 -0
- {dense_evolution-8.0.2 → dense_evolution-8.0.3}/setup.cfg +0 -0
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Business Source License 1.1 (BSL 1.1)
|
|
2
|
+
|
|
3
|
+
**Software:** Dense Evolution
|
|
4
|
+
**Licensor:** Salvatore Pennacchio <jtatopenn@libero.it> [tatopenn-cell]
|
|
5
|
+
|
|
6
|
+
This Business Source License (the "License") applies to the source code, object code, algorithms, and configuration files of the software named "Dense Evolution" (the "Software").
|
|
7
|
+
|
|
8
|
+
## 1. License Parameters
|
|
9
|
+
|
|
10
|
+
* **Licensor:** Salvatore Pennacchio <jtatopenn@libero.it> [tatopenn-cell]
|
|
11
|
+
* **Software:** Dense Evolution (including updates, patches, kernel optimizations, and derivative works provided by the Licensor)
|
|
12
|
+
* **Change Date:** June 1, 2029
|
|
13
|
+
* **Change License:** Apache License, Version 2.0 (or subsequent versions, at the Licensor's sole discretion)
|
|
14
|
+
* **Licensed Use for Production:** Strictly non-commercial use. For use in commercial or industrial production environments, the computational limits set forth in Section 4 (Additional Use Grant) shall strictly apply.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 2. Grant of License and Attribution Obligation
|
|
19
|
+
|
|
20
|
+
Subject to the terms and computational limitations established herein, the Licensor hereby grants to the Licensee a non-exclusive, worldwide, royalty-free, and irrevocable (conditional upon continuous compliance with these terms) license to use, reproduce, distribute, modify, and create derivative works of the Software.
|
|
21
|
+
|
|
22
|
+
**Mandatory Attribution Condition:** Any copy, portion, or derivative work of the Software (including third-party software, cloud platforms, or API interfaces integrating Dense Evolution) must visibly, permanently, and unaltered include the original copyright notice and attribution to the Licensor in the following format:
|
|
23
|
+
`© 2026 Salvatore Pennacchio <jtatopenn@libero.it> [tatopenn-cell] - Dense Evolution`.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## 3. General Use Conditions and Restrictions
|
|
28
|
+
|
|
29
|
+
The Software may be used, reproduced, distributed, and modified, provided that such use is **not intended for commercial production purposes** or for providing commercial cloud/computational services that compete directly with the products or services offered by the Licensor, except as expressly permitted under Section 4 or as of the Change Date (Section 5).
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## 4. Additional Use Grant (Limited Commercial Use)
|
|
34
|
+
|
|
35
|
+
Notwithstanding the restrictions in Section 3, the Licensee is authorized to use the Software for commercial production, industrial, or paid consulting purposes, without the need for a separate paid license, exclusively if the following computational limits are respected:
|
|
36
|
+
|
|
37
|
+
* **Total Qubit Limit:** The executed quantum simulation must not exceed a size of **24 qubits allocated in memory**. This limit applies to the cumulative sum of all instances, processes, threads, or parallel cluster nodes running concurrently by the same organization or end user.
|
|
38
|
+
* **Circuits and Shots Limit:** The maximum computational volume allowed in a production environment is fixed at **1000 distinct quantum circuit structures per day**, each of which may be executed for a maximum of **10,000 equivalent samples (shots)** per individual circuit.
|
|
39
|
+
|
|
40
|
+
Any use that exceeds or circumvents (via splitting, wrapping, or proxy techniques) any single parameter listed above strictly requires the prior execution of a separate commercial license agreement with the Licensor.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## 5. Transition to Change License
|
|
45
|
+
|
|
46
|
+
As of **June 1, 2029** (the "Change Date"), this License shall automatically cease to have effect on the Software and all versions released prior to that date. From that moment forward, the Software will permanently and freely become available under the terms of the **Apache License 2.0**. Until the Change Date, this BSL 1.1 License shall remain in full force, validity, and effect.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 6. Disclaimer of Warranty and Limitation of Liability
|
|
51
|
+
|
|
52
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
53
|
+
|
|
54
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 7. Governing Law and Jurisdiction
|
|
59
|
+
|
|
60
|
+
This License shall be governed by, construed, and enforced in accordance with the laws of **Italy**. Any dispute arising out of or in connection with the interpretation, execution, or validity of this License shall be submitted to the exclusive jurisdiction of the **Court of Milan, Italy**.
|
|
61
|
+
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dense-evolution
|
|
3
|
-
Version: 8.0.
|
|
3
|
+
Version: 8.0.3
|
|
4
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
5
|
Author-email: Salvatore Pennacchio <jtatopenn@libero.it>
|
|
6
|
-
License:
|
|
6
|
+
License: Business Source License 1.1
|
|
7
7
|
Project-URL: Homepage, https://github.com/tatopenn-cell/Dense-Evolution
|
|
8
|
-
Project-URL: Documentation, https://github.com/tatopenn-cell/Dense-Evolution/
|
|
8
|
+
Project-URL: Documentation, https://github.com/tatopenn-cell/Dense-Evolution/blob/main/LICENSE
|
|
9
9
|
Project-URL: Repository, https://github.com/tatopenn-cell/Dense-Evolution
|
|
10
10
|
Project-URL: Bug Tracker, https://github.com/tatopenn-cell/Dense-Evolution/blob/main/dense_evolution.py
|
|
11
11
|
Keywords: quantum-computing,quantum-simulation,statevector,jax,cupy,cuda-acceleration,openqasm,nisq-noise,hpc,linear-kernel-fusion
|
|
12
12
|
Classifier: Development Status :: 5 - Production/Stable
|
|
13
13
|
Classifier: Intended Audience :: Science/Research
|
|
14
14
|
Classifier: Intended Audience :: Developers
|
|
15
|
-
Classifier: License ::
|
|
15
|
+
Classifier: License :: Other/Proprietary License
|
|
16
16
|
Classifier: Programming Language :: Python :: 3
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.9
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.10
|
|
@@ -22,6 +22,7 @@ Classifier: Topic :: Scientific/Engineering :: Physics
|
|
|
22
22
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
23
|
Requires-Python: >=3.9
|
|
24
24
|
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE.md
|
|
25
26
|
Requires-Dist: numpy>=1.22.0
|
|
26
27
|
Requires-Dist: matplotlib>=3.5.0
|
|
27
28
|
Requires-Dist: psutil>=5.9.0
|
|
@@ -34,6 +35,7 @@ Provides-Extra: full
|
|
|
34
35
|
Requires-Dist: jax>=0.4.0; extra == "full"
|
|
35
36
|
Requires-Dist: jaxlib>=0.4.0; extra == "full"
|
|
36
37
|
Requires-Dist: cupy-cuda12x>=12.0.0; extra == "full"
|
|
38
|
+
Dynamic: license-file
|
|
37
39
|
|
|
38
40
|
# 💎 Dense Evolution
|
|
39
41
|
|
|
@@ -41,7 +43,7 @@ Requires-Dist: cupy-cuda12x>=12.0.0; extra == "full"
|
|
|
41
43
|
[](https://github.com/tatopenn-cell/Dense-Evolution/actions/workflows/ci.yml)
|
|
42
44
|
[](https://pypi.org/project/dense-evolution/)
|
|
43
45
|
[](https://www.python.org/)
|
|
44
|
-
[](https://github.com/tatopenn-cell/Dense-Evolution/blob/main/LICENSE)
|
|
45
47
|
[](https://github.com/tatopenn-cell/Dense-Evolution/actions)
|
|
46
48
|
|
|
47
49
|
# pip install dense-evolution
|
|
@@ -330,32 +332,76 @@ Dense-Evolution/
|
|
|
330
332
|
|
|
331
333
|
---
|
|
332
334
|
|
|
333
|
-
## 📜
|
|
335
|
+
## 📜 License and Legal Notice
|
|
336
|
+
|
|
337
|
+
This project is distributed under the terms of the **Business Source License 1.1 (BSL 1.1)**.
|
|
338
|
+
|
|
339
|
+
* **Non-Commercial Use:** Completely free and open for research, academic, and non-commercial purposes.
|
|
340
|
+
* **Limited Commercial Use:** Free for commercial production up to **24 qubits** and **1,000 circuits (with max 10,000 shots each) per day**. Any use beyond these limits requires a separate commercial license.
|
|
341
|
+
* **Future Open Source Transition:** On **June 1, 2026**, this project will automatically transition to a fully open-source **Apache License 2.0**.
|
|
334
342
|
|
|
335
|
-
Il progetto è interamente distribuito sotto i termini della licenza **MIT**.
|
|
336
343
|
|
|
337
344
|
```text
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
of
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
345
|
+
# Business Source License 1.1 (BSL 1.1)
|
|
346
|
+
|
|
347
|
+
**Software:** Dense Evolution
|
|
348
|
+
**Licensor:** Salvatore Pennacchio <jtatopenn@libero.it> [tatopenn-cell]
|
|
349
|
+
|
|
350
|
+
This Business Source License (the "License") applies to the source code, object code, algorithms, and configuration files of the software named "Dense Evolution" (the "Software").
|
|
351
|
+
|
|
352
|
+
## 1. License Parameters
|
|
353
|
+
|
|
354
|
+
* **Licensor:** Salvatore Pennacchio <jtatopenn@libero.it> [tatopenn-cell]
|
|
355
|
+
* **Software:** Dense Evolution (including updates, patches, kernel optimizations, and derivative works provided by the Licensor)
|
|
356
|
+
* **Change Date:** June 1, 2029
|
|
357
|
+
* **Change License:** Apache License, Version 2.0 (or subsequent versions, at the Licensor's sole discretion)
|
|
358
|
+
* **Licensed Use for Production:** Strictly non-commercial use. For use in commercial or industrial production environments, the computational limits set forth in Section 4 (Additional Use Grant) shall strictly apply.
|
|
359
|
+
|
|
360
|
+
---
|
|
361
|
+
|
|
362
|
+
## 2. Grant of License and Attribution Obligation
|
|
363
|
+
|
|
364
|
+
Subject to the terms and computational limitations established herein, the Licensor hereby grants to the Licensee a non-exclusive, worldwide, royalty-free, and irrevocable (conditional upon continuous compliance with these terms) license to use, reproduce, distribute, modify, and create derivative works of the Software.
|
|
365
|
+
|
|
366
|
+
**Mandatory Attribution Condition:** Any copy, portion, or derivative work of the Software (including third-party software, cloud platforms, or API interfaces integrating Dense Evolution) must visibly, permanently, and unaltered include the original copyright notice and attribution to the Licensor in the following format:
|
|
367
|
+
`© 2026 Salvatore Pennacchio <jtatopenn@libero.it> [tatopenn-cell] - Dense Evolution`.
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
## 3. General Use Conditions and Restrictions
|
|
372
|
+
|
|
373
|
+
The Software may be used, reproduced, distributed, and modified, provided that such use is **not intended for commercial production purposes** or for providing commercial cloud/computational services that compete directly with the products or services offered by the Licensor, except as expressly permitted under Section 4 or as of the Change Date (Section 5).
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## 4. Additional Use Grant (Limited Commercial Use)
|
|
378
|
+
|
|
379
|
+
Notwithstanding the restrictions in Section 3, the Licensee is authorized to use the Software for commercial production, industrial, or paid consulting purposes, without the need for a separate paid license, exclusively if the following computational limits are respected:
|
|
380
|
+
|
|
381
|
+
* **Total Qubit Limit:** The executed quantum simulation must not exceed a size of **24 qubits allocated in memory**. This limit applies to the cumulative sum of all instances, processes, threads, or parallel cluster nodes running concurrently by the same organization or end user.
|
|
382
|
+
* **Circuits and Shots Limit:** The maximum computational volume allowed in a production environment is fixed at **1000 distinct quantum circuit structures per day**, each of which may be executed for a maximum of **10,000 equivalent samples (shots)** per individual circuit.
|
|
383
|
+
|
|
384
|
+
Any use that exceeds or circumvents (via splitting, wrapping, or proxy techniques) any single parameter listed above strictly requires the prior execution of a separate commercial license agreement with the Licensor.
|
|
385
|
+
|
|
386
|
+
---
|
|
387
|
+
|
|
388
|
+
## 5. Transition to Change License
|
|
389
|
+
|
|
390
|
+
As of **June 1, 2029** (the "Change Date"), this License shall automatically cease to have effect on the Software and all versions released prior to that date. From that moment forward, the Software will permanently and freely become available under the terms of the **Apache License 2.0**. Until the Change Date, this BSL 1.1 License shall remain in full force, validity, and effect.
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
## 6. Disclaimer of Warranty and Limitation of Liability
|
|
395
|
+
|
|
396
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
397
|
+
|
|
398
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
## 7. Governing Law and Jurisdiction
|
|
403
|
+
|
|
404
|
+
This License shall be governed by, construed, and enforced in accordance with the laws of **Italy**. Any dispute arising out of or in connection with the interpretation, execution, or validity of this License shall be submitted to the exclusive jurisdiction of the **Court of Milan, Italy**.
|
|
359
405
|
```
|
|
360
406
|
|
|
361
407
|
## 💎 Technical Appendix: Advanced JAX XLA Optimizations
|
|
@@ -399,75 +445,47 @@ jax.block_until_ready(sv_final)
|
|
|
399
445
|
|
|
400
446
|
print(f"🚀 Tempo di calcolo puro in Beast Mode: {time.time() - start:.6f} secondi")
|
|
401
447
|
```
|
|
402
|
-
## 🛠️ 2. Native OpenQASM 2.0 Integration via QASMParser
|
|
403
|
-
The QASMParser module parses OpenQASM 2.0 source code, translating instructions directly into the flat linear format required by the simulation backend. The raw text string is processed natively by the parse() method, which outputs a valid QASMCircuit object. This architecture eliminates the need for external dictionary maps or manual type adapters.
|
|
404
|
-
Before execution, the circuit object can be verified through the native validate() method to guarantee structural integrity and prevent runtime exceptions during deep JIT compilation.
|
|
405
|
-
|
|
406
|
-
## OpenQASM 2.0 Parsing and Execution Example:
|
|
407
|
-
|
|
408
|
-
```python
|
|
409
|
-
import dense_evolution as de
|
|
410
|
-
|
|
411
|
-
# Stringa QASM 2.0 standard
|
|
412
|
-
qasm_string = """
|
|
413
|
-
OPENQASM 2.0;
|
|
414
|
-
include "qelib1.inc";
|
|
415
|
-
qreg q[2];
|
|
416
|
-
h q[0];
|
|
417
|
-
cx q[0], q[1];"""
|
|
418
|
-
|
|
419
|
-
# 1. Inizializzazione del simulatore e del parser
|
|
420
|
-
sim = de.DenseSVSimulator(n_qubits=2)
|
|
421
|
-
parser = de.QASMParser()
|
|
422
448
|
|
|
423
|
-
|
|
424
|
-
parsed_circuit = parser.parse(qasm_string)
|
|
449
|
+
## 🪐 High-Performance OpenQASM 3.0 Hybrid Execution Engine
|
|
425
450
|
|
|
426
|
-
|
|
427
|
-
print(f"DEBUG: parsed_circuit.ops type: {type(parsed_circuit.ops)}")
|
|
428
|
-
print(f"DEBUG: parsed_circuit.ops content: {parsed_circuit.ops}")
|
|
451
|
+
The `DenseSVSimulator` features an integrated OpenQASM 3.0 compilation pipeline. It bridges hardware specifications with optimized static compilation layers. The engine maps high-level instructions directly into unified JAX XLA operations, eliminating tracking degradation and runtime interpreter bottlenecks.
|
|
429
452
|
|
|
430
|
-
|
|
431
|
-
# According to dense_evolution.py source code, the QASMCircuit object stores gates in 'ops' attribute.
|
|
432
|
-
# The previous KeyError indicates a format mismatch, not an AttributeError.
|
|
433
|
-
# We need to convert parsed_circuit.ops to the format expected by run_circuit_jit_beast_mode.
|
|
453
|
+
### ⚙️ Key Computational Paradigms
|
|
434
454
|
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
gate_name = op['name']
|
|
439
|
-
qubits = op['qubits']
|
|
440
|
-
# Combine name and qubits into a tuple, ensuring qubits are appended as individual arguments
|
|
441
|
-
converted_circuit_list.append(tuple([gate_name] + qubits))
|
|
455
|
+
* **Zero-Overhead Control Flow**
|
|
456
|
+
Conditional `if/else` branches compile without breaking execution streams.
|
|
457
|
+
This setup eliminates host-level loop delays during mid-circuit measurements.
|
|
442
458
|
|
|
443
|
-
|
|
459
|
+
* **Micro-Fused AST Translation**
|
|
460
|
+
The `QASMParser` resolves complex sub-routines and multi-dimensional registers.
|
|
461
|
+
It generates a flattened primitive topology for the Beast Mode engine.
|
|
444
462
|
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
```
|
|
463
|
+
* **Deterministic Resource Bound**
|
|
464
|
+
Strictly handles dynamic mathematical arguments like $\text{rx}(\pi/4 \times \theta)$.
|
|
465
|
+
It preserves a machine-epsilon zero-drift footprint ($\Delta = 1.11 \times 10^{-16}$) during updates.
|
|
449
466
|
|
|
450
|
-
## Simulating and Measuring the QASM 3.0 Circuit
|
|
451
|
-
Now, let's simulate the QASM 3.0 circuit we just parsed and see the measurement results using the DenseSVSimulator's measure method.
|
|
452
467
|
|
|
453
468
|
```python
|
|
454
469
|
import dense_evolution as de
|
|
470
|
+
import numpy as np
|
|
455
471
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
qubit[
|
|
472
|
+
sim = de.DenseSVSimulator(n_qubits=3, use_gpu=False, use_float32=False)
|
|
473
|
+
|
|
474
|
+
qasm3_program = """OPENQASM 3.0;
|
|
475
|
+
include "stdgates.inc";
|
|
476
|
+
qubit[3] q;
|
|
461
477
|
bit[2] c;
|
|
462
478
|
h q[0];
|
|
463
479
|
cx q[0], q[1];
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
480
|
+
bit c[0] = measure q[0];
|
|
481
|
+
if (c[0] == 1) {
|
|
482
|
+
x q[2];
|
|
483
|
+
}
|
|
467
484
|
"""
|
|
468
|
-
parsed_circuit = parser.parse(qasm3_circuit_str)
|
|
469
485
|
|
|
470
|
-
|
|
486
|
+
parser = de.QASMParser()
|
|
487
|
+
parsed_circuit = parser.parse(qasm3_program)
|
|
488
|
+
|
|
471
489
|
def convert_ops_for_simulator(ops_list):
|
|
472
490
|
converted_ops = []
|
|
473
491
|
for op in ops_list:
|
|
@@ -475,50 +493,26 @@ def convert_ops_for_simulator(ops_list):
|
|
|
475
493
|
qubits = op['qubits']
|
|
476
494
|
params = op['params']
|
|
477
495
|
if params:
|
|
478
|
-
# For parametric gates, format is (name, param1, ..., paramN, qubit1, ..., qubitN)
|
|
479
496
|
converted_ops.append(tuple([name] + params + qubits))
|
|
480
497
|
else:
|
|
481
|
-
# For non-parametric gates, format is (name, qubit1, ..., qubitN)
|
|
482
498
|
converted_ops.append(tuple([name] + qubits))
|
|
483
499
|
return converted_ops
|
|
484
500
|
|
|
485
|
-
|
|
486
|
-
|
|
501
|
+
circuit_operations = convert_ops_for_simulator(parsed_circuit.ops)
|
|
502
|
+
sim.run_circuit_jit_beast_mode(circuit_operations)
|
|
487
503
|
|
|
488
|
-
|
|
489
|
-
sim = de.DenseSVSimulator(n_qubits=parsed_circuit.n_qubits)
|
|
504
|
+
final_state = sim.get_statevector()
|
|
490
505
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
print("
|
|
494
|
-
|
|
495
|
-
measurements = []
|
|
496
|
-
for _ in range(num_shots):
|
|
497
|
-
sim.set_initial_state() # Corrected: used set_initial_state() instead of reset_state()
|
|
498
|
-
sim.run_circuit_jit_beast_mode(simulator_ops) # Use the converted operations list
|
|
506
|
+
print("\n" + "="*60)
|
|
507
|
+
print("📊 REPORT - DENSE-EVOLUTION OPENQASM 3.0")
|
|
508
|
+
print("="*60)
|
|
509
|
+
print(f"🔹 Probability Vector:\n{sim.get_probabilities()}\n")
|
|
499
510
|
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
measurements.append((measured_c0, measured_c1))
|
|
511
|
+
norma = np.sum(np.abs(final_state)**2)
|
|
512
|
+
print(f"🔹 State Unitary Tolerance: {norma:.4f}")
|
|
513
|
+
print("🔍 Drift Verification:", "DONE" if np.isclose(norma, 1.0) else "ANOMALY")
|
|
514
|
+
print("="*60)
|
|
505
515
|
|
|
506
|
-
print(f"Measurements (c0, c1) over {num_shots} shots: {measurements}")
|
|
507
|
-
|
|
508
|
-
# To get probabilities of all states (without classical bit mapping from QASM measure),
|
|
509
|
-
# you can use `get_probabilities()` directly after running the circuit.
|
|
510
|
-
print("\n--- Probabilities of all states (after 1 run) ---")
|
|
511
|
-
sim.set_initial_state()
|
|
512
|
-
sim.run_circuit_jit_beast_mode(simulator_ops)
|
|
513
|
-
probabilities = sim.get_probabilities()
|
|
514
|
-
print(probabilities)
|
|
515
|
-
|
|
516
|
-
# Display top probabilities for clarity
|
|
517
|
-
import numpy as np
|
|
518
|
-
sorted_indices = np.argsort(probabilities)[::-1]
|
|
519
|
-
print("\nTop 5 probabilities:")
|
|
520
|
-
for i in sorted_indices[:5]:
|
|
521
|
-
print(f"State |{i:0{parsed_circuit.n_qubits}b}⟩: {probabilities[i]:.4f}")
|
|
522
516
|
```
|
|
523
517
|
------------------------------
|
|
524
518
|
## 🧠 3. Stochastic Noise Simulation (NoiseModel)
|
|
@@ -1144,34 +1138,36 @@ print("="*80)
|
|
|
1144
1138
|
* Circuit optimization loops: VQE, QAOA, variational algorithms with fixed structure
|
|
1145
1139
|
* Shot-based sampling simulation: Execute same circuit many times with different measurements
|
|
1146
1140
|
|
|
1147
|
-
## ⚠️
|
|
1141
|
+
## ⚠️ Performance & Scaling Limitations
|
|
1142
|
+
|
|
1143
|
+
* **Memory Overhead:** The dense statevector simulation approach scales exponentially. On standard hardware architectures, execution is optimal up to **~24 qubits**. For deep or larger scale systems, consider alternative approaches like Matrix Product States (MPS).
|
|
1144
|
+
* **Licensing Threshold:** Please note that while the hardware can push further, commercial production use is capped at **24 qubits** under the terms of the BSL 1.1 license.
|
|
1145
|
+
|
|
1146
|
+
## 🚀 Hardware Recommendations & Benchmarks
|
|
1148
1147
|
|
|
1149
|
-
* Memory: Dense statevector limited to ~24 qubits on standard hardware (use MPS for larger systems)
|
|
1150
1148
|
|
|
1151
|
-
|
|
1149
|
+
| Hardware Platform | Max Practical Qubits (Dense) | Performance Gain vs Qiskit | Operational Notes |
|
|
1150
|
+
| :--- | :---: | :---: | :--- |
|
|
1151
|
+
| **Standard CPU** *(e.g., Colab Free)* | 24 | **120x – 5,000x+** | Verified and benchmarked baseline configuration. |
|
|
1152
|
+
| **High-RAM CPU** *(16+ GB RAM)* | 26 | **120x – 5,000x+** | Performance scales with host memory bandwidth. |
|
|
1153
|
+
| **NVIDIA GPU** *(CUDA-Enabled)* | 28+ | **10,000x+** * | Accelerated via CuPy backend execution. |
|
|
1154
|
+
| **Google Cloud TPU** | 28+ | **20,000x+** * | Optimized via JAX native XLA compilation. |
|
|
1152
1155
|
|
|
1153
|
-
|
|
1154
|
-
|---|---|---|---|
|
|
1155
|
-
| CPU (Colab Free) | 24 | 120-5000x+ | Tested configuration |
|
|
1156
|
-
| CPU (High RAM) | 26 | 120-5000x+ | 16+ GB recommended |
|
|
1157
|
-
| NVIDIA GPU | 28+ | 10000x+* | CUDA-enabled, estimated |
|
|
1158
|
-
| TPU | 28+ | 20000x+* | Google Cloud, estimated |
|
|
1156
|
+
*\*Note: GPU/TPU performance gains are projected based on JAX/XLA scaling characteristics and native kernel execution profiles. Full automated benchmarks will be introduced in upcoming releases.*
|
|
1159
1157
|
|
|
1160
|
-
|
|
1158
|
+
## 🧠 Architectural Insights: Why is it so fast?
|
|
1161
1159
|
|
|
1162
|
-
|
|
1160
|
+
1. **JAX JIT Compilation:** Circuit operations are JIT-compiled directly into highly optimized XLA machine code, entirely bypassing the Python interpreter overhead.
|
|
1161
|
+
2. **Linear Kernel Fusion:** Multiple sequential gate operations are fused dynamically into single monolithic CPU/GPU computational kernels, minimizing memory roundtrips.
|
|
1162
|
+
3. **Hardware-Adaptive Memory Layout:** Contiguous statevector memory storage architecture, highly optimized for vectorization and parallel cache locality.
|
|
1163
|
+
4. **Graph Caching:** Compiled execution graphs are automatically cached and reused across subsequent execution loops or optimization shots.
|
|
1163
1164
|
|
|
1164
|
-
|
|
1165
|
-
2. Kernel Fusion: Multiple gate operations fused into single GPU/CPU kernels
|
|
1166
|
-
3. Memory Layout: Contiguous statevector storage optimized for vectorized operations
|
|
1167
|
-
4. Caching: Compiled functions cached and reused across executions
|
|
1165
|
+
## 🤝 Contribute Benchmarks
|
|
1168
1166
|
|
|
1169
|
-
|
|
1170
|
-
Found better (or worse) results on your hardware? Open an issue or PR with:
|
|
1167
|
+
Discovered different scaling behavior or performance metrics on your specific hardware stack? Help us refine and map the performance of **Dense Evolution**! Please open an Issue or Pull Request providing:
|
|
1171
1168
|
|
|
1172
|
-
* Hardware
|
|
1173
|
-
*
|
|
1174
|
-
* Timing results
|
|
1169
|
+
* **Hardware Topology:** Exact CPU/GPU models, Host RAM, and CUDA toolkit version.
|
|
1170
|
+
* **Reproducible Example:** Code snippet or script used for the test run.
|
|
1171
|
+
* **Execution Metrics:** Timing results and memory allocation logs.
|
|
1175
1172
|
|
|
1176
|
-
Help us optimize Dense-Evolution for your use case!
|
|
1177
1173
|
|