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
Add routing to QVM page, Fix inconsistent title #5904
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
@ammareltigani @tanujkhattar Please do a quick once-over of this for technical correctness. If you have other feedback as well I'd love to hear it. |
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 % one technical detail regarding recommending users the sequence of transformers to run on their circuits.
"1. Transform your circuit to use the correct gate set with `cirq.optimize_for_target_gateset`. Read [Transformers](/cirq/transform/transformers) for more on how to modify circuits. \n", | ||
"2. Choose qubits on the virtual device for your circuit to run on. The connectivity required by your circuit must be supported by the connectivity present in your chosen qubit set. See [Qubit Picking](/cirq/hardware/qubit_picking) for more advice.\n", | ||
"3. Map your transformed circuit to those qubits with `cirq.Circuit`'s `transform_qubits` function. This may require some careful planning depending on your particular circuit. \n", | ||
"1. Map and route your circuit onto the device with `cirq.RouteCQC`. Read [Routing Transformer](/cirq/transform/routing_transformer) to learn how to fit a circuit onto a device. \n", |
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.
One important note here is that cirq.RouteCQC
expects your circuit to only contain 1 and 2 qubit gates. If the circuit contains multi-qubit gates; then those multi qubit gates must be "expanded" / "decomposed" in terms of 1/2q gates before calling the cirq.RouteCQC
method.
An example would be to add a QuantumFourierTransformGate
on > 2 qubits.
One easy way to do this is to run the expand_composite
transformer before calling cirq.RouteCQC
>>> cirq.expand_composite(circuit, no_decomp=lambda op: cirq.num_qubits(op) <= 2)
Expand composite is also run as part of optimize_for_target_gateset
; so users can do:
cirq.expand_composite
/cirq.optimize_for_target_gateset
cirq.RouteCQC
cirq.optimize_for_target_gateset
(again).
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.
What parts of optimize_for_target_gateset
does RouteCQC
not respect that force us to run it a second time? Would it be OK to switch the pipeline to just optimize then route?
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.
No, because RouteCQC
will insert swap
gates, which might not be a native operation on all devices and therefore we'd need to decompose the newly inserted swaps into the target gateset that the device supports.
A couple places called QVM Basic Example instead QVM Circuit Preparation. Fixed.
Changed QVM Basic Example to incorporate new routing functionality as the default, instead of having users pick qubits and route their circuits manually.