Skip to content

Add a diff tool for comparing multiple Cirq.Circuits in Jupyter Notebooks #4510

Open
@freyam

Description

@freyam

Is your feature request related to a use case or problem? Please describe.

Tanuj has an amazing idea to visualize the differences between circuits.

Logger Design

  • register_initial and register_final methods will be used to maintain the state of the circuits and compute the difference between initial and final circuits.
  • The difference between initial and final circuits will be stored for each call. Also, common stats like circuit depth, number of one / two qubit gates, circuit duration etc. will be computed and stored for each time step.
  • Finally, a plot method will bring up an interactive widget to plot the state of the initial and final circuits highlighting the difference for each time step of the optimization.

logger

Source: RFC: Circuit Transformers API #Logger Design

We could adopt this same technique to also implement a new module that shows the difference between N given circuits (N >= 2) in a clean SVG format or a GIF transition. We could adopt to use 3rd party open-source tools for this or a simple SVG diff-tool also might suffice.

Describe the solution you'd like

Task 0

Task 1

  • Create a diff tool that takes 2 cirq.Circuits as input and prints the differences between them in a nice way (will share demos soon.)

Task 2

  • Upgrade the tool made in Task 1 that takes N cirq.Circuits as input and prints the differences in a neat tabular form or a slider form.

Task 3

  • Convert the tool into an IPython widget which can be directly installed in Jupyter Notebooks.

Completing all the 3 tasks would be really helpful to all the users as it would allow an easy way to work around optimizers (and transformers) that modify the circuits. Now, users would be able to track the optimization (or transformation).

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

P2 - we should do it in the next couple of quarters

cc @tanujkhattar

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions