Skip to content

fix: ModifierResolverPass preserve non-local edges with classical DAG#1792

Open
nicolaassolini-qntm wants to merge 16 commits into
mainfrom
na/1789-DAG-bug
Open

fix: ModifierResolverPass preserve non-local edges with classical DAG#1792
nicolaassolini-qntm wants to merge 16 commits into
mainfrom
na/1789-DAG-bug

Conversation

@nicolaassolini-qntm

Copy link
Copy Markdown
Contributor

closes #1789

When a DFG classical block is found, the DFG is copied as it is. When the DFG contained a non-local edge (a function call), an invalid hugr was generated since the edge was not copied.

@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.11765% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.77%. Comparing base (f494f3a) to head (9e8c854).

Files with missing lines Patch % Lines
tket/src/modifier/modifier_resolver/dfg_modify.rs 94.11% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1792      +/-   ##
==========================================
+ Coverage   85.74%   85.77%   +0.02%     
==========================================
  Files         198      198              
  Lines       31478    31527      +49     
  Branches    30033    30082      +49     
==========================================
+ Hits        26991    27041      +50     
  Misses       3208     3208              
+ Partials     1279     1278       -1     
Flag Coverage Δ
python 91.91% <ø> (ø)
qis-compiler 74.17% <ø> (ø)
rust 85.47% <94.11%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@codspeed-hq

codspeed-hq Bot commented Jul 3, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 9 untouched benchmarks


Comparing na/1789-DAG-bug (9e8c854) with main (f494f3a)

Open in CodSpeed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an invalid HUGR generation case in ModifierResolverPass by ensuring that when a classical DFG (or other sub-container) is copied wholesale, any non-local static function-call edges into that copied subtree are preserved via the resolver’s call-map reconnection mechanism.

Changes:

  • Enhance copy_sub_container_no_modification to detect and preserve non-local EdgeKind::Function inputs by recording them into call_map when copying a subtree.
  • Add a new Rust regression test case intended to cover external function-call edges within a DFG context under modifiers.
  • Extend the classical_function.py modifier example to include a higher-order classical call inside a modified context (dagger + control).

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
tket/src/modifier/modifier_resolver/dfg_modify.rs Preserves non-local static function-call edges when copying an unmodified subtree; adds a regression test case.
test_files/modifier_examples/classical_function.py Adds a higher-order classical call inside a modified context to exercise the reported scenario.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tket/src/modifier/modifier_resolver/dfg_modify.rs Outdated
@nicolaassolini-qntm nicolaassolini-qntm marked this pull request as ready for review July 7, 2026 10:43
@nicolaassolini-qntm nicolaassolini-qntm requested a review from a team as a code owner July 7, 2026 10:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated no new comments.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

Comment thread test_files/modifier_examples/classical_function.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Modifying higher order classical function after normalization produce invalid hugrs

2 participants