Skip to content

cirq.plot_decompose(op_tree) to plot the decompose relationships b/w operations #4857

@tanujkhattar

Description

@tanujkhattar

As part of https://tinyurl.com/cirq-organize-decompose-rfc, we want to have a cirq.plot_decompose(op_tree) method which can take in an op-tree and plot the decomposition graph built by recursively calling cirq.deocmpose_once() to each operation till they cannot decompose anymore.

Some things to consider:

  • Control by a flag whether the decomposition graph should contain individual operations as nodes (eg: cirq.X vs cirq.X ** 0.5) or whether it should contain the operation class as nodes (so both cirq.X and cirq.X ** 0.5 will be represented by XPowGate).
  • We can also consider returning the constructed nx.Graph from the method so the user has the opportunity to play around with it if they wish to.

For a reference of the resulting plots, see Visualizing Gate Relationships colab

Part of #3242

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/decomposearea/visualizationkind/feature-requestDescribes new functionalitypriority/p2Next release should contain itpriority/reviewReassess the priority of this item at the next opportunity.triage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked on

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions