Skip to content

Print subcircuits out-of-line #3605

Open
@95-martin-orion

Description

@95-martin-orion

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

In #3580, a circuit containing CircuitOperations will print those operations inline. This can make the diagram much larger in the best case, and impossible to read in more complex situations.

Describe the solution you'd like

CircuitOperations should be printed outside the circuit, with an identifier replacing them inline. Example:

a, b, c = cirq.LineQubit.range(2)
op = cirq.CircuitOperation(cirq.FrozenCircuit(
  cirq.H(a), cirq.CZ(a, b), cirq.H(a)
))
circuit = cirq.Circuit(
  cirq.X(a), cirq.H(b), cirq.X(c),
  op.with_qubits(c, a),
)
print(circuit)

# output
circuit body:
0 --X--[ (1) subcircuit ]--
       |
1 --H--+-------------------
       |
2 --X--[ (0) subcircuit ]--

subcircuit:
0 --H--@--H--
       |
1 -----@-----

Some way to explicitly name FrozenCircuits would be useful for this.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/formattingcomplexity/mediumintroduces/modifies 3-5 concepts, takes max up to a month for an advanced contributorgood for learningFor beginners in QC, this will help picking up some knowledge. Bit harder than "good first issues"kind/feature-requestDescribes new functionalitystatus/needs-agreed-designWe want to do this, but it needs an agreed upon design before implementationtriage/acceptedA consensus emerged that this bug report, feature request, or other action should be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions