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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/demo_iqm_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ def demo_run_circuit() -> None:

sampler = IQMSampler(os.environ['IQM_SERVER_URL'])

circuit_decomposed = sampler.device.decompose_circuit(circuit)
circuit_routed, _, _ = sampler.device.route_circuit(circuit_decomposed)
circuit = simplify_circuit(circuit_routed)
circuit_routed, _, _ = sampler.device.route_circuit(circuit)
circuit_decomposed = sampler.device.decompose_circuit(circuit_routed)
circuit = simplify_circuit(circuit_decomposed)
Comment on lines +53 to +55
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.

Copy link
Contributor

Choose a reason for hiding this comment

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

route_circuit uses a Cirq pass which is should be gateset agnostic.

As for Deneb, the route_circuit code checks if the device supports moves, if so, it will decompose after adding swaps and then calls transpile_insert_moves_into_circuit.
See also https://github.com/iqm-finland/cirq-on-iqm/blob/main/src/iqm/cirq_iqm/devices/iqm_device.py#L256

If you are supposed to decompose before routing, then I think route_circuit should return a decomposed circuit and thus call decompose by itself, returning decomposed swaps, and leave the docs as is.
Otherwise, I think we should have a simple transpile wrapper that calls everything in the correct order depending on which device needs what, so that users don't run into these shenanigans.

print('\nTranspiled and routed circuit:\n')
print(circuit)
print('\n')
Expand Down