imaimaimai.net

Home / Posts / Publications

Graphical Representation for Quantum Circuits in ASCII

Writing quantum circuits graphically is excellent way to show the operations performed on qubits, often clearer than a series of symbolic gate operations, such as those used in OpenQASM. However, in text-based communication, generating and attaching this kind of image is often impractical. It can be cumbersome to attach large circuit images to an email or to post them in Slack.

I was very impressed by a slightly older post proposing a way to render quantum circuits using ASCII art, and I would like to introduce my expanded version of this system here.

  • | … qubit wire
  • - … connector between qubits
  • + … cross of wire and connector
  • X, Z, H … 1-qubit gate
  • @ … control (when it is 1)
  • 0 … control (when it is 0)
  • MZ … X measurement
  • MX … Z measurement
  • || (=) … classical communication (wire)
  • |0>, |1>, |+>, |->, |psi> … quantum state

For example, a circuit for the quantum transportation can be rendered as:

|psi>   |0>     |0>
|       |       |
|       H       |
|       @-------X
|       |       |
@-------X       |
|       |       |
H       MZ======X
MZ==============Z
                |

As you see, a key difference from the standard graphical representation is the time direction: it flows from top to bottom.