quantum-debugger 0.4.0__tar.gz → 0.4.2__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.
- quantum_debugger-0.4.2/CHANGELOG.md +110 -0
- {quantum_debugger-0.4.0/quantum_debugger.egg-info → quantum_debugger-0.4.2}/PKG-INFO +75 -17
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/README.md +72 -14
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/__init__.py +1 -1
- quantum_debugger-0.4.2/quantum_debugger/integrations/__init__.py +8 -0
- quantum_debugger-0.4.2/quantum_debugger/integrations/cirq_adapter.py +270 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2/quantum_debugger.egg-info}/PKG-INFO +75 -17
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger.egg-info/SOURCES.txt +62 -1
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger.egg-info/top_level.txt +1 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/setup.py +3 -3
- quantum_debugger-0.4.2/tests/__init__.py +1 -0
- quantum_debugger-0.4.2/tests/cirq/__init__.py +1 -0
- quantum_debugger-0.4.2/tests/cirq/test_cirq_advanced.py +412 -0
- quantum_debugger-0.4.2/tests/cirq/test_cirq_edge_cases.py +423 -0
- quantum_debugger-0.4.2/tests/cirq/test_cirq_integration.py +287 -0
- quantum_debugger-0.4.2/tests/conftest.py +55 -0
- quantum_debugger-0.4.2/tests/integration/__init__.py +1 -0
- quantum_debugger-0.4.2/tests/integration/test_integration.py +308 -0
- quantum_debugger-0.4.2/tests/qml/__init__.py +1 -0
- quantum_debugger-0.4.2/tests/qml/test_edge_cases.py +522 -0
- quantum_debugger-0.4.2/tests/qml/test_properties.py +248 -0
- quantum_debugger-0.4.2/tests/qml/test_qaoa.py +195 -0
- quantum_debugger-0.4.2/tests/qml/test_qml_parameterized_gates.py +343 -0
- quantum_debugger-0.4.2/tests/qml/test_regression.py +258 -0
- quantum_debugger-0.4.2/tests/qml/test_training.py +181 -0
- quantum_debugger-0.4.2/tests/qml/test_vqe.py +153 -0
- quantum_debugger-0.4.2/tests/unit/CONVERSION_TRACKER.py +40 -0
- quantum_debugger-0.4.2/tests/unit/__init__.py +1 -0
- quantum_debugger-0.4.2/tests/unit/test_advanced.py +403 -0
- quantum_debugger-0.4.2/tests/unit/test_backend_comprehensive.py +211 -0
- quantum_debugger-0.4.2/tests/unit/test_backend_integration.py +67 -0
- quantum_debugger-0.4.2/tests/unit/test_backends.py +68 -0
- quantum_debugger-0.4.2/tests/unit/test_backends_advanced.py +155 -0
- quantum_debugger-0.4.2/tests/unit/test_backends_comprehensive.py +126 -0
- quantum_debugger-0.4.2/tests/unit/test_backends_fast.py +90 -0
- quantum_debugger-0.4.2/tests/unit/test_circuit_noise.py +131 -0
- quantum_debugger-0.4.2/tests/unit/test_circuit_noise_advanced.py +423 -0
- quantum_debugger-0.4.2/tests/unit/test_circuit_noise_unique.py +590 -0
- quantum_debugger-0.4.2/tests/unit/test_compatibility.py +86 -0
- quantum_debugger-0.4.2/tests/unit/test_comprehensive.py +481 -0
- quantum_debugger-0.4.2/tests/unit/test_distribution.py +142 -0
- quantum_debugger-0.4.2/tests/unit/test_docstrings.py +60 -0
- quantum_debugger-0.4.2/tests/unit/test_extreme.py +538 -0
- quantum_debugger-0.4.2/tests/unit/test_gpu_quick.py +34 -0
- quantum_debugger-0.4.2/tests/unit/test_hardware_profiles_extended.py +151 -0
- quantum_debugger-0.4.2/tests/unit/test_hardware_profiles_phase3.py +165 -0
- quantum_debugger-0.4.2/tests/unit/test_mitigation_comprehensive.py +370 -0
- quantum_debugger-0.4.2/tests/unit/test_mitigation_final.py +229 -0
- quantum_debugger-0.4.2/tests/unit/test_mitigation_observables.py +200 -0
- quantum_debugger-0.4.2/tests/unit/test_mitigation_zne.py +184 -0
- quantum_debugger-0.4.2/tests/unit/test_noise.py +119 -0
- quantum_debugger-0.4.2/tests/unit/test_noise_advanced.py +592 -0
- quantum_debugger-0.4.2/tests/unit/test_noise_extreme.py +464 -0
- quantum_debugger-0.4.2/tests/unit/test_noise_final.py +462 -0
- quantum_debugger-0.4.2/tests/unit/test_noise_performance.py +385 -0
- quantum_debugger-0.4.2/tests/unit/test_noise_quantum_info.py +427 -0
- quantum_debugger-0.4.2/tests/unit/test_noise_ultimate.py +176 -0
- quantum_debugger-0.4.2/tests/unit/test_parallel.py +181 -0
- quantum_debugger-0.4.2/tests/unit/test_production.py +491 -0
- quantum_debugger-0.4.2/tests/unit/test_qiskit_complex.py +270 -0
- quantum_debugger-0.4.2/tests/unit/test_qiskit_extreme.py +373 -0
- quantum_debugger-0.4.2/tests/unit/test_qiskit_ultra.py +282 -0
- quantum_debugger-0.4.2/tests/unit/test_qml_advanced.py +253 -0
- quantum_debugger-0.4.2/tests/unit/test_qml_comprehensive.py +306 -0
- quantum_debugger-0.4.2/tests/unit/test_qml_memory.py +209 -0
- quantum_debugger-0.4.2/tests/unit/test_qml_threading.py +219 -0
- quantum_debugger-0.4.2/tests/unit/test_qml_tricky.py +339 -0
- quantum_debugger-0.4.2/tests/unit/test_quickstart.py +156 -0
- quantum_debugger-0.4.2/tests/unit/test_v0.4.0_integration.py +118 -0
- quantum_debugger-0.4.2/tests/unit/test_validation.py +459 -0
- quantum_debugger-0.4.0/CHANGELOG.md +0 -40
- quantum_debugger-0.4.0/quantum_debugger/integrations/__init__.py +0 -9
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/LICENSE +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/MANIFEST.in +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/examples/bell_state_debug.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/examples/benchmarks.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/examples/grover_profiling.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/examples/interactive_demo.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/examples/qaoa_maxcut_example.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/examples/qiskit_integration_demo.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/examples/qml_basic_example.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/examples/vqe_h2_example.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/backends/__init__.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/backends/base.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/backends/cupy_backend.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/backends/numba_backend.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/backends/numpy_backend.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/backends/sparse_backend.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/core/__init__.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/core/circuit.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/core/gates.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/core/quantum_state.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/debugger/__init__.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/debugger/breakpoints.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/debugger/debugger.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/debugger/inspector.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/integrations/qiskit_adapter.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/mitigation/__init__.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/mitigation/core/__init__.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/mitigation/core/extrapolator.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/mitigation/core/folder.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/mitigation/zne.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/noise/__init__.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/noise/composite_noise.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/noise/hardware_profiles.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/noise/noise_helpers.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/noise/noise_models.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/noise/stochastic_sampler.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/parallel/__init__.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/parallel/executor.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/profiler/__init__.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/profiler/metrics.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/profiler/profiler.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/qml/__init__.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/qml/algorithms/__init__.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/qml/algorithms/qaoa.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/qml/algorithms/vqe.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/qml/ansatz/__init__.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/qml/gates/__init__.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/qml/gates/parameterized.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/qml/hamiltonians/__init__.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/qml/hamiltonians/molecular.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/qml/optimizers/__init__.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/qml/training/__init__.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/qml/utils/__init__.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/qml/utils/gradients.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/visualization/__init__.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/visualization/bloch_sphere.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger/visualization/state_viz.py +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger.egg-info/dependency_links.txt +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/quantum_debugger.egg-info/requires.txt +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/requirements.txt +0 -0
- {quantum_debugger-0.4.0 → quantum_debugger-0.4.2}/setup.cfg +0 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to QuantumDebugger will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.4.2] - 2025-12-22
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Complete pytest migration**: All 200 legacy script-style tests converted to pytest format
|
|
12
|
+
- **Hardware profiles extended**: AWS Braket, Azure Quantum provider support
|
|
13
|
+
- **2025 hardware updates**: IBM Heron, Google Willow, IonQ Forte profiles
|
|
14
|
+
- **Advanced backend tests**: 8 edge case and performance tests
|
|
15
|
+
- **GPU backend support**: CuPy backend availability testing
|
|
16
|
+
- **Enhanced test coverage**: 656 comprehensive tests (all passing ✅)
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- Migrated all legacy test files from script execution to pytest format
|
|
20
|
+
- Updated test structure for better CI/CD compatibility
|
|
21
|
+
- Enhanced backend validation with 6 comprehensive backend tests
|
|
22
|
+
- Improved hardware profile testing (18 tests total)
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
- Test suite compatibility issues
|
|
26
|
+
- Backend detection for GPU/CuPy
|
|
27
|
+
- Hardware profile version tracking
|
|
28
|
+
|
|
29
|
+
### Documentation
|
|
30
|
+
- Updated README.md with v0.4.2 features and test count
|
|
31
|
+
- Added comprehensive testing section in README
|
|
32
|
+
- Created FINAL_TEST_SUMMARY.md with complete 656 test breakdown
|
|
33
|
+
- Fixed all documentation links (tutorials, examples, LICENSE)
|
|
34
|
+
- Updated version numbers across all files
|
|
35
|
+
|
|
36
|
+
### Testing
|
|
37
|
+
- **656 total tests** (all passing ✅)
|
|
38
|
+
- All script-style tests converted to pytest
|
|
39
|
+
- Complete test coverage documentation
|
|
40
|
+
|
|
41
|
+
## [0.4.1] - 2024-12-XX
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
- Additional QML features and optimizations
|
|
45
|
+
- Performance improvements
|
|
46
|
+
|
|
47
|
+
## [0.4.0] - 2024-12-XX
|
|
48
|
+
|
|
49
|
+
### Added
|
|
50
|
+
- **Quantum Machine Learning Module**
|
|
51
|
+
- Parameterized gates (RX, RY, RZ with trainable parameters)
|
|
52
|
+
- VQE algorithm for molecular chemistry
|
|
53
|
+
- QAOA for combinatorial optimization
|
|
54
|
+
- Training framework with 4 optimizers (Adam, SGD, SPSA, RMSprop)
|
|
55
|
+
- Gradient computation (parameter shift rule, finite differences)
|
|
56
|
+
- 316 comprehensive tests
|
|
57
|
+
- 3 tutorials, 4 example scripts
|
|
58
|
+
|
|
59
|
+
### Changed
|
|
60
|
+
- Enhanced circuit profiling
|
|
61
|
+
- Improved state visualization
|
|
62
|
+
|
|
63
|
+
## [0.3.0] - 2024-12-XX
|
|
64
|
+
|
|
65
|
+
### Added
|
|
66
|
+
- Realistic noise models (4 types)
|
|
67
|
+
- Hardware profiles (IBM, Google, IonQ, Rigetti)
|
|
68
|
+
- Qiskit Aer validation
|
|
69
|
+
- 89 new tests
|
|
70
|
+
|
|
71
|
+
## [0.2.0] - 2024-XX-XX
|
|
72
|
+
|
|
73
|
+
### Added
|
|
74
|
+
- Bidirectional circuit conversion with Qiskit
|
|
75
|
+
- CP gate support
|
|
76
|
+
- 12-qubit support
|
|
77
|
+
|
|
78
|
+
## [0.1.1] - 2024-12-03
|
|
79
|
+
|
|
80
|
+
### Fixed
|
|
81
|
+
- Fixed SWAP gate matrix for little-endian qubit ordering
|
|
82
|
+
- Fixed CNOT gate matrix for little-endian qubit ordering
|
|
83
|
+
- Fixed Toffoli gate matrix for little-endian qubit ordering
|
|
84
|
+
- Fixed entanglement detection for Bell states
|
|
85
|
+
- Rewrote multi-qubit gate expansion algorithm using tensor products
|
|
86
|
+
|
|
87
|
+
### Added
|
|
88
|
+
- 69 comprehensive tests (100% pass rate)
|
|
89
|
+
- Test suites: quickstart, advanced, comprehensive, extreme, validation, production, edge cases
|
|
90
|
+
- Numerical stability tests (100+ consecutive operations)
|
|
91
|
+
- Quantum mechanics validation tests
|
|
92
|
+
- Production readiness tests
|
|
93
|
+
|
|
94
|
+
### Changed
|
|
95
|
+
- Improved gate expansion algorithm for better accuracy
|
|
96
|
+
- Enhanced test coverage to 69 tests across 7 test suites
|
|
97
|
+
|
|
98
|
+
## [0.1.0] - 2024-11-30
|
|
99
|
+
|
|
100
|
+
### Added
|
|
101
|
+
- Initial release
|
|
102
|
+
- Core quantum state representation
|
|
103
|
+
- 15+ quantum gates (H, X, Y, Z, S, T, RX, RY, RZ, PHASE, CNOT, CZ, SWAP, Toffoli)
|
|
104
|
+
- Step-through debugger with breakpoints
|
|
105
|
+
- Circuit profiler with optimization suggestions
|
|
106
|
+
- State visualization tools
|
|
107
|
+
- Bloch sphere representation
|
|
108
|
+
- Support for up to 15 qubits
|
|
109
|
+
- Example circuits and demos
|
|
110
|
+
- Comprehensive documentation
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: quantum-debugger
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
4
4
|
Summary: Interactive quantum circuit debugger and Quantum Machine Learning library with VQE, QAOA, and parameterized gates
|
|
5
5
|
Home-page: https://github.com/Raunakg2005/quantum-debugger
|
|
6
|
-
Author:
|
|
7
|
-
Author-email:
|
|
6
|
+
Author: Raunak Kumar Gupta
|
|
7
|
+
Author-email: raunak.gupta@somaiya.edu
|
|
8
8
|
Project-URL: Bug Reports, https://github.com/Raunakg2005/quantum-debugger/issues
|
|
9
9
|
Project-URL: Source, https://github.com/Raunakg2005/quantum-debugger
|
|
10
10
|
Project-URL: Documentation, https://github.com/Raunakg2005/quantum-debugger#readme
|
|
@@ -55,13 +55,13 @@ Dynamic: summary
|
|
|
55
55
|
**Interactive debugger, profiler, and quantum machine learning library for quantum circuits**
|
|
56
56
|
|
|
57
57
|
[](https://pypi.org/project/quantum-debugger/)
|
|
58
|
-
[](./tests/FINAL_TEST_SUMMARY.md)
|
|
59
59
|
[]()
|
|
60
60
|
[]()
|
|
61
61
|
|
|
62
62
|
A powerful Python library for quantum circuit debugging, state inspection, performance analysis, and **quantum machine learning**. Now with VQE, QAOA, and parameterized quantum circuits!
|
|
63
63
|
|
|
64
|
-
## ✨ What's New in v0.4.
|
|
64
|
+
## ✨ What's New in v0.4.2
|
|
65
65
|
|
|
66
66
|
**Quantum Machine Learning Module** 🚀
|
|
67
67
|
|
|
@@ -82,7 +82,10 @@ print(f"Ground state energy: {result['ground_state_energy']:.6f} Hartree")
|
|
|
82
82
|
- ✅ **QAOA** (Quantum optimization for MaxCut problems)
|
|
83
83
|
- ✅ **Training Framework** (Adam, SGD, SPSA, RMSprop optimizers)
|
|
84
84
|
- ✅ **Gradient Computation** (Parameter shift rule, finite differences)
|
|
85
|
-
- ✅ **
|
|
85
|
+
- ✅ **656 comprehensive tests** (all passing ✅)
|
|
86
|
+
- ✅ **Complete pytest migration** (all legacy scripts converted)
|
|
87
|
+
- ✅ **Hardware profiles** (AWS Braket, Azure Quantum, 2025 updates)
|
|
88
|
+
- ✅ **Enhanced backends** (Advanced validation, GPU support)
|
|
86
89
|
|
|
87
90
|
See full [QML Documentation](#quantum-machine-learning-v040) below.
|
|
88
91
|
|
|
@@ -96,7 +99,7 @@ See full [QML Documentation](#quantum-machine-learning-v040) below.
|
|
|
96
99
|
- **Noise Simulation** - Realistic hardware noise models
|
|
97
100
|
- **Qiskit Integration** - Import/export circuits from Qiskit
|
|
98
101
|
|
|
99
|
-
### Quantum Machine Learning (
|
|
102
|
+
### Quantum Machine Learning (v0.4.0+)
|
|
100
103
|
- **Parameterized Circuits** - Trainable quantum gates
|
|
101
104
|
- **VQE** - Molecular ground state finding
|
|
102
105
|
- **QAOA** - Combinatorial optimization
|
|
@@ -361,14 +364,16 @@ See [test files](.) for details.
|
|
|
361
364
|
## 📖 Documentation
|
|
362
365
|
|
|
363
366
|
- **Tutorials:**
|
|
364
|
-
- [Parameterized Gates Tutorial](tutorials/parameterized_gates_tutorial.md)
|
|
365
|
-
- [VQE Preparation Guide](tutorials/vqe_preparation.md)
|
|
366
|
-
- [QAOA Tutorial](tutorials/qaoa_tutorial.md)
|
|
367
|
+
- [Parameterized Gates Tutorial](./tutorials/parameterized_gates_tutorial.md)
|
|
368
|
+
- [VQE Preparation Guide](./tutorials/vqe_preparation.md)
|
|
369
|
+
- [QAOA Tutorial](./tutorials/qaoa_tutorial.md)
|
|
370
|
+
- [Noise Tutorial](./tutorials/noise_tutorial.md)
|
|
371
|
+
- [ZNE Tutorial](./tutorials/zne_tutorial.md)
|
|
367
372
|
|
|
368
373
|
- **Examples:**
|
|
369
|
-
- [VQE H2 Molecule](examples/vqe_h2_example.py)
|
|
370
|
-
- [QAOA MaxCut](examples/qaoa_maxcut_example.py)
|
|
371
|
-
- [
|
|
374
|
+
- [VQE H2 Molecule](./examples/vqe_h2_example.py)
|
|
375
|
+
- [QAOA MaxCut](./examples/qaoa_maxcut_example.py)
|
|
376
|
+
- [QML Basic Example](./examples/qml_basic_example.py)
|
|
372
377
|
|
|
373
378
|
## 📈 Version History
|
|
374
379
|
|
|
@@ -410,21 +415,74 @@ See [test files](.) for details.
|
|
|
410
415
|
- [ ] Quantum error correction tools
|
|
411
416
|
- [ ] Production deployment tools
|
|
412
417
|
|
|
418
|
+
## 🧪 Testing
|
|
419
|
+
|
|
420
|
+
**v0.4.2: 656 Comprehensive Tests** ✅
|
|
421
|
+
|
|
422
|
+
### Test Suite Coverage
|
|
423
|
+
- **Core Tests**: 441 tests (quantum operations, circuits, debugging)
|
|
424
|
+
- **QML Tests**: 139 tests (VQE, QAOA, training, parameterized gates)
|
|
425
|
+
- **Integration**: 76 tests (Cirq, Qiskit, backend validation)
|
|
426
|
+
- **All test files converted to pytest format**
|
|
427
|
+
|
|
428
|
+
### Running Tests
|
|
429
|
+
|
|
430
|
+
```bash
|
|
431
|
+
# Run all tests
|
|
432
|
+
pytest tests/ -v
|
|
433
|
+
|
|
434
|
+
# Run specific test suites
|
|
435
|
+
pytest tests/unit/ -v # Core unit tests
|
|
436
|
+
pytest tests/cirq/ -v # Cirq integration
|
|
437
|
+
pytest tests/qiskit/ -v # Qiskit integration
|
|
438
|
+
pytest tests/qml/ -v # QML tests
|
|
439
|
+
|
|
440
|
+
# Run with coverage
|
|
441
|
+
pytest tests/ --cov=quantum_debugger --cov-report=html
|
|
442
|
+
|
|
443
|
+
# Run specific converted tests
|
|
444
|
+
pytest tests/unit/test_backends_advanced.py -v
|
|
445
|
+
pytest tests/unit/test_hardware_profiles_phase3.py -v
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### Test Documentation
|
|
449
|
+
- 📊 [Complete Test Summary](./tests/FINAL_TEST_SUMMARY.md) - Full breakdown of all 656 tests
|
|
450
|
+
- 📁 [Test Structure](./tests/README.md) - Organization and conventions
|
|
451
|
+
|
|
452
|
+
### Test Categories
|
|
453
|
+
1. **Backend Tests** (59 tests) - NumPy, Sparse, GPU backends
|
|
454
|
+
2. **Noise Tests** (64 tests) - Noise models, hardware profiles
|
|
455
|
+
3. **Mitigation Tests** (28 tests) - ZNE, error mitigation
|
|
456
|
+
4. **Hardware Profiles** (18 tests) - AWS Braket, Azure Quantum, 2025 updates
|
|
457
|
+
5. **QML Tests** (139 tests) - VQE, QAOA, training framework
|
|
458
|
+
6. **Integration Tests** (76 tests) - Cirq, Qiskit compatibility
|
|
459
|
+
|
|
413
460
|
## 🤝 Contributing
|
|
414
461
|
|
|
415
462
|
Contributions welcome! Please ensure tests pass:
|
|
416
463
|
|
|
417
464
|
```bash
|
|
418
|
-
pytest
|
|
465
|
+
pytest tests/ -v --tb=short
|
|
419
466
|
```
|
|
420
467
|
|
|
468
|
+
See [Testing Section](#testing) for details.
|
|
469
|
+
|
|
421
470
|
## 📄 License
|
|
422
471
|
|
|
423
|
-
MIT License - see [LICENSE](LICENSE) file.
|
|
472
|
+
MIT License - see [LICENSE](./LICENSE) file.
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
## 🙏 Acknowledgments
|
|
477
|
+
|
|
478
|
+
**Author:** Raunak Kumar Gupta
|
|
479
|
+
**Supervised by:** Dr. Vaibhav Prakash Vasani
|
|
480
|
+
**Institution:** K.J. Somaiya School of Engineering
|
|
424
481
|
|
|
425
482
|
---
|
|
426
483
|
|
|
427
484
|
**PyPI:** https://pypi.org/project/quantum-debugger/
|
|
428
|
-
**Author:**
|
|
429
|
-
**
|
|
485
|
+
**Author:** Raunak Kumar Gupta
|
|
486
|
+
**Institution:** K.J. Somaiya School of Engineering
|
|
487
|
+
**Version:** 0.4.2
|
|
430
488
|
**Python:** 3.9+
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
**Interactive debugger, profiler, and quantum machine learning library for quantum circuits**
|
|
4
4
|
|
|
5
5
|
[](https://pypi.org/project/quantum-debugger/)
|
|
6
|
-
[](./tests/FINAL_TEST_SUMMARY.md)
|
|
7
7
|
[]()
|
|
8
8
|
[]()
|
|
9
9
|
|
|
10
10
|
A powerful Python library for quantum circuit debugging, state inspection, performance analysis, and **quantum machine learning**. Now with VQE, QAOA, and parameterized quantum circuits!
|
|
11
11
|
|
|
12
|
-
## ✨ What's New in v0.4.
|
|
12
|
+
## ✨ What's New in v0.4.2
|
|
13
13
|
|
|
14
14
|
**Quantum Machine Learning Module** 🚀
|
|
15
15
|
|
|
@@ -30,7 +30,10 @@ print(f"Ground state energy: {result['ground_state_energy']:.6f} Hartree")
|
|
|
30
30
|
- ✅ **QAOA** (Quantum optimization for MaxCut problems)
|
|
31
31
|
- ✅ **Training Framework** (Adam, SGD, SPSA, RMSprop optimizers)
|
|
32
32
|
- ✅ **Gradient Computation** (Parameter shift rule, finite differences)
|
|
33
|
-
- ✅ **
|
|
33
|
+
- ✅ **656 comprehensive tests** (all passing ✅)
|
|
34
|
+
- ✅ **Complete pytest migration** (all legacy scripts converted)
|
|
35
|
+
- ✅ **Hardware profiles** (AWS Braket, Azure Quantum, 2025 updates)
|
|
36
|
+
- ✅ **Enhanced backends** (Advanced validation, GPU support)
|
|
34
37
|
|
|
35
38
|
See full [QML Documentation](#quantum-machine-learning-v040) below.
|
|
36
39
|
|
|
@@ -44,7 +47,7 @@ See full [QML Documentation](#quantum-machine-learning-v040) below.
|
|
|
44
47
|
- **Noise Simulation** - Realistic hardware noise models
|
|
45
48
|
- **Qiskit Integration** - Import/export circuits from Qiskit
|
|
46
49
|
|
|
47
|
-
### Quantum Machine Learning (
|
|
50
|
+
### Quantum Machine Learning (v0.4.0+)
|
|
48
51
|
- **Parameterized Circuits** - Trainable quantum gates
|
|
49
52
|
- **VQE** - Molecular ground state finding
|
|
50
53
|
- **QAOA** - Combinatorial optimization
|
|
@@ -309,14 +312,16 @@ See [test files](.) for details.
|
|
|
309
312
|
## 📖 Documentation
|
|
310
313
|
|
|
311
314
|
- **Tutorials:**
|
|
312
|
-
- [Parameterized Gates Tutorial](tutorials/parameterized_gates_tutorial.md)
|
|
313
|
-
- [VQE Preparation Guide](tutorials/vqe_preparation.md)
|
|
314
|
-
- [QAOA Tutorial](tutorials/qaoa_tutorial.md)
|
|
315
|
+
- [Parameterized Gates Tutorial](./tutorials/parameterized_gates_tutorial.md)
|
|
316
|
+
- [VQE Preparation Guide](./tutorials/vqe_preparation.md)
|
|
317
|
+
- [QAOA Tutorial](./tutorials/qaoa_tutorial.md)
|
|
318
|
+
- [Noise Tutorial](./tutorials/noise_tutorial.md)
|
|
319
|
+
- [ZNE Tutorial](./tutorials/zne_tutorial.md)
|
|
315
320
|
|
|
316
321
|
- **Examples:**
|
|
317
|
-
- [VQE H2 Molecule](examples/vqe_h2_example.py)
|
|
318
|
-
- [QAOA MaxCut](examples/qaoa_maxcut_example.py)
|
|
319
|
-
- [
|
|
322
|
+
- [VQE H2 Molecule](./examples/vqe_h2_example.py)
|
|
323
|
+
- [QAOA MaxCut](./examples/qaoa_maxcut_example.py)
|
|
324
|
+
- [QML Basic Example](./examples/qml_basic_example.py)
|
|
320
325
|
|
|
321
326
|
## 📈 Version History
|
|
322
327
|
|
|
@@ -358,21 +363,74 @@ See [test files](.) for details.
|
|
|
358
363
|
- [ ] Quantum error correction tools
|
|
359
364
|
- [ ] Production deployment tools
|
|
360
365
|
|
|
366
|
+
## 🧪 Testing
|
|
367
|
+
|
|
368
|
+
**v0.4.2: 656 Comprehensive Tests** ✅
|
|
369
|
+
|
|
370
|
+
### Test Suite Coverage
|
|
371
|
+
- **Core Tests**: 441 tests (quantum operations, circuits, debugging)
|
|
372
|
+
- **QML Tests**: 139 tests (VQE, QAOA, training, parameterized gates)
|
|
373
|
+
- **Integration**: 76 tests (Cirq, Qiskit, backend validation)
|
|
374
|
+
- **All test files converted to pytest format**
|
|
375
|
+
|
|
376
|
+
### Running Tests
|
|
377
|
+
|
|
378
|
+
```bash
|
|
379
|
+
# Run all tests
|
|
380
|
+
pytest tests/ -v
|
|
381
|
+
|
|
382
|
+
# Run specific test suites
|
|
383
|
+
pytest tests/unit/ -v # Core unit tests
|
|
384
|
+
pytest tests/cirq/ -v # Cirq integration
|
|
385
|
+
pytest tests/qiskit/ -v # Qiskit integration
|
|
386
|
+
pytest tests/qml/ -v # QML tests
|
|
387
|
+
|
|
388
|
+
# Run with coverage
|
|
389
|
+
pytest tests/ --cov=quantum_debugger --cov-report=html
|
|
390
|
+
|
|
391
|
+
# Run specific converted tests
|
|
392
|
+
pytest tests/unit/test_backends_advanced.py -v
|
|
393
|
+
pytest tests/unit/test_hardware_profiles_phase3.py -v
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
### Test Documentation
|
|
397
|
+
- 📊 [Complete Test Summary](./tests/FINAL_TEST_SUMMARY.md) - Full breakdown of all 656 tests
|
|
398
|
+
- 📁 [Test Structure](./tests/README.md) - Organization and conventions
|
|
399
|
+
|
|
400
|
+
### Test Categories
|
|
401
|
+
1. **Backend Tests** (59 tests) - NumPy, Sparse, GPU backends
|
|
402
|
+
2. **Noise Tests** (64 tests) - Noise models, hardware profiles
|
|
403
|
+
3. **Mitigation Tests** (28 tests) - ZNE, error mitigation
|
|
404
|
+
4. **Hardware Profiles** (18 tests) - AWS Braket, Azure Quantum, 2025 updates
|
|
405
|
+
5. **QML Tests** (139 tests) - VQE, QAOA, training framework
|
|
406
|
+
6. **Integration Tests** (76 tests) - Cirq, Qiskit compatibility
|
|
407
|
+
|
|
361
408
|
## 🤝 Contributing
|
|
362
409
|
|
|
363
410
|
Contributions welcome! Please ensure tests pass:
|
|
364
411
|
|
|
365
412
|
```bash
|
|
366
|
-
pytest
|
|
413
|
+
pytest tests/ -v --tb=short
|
|
367
414
|
```
|
|
368
415
|
|
|
416
|
+
See [Testing Section](#testing) for details.
|
|
417
|
+
|
|
369
418
|
## 📄 License
|
|
370
419
|
|
|
371
|
-
MIT License - see [LICENSE](LICENSE) file.
|
|
420
|
+
MIT License - see [LICENSE](./LICENSE) file.
|
|
421
|
+
|
|
422
|
+
---
|
|
423
|
+
|
|
424
|
+
## 🙏 Acknowledgments
|
|
425
|
+
|
|
426
|
+
**Author:** Raunak Kumar Gupta
|
|
427
|
+
**Supervised by:** Dr. Vaibhav Prakash Vasani
|
|
428
|
+
**Institution:** K.J. Somaiya School of Engineering
|
|
372
429
|
|
|
373
430
|
---
|
|
374
431
|
|
|
375
432
|
**PyPI:** https://pypi.org/project/quantum-debugger/
|
|
376
|
-
**Author:**
|
|
377
|
-
**
|
|
433
|
+
**Author:** Raunak Kumar Gupta
|
|
434
|
+
**Institution:** K.J. Somaiya School of Engineering
|
|
435
|
+
**Version:** 0.4.2
|
|
378
436
|
**Python:** 3.9+
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Cirq Adapter - Convert between Cirq and QuantumDebugger circuits
|
|
3
|
+
|
|
4
|
+
This module provides bidirectional conversion:
|
|
5
|
+
- Import Cirq Circuit → QuantumDebugger circuit
|
|
6
|
+
- Export QuantumDebugger circuit → Cirq Circuit
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
import numpy as np
|
|
10
|
+
from typing import Optional, List, Tuple
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
import cirq
|
|
14
|
+
CIRQ_AVAILABLE = True
|
|
15
|
+
except ImportError:
|
|
16
|
+
CIRQ_AVAILABLE = False
|
|
17
|
+
cirq = None
|
|
18
|
+
|
|
19
|
+
from ..core.circuit import QuantumCircuit as QDCircuit
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class CirqAdapter:
|
|
23
|
+
"""Adapter for converting between Cirq and QuantumDebugger circuits"""
|
|
24
|
+
|
|
25
|
+
# Gate name mapping: Cirq → QuantumDebugger
|
|
26
|
+
GATE_MAP = {
|
|
27
|
+
'H': 'h',
|
|
28
|
+
'X': 'x',
|
|
29
|
+
'Y': 'y',
|
|
30
|
+
'Z': 'z',
|
|
31
|
+
'S': 's',
|
|
32
|
+
'T': 't',
|
|
33
|
+
'CNOT': 'cnot',
|
|
34
|
+
'CX': 'cnot',
|
|
35
|
+
'CZ': 'cz',
|
|
36
|
+
'SWAP': 'swap',
|
|
37
|
+
'TOFFOLI': 'toffoli',
|
|
38
|
+
'CCX': 'toffoli',
|
|
39
|
+
'Rx': 'rx',
|
|
40
|
+
'Ry': 'ry',
|
|
41
|
+
'Rz': 'rz',
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@staticmethod
|
|
45
|
+
def check_cirq_available():
|
|
46
|
+
"""Check if Cirq is installed"""
|
|
47
|
+
if not CIRQ_AVAILABLE:
|
|
48
|
+
raise ImportError(
|
|
49
|
+
"Cirq is not installed. Install with: pip install cirq"
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def from_cirq(cls, cirq_circuit: 'cirq.Circuit') -> QDCircuit:
|
|
54
|
+
"""
|
|
55
|
+
Convert a Cirq Circuit to QuantumDebugger circuit
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
cirq_circuit: Cirq Circuit to convert
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
QuantumDebugger QuantumCircuit
|
|
62
|
+
|
|
63
|
+
Example:
|
|
64
|
+
>>> import cirq
|
|
65
|
+
>>> q0, q1 = cirq.LineQubit.range(2)
|
|
66
|
+
>>> cirq_circuit = cirq.Circuit()
|
|
67
|
+
>>> cirq_circuit.append([cirq.H(q0), cirq.CNOT(q0, q1)])
|
|
68
|
+
>>> qd_circuit = CirqAdapter.from_cirq(cirq_circuit)
|
|
69
|
+
"""
|
|
70
|
+
cls.check_cirq_available()
|
|
71
|
+
|
|
72
|
+
# Get all qubits and create mapping
|
|
73
|
+
qubits = sorted(cirq_circuit.all_qubits())
|
|
74
|
+
qubit_map = {q: i for i, q in enumerate(qubits)}
|
|
75
|
+
num_qubits = len(qubits)
|
|
76
|
+
|
|
77
|
+
# Create QuantumDebugger circuit
|
|
78
|
+
qd_circuit = QDCircuit(num_qubits)
|
|
79
|
+
|
|
80
|
+
# Convert each operation
|
|
81
|
+
for moment in cirq_circuit:
|
|
82
|
+
for operation in moment:
|
|
83
|
+
gate = operation.gate
|
|
84
|
+
gate_qubits = operation.qubits
|
|
85
|
+
|
|
86
|
+
# Get qubit indices
|
|
87
|
+
qubit_indices = [qubit_map[q] for q in gate_qubits]
|
|
88
|
+
|
|
89
|
+
# Determine gate type using string comparison (more reliable)
|
|
90
|
+
gate_str = str(gate).upper()
|
|
91
|
+
gate_name = None
|
|
92
|
+
params = []
|
|
93
|
+
|
|
94
|
+
# Check gates by string representation
|
|
95
|
+
if 'H' == gate_str:
|
|
96
|
+
gate_name = 'h'
|
|
97
|
+
elif 'X' == gate_str:
|
|
98
|
+
gate_name = 'x'
|
|
99
|
+
elif 'Y' == gate_str:
|
|
100
|
+
gate_name = 'y'
|
|
101
|
+
elif 'Z' == gate_str:
|
|
102
|
+
gate_name = 'z'
|
|
103
|
+
elif 'S' == gate_str:
|
|
104
|
+
gate_name = 's'
|
|
105
|
+
elif 'T' == gate_str:
|
|
106
|
+
gate_name = 't'
|
|
107
|
+
elif 'CNOT' in gate_str or 'CX' in gate_str:
|
|
108
|
+
gate_name = 'cnot'
|
|
109
|
+
elif 'CZ' == gate_str:
|
|
110
|
+
gate_name = 'cz'
|
|
111
|
+
elif 'SWAP' in gate_str:
|
|
112
|
+
gate_name = 'swap'
|
|
113
|
+
elif 'CCX' in gate_str or 'TOFFOLI' in gate_str:
|
|
114
|
+
gate_name = 'toffoli'
|
|
115
|
+
elif gate_str.startswith('RX'):
|
|
116
|
+
gate_name = 'rx'
|
|
117
|
+
# Extract angle from gate
|
|
118
|
+
if hasattr(gate, 'exponent'):
|
|
119
|
+
params = [gate.exponent * np.pi]
|
|
120
|
+
elif hasattr(gate, '_rads'):
|
|
121
|
+
params = [gate._rads]
|
|
122
|
+
elif gate_str.startswith('RY'):
|
|
123
|
+
gate_name = 'ry'
|
|
124
|
+
if hasattr(gate, 'exponent'):
|
|
125
|
+
params = [gate.exponent * np.pi]
|
|
126
|
+
elif hasattr(gate, '_rads'):
|
|
127
|
+
params = [gate._rads]
|
|
128
|
+
elif gate_str.startswith('RZ'):
|
|
129
|
+
gate_name = 'rz'
|
|
130
|
+
if hasattr(gate, 'exponent'):
|
|
131
|
+
params = [gate.exponent * np.pi]
|
|
132
|
+
elif hasattr(gate, '_rads'):
|
|
133
|
+
params = [gate._rads]
|
|
134
|
+
|
|
135
|
+
# Apply gate to QuantumDebugger circuit
|
|
136
|
+
if gate_name:
|
|
137
|
+
gate_method = getattr(qd_circuit, gate_name)
|
|
138
|
+
if params:
|
|
139
|
+
# Parameterized gate
|
|
140
|
+
gate_method(*params, *qubit_indices)
|
|
141
|
+
else:
|
|
142
|
+
# Standard gate
|
|
143
|
+
gate_method(*qubit_indices)
|
|
144
|
+
else:
|
|
145
|
+
print(f"Warning: Gate '{gate_str}' not supported in QuantumDebugger, skipping")
|
|
146
|
+
|
|
147
|
+
return qd_circuit
|
|
148
|
+
|
|
149
|
+
@classmethod
|
|
150
|
+
def to_cirq(cls, qd_circuit: QDCircuit, qubits: Optional[List['cirq.Qubit']] = None) -> 'cirq.Circuit':
|
|
151
|
+
"""
|
|
152
|
+
Convert a QuantumDebugger circuit to Cirq Circuit
|
|
153
|
+
|
|
154
|
+
Args:
|
|
155
|
+
qd_circuit: QuantumDebugger circuit to convert
|
|
156
|
+
qubits: Optional list of Cirq qubits to use. If None, LineQubits are created.
|
|
157
|
+
|
|
158
|
+
Returns:
|
|
159
|
+
Cirq Circuit
|
|
160
|
+
|
|
161
|
+
Example:
|
|
162
|
+
>>> from quantum_debugger import QuantumCircuit
|
|
163
|
+
>>> qd_circuit = QuantumCircuit(2)
|
|
164
|
+
>>> qd_circuit.h(0)
|
|
165
|
+
>>> qd_circuit.cnot(0, 1)
|
|
166
|
+
>>> cirq_circuit = CirqAdapter.to_cirq(qd_circuit)
|
|
167
|
+
"""
|
|
168
|
+
cls.check_cirq_available()
|
|
169
|
+
|
|
170
|
+
# Create qubits if not provided
|
|
171
|
+
if qubits is None:
|
|
172
|
+
qubits = [cirq.LineQubit(i) for i in range(qd_circuit.num_qubits)]
|
|
173
|
+
elif len(qubits) != qd_circuit.num_qubits:
|
|
174
|
+
raise ValueError(f"Number of qubits ({len(qubits)}) doesn't match circuit ({qd_circuit.num_qubits})")
|
|
175
|
+
|
|
176
|
+
# Create Cirq circuit
|
|
177
|
+
cirq_circuit = cirq.Circuit()
|
|
178
|
+
|
|
179
|
+
# Convert each gate
|
|
180
|
+
for gate in qd_circuit.gates:
|
|
181
|
+
gate_name = gate.name.lower()
|
|
182
|
+
gate_qubits = [qubits[i] for i in gate.qubits]
|
|
183
|
+
params = gate.params if gate.params else {}
|
|
184
|
+
|
|
185
|
+
# Map to Cirq gates
|
|
186
|
+
if gate_name == 'h':
|
|
187
|
+
cirq_circuit.append(cirq.H(gate_qubits[0]))
|
|
188
|
+
elif gate_name == 'x':
|
|
189
|
+
cirq_circuit.append(cirq.X(gate_qubits[0]))
|
|
190
|
+
elif gate_name == 'y':
|
|
191
|
+
cirq_circuit.append(cirq.Y(gate_qubits[0]))
|
|
192
|
+
elif gate_name == 'z':
|
|
193
|
+
cirq_circuit.append(cirq.Z(gate_qubits[0]))
|
|
194
|
+
elif gate_name == 's':
|
|
195
|
+
cirq_circuit.append(cirq.S(gate_qubits[0]))
|
|
196
|
+
elif gate_name == 't':
|
|
197
|
+
cirq_circuit.append(cirq.T(gate_qubits[0]))
|
|
198
|
+
elif gate_name == 'cnot':
|
|
199
|
+
cirq_circuit.append(cirq.CNOT(gate_qubits[0], gate_qubits[1]))
|
|
200
|
+
elif gate_name == 'cz':
|
|
201
|
+
cirq_circuit.append(cirq.CZ(gate_qubits[0], gate_qubits[1]))
|
|
202
|
+
elif gate_name == 'swap':
|
|
203
|
+
cirq_circuit.append(cirq.SWAP(gate_qubits[0], gate_qubits[1]))
|
|
204
|
+
elif gate_name == 'toffoli':
|
|
205
|
+
cirq_circuit.append(cirq.CCX(gate_qubits[0], gate_qubits[1], gate_qubits[2]))
|
|
206
|
+
elif gate_name == 'rx' and 'theta' in params:
|
|
207
|
+
# Convert radians to Cirq exponent
|
|
208
|
+
exponent = params['theta'] / np.pi
|
|
209
|
+
cirq_circuit.append(cirq.Rx(rads=params['theta'])(gate_qubits[0]))
|
|
210
|
+
elif gate_name == 'ry' and 'theta' in params:
|
|
211
|
+
cirq_circuit.append(cirq.Ry(rads=params['theta'])(gate_qubits[0]))
|
|
212
|
+
elif gate_name == 'rz' and 'theta' in params:
|
|
213
|
+
cirq_circuit.append(cirq.Rz(rads=params['theta'])(gate_qubits[0]))
|
|
214
|
+
elif gate_name == 'cp' and 'theta' in params:
|
|
215
|
+
# Controlled phase
|
|
216
|
+
cirq_circuit.append(cirq.CZPowGate(exponent=params['theta']/np.pi)(gate_qubits[0], gate_qubits[1]))
|
|
217
|
+
elif gate_name == 'phase' and 'theta' in params:
|
|
218
|
+
# Phase gate
|
|
219
|
+
cirq_circuit.append(cirq.ZPowGate(exponent=params['theta']/np.pi)(gate_qubits[0]))
|
|
220
|
+
else:
|
|
221
|
+
print(f"Warning: Gate '{gate_name}' not recognized for Cirq conversion, skipping")
|
|
222
|
+
|
|
223
|
+
return cirq_circuit
|
|
224
|
+
|
|
225
|
+
@classmethod
|
|
226
|
+
def compare_circuits(cls, cirq_circuit: 'cirq.Circuit', qd_circuit: QDCircuit) -> dict:
|
|
227
|
+
"""
|
|
228
|
+
Compare a Cirq circuit with a QuantumDebugger circuit
|
|
229
|
+
|
|
230
|
+
Returns:
|
|
231
|
+
Dictionary with comparison results
|
|
232
|
+
"""
|
|
233
|
+
cls.check_cirq_available()
|
|
234
|
+
|
|
235
|
+
cirq_num_qubits = len(cirq_circuit.all_qubits())
|
|
236
|
+
cirq_num_ops = sum(len(moment) for moment in cirq_circuit)
|
|
237
|
+
|
|
238
|
+
return {
|
|
239
|
+
'num_qubits_match': cirq_num_qubits == qd_circuit.num_qubits,
|
|
240
|
+
'num_gates_match': cirq_num_ops == len(qd_circuit.gates),
|
|
241
|
+
'cirq_qubits': cirq_num_qubits,
|
|
242
|
+
'qd_qubits': qd_circuit.num_qubits,
|
|
243
|
+
'cirq_gates': cirq_num_ops,
|
|
244
|
+
'qd_gates': len(qd_circuit.gates),
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
@classmethod
|
|
248
|
+
def simulate_cirq(cls, qd_circuit: QDCircuit) -> dict:
|
|
249
|
+
"""
|
|
250
|
+
Simulate a QuantumDebugger circuit using Cirq's simulator
|
|
251
|
+
|
|
252
|
+
Args:
|
|
253
|
+
qd_circuit: QuantumDebugger circuit to simulate
|
|
254
|
+
|
|
255
|
+
Returns:
|
|
256
|
+
Dictionary with simulation results
|
|
257
|
+
"""
|
|
258
|
+
cls.check_cirq_available()
|
|
259
|
+
|
|
260
|
+
# Convert to Cirq
|
|
261
|
+
cirq_circuit = cls.to_cirq(qd_circuit)
|
|
262
|
+
|
|
263
|
+
# Simulate
|
|
264
|
+
simulator = cirq.Simulator()
|
|
265
|
+
result = simulator.simulate(cirq_circuit)
|
|
266
|
+
|
|
267
|
+
return {
|
|
268
|
+
'state_vector': result.final_state_vector,
|
|
269
|
+
'measurements': result.measurements if hasattr(result, 'measurements') else None,
|
|
270
|
+
}
|