Project Description
The project aims to improve the quantum circuit visualization capabilities of QuTiP-QIP by introducing a new framework for circuit rendering that doesnβt rely on external dependencies. Presently, circuit visualization relies on LaTeX and ImageMagick, which can be problematic for users. This solution plans to create two rendering modules: one utilizing matplotlib for visually appealing and precise quantum circuit diagrams, and another ASCII text-based rendering. The matplotlib renderer will also support generating circuit visualizations within IPython environments like Jupyter Notebook, while the text-based renderer will cater to command-line interactions. Apart from the rendering modules a Circuit Renderer Selector will also be included in the project deliverables, enabling users to easily choose their preferred rendering method among LaTeX, Matplotlib, or Text-Based options. These tools will enable users to visualize quantum circuits more efficiently and effectively, making it easier to work with QuTiP.
Mentors: Boxi Li, Alex Pitchford, Neill Lambert
Deliverables
Contributions
Weekly Progress Documented Here: Weekly Blogs π
The following sections review all the contributions made to the project during the GSoC β24 coding period.
BaseRenderer
The BaseRenderer was designed as a parent class to improve the maintainability of newly added renderers and to establish a robust framework for incorporating future renderers. By employing a layered approach, it optimizes the compactness of quantum circuits, dynamically adjusting the layout as each gate is added. This method ensures efficient space management and enhances the clarity of complex quantum operations.
Furthermore, the BaseRenderer acts as a central hub for styling configurations through the StyleConfig
class. This dataclass consolidates all customization settings, enabling consistent and streamlined styling across different renderers.
Next, we will delve into the details of the two newly added renderers.
MatRenderer
A Matplotlib-based renderer was developed to plot complex quantum circuits, providing numerous customization options so users can adjust their circuits to meet specific needs. The features of the renderer were designed to ensure precise information delivery while maintaining visually appealing diagrams. We also prioritized compactness, arranging the circuit layout to be as optimal while maintaing the information delivery.
Example of Results
Further Details about MatRenderer
The MatRenderer offers four distinct color themes: qutip
, dark
, light
, and modern
. Users can personalize these themes further through styling configurations. They can also choose between the modern bulge
style and the classic box
style for gate appearances. The renderer enhances clarity with connectors for MultiQubit Gates and an option to display arguments.
MatRenderer also provides extensive customization options. Users can adjust wire labeling, background color, font family, font size, and more, creating a highly personalized and visually appealing representation of quantum circuits.
TextRenderer
Nowadays, most users rely on Matplotlib. However, users who interact with libraries through the terminal require a different type of renderer. TextRender is ideal for those using the terminal or for quick circuit checks to ensure the library correctly interprets their intentions. The TextRenderer has fewer customization options compared to the MatRenderers, but it still provides some level of customization.
Example of Results
ββββββββ ββββββββ βββββββββ βββββ :ββββ€ CNOT ββββ€ SNOT ββββ€ ββββ€ M ββββ
q1
βββββ¬βββ ββββββββ β β βββ₯ββ
β β β β :ββββββββββββββββββββββββ€ ISWAP βββββββββββ
q0
βββββββββ β
β :βββββββββββββββββββββββββββββββββββββ©βββββ
c0
Layer Alignment Customization
ββββββ ββββββ ββββββ :ββββ€ RZ ββββ€ RZ ββββ€ RX βββββββββββββββββ³ββββ
q2
ββββββ ββββββ ββββββ β
βββββ ββββββ ββββββββ ββββββββ β :ββββ€ H βββββ€ RX ββββ€ CNOT ββββ€ CNOT βββββββββ
q1
βββββ ββββββ βββββ¬βββ βββββ¬βββ β
ββββββ β β β :ββββ€ RX βββββββββββββββββββββββββββββββββ³ββββ
q0 ββββββ
Skips drawing a connection line for wires that are not directly involved in a MultiQubit Gate.
ββββββββββββ :ββββββββββββββββββββββββββββββββ³ββββ€ βββββββββββββββββββββββββββββββββββ³βββββ³ββββββββββββββββββ
q3
β β β β β β
βββββ β β β ββββββ΄βββββ β β :ββββ€ X βββββββββββββββββββββββββββ β β ββ€ βββββββββββββββββββββββββββββββββββββββββββββ
q2
βββββ β β β β β β β
βββββ ββββββββ β β β β β ββββββ βββββββ β β βββββ :ββββ€ H ββββββββββββββ€ CNOT βββββββ β β ββ€ FREDKIN ββββ€ CX ββββ€ CRX βββββββββββββββββββββ€ M ββββ
q1
βββββ β βββββ¬βββ β β β βββββββββββ ββββ¬ββ ββββ¬βββ β β βββ₯ββ
βββββ βββββ΄βββ β β β β β β β β βββββ β :ββββ€ H ββββ€ CNOT βββββββββββββββ³ββββ€ BERKELEY βββββββββββββββββββββββββββββββββββ³βββββ³ββββ€ M βββββββββββ
q0
βββββ ββββββββ ββββββββββββ βββ₯ββ β
β β :βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©βββββ
c1
β
β :ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ©ββββββββββββ c0
Complex Circuit
ββββββββ ββββββββ ββββββ ββββββββ ββββββββ ββββββ :ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ CNOT ββββββββββββ€ CNOT ββββ€ RZ ββββ€ CNOT ββββββββββββ€ CNOT ββββ€ RZ ββββ
q3
βββββ¬βββ βββββ¬βββ ββββββ βββββ¬βββ βββββ¬βββ ββββββ
ββββββββ ββββββββ ββββββ ββββββββ ββββββββ ββββββ β β β β :ββββββββββββββββββββββββββββββββββββββββ€ CNOT ββββββββββββ€ CNOT ββββ€ RZ ββββ€ CNOT ββββββββββββ€ CNOT ββββ€ RZ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
q2
βββββ¬βββ βββββ¬βββ ββββββ βββββ¬βββ βββββ¬βββ ββββββ β β β β
ββββββ ββββββββ ββββββββ β β β β β ββββββ β β ββββββ β :ββββ€ RZ ββββ€ CNOT ββββββββββββ€ CNOT ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ RX ββββββββββββββββββββββββββββββββ€ RY ββββββββββββββββββββββ
q1
ββββββ βββββ¬βββ βββββ¬βββ β β β β ββββββ ββββββ
ββββββ β ββββββ β β ββββββ β β ββββββ β :ββββ€ RZ ββββββββββββββ€ RX ββββββββββββββββββββββββ€ RX ββββββββββββββββββββββββββββββββ€ RY ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
q0 ββββββ ββββββ ββββββ ββββββ
Code
Pull Requests | Link | Status |
---|---|---|
MatRenderer | π | Merged |
Shifting LaTeX Code and Fixing Draw API | π | Merged |
TextRenderer + BaseRenderer + Tests + Documentation | π | Merged |
Tutorial Notebooks | π | Final Changes Ongoing |
Future Work
- Update LaTeX Renderer to adopt the BaseRenderer layer system, simplifying maintenance.
- Imporving test cases to thoroughly evaluate and verify MatRenderer outputs.
- Development of no-code GUI for quantum circuits to make the library more accessible to a wider audience.
Final Thoughts
This summer has been an incredible experience, as it marked my first time contributing to open source. I was thrilled to be selected for a project that aligned perfectly with my passion for both development and design. My previous experience with Quantum Circuits turned out to be a valuable asset and the project has sparked a strong interest in Quantum Computing.
Being part of this project has been a rewarding experience, allowing me to contribute to something meaningful. I loved being a part of the QuTiP community and am committed to continuing my contributions to the QIP package after GSOC. I am grateful to have had such amazing mentors who guided me throughout the process. I feel fortunate to have worked on a project that ignited my interests and provided opportunities for both personal and professional growth, challenging me to become a better developer.