qprof

Matrix exponential of “-i H t”

The qprof idea came just after the implementation of the quantum wave equation solver using QatHS, when I reached the optimisation step. Once again the issue was the lack of proper tooling around quantum computing frameworks: I wanted to optimise my implementation, but no tool I was aware of was capable of analysing the quantum circuits I generated and to give me the numbers I want.

The target of this project was to produce a gprof-compatible tool: a program that would analyse quantum circuits and output a summary in the exact same format as gprof.

The constraint on the output format (that should be exactly the same as gprof) was motivated by several points:

  1. gprof is nearly 40 years old and is still recognised as one of the standard tools to profile code nowadays. As such, I came to the conclusion that its output format should be the result of many years of polishing and is probably a good starting point.
  2. There exist a plethora of tools that plug themselves to gprof post-processing its output. I was mostly looking at the excellent gprof2dot tool that generates a dot file from gprof output. Having an output format compatible with gprof made the usage of all these tools possible and easy.

This project has already been tested on a big implementation involving a lot of nested calls: QatHS. The results are already quite nice as you can see on the following call graphs, generated with qprof, gprof2dot and Graphviz' dot tool using quantum circuits from QatHS.

Call graph with the QFT-based adder.
Call graph with the QFT-based adder.
Call graph with the arithmetic-based adder.
Call graph with the arithmetic-based adder.

I ended up reworking a little bit the implementation, taking out of qprof the circuit-wrapper code that was abstracting away the framework the circuit was written in to let qprof ingest a large variety of circuits. The new library doing that is called qcw (which stands for Quantum Circuit Wrapper) and is open-source and available on PyPI with plugins for qiskit, openqasm2 and myqlm.

Adrien Suau
Adrien Suau
Senior Open-Source Software Engineer

Open-source advocate working on the quantum error-correction software stack.