fix: Ensure there is no subtraction panic via underflow#16232
fix: Ensure there is no subtraction panic via underflow#16232chookity-pokk wants to merge 2 commits into
Conversation
|
Thank you for opening a new pull request. Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient. While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone. One or more of the following people are relevant to this code:
|
jakelishman
left a comment
There was a problem hiding this comment.
Thanks for the PR. This is currently targeting the wrong branch: we need to fix it on main, and then we'll backport it to the 2.4 series, since the fix is eligible. If we merge this, then main won't have it, so the bug would reappear in Qiskit 2.5. It'll probably be easier for you to open a new PR that's branched from main, rather than trying to re-target this one, since it's descended from stable/2.4 already.
Beyond that: can we add a one-sentence release note (reno new --edit fix-underflow-constrained-reschedule), and we'll need to add a regression test to stop this happening again.
In the Python version of
ConstrainedReschedulewhennext_t0q > new_t1qthe overlap gives a negative number, which is handled byoverlap = max(qreg_overlap, creg_overlap)followed by theif overlap > 0check.In Rust these values are u64 so the same subtraction panics on underflow. By using
saturating_subwe clamp to 0 so it matches the Python behavior.Fix #16231.
AI/LLM disclosure