Skip to content

feat: Add boundary edge traversal in SimpleReplacement #2231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 20, 2025

Conversation

lmondada
Copy link
Contributor

I believe these methods finally expose the "right" way to think of the boundary between a replacement and its subgraph, in particular this won't be broken as we extend SiblingSubgraph to express more types of subgraphs (see issue #2212).

The idea is simple: for any replacement, there must be links between ports that are just outside the subgraph in host, and ports that are linked to the input and output nodes of the replacement. These links are precisely the edges that will need to be added when the replacement is applied, between the existing host HUGR and the newly added nodes of the replacement. Specifically these edges link:

  • outgoing ports in host that are "just before the subgraph" (i.e. ports linked to an incoming port of subgraph) to incoming ports in replacement that are linked to the input node, and
  • incoming ports in host that are "just after the subgraph" (i.e. ports linked to an outgoing port of subgraph) to outgoing ports in replacement that are linked to the output node.

Copy link

codecov bot commented May 16, 2025

Codecov Report

Attention: Patch coverage is 98.88268% with 2 lines in your changes missing coverage. Please review.

Project coverage is 82.03%. Comparing base (fefa599) to head (bcd59d6).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
hugr-core/src/hugr/patch/simple_replace.rs 98.81% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2231      +/-   ##
==========================================
+ Coverage   82.00%   82.03%   +0.03%     
==========================================
  Files         234      234              
  Lines       41619    41702      +83     
  Branches    37532    37616      +84     
==========================================
+ Hits        34128    34209      +81     
  Misses       5518     5518              
- Partials     1973     1975       +2     
Flag Coverage Δ
python 85.21% <ø> (-0.01%) ⬇️
rust 81.68% <98.88%> (+0.03%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@lmondada lmondada marked this pull request as ready for review May 19, 2025 11:00
@lmondada lmondada requested a review from a team as a code owner May 19, 2025 11:00
@lmondada lmondada requested review from tatiana-s and removed request for tatiana-s May 19, 2025 11:00
@lmondada lmondada assigned aborgna-q and unassigned aborgna-q May 19, 2025
@lmondada lmondada requested review from acl-cqc and aborgna-q and removed request for acl-cqc May 19, 2025 11:03
Copy link
Collaborator

@aborgna-q aborgna-q left a comment

Choose a reason for hiding this comment

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

👍

#[derive(Debug, Clone, Copy)]
/// This is used to represent boundary edges that will be added between the host
/// and replacement graphs when applying a rewrite.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add Hash too ? (same on HostPort)

@lmondada lmondada added this pull request to the merge queue May 20, 2025
Merged via the queue into main with commit acf201f May 20, 2025
27 checks passed
@lmondada lmondada deleted the luca/add-bd-traversal-simple-repl branch May 20, 2025 15:26
@hugrbot hugrbot mentioned this pull request May 20, 2025
This was referenced May 29, 2025
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.

2 participants