Example output of the qasm2image tool on a 1-qubit adderBack in 2018 when I started working in quantum computing and implementing my first quantum circuits, qiskit was still a very (very) new library (somewhere around version 0.4.9, which was only compatible with Python 3.5 and 3.6).
When you start implementing complex quantum circuits, you always get it wrong on the first try, and then need to find where you made a mistake (or where the paper you were implementing was wrong…).
At that time, qiskit library did not have a proper circuit visualisation method. The only way of visualising quantum circuits from qiskit was to call a function included in the library that:
- Translated the quantum circuit to $\LaTeX$ code.
- Called
pdflatexon the generated $\LaTeX$ code. - (optional) Called the
converttool (on Linux ) to convert the generated PDF to another image format (e.g., SVG).
There were several issues with this method:
- A working $\LaTeX$ compiler should be present on the machine
- Some non-standard $\LaTeX$ package should be installed
- The conversion process was long and called external tools
pdflatexwas giving up as soon as the quantum circuit had more than $\approx 30$ gates
The last issue was particularly problematic for me: how can I debug my quantum circuits without having the possibility to view them in a understandable way?
The main goal of the project was to increase the limit on the quantum circuit size indirectly imposed by pdflatex.
During the development process, generating nice looking quantum circuit visualisations became a secondary goal: why looking at something ugly if it can be nice without too much efforts?
The project was a success: the main goal was achieved by generating images in SVG format, that could then be exported to PNG, PS and PDF thanks to the cairo library or left in a SVG format. The inclusion into qiskit has been discussed with some of qiskit maintainer but:
- The visualisation part of
qiskitwas on the verge of being reworked from scratch to address the exact same issues I tried to fix. qasm2imagewas developed as a “satelite” tool and was not really thought to be included in a larger code base.- The output of the
qasm2imagetool was, in my opinion, not good-looking enough to be included as-is.
A few months later, qiskit launched its new quantum circuit visualisation implementation, which is exceptional when compared to mine.