Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.11k stars 2.34k forks source link

Fully port InverseCancellation to Rust #13013

Closed mtreinish closed 3 weeks ago

mtreinish commented 1 month ago

Summary

This commit builds off of #12959 and the other data model in Rust infrastructure and migrates the InverseCancellation pass to operate fully in Rust. The full path of the transpiler pass now never leaves Rust until it has finished modifying the DAGCircuit. There is still some python interaction necessary to handle parts of the data model that are still in Python, mainly for handling parameter expressions. But otherwise the entirety of the pass operates in rust now.

This is just a first pass at the migration here, it moves the pass to use loops in rust. The next steps here are to look at operating the pass in parallel. There is no data dependency between the optimizations being done for different inverse gates/pairs so we should be able to the throughput of the pass by leveraging multithreading to handle each inverse option in parallel. This commit does not attempt this though, because of the Python dependency and also the data structures around gates and the dag aren't really setup for multithreading yet and there likely will need to be some work to support that.

Details and comments

~This PR is based on top of https://github.com/Qiskit/qiskit/pull/12959 and as such github shows the entire contents of https://github.com/Qiskit/qiskit/pull/12959 in addition to the contents of this PR. To see the contents of this PR you can look at HEAD on this branch, or just look at: https://github.com/Qiskit/qiskit/pull/13013/commits/00c7e10c23bb15ac2623c0132a90f11004354125~ rebased

Fixes #12271 Part of #12208

TODO:

qiskit-bot commented 1 month ago

One or more of the following people are relevant to this code:

coveralls commented 1 month ago

Pull Request Test Coverage Report for Build 10745716091

Details


Changes Missing Coverage Covered Lines Changed/Added Lines %
crates/circuit/src/dag_circuit.rs 39 41 95.12%
crates/accelerate/src/inverse_cancellation.rs 138 144 95.83%
<!-- Total: 181 189 95.77% -->
Files with Coverage Reduction New Missed Lines %
qiskit/synthesis/two_qubit/xx_decompose/decomposer.py 1 95.42%
crates/qasm2/src/lex.rs 2 93.23%
crates/qasm2/src/parse.rs 6 97.61%
<!-- Total: 9 -->
Totals Coverage Status
Change from base Build 10745615622: 0.02%
Covered Lines: 72883
Relevant Lines: 81746

💛 - Coveralls