-
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
Deprecate Instruction.condition
in favor of IfElseOp
#9556
Comments
This depends on #9417 and is blocked until it is implemented. |
In practice, the routing performance for conditioned single 1q and 2q blocks is currently very different compared to the |
TBH, I'm personally less concerned about that for this issue at least. It's an optimization/fix we can work on in parallel and also do post-deprecation. For me, to deprecate |
Agreed - I'm mostly trying to get these thoughts written down. Kevin and I had a meeting where that routing quality was a concern, so it'll affect some users, but it's likely lower priority than getting the |
I think this can be taken off 'on hold' since the work for #9417 is in flight, and doesn't strictly block the development of this issue, only its release. |
I looked at this today and I think it's too soon for 0.25 especially with the proposal freeze so close. Besides being blocked on #9417 actually merging (which there are enough moving pieces in progress still that it'll be tight to fit in the release). The actual mechanics of this are more involved than I think is reasonable in the time frame for 0.25, mostly around testing. There are 7685 tests that fail locally because of the deprecation warnings. These will all need to be updated to catch the deprecation warnings. If we want to do this I think the better time frame is to do this early in 0.26/0.45 to ensure we have enough debug time for any issues that will inevitably come up from the deprecation especially for something as core as |
This commit deprecates the Instruction.condition and c_if() method for removal in 2.0. This functionality has been superseded by the more sophisiticated `IfElseOp` for some time now. Removing the condition property will simplify the Qiskit data model as it is implemented in a kind of ad-hoc manner that adds additional overhead to manually check it in many places. For the unittest modifications the deprecation warning for the .condtion getter is suppressed for the entire suite because this gets triggered internally by the transpiler and a lot of other places, including from rust code as until it is removed we need to use it to check that piece of the data model. Fixes Qiskit#9556
* Deprecate the condition attribute and related functionality This commit deprecates the Instruction.condition and c_if() method for removal in 2.0. This functionality has been superseded by the more sophisiticated `IfElseOp` for some time now. Removing the condition property will simplify the Qiskit data model as it is implemented in a kind of ad-hoc manner that adds additional overhead to manually check it in many places. For the unittest modifications the deprecation warning for the .condtion getter is suppressed for the entire suite because this gets triggered internally by the transpiler and a lot of other places, including from rust code as until it is removed we need to use it to check that piece of the data model. Fixes #9556 * Add missing assertWarns * Handle deprecation warnings in visual tests too * Apply suggestions from code review Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com> * Use private attribute in py->rust conversion * Avoid deprecation warning in non-deprecated code This commit fixes some places in the code where we were using the deprecated functionality where it needed a path to persist the behavior or where the deprecation warning became a performance bottleneck. The code is updated accordingly and to catch issues like this in the future the warning filters are adjusted to be more selective. * Add missing test updates * Add filter for aer's condition usage and dag drawer * Fix lint --------- Co-authored-by: Elena Peña Tapia <57907331+ElePT@users.noreply.github.com>
What should we add?
Instruction.condition
is Qiskit's way of representing classical execution of instructions based on the values in specified classical registers. However, due to it's location as a property onInstruction
(but outsideparams
) has historically lead to it being overlooked, resulting in a handful of bugs where this condition information is either lost or not considered e.g. when evaluating instruction order (Some examples: #6475, #6810, #8553, #8040, #7950, #7247, #7006, #6994, #6583, #6192, #6016, #4727, #4672, #3164, #3215, #2667, #2571 .) Additionally, it is one of the pieces of mutable state that is currently preventing us from moving toward more lightweightOperation
instances ( to resolve e.g. #3800, #5895, #7624, and #9372 ).IfElseOp
can currently represent a superset of what can be expressed withInstruction.condition
and is more inline with how we expect to handle conditional and control flow operations going forward, so we should plan to deprecateInstruction.condition
with equivalent usage ofIfElseOp
. This issue is to discuss and plan that process.Deprecating
Instruction.condition
while maintaining full backwards compatibility seems difficult (due to both a change inOperation
type fromInstruction
toIfElseOp
, and due to.condition
being a property of theInstruction
without context of theQuantumCircuit
in which it is included). The following are two use cases to consider:Additionally, we should:
1)Updating existing visualization to inspect
IfElseOp
operations and, when possible, draw as an equivalentcondition
2)Updating
qiskit.assemble
, similarly to visualization, to replace applicableIfElseOp
s with their equivalentcondition
representationThe text was updated successfully, but these errors were encountered: