quantum-debugger 0.1.1__py3-none-any.whl

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.
@@ -0,0 +1,205 @@
1
+ """
2
+ Quantum state visualization
3
+ """
4
+
5
+ import numpy as np
6
+ import matplotlib.pyplot as plt
7
+ from typing import Optional
8
+ from quantum_debugger.core.quantum_state import QuantumState
9
+
10
+
11
+ class StateVisualizer:
12
+ """Visualize quantum states"""
13
+
14
+ @staticmethod
15
+ def plot_state_vector(state: QuantumState, show_phase: bool = True,
16
+ figsize: tuple = (12, 5)):
17
+ """
18
+ Plot state vector amplitudes and phases
19
+
20
+ Args:
21
+ state: Quantum state to visualize
22
+ show_phase: Whether to show phase information
23
+ figsize: Figure size
24
+ """
25
+ probabilities = state.get_probabilities()
26
+ amplitudes = np.abs(state.state_vector)
27
+ phases = np.angle(state.state_vector)
28
+
29
+ # Basis state labels
30
+ labels = [format(i, f'0{state.num_qubits}b') for i in range(state.dim)]
31
+ x = np.arange(state.dim)
32
+
33
+ if show_phase:
34
+ fig, (ax1, ax2) = plt.subplots(1, 2, figsize=figsize)
35
+
36
+ # Amplitudes
37
+ ax1.bar(x, amplitudes, color='steelblue', alpha=0.7)
38
+ ax1.set_xlabel('Basis State')
39
+ ax1.set_ylabel('Amplitude')
40
+ ax1.set_title('State Vector Amplitudes')
41
+ ax1.set_xticks(x)
42
+ ax1.set_xticklabels(labels, rotation=45, ha='right')
43
+ ax1.grid(True, alpha=0.3)
44
+
45
+ # Phases
46
+ colors = plt.cm.hsv(phases / (2 * np.pi) + 0.5)
47
+ ax2.bar(x, amplitudes, color=colors, alpha=0.7)
48
+ ax2.set_xlabel('Basis State')
49
+ ax2.set_ylabel('Amplitude')
50
+ ax2.set_title('Phases (color-coded)')
51
+ ax2.set_xticks(x)
52
+ ax2.set_xticklabels(labels, rotation=45, ha='right')
53
+ ax2.grid(True, alpha=0.3)
54
+
55
+ else:
56
+ fig, ax = plt.subplots(figsize=(figsize[0]//2, figsize[1]))
57
+ ax.bar(x, amplitudes, color='steelblue', alpha=0.7)
58
+ ax.set_xlabel('Basis State')
59
+ ax.set_ylabel('Amplitude')
60
+ ax.set_title('State Vector Amplitudes')
61
+ ax.set_xticks(x)
62
+ ax.set_xticklabels(labels, rotation=45, ha='right')
63
+ ax.grid(True, alpha=0.3)
64
+
65
+ plt.tight_layout()
66
+ plt.show()
67
+
68
+ @staticmethod
69
+ def plot_probabilities(state: QuantumState, figsize: tuple = (10, 6)):
70
+ """
71
+ Plot measurement probabilities
72
+
73
+ Args:
74
+ state: Quantum state
75
+ figsize: Figure size
76
+ """
77
+ probabilities = state.get_probabilities()
78
+ labels = [format(i, f'0{state.num_qubits}b') for i in range(state.dim)]
79
+ x = np.arange(state.dim)
80
+
81
+ plt.figure(figsize=figsize)
82
+ bars = plt.bar(x, probabilities, color='coral', alpha=0.7, edgecolor='darkred')
83
+
84
+ # Highlight most probable states
85
+ max_prob = np.max(probabilities)
86
+ for i, (bar, prob) in enumerate(zip(bars, probabilities)):
87
+ if prob > max_prob * 0.9:
88
+ bar.set_color('darkred')
89
+ bar.set_alpha(0.9)
90
+
91
+ plt.xlabel('Basis State', fontsize=12)
92
+ plt.ylabel('Probability', fontsize=12)
93
+ plt.title('Measurement Probabilities', fontsize=14, fontweight='bold')
94
+ plt.xticks(x, labels, rotation=45, ha='right')
95
+ plt.ylim(0, 1)
96
+ plt.grid(True, alpha=0.3, axis='y')
97
+ plt.tight_layout()
98
+ plt.show()
99
+
100
+ @staticmethod
101
+ def plot_density_matrix(state: QuantumState, figsize: tuple = (10, 8)):
102
+ """
103
+ Plot density matrix representation
104
+
105
+ Args:
106
+ state: Quantum state
107
+ figsize: Figure size
108
+ """
109
+ # Create density matrix
110
+ rho = np.outer(state.state_vector, state.state_vector.conj())
111
+
112
+ fig, (ax1, ax2) = plt.subplots(1, 2, figsize=figsize)
113
+
114
+ # Real part
115
+ im1 = ax1.imshow(np.real(rho), cmap='RdBu', vmin=-1, vmax=1)
116
+ ax1.set_title('Density Matrix (Real Part)')
117
+ ax1.set_xlabel('Basis State')
118
+ ax1.set_ylabel('Basis State')
119
+ plt.colorbar(im1, ax=ax1)
120
+
121
+ # Imaginary part
122
+ im2 = ax2.imshow(np.imag(rho), cmap='RdBu', vmin=-1, vmax=1)
123
+ ax2.set_title('Density Matrix (Imaginary Part)')
124
+ ax2.set_xlabel('Basis State')
125
+ ax2.set_ylabel('Basis State')
126
+ plt.colorbar(im2, ax=ax2)
127
+
128
+ plt.tight_layout()
129
+ plt.show()
130
+
131
+ @staticmethod
132
+ def plot_qubit_probabilities(state: QuantumState, figsize: tuple = (10, 6)):
133
+ """
134
+ Plot per-qubit measurement probabilities
135
+
136
+ Args:
137
+ state: Quantum state
138
+ figsize: Figure size
139
+ """
140
+ qubits = range(state.num_qubits)
141
+ prob_0 = []
142
+ prob_1 = []
143
+
144
+ for q in qubits:
145
+ p0 = state.get_measurement_probability(q, 0)
146
+ p1 = state.get_measurement_probability(q, 1)
147
+ prob_0.append(p0)
148
+ prob_1.append(p1)
149
+
150
+ x = np.arange(state.num_qubits)
151
+ width = 0.35
152
+
153
+ fig, ax = plt.subplots(figsize=figsize)
154
+ ax.bar(x - width/2, prob_0, width, label='|0⟩', color='steelblue', alpha=0.8)
155
+ ax.bar(x + width/2, prob_1, width, label='|1⟩', color='coral', alpha=0.8)
156
+
157
+ ax.set_xlabel('Qubit Index', fontsize=12)
158
+ ax.set_ylabel('Probability', fontsize=12)
159
+ ax.set_title('Per-Qubit Measurement Probabilities', fontsize=14, fontweight='bold')
160
+ ax.set_xticks(x)
161
+ ax.set_xticklabels([f'q{i}' for i in qubits])
162
+ ax.legend()
163
+ ax.set_ylim(0, 1)
164
+ ax.grid(True, alpha=0.3, axis='y')
165
+
166
+ plt.tight_layout()
167
+ plt.show()
168
+
169
+ @staticmethod
170
+ def plot_state_comparison(state1: QuantumState, state2: QuantumState,
171
+ labels: tuple = ('State 1', 'State 2'),
172
+ figsize: tuple = (12, 6)):
173
+ """
174
+ Compare two quantum states
175
+
176
+ Args:
177
+ state1: First quantum state
178
+ state2: Second quantum state
179
+ labels: Labels for the states
180
+ figsize: Figure size
181
+ """
182
+ if state1.num_qubits != state2.num_qubits:
183
+ raise ValueError("States must have same number of qubits")
184
+
185
+ prob1 = state1.get_probabilities()
186
+ prob2 = state2.get_probabilities()
187
+
188
+ basis_labels = [format(i, f'0{state1.num_qubits}b') for i in range(state1.dim)]
189
+ x = np.arange(state1.dim)
190
+ width = 0.35
191
+
192
+ fig, ax = plt.subplots(figsize=figsize)
193
+ ax.bar(x - width/2, prob1, width, label=labels[0], alpha=0.8)
194
+ ax.bar(x + width/2, prob2, width, label=labels[1], alpha=0.8)
195
+
196
+ ax.set_xlabel('Basis State')
197
+ ax.set_ylabel('Probability')
198
+ ax.set_title('State Comparison')
199
+ ax.set_xticks(x)
200
+ ax.set_xticklabels(basis_labels, rotation=45, ha='right')
201
+ ax.legend()
202
+ ax.grid(True, alpha=0.3, axis='y')
203
+
204
+ plt.tight_layout()
205
+ plt.show()
@@ -0,0 +1,176 @@
1
+ Metadata-Version: 2.4
2
+ Name: quantum-debugger
3
+ Version: 0.1.1
4
+ Summary: Interactive debugger and profiler for quantum circuits
5
+ Home-page: https://github.com/yourusername/quantum-debugger
6
+ Author: warlord9004
7
+ Author-email: your.email@example.com
8
+ Project-URL: Bug Reports, https://github.com/yourusername/quantum-debugger/issues
9
+ Project-URL: Source, https://github.com/yourusername/quantum-debugger
10
+ Project-URL: Documentation, https://quantum-debugger.readthedocs.io
11
+ Keywords: quantum computing debugging profiling quantum-circuit visualization
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Science/Research
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Topic :: Scientific/Engineering :: Physics
16
+ Classifier: Topic :: Software Development :: Debuggers
17
+ Classifier: License :: OSI Approved :: MIT License
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.8
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Requires-Python: >=3.8
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Requires-Dist: numpy>=1.21.0
27
+ Requires-Dist: matplotlib>=3.5.0
28
+ Requires-Dist: scipy>=1.7.0
29
+ Provides-Extra: qiskit
30
+ Requires-Dist: qiskit>=0.39.0; extra == "qiskit"
31
+ Provides-Extra: cirq
32
+ Requires-Dist: cirq>=1.0.0; extra == "cirq"
33
+ Provides-Extra: dev
34
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
35
+ Requires-Dist: pytest-cov>=3.0.0; extra == "dev"
36
+ Requires-Dist: black>=22.0.0; extra == "dev"
37
+ Requires-Dist: flake8>=4.0.0; extra == "dev"
38
+ Requires-Dist: sphinx>=4.5.0; extra == "dev"
39
+ Dynamic: author
40
+ Dynamic: author-email
41
+ Dynamic: classifier
42
+ Dynamic: description
43
+ Dynamic: description-content-type
44
+ Dynamic: home-page
45
+ Dynamic: keywords
46
+ Dynamic: license-file
47
+ Dynamic: project-url
48
+ Dynamic: provides-extra
49
+ Dynamic: requires-dist
50
+ Dynamic: requires-python
51
+ Dynamic: summary
52
+
53
+ # QuantumDebugger 🔬
54
+
55
+ A powerful Python library for **interactive debugging and profiling of quantum circuits** with step-through execution, state visualization, and performance analysis.
56
+
57
+ ## 🌟 Features
58
+
59
+ ### 🐛 Interactive Debugging
60
+ - **Step-through execution**: Execute quantum circuits gate-by-gate
61
+ - **Breakpoints**: Set breakpoints at specific gates or conditions
62
+ - **State inspection**: Examine quantum state at any point in execution
63
+ - **Execution history**: Track and replay circuit execution
64
+ - **Rewind capability**: Step backwards through circuit execution
65
+
66
+ ### 📊 Visualization
67
+ - **State vector plots**: Visualize quantum state amplitudes and phases
68
+ - **Probability distributions**: See measurement probabilities
69
+ - **Bloch sphere**: 3D visualization for single qubit states
70
+ - **Circuit diagrams**: ASCII and graphical circuit representations
71
+
72
+ ### 📈 Performance Profiling
73
+ - **Gate depth analysis**: Measure circuit depth and critical paths
74
+ - **Complexity metrics**: Gate counts, T-count, CNOT count
75
+ - **Performance estimation**: Predict execution time on quantum hardware
76
+ - **Optimization suggestions**: Get recommendations for circuit improvements
77
+
78
+ ## 🚀 Quick Start
79
+
80
+ ### Installation
81
+
82
+ ```bash
83
+ pip install quantum-debugger
84
+ ```
85
+
86
+ ### Basic Usage
87
+
88
+ ```python
89
+ from quantum_debugger import QuantumCircuit, QuantumDebugger
90
+
91
+ # Create a Bell state circuit
92
+ qc = QuantumCircuit(2)
93
+ qc.h(0)
94
+ qc.cnot(0, 1)
95
+
96
+ # Debug the circuit
97
+ debugger = QuantumDebugger(qc)
98
+
99
+ # Step through execution
100
+ debugger.step() # Apply H gate
101
+ debugger.inspect_state() # Examine current state
102
+ debugger.visualize() # Show state visualization
103
+
104
+ debugger.step() # Apply CNOT
105
+ debugger.inspect_state() # See entangled state
106
+ ```
107
+
108
+ ### Setting Breakpoints
109
+
110
+ ```python
111
+ # Set breakpoint at gate 5
112
+ debugger.set_breakpoint(gate=5)
113
+
114
+ # Run until breakpoint
115
+ debugger.run_until_breakpoint()
116
+
117
+ # Conditional breakpoint
118
+ debugger.set_breakpoint(condition=lambda state: state.is_entangled())
119
+ ```
120
+
121
+ ### Profiling
122
+
123
+ ```python
124
+ from quantum_debugger import CircuitProfiler
125
+
126
+ profiler = CircuitProfiler(qc)
127
+ report = profiler.analyze()
128
+
129
+ print(f"Gate depth: {report.depth}")
130
+ print(f"Total gates: {report.gate_count}")
131
+ print(f"CNOT count: {report.cnot_count}")
132
+ ```
133
+
134
+ ## 📚 Examples
135
+
136
+ Check out the `examples/` directory for:
137
+ - **Bell State Debugging**: Step-by-step entanglement creation
138
+ - **Grover's Algorithm**: Profiling and optimization
139
+ - **Interactive Demo**: Full feature showcase
140
+
141
+ ## 🛠️ Requirements
142
+
143
+ - Python 3.8+
144
+ - NumPy
145
+ - Matplotlib
146
+ - (Optional) Qiskit/Cirq for integration
147
+
148
+ ## 🤝 Contributing
149
+
150
+ Contributions welcome! Please feel free to submit a Pull Request.
151
+
152
+ ## 📄 License
153
+
154
+ MIT License - feel free to use in your quantum computing projects!
155
+
156
+ ## 🎯 Why QuantumDebugger?
157
+
158
+ Unlike existing quantum libraries that focus on circuit creation and execution, **QuantumDebugger** is specifically designed for:
159
+ - **Learning**: Understand how quantum algorithms work step-by-step
160
+ - **Development**: Debug complex quantum circuits efficiently
161
+ - **Research**: Analyze and optimize quantum algorithms
162
+ - **Teaching**: Demonstrate quantum concepts interactively
163
+
164
+ ## 📖 Documentation
165
+
166
+ Full documentation available at: [quantum-debugger.readthedocs.io](https://quantum-debugger.readthedocs.io)
167
+
168
+ ## 🌐 Links
169
+
170
+ - **GitHub**: [github.com/yourusername/quantum-debugger](https://github.com/yourusername/quantum-debugger)
171
+ - **PyPI**: [pypi.org/project/quantum-debugger](https://pypi.org/project/quantum-debugger)
172
+ - **Issues**: [Report bugs](https://github.com/yourusername/quantum-debugger/issues)
173
+
174
+ ---
175
+
176
+ Made with ❤️ for the quantum computing community
@@ -0,0 +1,20 @@
1
+ quantum_debugger/__init__.py,sha256=UTj22gMwrBYuWDBmvtHtdgT0WZ_ylQ6OCqG_-zNUCSI,640
2
+ quantum_debugger/core/__init__.py,sha256=ojMpqbMRSQdiRpF2iAOUM3D_negdLOvy1VQ1wFW8tLs,279
3
+ quantum_debugger/core/circuit.py,sha256=f-MRmWAuT8x4fk8eVp7qpm6fCSB-oHJYxkgrhHC_xlQ,9193
4
+ quantum_debugger/core/gates.py,sha256=cw63ZZkl-MXhMw3WfBcqg5k9UxaXDpf6VN3nSnjn23g,5061
5
+ quantum_debugger/core/quantum_state.py,sha256=hdpHEdjfIt7Felw--RfekbEdPY_FU0Ibh7O4VMpt5Pk,11279
6
+ quantum_debugger/debugger/__init__.py,sha256=VC6euTgiCvO_UDrpxoHuCz31o0JXqfroLrxxRMCii8c,337
7
+ quantum_debugger/debugger/breakpoints.py,sha256=lM8Z9NSFrybKwMyYLPlqWJRC6Is3MmxlbF5y6fDBcD4,4101
8
+ quantum_debugger/debugger/debugger.py,sha256=ueztgZ478hLFBB-xtbIoMK2rzkQxh1puoYhABPy4ujY,7878
9
+ quantum_debugger/debugger/inspector.py,sha256=7k-nAFUJA8nm9VQ0cpbe7Vrto-OO5DM7jfQ9ZnQieKM,7565
10
+ quantum_debugger/profiler/__init__.py,sha256=ZYbtYEaVgijT2i076h1BGfR_DnGitGSCEclh7OrmcF4,231
11
+ quantum_debugger/profiler/metrics.py,sha256=mxttKr2dwYwnWyZdR3oJeY5U2ELKeGOKDUyK52YtmGU,4604
12
+ quantum_debugger/profiler/profiler.py,sha256=lXDsMu9Kj6cOrUJGfCoI7939NPgLYdmDlqC_LpyRzVI,6539
13
+ quantum_debugger/visualization/__init__.py,sha256=qeIFZMT1BMWVAaX9f_kcmIEA3CzndgVA0ngdmAvXuv0,249
14
+ quantum_debugger/visualization/bloch_sphere.py,sha256=CNV6ALN3S6bLY5AAuB8ds9fz-Xt2u7hnX-ja_pfuuvs,5867
15
+ quantum_debugger/visualization/state_viz.py,sha256=Cu3qufFmXTpFXDivEZmo8B5sVLjCDewlQZ-1GeKKkyg,7303
16
+ quantum_debugger-0.1.1.dist-info/licenses/LICENSE,sha256=r3tw9CUJkHJY5tPgcdr3ayN_GerX51xh9LglroEYJRE,1106
17
+ quantum_debugger-0.1.1.dist-info/METADATA,sha256=9O59sTEErZVj9YAAvPkhMLC2xgEatRVruX0qmQzgkPE,5719
18
+ quantum_debugger-0.1.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
19
+ quantum_debugger-0.1.1.dist-info/top_level.txt,sha256=DkmRIw_4yddkQwWfzQYDUJrWsjgU84PG_zMXiYmQmjQ,17
20
+ quantum_debugger-0.1.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 QuantumDebugger Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ quantum_debugger