Skip to content

feat: Add python definitions for the TKET metadata keys#1535

Merged
aborgna-q merged 6 commits into
mainfrom
ab/py-metadata
May 12, 2026
Merged

feat: Add python definitions for the TKET metadata keys#1535
aborgna-q merged 6 commits into
mainfrom
ab/py-metadata

Conversation

@aborgna-q

Copy link
Copy Markdown
Collaborator

We should also add a metadata for inline hints either here or in #1532, whichever gets merged second.

@codecov

codecov Bot commented Apr 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 69.73684% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.05%. Comparing base (54998e1) to head (ddb56dd).

Files with missing lines Patch % Lines
tket-py/tket/metadata.py 60.34% 23 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1535      +/-   ##
==========================================
- Coverage   84.09%   84.05%   -0.05%     
==========================================
  Files         188      189       +1     
  Lines       29298    29358      +60     
  Branches    28172    28174       +2     
==========================================
+ Hits        24639    24676      +37     
- Misses       3479     3502      +23     
  Partials     1180     1180              
Flag Coverage Δ
python 90.75% <61.01%> (-1.64%) ⬇️
qis-compiler 91.66% <ø> (ø)
rust 83.76% <100.00%> (+<0.01%) ⬆️

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.

@acl-cqc acl-cqc 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.

In #1449 I found myself wondering, does this not exist...so yes thank you :-) 👍.

Mostly just naming suggestions, nothing major, looks good!

Comment thread tket-py/tket/metadata.py Outdated
KEY = _metadata.CIRCUIT_REWRITE_TRACES


class Unitary(Metadata[int]):

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.

Maybe UnitaryFlags? It's definitely not a unitary (i.e. matrix) itself

Comment thread tket-py/tket/metadata.py Outdated
KEY = _metadata.INPUT_PARAMETERS


class OpGroup(Metadata[str]):

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.

Perhaps PytketOpGroup? And elsewhere in this file for other metadata relating to pytket, but there are some that are not

Comment thread tket-py/tket/metadata.py
Comment thread tket-py/tket/metadata.py Outdated
Comment thread tket-py/tket/metadata.py Outdated
Comment thread tket-py/tket/metadata.py Outdated
return _read_pytket_register(cls.KEY, value)


class Phase(Metadata[str]):

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.

PytketPhaseExpr?

Comment thread tket-py/tket/metadata.py Outdated
individual_matches: int


class MaxQubits(Metadata[int]):

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.

Should this be MaxQubitsHint?

Comment thread tket-py/tket/metadata.py Outdated
>>> node.metadata.get(QubitRegisters)
[('q', [0]), ('ancilla', [1])]
"""
# Changes to this file **MUST** be reflected in `tket/src/metadata.rs`

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.

In the sense that they ought to match, but this doesn't mean that things will break if they don't match, right? Isn't that SHOULD ?

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.

I guess this means that all of my suggested renames should be applied on the rust side too, heh

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Changed to a SHOULD. I'll do the renaming on both rust and python (with some aliases for backwards compatibility)

Comment thread tket-py/tket/metadata.py Outdated
Comment thread tket-py/tket/metadata.py Outdated
@aborgna-q aborgna-q added this pull request to the merge queue May 12, 2026
Merged via the queue into main with commit 1bfef9a May 12, 2026
23 of 24 checks passed
@aborgna-q aborgna-q deleted the ab/py-metadata branch May 12, 2026 15:40
This was referenced May 12, 2026
jpacold pushed a commit to jpacold/tket2 that referenced this pull request May 23, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.13.1](Quantinuum/tket2@tket-py-v0.13.0...tket-py-v0.13.1)
(2026-05-19)


### Features

* Add python definitions for the TKET metadata keys
([Quantinuum#1535](Quantinuum#1535))
([1bfef9a](Quantinuum@1bfef9a))
* Clean Up by Deleting Unconnected Nodes after Modifier Solve
([Quantinuum#1557](Quantinuum#1557))
([d706867](Quantinuum@d706867))
* expose the QSystemPass to Python
([Quantinuum#1556](Quantinuum#1556))
([394a610](Quantinuum@394a610))
* InlineFunctionsPass
([Quantinuum#1524](Quantinuum#1524))
([f40dcef](Quantinuum@f40dcef))
* InlineHint metadata
([Quantinuum#1532](Quantinuum#1532))
([e7949c2](Quantinuum@e7949c2))


### Bug Fixes

* Apply modifiers through function calls
([Quantinuum#1531](Quantinuum#1531))
([6a13f0c](Quantinuum@6a13f0c))
* Incorrect matching of pytket parameters to unsupported graph ports
([Quantinuum#1561](Quantinuum#1561))
([4fc5a25](Quantinuum@4fc5a25))
* Passes with Nested Modifier
([Quantinuum#1546](Quantinuum#1546))
([bf6df51](Quantinuum@bf6df51))
* Update examples link in README.md
([Quantinuum#1506](Quantinuum#1506))
([9a25ec8](Quantinuum@9a25ec8))


### Documentation

* Simplify package description.
([Quantinuum#1547](Quantinuum#1547))
([54e855f](Quantinuum@54e855f))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: Agustín Borgna <agustin.borgna@quantinuum.com>
@hugrbot hugrbot mentioned this pull request Jun 1, 2026
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