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

switch order of route and decompose #145

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

manzanillo
Copy link
Member

Currently, the example proposes to first run decompose_circuit followed by a route_circuit.
However, if the routing needs to introduce swap gates, these will stay in the circuit until execution where they lead to an error:

OperationNotSupportedError: <class 'cirq.ops.swap_gates.SwapPowGate'> not natively supported.

Therefore, the order of these two operations needs to be reversed.

@manzanillo manzanillo requested a review from smite February 10, 2025 15:03
@smite
Copy link
Member

smite commented Feb 11, 2025

Currently, the example proposes to first run decompose_circuit followed by a route_circuit. However, if the routing needs to introduce swap gates, these will stay in the circuit until execution where they lead to an error:

Therefore, the order of these two operations needs to be reversed.

Yeah, correct. But if the initial circuit has n-qubit gates in it, with n>2, it needs to be decomposed also before routing. So in general the order is decompose-route-decompose.

Comment on lines +53 to +55
circuit_routed, _, _ = sampler.device.route_circuit(circuit)
circuit_decomposed = sampler.device.decompose_circuit(circuit_routed)
circuit = simplify_circuit(circuit_decomposed)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test this against a station? Does route_circuit accept CX, which is not a native gate?

Copy link
Member Author

@manzanillo manzanillo Feb 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I tested it with a QAOA and GHZ: routing takes CNOT gates even though they are not native to sampler.device.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants