-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Change qubit str representation #5343
Conversation
- Changes grid qubit string representation from (x, y) to q(x, y) and line qubit from 1 to q1. - This will make the string representation more distinctive. - Added _circuit_diagram_info_ for Qid objects to make circuit diagrams customizable for qubits. This allows us to keep circuit diagrams largely unchanged. - Other components such as pauli strings, that rely on qubit str representation for formatting are changed. This is a BREAKING CHANGE for anyone relying on string representation of qubits. Fixes: quantumlib#2405
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the q
function, line qubits would look like q(0), q(1)
instead of q0, q1
. Do we want to use the parenthesized form instead?
One place we should think carefully about is that qubit string representations get included in measurement keys by default if no key is specified. I think this should be ok, but there may be some places where we assume the form of these measurement keys.
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Ok, I have cleared out all the test failures, and this is now ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, just a few minor comments and one question about whether we want to revert to the (x, y)
form for grid device diagrams (as we use in circuit diagrams). Also, I think it'd be good to have some other folks look at this before we do it, since the measurement key changes in particular may pose compatibility concerns for results that were saved with the old format. @zchen088, would this be an issue for datasets we've saved internally?
│ | ||
2: ───H(2)─── | ||
2: ───H(q(2))─── |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a bit odd to me that controlled operation shows the applied qubits like this, since that should be clear from the qubit lines. Would be nice to change this to just show the gate diagram info if possible. But that could be a future PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a custom gate in the test code and is not used outside the test, so I am not too worried about it. Normal controlled operations are unaffected.
q(3, 0)───q(3, 1) | ||
│ │ | ||
│ │ | ||
q(4, 0)───q(4, 1)""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use the circuit diagram info representation in grid device, as we do when labeling qubit lines in circuits?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@maffoo This change was announced at cirq-cync, but I am open to other modes of communication, especially internally. |
Co-authored-by: Matthew Neeley <mneeley@gmail.com>
Co-authored-by: Matthew Neeley <mneeley@gmail.com>
I will be submitting this change soon, so chime in if you have any requested changes. |
* Change qubit str representation - Changes grid qubit string representation from (x, y) to q(x, y) and line qubit from 1 to q1. - This will make the string representation more distinctive. - Added _circuit_diagram_info_ for Qid objects to make circuit diagrams customizable for qubits. This allows us to keep circuit diagrams largely unchanged. - Other components such as pauli strings, that rely on qubit str representation for formatting are changed. This is a BREAKING CHANGE for anyone relying on string representation of qubits. Fixes: quantumlib#2405 * Fix a bunch of tests. * A few more errors. * Switch to q(0) and fix a bunch of tests. * Formatting and more tests fixed. * Fix more tests. * Fix two last tests. * Fix bb84 example. * Fix contrib and notebook tests. * Update cirq-core/cirq/sim/simulator_test.py Co-authored-by: Matthew Neeley <mneeley@gmail.com> * Update cirq-core/cirq/circuits/circuit.py Co-authored-by: Matthew Neeley <mneeley@gmail.com> * Revert Grid Device to use circuit diagram names instead. Co-authored-by: Matthew Neeley <mneeley@gmail.com>
* Change qubit str representation - Changes grid qubit string representation from (x, y) to q(x, y) and line qubit from 1 to q1. - This will make the string representation more distinctive. - Added _circuit_diagram_info_ for Qid objects to make circuit diagrams customizable for qubits. This allows us to keep circuit diagrams largely unchanged. - Other components such as pauli strings, that rely on qubit str representation for formatting are changed. This is a BREAKING CHANGE for anyone relying on string representation of qubits. Fixes: quantumlib#2405 * Fix a bunch of tests. * A few more errors. * Switch to q(0) and fix a bunch of tests. * Formatting and more tests fixed. * Fix more tests. * Fix two last tests. * Fix bb84 example. * Fix contrib and notebook tests. * Update cirq-core/cirq/sim/simulator_test.py Co-authored-by: Matthew Neeley <mneeley@gmail.com> * Update cirq-core/cirq/circuits/circuit.py Co-authored-by: Matthew Neeley <mneeley@gmail.com> * Revert Grid Device to use circuit diagram names instead. Co-authored-by: Matthew Neeley <mneeley@gmail.com>
and line qubit from 1 to q1.
customizable for qubits. This allows us to keep circuit diagrams
largely unchanged.
representation for formatting are changed.
This is a BREAKING CHANGE for anyone relying on string representation
of qubits. This also changes default measurement keys and the '.measurements()'
functionality of results, since these use the string representation of qubits.
Fixes: #2405