-
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
Remove condition/c_if, duration, and unit from instructions #13506
base: main
Are you sure you want to change the base?
Conversation
This commit removes the per instruction attributes for condition, duration, and unit. These attributes were deprecated in 1.3.0. Besides the label these attributes were the only mutable state for singleton instructions and removing them simplifies what needs to be tracked for instructions in both Python and rust. The associated methods and classes that were previously dependent on these attributes are also removed as they no longer serve a purpose. The removal of condition in particular removes a lot of logic from Qiskit especially from the transpiler because it was a something that needed to be checked outside of the normal data model for every operation. This PR simplifies the representation of this extra mutable state in Rust by removing the `ExtraInstructionAttributes` struct and replacing it with a `Option<Box<String>>`. The `Option<Box<String>>` is used instead of the simpler `Option<String>` because this this reduces the size of the label field from 24 bytes for `Option<String>` to 8 bytes for `Option<Box<String>>` with an extra layer of pointer indirection and a second heap allocation. This will have runtime overhead when labels are set, but because the vast majority of operations don't set labels the tradeoff for optimizing for the None case makes more sense. Another option would have been to use `Box<str>` here which is the equivalent of `Box<[u8]>` (where `String` is the equivalent to `Vec<u8>`) and from a runtime memory tradeoff would be a better choice for this application if labels were commonly used as labels aren't growable. But that requires 16 bytes instead of 8 and we'd be wasting an additional 8 bytes for each instruction in the circuit which isn't worth the cost.
Is there a replacement method for getting circuit timing if |
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.
Thanks for the titanic removal!! I have taken a look up to qiskit/transpiler/passes/scheduling/scheduling/asap.py
and left a couple of minor comments and replied to a few of the discussion points Jake opened. Overall I think it looks good. I will continue with part 2 of the review after a break.
Co-authored-by: Elena Peña Tapia <[email protected]>
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.
Second part of the review completed! I didn't see any issues stand out from the tests/ final passes. I started leaving reno suggestions, changed my mind (it will be easier to edit in the release preparation PR), but the interface wasn't responding so I couldn't delete them. My only question is whether we should comment in this collection of renos the fact that BasicSimulator no longer supports control flow. I didn't add it at the time, and I could edit that reno too, I just thing it would be good to have it documented somewhere.
Don't worry I'll ignore them then. :)
I can add a note about it, it feels a bit weird to call it out on it's own. But you're right we should mention it. |
Co-authored-by: Elena Peña Tapia <[email protected]>
This commit removes the deprecated duration attributes for circuits. This was deprecated in the 1.3.0 release and replaced by the QuantumCircuit.estimate_duration() method in 1.4.0. This commit is based on top of Qiskit#13506 and is blocked on Qiskit#13708 and Qiskit#13662 (as many tests using this functionality are of these deprecated components)
Summary
This commit removes the per instruction attributes for condition, duration, and unit. These attributes were deprecated in 1.3.0. Besides the label these attributes were the only mutable state for singleton instructions and removing them simplifies what needs to be tracked for instructions in both Python and rust. The associated methods and classes that were previously dependent on these attributes are also removed as they no longer serve a purpose. The removal of condition in particular removes a lot of logic from Qiskit especially from the transpiler because it was a something that needed to be checked outside of the normal data model for every operation.
This PR simplifies the representation of this extra mutable state in Rust by removing the
ExtraInstructionAttributes
struct and replacing it with aOption<Box<String>>
. TheOption<Box<String>>
is used instead of the simplerOption<String>
because this this reduces the size of the label field from 24 bytes forOption<String>
to 8 bytes forOption<Box<String>>
with an extra layer of pointer indirection and a second heap allocation. This will have runtime overhead when labels are set, but because the vast majority of operations don't set labels the tradeoff for optimizing for the None case makes more sense. Another option would have been to useBox<str>
here which is the equivalent ofBox<[u8]>
(whereString
is the equivalent toVec<u8>
) and from a runtime memory tradeoff would be a better choice for this application if labels were commonly used as labels aren't growable. But that requires 16 bytes instead of 8 and we'd be wasting an additional 8 bytes for each instruction in the circuit which isn't worth the cost.Details and comments
TODO:
c_if
usage in tests (there's >200 instances of it still)