-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[WIP] Oxidize qubit tracker for HighLevelSynthesis #13180
Conversation
One or more of the following people are relevant to this code:
|
Pull Request Test Coverage Report for Build 10922540254Details
💛 - Coveralls |
/// Track qubits by their state | ||
#[pyclass] | ||
pub struct QubitTracker { | ||
qubits: Vec<Qubit>, |
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.
I think a simple optimization you can make here is to use num_qubits: u32
instead of a Vec
. In rust the Qubit
object is just an integer in 0..n
so it'll always be contiguous so we don't need to store the entire list and can just store the max index and then either do a comparison if it's in the circuit or an iterator (0..self.num_qubits)
depending on how you were using qubits
here.
Closed in favor of #13369. |
Summary
In #12911, we have added the
QubitTracker
class, which tracks the state of qubits for high-level synthesis. WhenHighLevelSynthesis
runs non-trivially (i.e. does not take the "fast path", see #13070), this state tracking requires a large number of ssllllooooww Python set-based manipulations.As an example, the following code
runs in about
3.2
seconds (on my laptop). The current PR almost verbatim reimplementsQubitTracker
in Rust, with the example above now running in0.11
seconds (i.e. about 30x faster).It also adds a few Python tests for
QubitTracker
.This does not require release notes since
QubitTracker
is an internal class and should not be exposed to the users.This is still work-in-progress because I would like to further revise
QubitTracker
's API and improve the internal data structures.