Skip to content

fix: Always load parameter expressions as half turns in the decoder#1083

Merged
aborgna-q merged 3 commits intomainfrom
ab/fix-zz-max
Aug 29, 2025
Merged

fix: Always load parameter expressions as half turns in the decoder#1083
aborgna-q merged 3 commits intomainfrom
ab/fix-zz-max

Conversation

@aborgna-q
Copy link
Collaborator

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

  • Fixes ZZMax being lowered as a ZZPhase(𝛑/2) instead of ZZPhase(1/2).
  • Renames (via deprecation) PytketDecoder::load_parameter to PytketDecoder::load_half_turns to properly convey it's behaviour.

BEGIN_COMMIT_OVERRIDE

fix: Incorrect ZZMax decoding from pytket (#1083)

END_COMMIT_OVERRIDE

@aborgna-q aborgna-q requested a review from ss2165 August 29, 2025 08:32
@aborgna-q aborgna-q requested a review from a team as a code owner August 29, 2025 08:32
@codecov
Copy link

codecov bot commented Aug 29, 2025

Codecov Report

❌ Patch coverage is 91.30435% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.06%. Comparing base (bc9f363) to head (05ef434).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
tket/src/serialize/pytket/decoder.rs 87.50% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1083      +/-   ##
==========================================
- Coverage   79.14%   79.06%   -0.08%     
==========================================
  Files         115      115              
  Lines       13390    13397       +7     
  Branches    12608    12615       +7     
==========================================
- Hits        10597    10592       -5     
- Misses       2139     2150      +11     
- Partials      654      655       +1     
Flag Coverage Δ
python 92.83% <ø> (ø)
rust 78.20% <91.30%> (-0.09%) ⬇️

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 on lines +687 to +690
/// * `type_hint` - A hint for the type of the parameter we want to load.
/// This lets us decide between using [`ConstRotation`] and [`ConstF64`]
/// for constants. The actual returned type may be different.
pub fn load_half_turns_parameter(
Copy link
Collaborator Author

@aborgna-q aborgna-q Aug 29, 2025

Choose a reason for hiding this comment

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

If we remove the type hints here and, e.g. load always as floats, then the badger pass fails since it's not expecting having to optimize constF4 -> Rotation::from_halfturns before running.

It also leads to unnecessary boilerplate.

@@ -725,7 +727,8 @@ impl WireTracker {
PytketParam::InputVariable { name } => {
// Special case for the name "pi": inserts a `ConstRotation(PI)` instead.
match (name, type_hint) {
Copy link
Member

Choose a reason for hiding this comment

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

is this comment still accurate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed to "inserts a constant"

@aborgna-q aborgna-q added this pull request to the merge queue Aug 29, 2025
@aborgna-q aborgna-q removed this pull request from the merge queue due to a manual request Aug 29, 2025
@aborgna-q aborgna-q enabled auto-merge August 29, 2025 08:58
@aborgna-q aborgna-q added this pull request to the merge queue Aug 29, 2025
Merged via the queue into main with commit 4752663 Aug 29, 2025
20 checks passed
@aborgna-q aborgna-q deleted the ab/fix-zz-max branch August 29, 2025 09:05
github-merge-queue bot pushed a commit that referenced this pull request Aug 29, 2025
🤖 I have created a release *beep* *boop*
---


##
[0.12.6](tket-py-v0.12.5...tket-py-v0.12.6)
(2025-08-29)


### Bug Fixes

* Incorrect ZZMax decoding from pytket
([#1083](#1083))
([4752663](4752663))

---
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 Aug 29, 2025
@hugrbot hugrbot mentioned this pull request Sep 15, 2025
github-merge-queue bot pushed a commit that referenced this pull request Sep 15, 2025
## 🤖 New release

* `tket`: 0.14.0 -> 0.15.0 (✓ API compatible changes)
* `tket-qsystem`: 0.20.1 -> 0.21.0 (✓ API compatible changes)

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

## `tket`

<blockquote>

##
[0.15.0](tket-v0.14.0...tket-v0.15.0)
- 2025-09-15

### Bug Fixes

- [**breaking**] Fix rotation -> float param type conversion
([#1061](#1061))
- Pytket barrier operations not being decoded
([#1069](#1069))
- Always load parameter expressions as half turns in the decoder
([#1083](#1083))
- Move attribute to come after all the cases.
([#1112](#1112))

### New Features

- Capture pytket's output permutation explicitly in the hugr
connectivity ([#1075](#1075))
- Add ResourceScope ([#1052](#1052))
- [**breaking**] Remove unnecessary Arc from PytketDecoder method
([#1114](#1114))
- [**breaking**] Remove deprecated definitions
([#1113](#1113))
</blockquote>

## `tket-qsystem`

<blockquote>

##
[0.21.0](tket-qsystem-v0.20.1...tket-qsystem-v0.21.0)
- 2025-09-15

### Bug Fixes

- [**breaking**] Fix rotation -> float param type conversion
([#1061](#1061))
- Pytket barrier operations not being decoded
([#1069](#1069))
- *(qystem)* fix angle bug in CZ decomposition
([#1080](#1080))
- Always load parameter expressions as half turns in the decoder
([#1083](#1083))

### New Features

- Add a `borrow_array` type replacement pass
([#975](#975))
- Add gpu module ([#1090](#1090))
- [**breaking**] Remove unnecessary Arc from PytketDecoder method
([#1114](#1114))
- [**breaking**] Remove deprecated definitions
([#1113](#1113))

### Refactor

- [**breaking**] Factor out wasm extension code into compute module
([#1089](#1089))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).

---------

Co-authored-by: Agustín Borgna <121866228+aborgna-q@users.noreply.github.com>
Co-authored-by: Alec Edgington <54802828+cqc-alec@users.noreply.github.com>
@hugrbot hugrbot mentioned this pull request Sep 16, 2025
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