Repository navigation
Added visualization for qubit permutations for routed circuits - #5848
Conversation
95-martin-orion
left a comment
There was a problem hiding this comment.
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.
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.
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.
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)
…ani/Cirq into routing-visualization syncing with upstream master
tanujkhattar
left a comment
There was a problem hiding this comment.
LGTM % minor nits.
We can merge once the merge conflicts and nits are resolved.
| 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.
Don't include an internal class in the global cirq namespace.
There was a problem hiding this comment.
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.
* 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.