Skip to content

refactor!: Deprecate commands iterator - #1611

Merged
aborgna-q merged 7 commits into
mainfrom
ab/deprecate-commands
May 27, 2026
Merged

aborgna-q merged 7 commits into
mainfrom
ab/deprecate-commands

Conversation

@aborgna-q

@aborgna-q aborgna-q commented May 20, 2026 •

Copy link
Copy Markdown
Collaborator

The CommandsIterator was one of the first utilities defined in this repo, and is quite focused on pytket-style flat circuits with basic quantum operations, qubit wires, and bit wires.
This definition grew stale quickly, but it was used throughout the repo nonetheless.

This PR removes such uses and marks the definition as deprecated. We should be able to remove it on tket 0.20.0.

I added a toposorted_children and a count_ops method to Circuit to replace commands usage.
These will be moved to an extension trait in the future as part of #1060.

BREAKING CHANGE: Circuit::circuit_cost now computes the cost of all descendant nodes of a circuit, not just TketOps.

@aborgna-q
aborgna-q requested a review from a team as a code owner May 20, 2026 15:38
@codecov

codecov Bot commented May 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.35802% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.63%. Comparing base (084c9de) to head (241fdcc).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
tket/src/passes/commutation.rs 82.60% 9 Missing and 3 partials ⚠️
tket/src/circuit.rs 96.42% 0 Missing and 1 partial ⚠️
tket/src/rewrite/strategy.rs 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1611      +/-   ##
==========================================
+ Coverage   85.52%   85.63%   +0.11%     
==========================================
  Files         184      184              
  Lines       29077    29414     +337     
  Branches    27876    28213     +337     
==========================================
+ Hits        24868    25189     +321     
- Misses       3075     3092      +17     
+ Partials     1134     1133       -1     
Flag Coverage Δ
python 90.45% <ø> (ø)
qis-compiler 91.66% <ø> (ø)
rust 85.42% <91.35%> (+0.11%) ⬆️

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.

Comment thread tket-py/src/state/cost.rs
Comment thread tket/tests/badger_termination.rs
Comment thread tket/tests/badger_termination.rs Outdated
Comment thread tket/src/ops.rs
Comment thread tket/src/optimiser/badger.rs Outdated
Comment thread tket/src/optimiser/badger.rs Outdated
Comment thread tket/src/passes/utils/chunks.rs
Comment thread tket/src/circuit.rs Outdated
Comment thread tket/src/passes/commutation.rs Outdated
Comment on lines +79 to +83
fn ensure_resource_slot(
qubit_free_slice: &mut Vec<usize>,
slices: &mut SliceVec,
resource: ResourceId,
) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I have difficulty gauging what this function does. Could you add a comment / make this (especially the name) clearer?

@aborgna-q aborgna-q changed the title refactor: Deprecate commands iterator refactor!: Deprecate commands iterator May 26, 2026
@aborgna-q
aborgna-q enabled auto-merge May 27, 2026 15:04
@aborgna-q
aborgna-q added this pull request to the merge queue May 27, 2026
Merged via the queue into main with commit 8a43301 May 27, 2026
24 checks passed
@aborgna-q
aborgna-q deleted the ab/deprecate-commands branch May 27, 2026 15:14
nrdcid pushed a commit to nrdcid/tket2 that referenced this pull request Jun 4, 2026
## 🤖 New release

* `tket`: 0.18.0 -> 0.19.0 (✓ API compatible changes)
* `tket-qsystem`: 0.24.0 -> 0.25.0 (✓ API compatible changes)

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

## `tket`

<blockquote>

##
[0.19.0](Quantinuum/tket2@tket-v0.18.0...tket-v0.19.0)
- 2026-05-28

### Bug Fixes

- Apply modifiers through function calls
([Quantinuum#1531](Quantinuum#1531))
- Incorrect matching of pytket parameters to unsupported graph ports
([Quantinuum#1561](Quantinuum#1561))
- [**breaking**] Passes with Nested Modifier
([Quantinuum#1546](Quantinuum#1546))
- bug in hugr building when `control` modifiers are nested
([Quantinuum#1550](Quantinuum#1550))
- Multiple fixes to the pytket encoder
([Quantinuum#1566](Quantinuum#1566))
- [**breaking**] Replace non-deterministic iterations on hash maps
([Quantinuum#1582](Quantinuum#1582))
- Set inputs of functions loaded as values to top during dataflow
analysis ([Quantinuum#1595](Quantinuum#1595))
- Using indexes inside dagger modifier
([Quantinuum#1588](Quantinuum#1588))
- address Miri unsoundness by installing nextest and skipping FFI/long
running tests ([Quantinuum#1565](Quantinuum#1565))
- skip test_nested_array to resolve miri unsoundness
([Quantinuum#1623](Quantinuum#1623))

### New Features

- *(const-fold)* combine Consts for each out-port; write prepopulated
inputs ([Quantinuum#1489](Quantinuum#1489))
- InlineFunctionsPass
([Quantinuum#1524](Quantinuum#1524))
- upgrade to hugr v0.27.1
([Quantinuum#1568](Quantinuum#1568))
- [**breaking**] Ignore empty circuits when encoding Hugr regions into
pytket ([Quantinuum#1562](Quantinuum#1562))
- Add python definitions for the TKET metadata keys
([Quantinuum#1535](Quantinuum#1535))
- Clean Up by Deleting Unconnected Nodes after Modifier Solve
([Quantinuum#1557](Quantinuum#1557))
- InlineHint metadata
([Quantinuum#1532](Quantinuum#1532))
- Allowing control flow in `control`
([Quantinuum#1603](Quantinuum#1603))

### Performance

- Improve modifier resolver pass by visiting nodes in a set
([Quantinuum#1621](Quantinuum#1621))
- Avoid string formatting in Hugr op hashing
([Quantinuum#1624](Quantinuum#1624))

### Refactor

- Replace portgraph toposort in CommandIterator with node vector
([Quantinuum#1608](Quantinuum#1608))
- [**breaking**] Deprecate commands iterator
([Quantinuum#1611](Quantinuum#1611))

### Testing

- Pin guppy version in example files, fix test
([Quantinuum#1534](Quantinuum#1534))
- Skip slow modifier test
([Quantinuum#1587](Quantinuum#1587))
- Add modifier test for subscripted control qubits
([Quantinuum#1601](Quantinuum#1601))
</blockquote>

## `tket-qsystem`

<blockquote>

##
[0.25.0](Quantinuum/tket2@tket-qsystem-v0.24.0...tket-qsystem-v0.25.0)
- 2026-05-28

### Bug Fixes

- Multiple fixes to the pytket encoder
([Quantinuum#1566](Quantinuum#1566))
- [**breaking**] Replace non-deterministic iterations on hash maps
([Quantinuum#1582](Quantinuum#1582))

### New Features

- expose the QSystemPass to Python
([Quantinuum#1556](Quantinuum#1556))
- upgrade to hugr v0.27.1
([Quantinuum#1568](Quantinuum#1568))
- [**breaking**] Ignore empty circuits when encoding Hugr regions into
pytket ([Quantinuum#1562](Quantinuum#1562))
- *(qsystem)* [**breaking**] multiple platform extensions
([Quantinuum#1567](Quantinuum#1567))

### Refactor

- [**breaking**] Deprecate commands iterator
([Quantinuum#1611](Quantinuum#1611))

### Testing

- Pin guppy version in example files, fix test
([Quantinuum#1534](Quantinuum#1534))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
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