qasm2image

Example output of the qasm2image tool on a 1-qubit adder

Initiation of the project

This project started before the qiskit library developers implemented a proper circuit visualisation method. When the development of qasm2image started, the only way of visualising quantum circuits from qiskit was to call a function included in the library that:

  1. Translates the quantum circuit to $\LaTeX$ code.
  2. Calls pdflatex on the generated $\LaTeX$ code.
  3. (optional) Calls the convert tool (on Linux ) to convert the generated PDF to another image format.

There were several issues with this method:

  1. A working $\LaTeX$ compiler should be present on the machine
  2. Some non-standard $\LaTeX$ package should be installed
  3. The conversion process is long and calls external tools
  4. pdflatex was 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 try to debug my quantum program without having the possibility to view it in a understandable way?

Goal of the project

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?

Conclusion of the project

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:

  1. The visualisation part of qiskit was on the verge of being reworked from scratch to address the exact same issues I tried to fix.
  2. qasm2image was developed as a “satelite” tool and was not really thought to be included in a larger code base.
  3. The output of the qasm2image tool 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.

Adrien Suau
Adrien Suau
Entrepreneur in Quantum Computing

I am an entrepreneur in quantum computing. I also do business consulting, so feel free to reach out!