Skip to content
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

Closed

Conversation

augustehirth
Copy link
Collaborator

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.

@augustehirth augustehirth requested review from a team, vtomole and cduck as code owners October 3, 2022 06:11
@CirqBot CirqBot added the size: M 50< lines changed <250 label Oct 3, 2022
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@augustehirth
Copy link
Collaborator Author

@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.

Copy link
Collaborator

@tanujkhattar tanujkhattar left a 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",
Copy link
Collaborator

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:

  1. cirq.expand_composite / cirq.optimize_for_target_gateset
  2. cirq.RouteCQC
  3. cirq.optimize_for_target_gateset (again).

Copy link
Collaborator Author

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?

Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: M 50< lines changed <250 Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants