The Quantum Software and Algorithms Research Lab at UBC introduces CircInspect, the first visual tool for debugging quantum programs in PennyLane.
CircInspect offers adaptive visualization of quantum circuits, enabling you to explore your quantum programs at varying levels of abstraction. You can zoom into subroutines, trace program outputs, and set breakpoints to isolate the source of a bug.
CircInspect has two different modes: Debugger Mode and Real-Time Development Mode. With integrated debugger support, Debugger Mode allows for monitoring of structural and behavioural changes at breakpoints. Real-Time Development mode updates the circuit dynamically as you type, providing immediate feedback and deeper insight into how code translates into quantum circuits.
We are researching how quantum developers debug their programs and CircInspect is a part of that effort. If you’re building algorithms with PennyLane, please give it a try and send us your feedback.
In Debugger Mode, you can isolate and examine individual quantum circuit components while monitoring changes in program structure and output at breakpoints. To set a breakpoint, select “Debugger Mode” from the dropdown menu in the top left, and click on the line number. You can then click “Start Debugger” and use the buttons to step through your code.
You can selectively observe inputs to subroutines and main circuit output by using the tree structure of function calls under the circuit visualization. Click on the function name, shown by the red box, to create a pop up with additional information.
Use the dropdown menu at any time to switch to “Real-Time Development” mode. CircInspect will dynamically update the quantum circuit visualization as the code is modified.
CircInspect is freely available online. The instructions below are for local installation.
CircInspect is developed with React for the front-end, while the back-end is powered by Python and Flask. Some UI elements and code editor setup were inspired by the blog "How to Build a Code Editor with React that Compiles and Executes in 40+ Languages", written by Manu Arora. MongoDB is used to track how users interact with the application, specifically to monitor which features they use and how often they engage with different parts of CircInspect.
To install the backend server, go into CircInspect/server
directory and run
pip install -r requirements.txt
The following will be installed:
numpy==1.26.2
pennylane==0.37.0
flask==3.0.0
google-api-python-client==2.132.0
google-auth-oauthlib==1.2.0
pymongo==4.7.2
dill==0.3.8
matplotlib==3.8.2
To install the frontend server, install Node.js, go into CircInspect/client
directory and run
npm i
To install the database, follow the instructions in the MongoDB website.
To run the development servers:
- If MongoDB is not running, run below command on your terminal to start MongoDB:
sudo systemctl start mongod
- To check that MongoDB is running, run
sudo systemctl status mongod
- Open three terminal windows
- On the first one, go into
CircInspect/client
directory and run
npm start
- On the second one, go into
CircInspect
directory (project root) and run
flask --app server.app run --debug
- On the third one, go into
CircInspect
directory (project root) and run
flask --app execserver.app run --debug --port=5001
To enable authentication, change the noAuth
flag in client/src/App.js to false
and change the NOAUTH
flag on server/app.py to False
.
Follow the instructions in tests/README.md to run automated tests. Follow the instructions in performance_tests/README.md to run performance tests that characterize the runtime of CircInspect.
CircInsepct is available open source under the Apache 2.0 License. Contributions are welcome. Please follow the instructions in the following link to contribute: How to contribute?
The primary developers of CircInspect are Mushahid Khan (@mushahidkhan835) and Cihan Bosnali (@CihanBosnali).
The authors acknowledge funding from the NSERC CREATE in Quantum Computing Program (grant number 543245), NSERC Alliance Quantum, UBC 4YF, and UBC WLIURA programs. Thanks to Prashant Nair, QSAR Lab members, and the PennyLane team at Xanadu for testing and providing feedback on CircInspect.
If you use CircInspect as part of your workflow, we would appreciate if you cite it using the BibTeX below.
@INPROCEEDINGS{10821435,
author={Khan, Mushahid and Nair, Prashant J. and Di Matteo, Olivia},
booktitle={2024 IEEE International Conference on Quantum Computing and Engineering (QCE)},
title={CircInspect: Integrating Visual Circuit Analysis, Abstraction, and Real-Time Development in Quantum Debugging},
year={2024},
volume={01},
number={},
pages={1000-1006},
doi={10.1109/QCE60285.2024.00119}}