dagcircuit: transfer DAG-level variables in substitute_node_with_dag (backport #15542) - #16744
Merged
Merged
Conversation
#15542) * dagcircuit: transfer DAG-level variables in substitute_node_with_dag (fixes #15509)\n\n- Add input/captured/declared vars and stretches from replacement DAG\n- Add tests verifying input vars and captured/declared vars transfer\n- Add release note entry * Apply Black formatting to test file * Update test_dagcircuit.py * Fix variable transfer to skip already-present variables Previously, substitute_node_with_dag() would try to add all variables from the replacement DAG, including those already present in the target DAG. This violated the constraint that a DAG cannot have both input and captured variables simultaneously when the same variable object appears in both contexts. Now check if each variable is already present before adding it, matching the behavior of compose() with inline_captures=False. * addressing review comments * fixing failing check for node variable substitution in dagcircuit. The check was failing because the node variable substitution was not being applied correctly in the dagcircuit code. This commit fixes that issue by ensuring that the node variable substitution is applied correctly when checking for node variables in the dagcircuit code. * adressing review comments * reno (cherry picked from commit f671c03)
Collaborator
|
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:
|
Coverage Report for CI Build 31534121907Coverage increased (+0.01%) to 87.746%Details
Uncovered Changes
Coverage Regressions6 previously-covered lines in 2 files lost coverage.
Coverage Stats
💛 - Coveralls |
ShellyGarion
approved these changes
Aug 12, 2026
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.
Fixes missing variable/stretches when the replacement DAG carries declarations (e.g., for control-flow conditions/targets).
Adds tests for input-vars and captured/declared-vars transfer.
Includes a release note.
Closes #15509.
AI/LLM disclosure
This is an automatic backport of pull request #15542 done by [Mergify](https://mergify.com).