Skip to content

feat: Add emitters for tket-qsystem #1039

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 5 commits into from
Aug 15, 2025
Merged

feat: Add emitters for tket-qsystem #1039

merged 5 commits into from
Aug 15, 2025

Conversation

aborgna-q
Copy link
Collaborator

@aborgna-q aborgna-q commented Aug 15, 2025

Implements encoder/decoders for the tket.qsystem and tket.futures extensions.

Currently I'm only translating PhasedX, ZZPhase and ZZMax from pytket, as those are the operations that can be represented directly with QSystemOps.
Should we include more?

Copy link

codecov bot commented Aug 15, 2025

Codecov Report

❌ Patch coverage is 76.66667% with 42 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.45%. Comparing base (6a1e604) to head (aec22d1).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
tket-qsystem/src/pytket/qsystem.rs 65.75% 22 Missing and 3 partials ⚠️
tket-qsystem/src/pytket/futures.rs 69.23% 11 Missing and 1 partial ⚠️
tket-qsystem/src/pytket/tests.rs 90.90% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1039      +/-   ##
==========================================
- Coverage   78.47%   78.45%   -0.02%     
==========================================
  Files          98      102       +4     
  Lines       12461    12641     +180     
  Branches    12182    12362     +180     
==========================================
+ Hits         9779     9918     +139     
- Misses       2035     2072      +37     
- Partials      647      651       +4     
Flag Coverage Δ
python 81.00% <ø> (ø)
rust 78.40% <76.66%> (-0.02%) ⬇️

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.

@aborgna-q aborgna-q force-pushed the ab/decoder-qsystem branch 4 times, most recently from f8f71f0 to 6a8c187 Compare August 15, 2025 15:00
Base automatically changed from ab/decoder-extension to main August 15, 2025 15:05
@aborgna-q aborgna-q requested a review from cqc-alec August 15, 2025 15:18
@aborgna-q aborgna-q marked this pull request as ready for review August 15, 2025 15:18
@aborgna-q aborgna-q requested a review from a team as a code owner August 15, 2025 15:18
Comment on lines 63 to 64
QSystemOp::LazyMeasureReset => PytketOptype::Measure,
QSystemOp::MeasureReset => PytketOptype::Measure,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if these are right -- pytket Measure doesn't necessarily imply Reset. Also not sure if it matters.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right. It should probable be translated into two commands.
There's no utility to write that quickly yet, so I'll leave them as unsupported for now.

for (key, value) in &perm {
let valid_qubits = circ.qubits.contains(&register::Qubit::from(key.clone()))
&& circ.qubits.contains(&register::Qubit::from(value.clone()));
let valid_bits = circ.bits.contains(&register::Bit::from(key.clone()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

The implicit permutation should contain qubits only, no bits.

@aborgna-q aborgna-q requested a review from cqc-alec August 15, 2025 16:03
@aborgna-q aborgna-q added this pull request to the merge queue Aug 15, 2025
Merged via the queue into main with commit 5514164 Aug 15, 2025
20 checks passed
@aborgna-q aborgna-q deleted the ab/decoder-qsystem branch August 15, 2025 16:16
@hugrbot hugrbot mentioned this pull request Aug 15, 2025
github-merge-queue bot pushed a commit that referenced this pull request Aug 18, 2025
Depends on #1039

- Adds an optional config parameter to all the `load_tk1` / `save_tk1`
utilities, so we don't use the default by mistake.
- Uses the new qsystem encoder/decoders in `tket-py`, so now we can load
`ZZMax`/`ZZPhase`/`PhasedX`

BREAKING CHANGE: Added encode/decode config arguments to pytket
load/store utilities

This is not a breaking change for the python lib, so I'll override the
flag for release-please:

BEGIN_COMMIT_OVERRIDE

feat: Support qsystem native operations when loading pytket circuits 

END_COMMIT_OVERRIDE
github-merge-queue bot pushed a commit that referenced this pull request Aug 18, 2025
## 🤖 New release

* `tket`: 0.13.2 -> 0.14.0 (✓ API compatible changes)
* `tket-qsystem`: 0.18.1 -> 0.19.0 (✓ API compatible changes)

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

## `tket`

<blockquote>

##
[0.14.0](tket-v0.13.2...tket-v0.14.0)
- 2025-08-18

### New Features

- [**breaking**] Allow PytketTypeTranslators to translate nested types
([#1038](#1038))
- Define a wire tracker for the new pytket decoder
([#1036](#1036))
- [**breaking**] Reworked pytket decoder framework
([#1030](#1030))
- [**breaking**] Use qsystem encoder/decoders in tket-py
([#1041](#1041))
- [**breaking**] Avoid eagerly cloning SerialCircuits when decoding from
pytket ([#1048](#1048))

### Refactor

- [**breaking**] Rename tk2 encoder names to tket
([#1037](#1037))
</blockquote>

## `tket-qsystem`

<blockquote>

##
[0.19.0](tket-qsystem-v0.18.1...tket-qsystem-v0.19.0)
- 2025-08-18

### New Features

- Add emitters for tket-qsystem
([#1039](#1039))
- [**breaking**] Avoid eagerly cloning SerialCircuits when decoding from
pytket ([#1048](#1048))
</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