quantumlib / Cirq

A Python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
Apache License 2.0
4.29k stars 1.02k forks source link

Add integration with QPIC for drawing circuit diagrams #5895

Open tanujkhattar opened 2 years ago

tanujkhattar commented 2 years ago

Is your feature request related to a use case or problem? Please describe. As the size of the circuits we build with Cirq increases, the ASCII style circuit diagrams do not scale very well. We also need a way to draw diagrams for publications in latex and it would be nice if Cirq users have a way to convert their cirq circuits into nice latex diagrams.

Describe the solution you'd like QPIC is a flexible and powerful framework for drawing quantum circuit diagrams. See https://github.com/qpic/qpic for more details.

What is the urgency from your perspective for this issue? Is it blocking important work?

P1 - I need this no later than the next release (end of quarter)

Dripto commented 2 years ago

Other options could be quantikz (https://arxiv.org/abs/1809.03842) or qcircuit, unsure if those tools have different licenses that are more amenable

tanujkhattar commented 2 years ago

A good thing about QPIC is that it reads circuits written in an intermediate representation and then generates the corresponding latex code automatically. IIUC, other packages like quantikz / qcircuit provide packages that can be included in a latex document but there would be a non-trivial conversion from a cirq circuit object to the corresponding latex code using commands from these packages. With QPIC, we just need to worry about representing the same circuit in a much more easily human readable IR, that can potentially be tweaked by users manually as well, before passing it over to QPIC to generate the actual diagrams.

For example, we already have an integration to qcircuit, but this integration depends on first generating a cirq-style text diagram and then converting the text diagram to latex using qcircuit. See https://github.com/quantumlib/Cirq/blob/ff81f807bd00b8d0654466b0fdcb3224a687f877/cirq-core/cirq/contrib/qcircuit/qcircuit_diagram.py#L66

tanujkhattar commented 2 years ago

From cirq sync: