Fix nested control-flow padding state - #3076
Open
sankalpsthakur wants to merge 4 commits into
Open
Conversation
Collaborator
|
@sankalpsthakur could you open an issue with a bug report explaining what's the issue you're encountering? |
Author
sankalpsthakur
force-pushed
the
fix-3005-block-base-padder
branch
3 times, most recently
from
July 28, 2026 10:09
dbace93 to
a4372c4
Compare
Tool attribution belongs in the PR description and commit trailers, not as inline comments in library and test code. The AI/LLM disclosure checkboxes in the PR body are unchanged.
sankalpsthakur
force-pushed
the
fix-3005-block-base-padder
branch
from
July 31, 2026 12:04
601a1b8 to
147b5cf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix nested control-flow padding so traversal state stays scoped to the block being visited and rebuilt control-flow operations retain their scheduled block index.
Details and comments
BlockBasePadderreused_idle_afterand_current_block_idxwhile recursively visiting nested blocks. A nested visit could therefore overwrite the parent block's timing state. The control-flow rebuild path also dropped the scheduled block index, and the final fast-path barrier call passed its time and block arguments in the wrong order.This change preserves and restores parent traversal state, carries the scheduled index through rebuilt control-flow operations, and corrects the barrier arguments. Focused regressions cover nested branch traversal and the final fast-path barrier.
Validation:
pytest -q test/unit/transpiler/passes/scheduling/test_scheduler.py test/unit/transpiler/passes/scheduling/test_dynamical_decoupling.py(159 passed)git diff --checkFixes #3077
This is the focused control-flow metadata subset originally catalogued in #3005; the separate idle-qubit detection bug in #3005 remains outside this PR.
Why this matters
Corrupted scheduling metadata in dynamic circuits can shift control-flow start times and attach barriers to the wrong block. That breaks downstream padding and decoupling passes silently — the kind of bug that only surfaces on nested
if_test/whilecircuits.Related
block_base_padder.py#3005 — idle-qubit detection remains openAI/LLM disclosure