Skip to content

feat!: Interval is independent of resource IDs and scope position#1205

Merged
doug-q merged 7 commits intomainfrom
lm/interval-pr
Nov 6, 2025
Merged

feat!: Interval is independent of resource IDs and scope position#1205
doug-q merged 7 commits intomainfrom
lm/interval-pr

Conversation

@lmondada
Copy link
Copy Markdown
Contributor

@lmondada lmondada commented Oct 27, 2025

Previously, Intervals were storing ResourceIds and Positions. This made them only valid for a specific ResourceScope. This data is no longer stored, so that Intervals are now valid independently of the choice of ResourceIds and Positions. See the docstring of Interval and the added test.

BREAKING CHANGE: most methods of resource::Interval now take a ResourceScope argument; Interval::singleton constructor renamed to Interval::new_singleton

@hugrbot
Copy link
Copy Markdown
Collaborator

hugrbot commented Oct 27, 2025

This PR contains breaking changes to the public Rust API.

cargo-semver-checks summary
    Building tket v0.16.0 (current)
     Built [  40.749s] (current)
   Parsing tket v0.16.0 (current)
    Parsed [   0.095s] (current)
  Building tket v0.16.0 (baseline)
     Built [  40.464s] (baseline)
   Parsing tket v0.16.0 (baseline)
    Parsed [   0.089s] (baseline)
  Checking tket v0.16.0 -> v0.16.0 (assume minor change)
   Checked [   0.079s] 159 checks: 158 pass, 1 fail, 0 warn, 41 skip

--- failure struct_missing: pub struct removed or renamed ---

Description:
A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely.
      ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.45.0/src/lints/struct_missing.ron

Failed in:
struct tket::resource::Interval, previously in file /home/runner/work/tket2/tket2/BASELINE_BRANCH/tket/src/resource/interval.rs:13

   Summary semver requires new major version: 1 major and 0 minor checks failed
  Finished [  82.809s] tket
  Building tket-qsystem v0.22.0 (current)
     Built [  42.015s] (current)
   Parsing tket-qsystem v0.22.0 (current)
    Parsed [   0.028s] (current)
  Building tket-qsystem v0.22.0 (baseline)
     Built [  42.351s] (baseline)
   Parsing tket-qsystem v0.22.0 (baseline)
    Parsed [   0.029s] (baseline)
  Checking tket-qsystem v0.22.0 -> v0.22.0 (assume minor change)
   Checked [   0.046s] 159 checks: 159 pass, 41 skip
   Summary no semver update required
  Finished [  87.067s] tket-qsystem

@codecov
Copy link
Copy Markdown

codecov bot commented Oct 27, 2025

Codecov Report

❌ Patch coverage is 91.82156% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.07%. Comparing base (ad16531) to head (8b2482c).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
tket/src/subcircuit/interval.rs 91.89% 11 Missing and 10 partials ⚠️
tket/src/resource/scope.rs 88.88% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1205      +/-   ##
==========================================
+ Coverage   78.73%   79.07%   +0.34%     
==========================================
  Files         159      159              
  Lines       20157    20290     +133     
  Branches    19055    19188     +133     
==========================================
+ Hits        15870    16045     +175     
+ Misses       3310     3260      -50     
- Partials      977      985       +8     
Flag Coverage Δ
python 92.65% <ø> (ø)
qis-compiler 68.40% <ø> (ø)
rust 78.72% <91.82%> (+0.36%) ⬆️

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 October 27, 2025 10:06
@lmondada lmondada requested a review from a team as a code owner October 27, 2025 10:06
@lmondada lmondada requested review from doug-q and removed request for doug-q October 27, 2025 10:06
@lmondada
Copy link
Copy Markdown
Contributor Author

lmondada commented Oct 27, 2025

@mariagg-quantinuum Could you review this please? I cannot requests from you atm 🫠

@mariagg-quantinuum
Copy link
Copy Markdown
Contributor

mariagg-quantinuum commented Oct 29, 2025

Checked this PR, all seems to work and make sense to me 👍 @lmondada
also I think you might be able to set me as a reviewer now so I can tick "review done"

@lmondada
Copy link
Copy Markdown
Contributor Author

Cheers, and

I think you might be able to set me as a reviewer now so I can tick "review done"

yes indeed, I can 🎉

@lmondada lmondada requested a review from doug-q October 29, 2025 14:14
@lmondada
Copy link
Copy Markdown
Contributor Author

@doug-q this was reviewed by @mariagg-quantinuum, but as she's not an owner of the repo, we would still need your approval.

A second pair of eyes is always good anyways! Thanks in advance 😊

github-merge-queue bot pushed a commit that referenced this pull request Oct 30, 2025
I want to define a `Subcircuit` as a combination of `Interval`s on
resource paths (the parts with linear, non-copyable data), and ASTs of
fully classical, copyable data.

- PR #1205 was opened to refine the notion of `Interval`
- this PR creates the `CopyableExpressionAST` type that corresponds to
ASTs of classical data in hugr graphs.

---------

Co-authored-by: Alan Lawrence <[email protected]>
@lmondada
Copy link
Copy Markdown
Contributor Author

lmondada commented Nov 5, 2025

@doug-q could you please review this when you have a moment?

Copy link
Copy Markdown
Contributor

@doug-q doug-q left a comment

Choose a reason for hiding this comment

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

Nice

@doug-q doug-q added this pull request to the merge queue Nov 6, 2025
Merged via the queue into main with commit b270af8 Nov 6, 2025
24 checks passed
@doug-q doug-q deleted the lm/interval-pr branch November 6, 2025 09:32
@hugrbot hugrbot mentioned this pull request Nov 6, 2025
github-merge-queue bot pushed a commit that referenced this pull request Feb 3, 2026
## 🤖 New release

* `tket`: 0.16.0 -> 0.17.0 (✓ API compatible changes)
* `tket-qsystem`: 0.22.0 -> 0.23.0 (✓ API compatible changes)

<details><summary><i><b>Changelog</b></i></summary><p>

## `tket`

<blockquote>

##
[0.17.0](tket-v0.16.0...tket-v0.17.0)
- 2026-02-02

### Bug Fixes

- *(encoded-circ)* Track unsupported wires between input and output
([#1224](#1224))
- Multiple fixes to the pytket encoder
([#1226](#1226))
- Don't use opgroup in pytket barrier encoding
([#1251](#1251))
- guppy_to_circuit always returns num_operations = 0
([#1200](#1200))
- *(pytket-decoder)* Avoid QAllocating and immediately freeing qubits
([#1256](#1256))
- Encoding of opaque subgraphs with no associated qubit/bit
([#1295](#1295))
- [**breaking**] Don't rely on command params for pytket barriers
([#1298](#1298))
- Track output qubits in CircuitInfo
([#1304](#1304))
- Wrongly reused qubit IDs in pytket encoding
([#1358](#1358))

### New Features

- Deprecate local find_tuple_unpack rewrite
([#1188](#1188))
- Add CopyableExpressionAST
([#1209](#1209))
- `NormalizeGuppy` pass to simplify generated structure
([#1220](#1220))
- [**breaking**] pytket EncodedCircuit struct for in-place pytket
optimisation ([#1211](#1211))
- [**breaking**] Interval is independent of resource IDs and scope
position ([#1205](#1205))
- Don't translate usizes to pytket
([#1241](#1241))
- BorrowSquashPass to elide redundant borrow/return ops
([#1159](#1159))
- [**breaking**] Bump hugr to 0.25.0
([#1325](#1325))
- Remove order edges in NormalizeGuppy pass
([#1326](#1326))
- [**breaking**] Remove deprecated unpack tuple pass
([#1387](#1387))

### Refactor

- Remove contain_qubits, use TypeUnpacker
([#1283](#1283))
- [**breaking**] Replace Subcircuit with SiblingSubgraph
([#1288](#1288))
- *(metadata)* [**breaking**] Migrate all metadata keys onto the new
metadata traits ([#1328](#1328))
</blockquote>

## `tket-qsystem`

<blockquote>

##
[0.23.0](tket-qsystem-v0.22.0...tket-qsystem-v0.23.0)
- 2026-02-02

### Bug Fixes

- [**breaking**] Don't rely on command params for pytket barriers
([#1298](#1298))
- Wrongly reused qubit IDs in pytket encoding
([#1358](#1358))

### New Features

- `NormalizeGuppy` pass to simplify generated structure
([#1220](#1220))
- Allow running arbitrary serializable pytket passes on hugrs
([#1266](#1266))
- BorrowSquashPass to elide redundant borrow/return ops
([#1159](#1159))
- [**breaking**] Bump hugr to 0.25.0
([#1325](#1325))
- Remove order edges in NormalizeGuppy pass
([#1326](#1326))
- hide new public funcs introduced by linearization
([#1333](#1333))

### Testing

- regenerate guppy_opt examples, and count gates
([#1249](#1249))
- run pytket on guppy_opt tests, measure (very limited) success
([#1250](#1250))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
@hugrbot hugrbot mentioned this pull request Feb 5, 2026
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.

4 participants