-
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
Added visualization for qubit permutations for routed circuits #5848
Added visualization for qubit permutations for routed circuits #5848
Conversation
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.
Seems reasonable to me overall. This is a slight departure from the usual "print the circuit to see its diagram" flow, but I think it's a good choice so we don't pollute the circuit with these no-op gates.
q1, q2 = op.qubits | ||
qdict[q1], qdict[q2] = qdict[q2], qdict[q1] | ||
ret_circuit.append(m) | ||
ret_circuit.append( |
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 injects qubit positions after every moment. Is this intended, or should positions only be injected after swaps which affect them?
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.
I think originally the plan was to inject qubit position info after every swap, not every moment. but now I am wondering which is more readable. Any thoughts on this? I'll soon push a commit with the former.
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.
My preference would be only after swaps, just to keep minimize bloat. There's an argument to be made that every moment ensures there's always a nearby reference for which qubit is which, but that feels less pressing to me (and likely a non-issue for even moderately complex circuits)
cirq-core/cirq/transformers/routing/visualize_routed_circuit_test.py
Outdated
Show resolved
Hide resolved
…ani/Cirq into routing-visualization syncing with upstream master
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.
LGTM % minor nits.
We can merge once the merge conflicts and nits are resolved.
@@ -494,6 +494,7 @@ def all_subclasses(cls): | |||
cirq.Pauli, | |||
# Private gates. | |||
cirq.transformers.analytical_decompositions.two_qubit_to_fsim._BGate, | |||
cirq.transformers.routing.visualize_routed_circuit._SwapPrintGate, |
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.
Don't include an internal class in the global cirq namespace.
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 seems like it has to be included under skip_classes
in this file or else I get the error
AssertionError: <class 'cirq.transformers.routing.visualize_routed_circuit._SwapPrintGate'> has no json file, please add a json file or add to the list of classes to be skipped if there is a reason this gate should not round trip to a gate via creating an operation.
cirq-core/cirq/transformers/routing/visualize_routed_circuit.py
Outdated
Show resolved
Hide resolved
* added circuit visualization code * made print gate private and added more tests * removed unused import and added gate to private list * addressed comments * added safeguard for wrong use of RoutingSwapTag * addressed nits * added return type for * added _SwapPrintGate again to and fixed type issue
…umlib#5848) * added circuit visualization code * made print gate private and added more tests * removed unused import and added gate to private list * addressed comments * added safeguard for wrong use of RoutingSwapTag * addressed nits * added return type for * added _SwapPrintGate again to and fixed type issue
…umlib#5848) * added circuit visualization code * made print gate private and added more tests * removed unused import and added gate to private list * addressed comments * added safeguard for wrong use of RoutingSwapTag * addressed nits * added return type for * added _SwapPrintGate again to and fixed type issue
Adds a function that visualizes the mapping of qubits after each moment in a routed circuit.