Name | qiskit-debugger JSON |
Version |
0.1.2
JSON |
| download |
home_page | |
Summary | Quantum Circuit debugger for the Qiskit SDK. |
upload_time | 2023-07-06 03:38:25 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.6 |
license | MIT License Copyright (c) [2023] [Sirajus Salekin, Harsh Joshi, & Palvit Garg] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 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. 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. |
keywords |
quantum
computing
debugger
qiskit
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Breakpoint Debugging on a Physical Qunatum Circuit
## Problem Description
In classical computing, debugging with breakpoint means halting the program
execution at any given point and freezing the program state. This allows
programmers to examine the program internals mid-execution (as in, what
variables contain which values, analyze control flow etc.) Unfortunately, in
quantum computing, doing this is not possible. Qubits in a quantum circuit have
probabilistic values (in superposition), and the act of measuring collapses the
qubits to a deterministic state.
Breakpoint debugging is still needed for quantum computing, so our problem boils
down to measuring at the breakpoint and preserving enough information to
“recreate” that state and continue execution from that point.
## Group Members
- Palvit Garg (pgarg5)
- Harshwardhan Joshi (hjoshi2)
- Shawn Salekin (ssaleki)
#### Presentation
[URL](https://docs.google.com/presentation/d/1SCwHKmPCc7U0Hl_CVZLNMto9HAEyD_zuz_fqGwnIzuc/edit?usp=sharing)
## Quickstart
1. Install with pip
```
pip install qiskit_debugger
```
2. Import the following the classes to experiment with the debugger like this:
```
from qiskit_debugger import QuantumDebugCircuit, QCDebugger, run_circuit
```
3. A motivating example of how to use the debugger classes:
```
qc = QuantumDebugCircuit(2)
qc.x(0)
qc.h(range(2))
qc.cx(0, 1)
qc.h(range(2))
qc.bp() # <-- Add a breakpoint here
qc.h(range(2))
qc.x(range(2))
qc.bp() # <-- Add a breakpoint here
qc.cx(1, 0)
qc.h(range(2))
qc.bp()
qc.draw()
# run each breakpoints
qdb = QCDebugger(qc)
qdb.c()
qdb.c()
qdb.c()
qdb.c()
```
Run the circuit as a whole w/o debugger
```
qc.measure_all()
result = run_circuit(qc)
print(result.get_counts())
```
If you want to use hardware you have to initiate the `QCDebugger` like so:
```
from qiskit import IBMQ
# loading IBMQ account
IBMQ.load_account()
provider = IBMQ.get_provider(hub='ibm-q-ncsu', group='nc-state', project='grad-qc-class')
# This is important, fill up the hw_backend variable like this.
hw_backend = provider.get_backend('ibm_oslo')
qdb = QCDebugger(qc, use_hardware=True)
```
## Solution Approaches
Let’s assume we have a circuit with multiple qubits, and it has a breakpoint
brk. The circuit before the breakpoint is called A, and after is called B. The
target is to measure the state of qubits at point brk.
To “recreate”, i.e., synthesize an equivalent circuit right after it is
measured, we thought of two possible methods.
~~1. **Approach 1**:
We make two circuits of varying length: one ends at the breakpoint, and the
other stops at the original end without stopping at the breakpoint. Then we run
both of these circuits.~~
(update 11/05/22): since this is a trivial and inefficient implementation, we
will focus our attention to approach 2.
2. **Approach 2**:
Create a custom gate using the unitary matrix that results from running circuit
part A, save it somewhere. Then create a custom gate using the saved unitary
matrix to circuit part B.This custom gate is equivalent to the circuit part A.
Now run this custom gate and then part B.
## Final Result
We have successfully implemented the first approach which uses a combination of simulation and hardware.
Using unitary matrices from unitary simulator runs and actual output from hardware runs,
we were able to correctly re-create the qubit states pre-measurement, and were able to successfully
resume the circuit after the breakpoint. Our implementation is readily usable as well. Our expectation with limited erorr propagation with this approach is also
verified. This approach can aid the quantum computing programmers in interacting with
and debugging their code in a more effective way, as long as the circuit width isn't too big.
On the other hand, we found that the pure hardware approach is cumbersome and expensive to implement. The key driver behind
this approach is Quantum Phase Estimation, and while there are a number of algorithms uses this sub-routine, in
practice it is a) not very precise, b) hard to implement, and c) limits the number of breakpoints to a handful
due to error propagation.
## Open Problems
- Implement a comprehensive test suite for the debugger implmentation
- Work out a way to extend the QPE and the hardware approach to extend to 2-,3-, and more qubit circuits
## Contributions During the Final Round
- Research and experiments with pure hawrdware approach - Palvit
- Experiments and implementation with simulator approach - Shawn
- Benchmakring, experiments, and final reports - Harsh
## Progress Made (Round 2)
- Synthesized a new circuit based on a unitary matrix and run it on a real
hardware.
- Assessed the importance of phase date in synthesizing a circuit from breakpoint
- Investigated different methods of generating unitary matrices
## Timeline (Detailed & Revised)
- Confirm whether and under what condition we can generate a unitary from a
hardware run (11/12/2022)
- Decide whether to use simulation or hardware based on the outcome of
generating unitary from the hardware runs (11/12/2022)
- Validate whether the phase data obtained from simulation(s) can be used in
synthesizing an equivalent circuit after a breakpoint
- Figure out a method to extract phase data from parallel simulation runs (11/19/2022)
- Implement a qiskit module/extension that would allow qiskit users to add
breakpoint(s) to their circuit.(11/26/2022)
- Add tests and run a number of experiments to validate the correctness of our
implementation.(11/26/2022)
## Project Timeline (Original)
- 11/01/2022: Implement approach 1
- 11/10/2022: Analyze the feasibility of implementing approach 2.
- 11/26/2022: Implement approach 2 (or a better one)
## Future Readings
- https://dl.acm.org/doi/abs/10.1145/3373376.3378488
- https://arxiv.org/pdf/2103.09172.pdf
## References
- https://qiskit.org/documentation/tutorials/circuits_advanced/02_operators_overview.html
- https://qiskit.org/documentation/stubs/qiskit.converters.circuit_to_instruction.html
- https://github.ncsu.edu/fmuelle/qc19/tree/master/hw/hw6/m3/csc591-quantum-debugging
- https://quantumcomputing.stackexchange.com/questions/27064/how-to-get-statevector-of-qubits-after-running-quantum-circuits-on-ibmq-real-har
Raw data
{
"_id": null,
"home_page": "",
"name": "qiskit-debugger",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "Sirajus Salekin <ssalekin14@gmail.com>",
"keywords": "quantum,computing,debugger,qiskit",
"author": "",
"author_email": "Sirajus Salekin <ssalekin14@gmail.com>, Palvit Garg <pgarg5@ncsu.edu>, Harshwardhan Joshi <hjoshi2@ncsu.edu>",
"download_url": "https://files.pythonhosted.org/packages/60/fa/f0a5ddd083a9bbc1f65c3085cc1c444395ab100ced3b90fd83addfefcaf9/qiskit_debugger-0.1.2.tar.gz",
"platform": null,
"description": "# Breakpoint Debugging on a Physical Qunatum Circuit\n\n## Problem Description\nIn classical computing, debugging with breakpoint means halting the program\nexecution at any given point and freezing the program state. This allows\nprogrammers to examine the program internals mid-execution (as in, what\nvariables contain which values, analyze control flow etc.) Unfortunately, in\nquantum computing, doing this is not possible. Qubits in a quantum circuit have\nprobabilistic values (in superposition), and the act of measuring collapses the\nqubits to a deterministic state.\n\nBreakpoint debugging is still needed for quantum computing, so our problem boils\ndown to measuring at the breakpoint and preserving enough information to\n\u201crecreate\u201d that state and continue execution from that point.\n\n## Group Members\n- Palvit Garg (pgarg5)\n- Harshwardhan Joshi (hjoshi2)\n- Shawn Salekin (ssaleki)\n\n#### Presentation\n[URL](https://docs.google.com/presentation/d/1SCwHKmPCc7U0Hl_CVZLNMto9HAEyD_zuz_fqGwnIzuc/edit?usp=sharing)\n\n## Quickstart\n1. Install with pip \n```\npip install qiskit_debugger\n``` \n\n2. Import the following the classes to experiment with the debugger like this:\n```\nfrom qiskit_debugger import QuantumDebugCircuit, QCDebugger, run_circuit\n```\n\n3. A motivating example of how to use the debugger classes:\n\n```\nqc = QuantumDebugCircuit(2)\nqc.x(0)\nqc.h(range(2))\nqc.cx(0, 1)\nqc.h(range(2))\nqc.bp() # <-- Add a breakpoint here\nqc.h(range(2))\nqc.x(range(2))\nqc.bp() # <-- Add a breakpoint here\nqc.cx(1, 0)\nqc.h(range(2))\nqc.bp()\n\nqc.draw()\n\n# run each breakpoints\nqdb = QCDebugger(qc)\nqdb.c()\nqdb.c()\nqdb.c()\nqdb.c()\n```\n\n\nRun the circuit as a whole w/o debugger\n\n```\nqc.measure_all()\nresult = run_circuit(qc)\nprint(result.get_counts())\n```\n\nIf you want to use hardware you have to initiate the `QCDebugger` like so:\n\n```\nfrom qiskit import IBMQ\n\n# loading IBMQ account\nIBMQ.load_account()\nprovider = IBMQ.get_provider(hub='ibm-q-ncsu', group='nc-state', project='grad-qc-class')\n# This is important, fill up the hw_backend variable like this.\nhw_backend = provider.get_backend('ibm_oslo')\n\nqdb = QCDebugger(qc, use_hardware=True)\n```\n\n## Solution Approaches \nLet\u2019s assume we have a circuit with multiple qubits, and it has a breakpoint\nbrk. The circuit before the breakpoint is called A, and after is called B. The\ntarget is to measure the state of qubits at point brk.\n\nTo \u201crecreate\u201d, i.e., synthesize an equivalent circuit right after it is\nmeasured, we thought of two possible methods. \n\n~~1. **Approach 1**:\nWe make two circuits of varying length: one ends at the breakpoint, and the\nother stops at the original end without stopping at the breakpoint. Then we run\nboth of these circuits.~~\n\n(update 11/05/22): since this is a trivial and inefficient implementation, we\nwill focus our attention to approach 2.\n\n2. **Approach 2**:\nCreate a custom gate using the unitary matrix that results from running circuit\npart A, save it somewhere. Then create a custom gate using the saved unitary\nmatrix to circuit part B.This custom gate is equivalent to the circuit part A.\nNow run this custom gate and then part B.\n\n## Final Result\nWe have successfully implemented the first approach which uses a combination of simulation and hardware.\nUsing unitary matrices from unitary simulator runs and actual output from hardware runs,\nwe were able to correctly re-create the qubit states pre-measurement, and were able to successfully\nresume the circuit after the breakpoint. Our implementation is readily usable as well. Our expectation with limited erorr propagation with this approach is also \nverified. This approach can aid the quantum computing programmers in interacting with\nand debugging their code in a more effective way, as long as the circuit width isn't too big.\n\nOn the other hand, we found that the pure hardware approach is cumbersome and expensive to implement. The key driver behind\nthis approach is Quantum Phase Estimation, and while there are a number of algorithms uses this sub-routine, in\npractice it is a) not very precise, b) hard to implement, and c) limits the number of breakpoints to a handful\ndue to error propagation.\n\n\n## Open Problems\n- Implement a comprehensive test suite for the debugger implmentation\n- Work out a way to extend the QPE and the hardware approach to extend to 2-,3-, and more qubit circuits\n\n\n## Contributions During the Final Round\n- Research and experiments with pure hawrdware approach - Palvit\n- Experiments and implementation with simulator approach - Shawn\n- Benchmakring, experiments, and final reports - Harsh\n\n## Progress Made (Round 2)\n- Synthesized a new circuit based on a unitary matrix and run it on a real\n hardware.\n- Assessed the importance of phase date in synthesizing a circuit from breakpoint\n- Investigated different methods of generating unitary matrices\n\n## Timeline (Detailed & Revised) \n- Confirm whether and under what condition we can generate a unitary from a\n hardware run (11/12/2022)\n- Decide whether to use simulation or hardware based on the outcome of\n generating unitary from the hardware runs (11/12/2022)\n- Validate whether the phase data obtained from simulation(s) can be used in\n synthesizing an equivalent circuit after a breakpoint \n- Figure out a method to extract phase data from parallel simulation runs (11/19/2022) \n- Implement a qiskit module/extension that would allow qiskit users to add\n breakpoint(s) to their circuit.(11/26/2022)\n- Add tests and run a number of experiments to validate the correctness of our\n implementation.(11/26/2022)\n\n## Project Timeline (Original)\n- 11/01/2022: Implement approach 1\n- 11/10/2022: Analyze the feasibility of implementing approach 2.\n- 11/26/2022: Implement approach 2 (or a better one)\n\n## Future Readings\n- https://dl.acm.org/doi/abs/10.1145/3373376.3378488\n- https://arxiv.org/pdf/2103.09172.pdf\n\n## References\n- https://qiskit.org/documentation/tutorials/circuits_advanced/02_operators_overview.html\n- https://qiskit.org/documentation/stubs/qiskit.converters.circuit_to_instruction.html\n- https://github.ncsu.edu/fmuelle/qc19/tree/master/hw/hw6/m3/csc591-quantum-debugging\n- https://quantumcomputing.stackexchange.com/questions/27064/how-to-get-statevector-of-qubits-after-running-quantum-circuits-on-ibmq-real-har\n\n",
"bugtrack_url": null,
"license": "MIT License Copyright (c) [2023] [Sirajus Salekin, Harsh Joshi, & Palvit Garg] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 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. 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. ",
"summary": "Quantum Circuit debugger for the Qiskit SDK.",
"version": "0.1.2",
"project_urls": {
"homepage": "https://github.com/salekinsirajus/quantum_circuit_debugger",
"repository": "https://github.com/salekinsirajus/quantum_circuit_debugger"
},
"split_keywords": [
"quantum",
"computing",
"debugger",
"qiskit"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "337443f3d08780c2408669952e459f5143bb71f27d4f63a71ae80c1161b704f4",
"md5": "b9618a5dcfe8458ac086f48a335d1bb0",
"sha256": "a02cea3350d499206f7a4e7cecd30e3f829103fb7cae9543e25f8ea0097a01d2"
},
"downloads": -1,
"filename": "qiskit_debugger-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b9618a5dcfe8458ac086f48a335d1bb0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 7414,
"upload_time": "2023-07-06T03:38:24",
"upload_time_iso_8601": "2023-07-06T03:38:24.231530Z",
"url": "https://files.pythonhosted.org/packages/33/74/43f3d08780c2408669952e459f5143bb71f27d4f63a71ae80c1161b704f4/qiskit_debugger-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "60faf0a5ddd083a9bbc1f65c3085cc1c444395ab100ced3b90fd83addfefcaf9",
"md5": "e7c6f03496960083a88661d3a4d4d788",
"sha256": "821a20ccfaaa27f2aaa5a04d0517bf37740c3339fb8178361bbe76c485b79647"
},
"downloads": -1,
"filename": "qiskit_debugger-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "e7c6f03496960083a88661d3a4d4d788",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 6874,
"upload_time": "2023-07-06T03:38:25",
"upload_time_iso_8601": "2023-07-06T03:38:25.706312Z",
"url": "https://files.pythonhosted.org/packages/60/fa/f0a5ddd083a9bbc1f65c3085cc1c444395ab100ced3b90fd83addfefcaf9/qiskit_debugger-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-06 03:38:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "salekinsirajus",
"github_project": "quantum_circuit_debugger",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "qiskit-debugger"
}