-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Oxidize CheckGateDirection #13042
Oxidize CheckGateDirection #13042
Conversation
Pull Request Test Coverage Report for Build 10757805126Details
💛 - Coveralls |
Some benchmark data, using circuits generated like this: tqc = generate_preset_pass_manager(1, coupling_map=CouplingMap.from_heavy_hex(7))
.run(qc) and this: tqc = generate_preset_pass_manager(1, GenericBackendV2(qubits))
.run(qc) where: qubits = 100
qc = random_circuit(qubits, qubits, seed=12234) (note that And results are measured like this: %%timeit
check_direction_pass.run(dag)
So ~5-11X improvement in this check by moving to Rust. Note that CouplingMap is (still) in Python while Target is in Rust, which may explain the run-time differences in Python and the speed-up differences between the target vs coupling map cases. |
One or more of the following people are relevant to this code:
|
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.
It might be helpful for benchmarking to generate a target with the same coupling map as the "coupling_map" case, as GenericBackendV2
generates a target with all-to-all connectivity by default. You could do this by running:
tqc = generate_preset_pass_manager(1, GenericBackendV2(qubits, coupling_map=CouplingMap.from_heavy_hex(7))).run(qc)
Thanks @ElePT . There are 2 paths for this pass: one is based on coupling map and one on target. So I think it doesn't really matter for this benchmarking to have the same coupling constraints, as long as we use the same constraints in each path separately both in Python and Rust . Anyway, FWIW, here is another comparison, this time using the same coupling constraints, basis gates and traspiler seed in all 4 runs (python/rust X coupling/target).
I see that I need to resolve conflicts in |
Also changing functions order in gate_direction.rs and adding Returns: doc
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.
This looks good, thanks for doing this. I left a few inline comments, but at a high level this has everything needed.
Thanks @mtreinish for the review and very helpful comments! Here is an updated benchmark result. The
|
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.
This is looking good, I think it's basically ready now thanks for making the updates. I just have a few small inline comments. But after those are addressed I think we're good to merge this.
…o check-gate-direction
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.
This LGTM now, thanks for making all the updates.
Summary
This PR ports the
CheckGateDirection
analysis pass to Rust.Details and comments
This PR includes:
CouplingMap
, the Python code converts the given coupling map to a set of edge pairs and pass it asPySet
to the Rust code.DAGCircuit.qubits
registry for mapping instruction qubit args to qubit indices when checking gate direction against either a coupling map edge set or a target.dag_circuit.rs
: making a pure Rust-friendly version oftwo_qubits_op
Close #12256