Skip to content

Conversation

@lmondada
Copy link
Contributor

@lmondada lmondada commented Aug 20, 2025

I'll put this as draft for the time being, given that it is already stacked on top of other two PRs.

Does what the title says: using ResourceScope's resource path tracking, we can check convexity of subcircuits very efficiently. Heavily inspired by portgraph's LineConvexChecker, see Quantinuum/portgraph#240.

Note that to be able to implement the convexity check, I changed Position from being a port property (i.e. each resource had its own position), to being a node-wide property. See the first of the two commits in this PR.

As is, the conversion Subcircuit -> SiblingSubgraph is correct but unnecessarily slow: at construction time, hugr will check convexity of the subgraph again. My plan is to open a PR in hugr that allows us to bypass convexity checks and use that here in place of SiblingSubgraph::try_new.

@lmondada lmondada changed the title feat: Add ResourceScope::is_convex feat!: Add ResourceScope::is_convex Aug 20, 2025
@codecov
Copy link

codecov bot commented Aug 20, 2025

Codecov Report

❌ Patch coverage is 92.75654% with 36 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (lm/new-new-subcircuit@bbf170f). Learn more about missing BASE report.

Files with missing lines Patch % Lines
tket/src/rewrite.rs 80.00% 15 Missing and 1 partial ⚠️
tket/src/rewrite/strategy.rs 78.78% 7 Missing ⚠️
tket/src/resource.rs 85.00% 3 Missing ⚠️
tket/src/resource/scope.rs 96.87% 2 Missing and 1 partial ⚠️
tket/src/rewrite/ecc_rewriter.rs 66.66% 3 Missing ⚠️
tket/src/resource/convex_checker.rs 95.91% 2 Missing ⚠️
tket/src/optimiser/badger.rs 93.75% 0 Missing and 1 partial ⚠️
tket/src/portmatching/matcher.rs 83.33% 1 Missing ⚠️
Additional details and impacted files
@@                   Coverage Diff                    @@
##             lm/new-new-subcircuit    #1057   +/-   ##
========================================================
  Coverage                         ?   80.27%           
========================================================
  Files                            ?      154           
  Lines                            ?    19669           
  Branches                         ?    18582           
========================================================
  Hits                             ?    15789           
  Misses                           ?     2994           
  Partials                         ?      886           
Flag Coverage Δ
python 92.63% <ø> (?)
qis-compiler 68.92% <ø> (?)
rust 79.94% <92.75%> (?)

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 force-pushed the lm/subcircuit-conv-checker branch 4 times, most recently from d3c5a60 to 7b02be7 Compare August 21, 2025 10:56
@lmondada lmondada force-pushed the lm/new-new-subcircuit branch from de70bd6 to 296ff69 Compare August 28, 2025 09:06
@lmondada lmondada force-pushed the lm/new-new-subcircuit branch from 296ff69 to fdce2c3 Compare September 4, 2025 14:39
@lmondada lmondada force-pushed the lm/new-new-subcircuit branch from fdce2c3 to 8af0f6d Compare September 30, 2025 14:15
@lmondada lmondada force-pushed the lm/subcircuit-conv-checker branch from 7b02be7 to 7343d5f Compare October 8, 2025 00:18
@lmondada lmondada force-pushed the lm/new-new-subcircuit branch from 8af0f6d to bbf170f Compare October 13, 2025 02:49
@lmondada lmondada force-pushed the lm/subcircuit-conv-checker branch from 7343d5f to 0565168 Compare October 31, 2025 12:59
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.

3 participants