Skip to content

dagcircuit: transfer DAG-level variables in substitute_node_with_dag (backport #15542) - #16744

Merged
ShellyGarion merged 1 commit into
stable/2.5from
mergify/bp/stable/2.5/pr-15542
Aug 12, 2026
Merged

dagcircuit: transfer DAG-level variables in substitute_node_with_dag (backport #15542)#16744
ShellyGarion merged 1 commit into
stable/2.5from
mergify/bp/stable/2.5/pr-15542

Conversation

@mergify

@mergify mergify Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

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

  • I didn't use LLM tooling, or only used it privately.
  • I used the following tool to help write this PR description:
  • I used the following tool to generate or modify code:

This is an automatic backport of pull request #15542 done by [Mergify](https://mergify.com).

#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)
@mergify
mergify Bot requested a review from a team as a code owner August 11, 2026 20:40
@mergify
mergify Bot requested a review from Cryoris August 11, 2026 20:40
@qiskit-bot

Copy link
Copy Markdown
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:

  • @Qiskit/terra-core

@github-actions github-actions Bot added the Changelog: Fixed Add a "Fixed" entry in the GitHub Release changelog. label Aug 11, 2026
@github-actions github-actions Bot added this to the 2.5.2 milestone Aug 11, 2026
@github-actions github-actions Bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Aug 11, 2026
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 31534121907

Coverage increased (+0.01%) to 87.746%

Details

  • Coverage increased (+0.01%) from the base build.
  • Patch coverage: 4 uncovered changes across 1 file (16 of 20 lines covered, 80.0%).
  • 6 coverage regressions across 2 files.

Uncovered Changes

File Changed Covered %
crates/circuit/src/dag_circuit.rs 20 16 80.0%

Coverage Regressions

6 previously-covered lines in 2 files lost coverage.

File Lines Losing Coverage Coverage
crates/qasm2/src/lex.rs 4 92.54%
crates/circuit/src/parameter/symbol_expr.rs 2 76.4%

Coverage Stats

Coverage Status
Relevant Lines: 128786
Covered Lines: 113004
Line Coverage: 87.75%
Coverage Strength: 997814.57 hits per line

💛 - Coveralls

@ShellyGarion
ShellyGarion added this pull request to the merge queue Aug 12, 2026
Merged via the queue into stable/2.5 with commit de39d68 Aug 12, 2026
32 checks passed
@ShellyGarion
ShellyGarion deleted the mergify/bp/stable/2.5/pr-15542 branch August 12, 2026 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Changelog: Fixed Add a "Fixed" entry in the GitHub Release changelog. Community PR PRs from contributors that are not 'members' of the Qiskit repo

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants