Skip to content

In text diagrams, writing a classical bit is shown as a control while using it as a control is not shown as a control #5688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Strilanc opened this issue Jul 8, 2022 · 5 comments · May be fixed by #7233
Labels
area/circuits area/visualization kind/bug-report Something doesn't seem to work. triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on

Comments

@Strilanc
Copy link
Contributor

Strilanc commented Jul 8, 2022

import cirq

print(cirq.Circuit(
    cirq.measure(cirq.LineQubit(0), key="abc"),
    cirq.X(cirq.LineQubit(0)).with_classical_controls("abc"),
))
0: ─────M───X───
        ║   ║
abc: ═══@═══^═══

The @ means control elsewhere in diagrams. The character below the M isn't a control it's an output; it should probably be an X. And the ^ for the control on the NOT gate should be an @ since that means control.

@Strilanc Strilanc added the kind/bug-report Something doesn't seem to work. label Jul 8, 2022
@Strilanc Strilanc changed the title In text diagrams, writing a classical bit is shown as a control and using it is not shown as a control In text diagrams, writing a classical bit is shown as a control while using it as a control is not shown as a control Jul 8, 2022
@dabacon
Copy link
Collaborator

dabacon commented Jul 12, 2022

Would making the second one an "@" would be confusing, since it might make someone think it actually is a CNOT? Similarly for the first making it an "X" would also be slightly misleading in that people could think this means a measurement is a someone an "X" gate.

@Strilanc
Copy link
Contributor Author

Strilanc commented Jul 16, 2022

Would making the second one an "@" would be confusing, since it might make someone think it actually is a CNOT?

But it is a controlled not. It's a classically controlled not. They wouldn't be confused about that, they would be right. In any case, the double lines on the vertical bar is a dead giveaway that it's classically controlled.

people could think this means a measurement is a someone an "X" gate.

A measurement kinda is a NOT gate on a classical bit, controlled by a quantum bit. I don't think there's any physical experiment you can do that distinguishes "measurement" from "CNOT from qubit to bit where bit is promised to be initially OFF".

@daxfohl
Copy link
Collaborator

daxfohl commented Jul 16, 2022

I agree with changing the control to @. For changing the target to X, my main concern is that now that we allow multiple writes to the same measurement key, X looks like an XOR, when it's actually just a write. Otherwise I agree here as well.

(I had also been thinking that we might want to add an "op" param to measure, allowing things like cirq.measure(q, key=m, op=XOR), which would XOR the current measurement with the previous one, and I kind of wanted to reserve X for that.)

@viathor viathor added triage/discuss Needs decision / discussion, bring these up during Cirq Cynque area/circuits area/visualization labels Jul 26, 2022
@verult
Copy link
Collaborator

verult commented Aug 10, 2022

From Cirq sync - biggest question is whether changing text diagram output would be considered a breaking change.

@dstrain115 dstrain115 added triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on and removed triage/discuss Needs decision / discussion, bring these up during Cirq Cynque labels Aug 17, 2022
@seunomonije
Copy link
Contributor

From Cirq sync:

  • Maybe the choice that we made to display classical control is not the best design choice, may not really be a bug
  • More of a behavior change to something that is obscure. Current behavior is awkward and questionable whether or not it’s intended.
  • Maybe we should introduce a new tag for issues like this

Consensus: We should accept this as a bug and get fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/circuits area/visualization kind/bug-report Something doesn't seem to work. triage/accepted A consensus emerged that this bug report, feature request, or other action should be worked on
Projects
Status: No status
Development

Successfully merging a pull request may close this issue.

8 participants