Skip to content
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

feat!: update measurement and alloc operations #702

Merged
merged 9 commits into from
Dec 2, 2024
Merged

feat!: update measurement and alloc operations #702

merged 9 commits into from
Dec 2, 2024

Conversation

ss2165
Copy link
Member

@ss2165 ss2165 commented Nov 26, 2024

Closes #691 Closes #692 Closes #693

  • Add TryQAlloc and MeasureFree to "tket2.quantum"
  • Lower new ops to "tket2.hseries"
  • Add MeasureReset to "tket2.hseries"

BREAKING CHANGE: hseries qalloc op replaced with fallible TryQalloc

@ss2165 ss2165 added the run-ci-checks Special label to force running all checks in CI label Nov 26, 2024
Base automatically changed from ss/hugr-bump to main November 28, 2024 17:26
@ss2165 ss2165 marked this pull request as ready for review November 28, 2024 17:30
@ss2165 ss2165 requested a review from a team as a code owner November 28, 2024 17:30
@ss2165 ss2165 requested review from lmondada and cqc-alec and removed request for lmondada November 28, 2024 17:30
@hugrbot
Copy link
Collaborator

hugrbot commented Nov 28, 2024

This PR contains breaking changes to the public Rust API.

cargo-semver-checks summary

--- failure enum_no_repr_variant_discriminant_changed: enum variant had its discriminant change value ---

Description:
The enum's variant had its discriminant value change. This breaks downstream code that used its value via a numeric cast like `as isize`.
      ref: https://doc.rust-lang.org/reference/items/enumerations.html#assigning-discriminant-values
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.36.0/src/lints/enum_no_repr_variant_discriminant_changed.ron

Failed in:
variant Tk2Op::QAlloc 17 -> 18 in /home/runner/work/tket2/tket2/PR_BRANCH/tket2/src/ops.rs:61
variant Tk2Op::QFree 18 -> 20 in /home/runner/work/tket2/tket2/PR_BRANCH/tket2/src/ops.rs:63
variant Tk2Op::Reset 19 -> 21 in /home/runner/work/tket2/tket2/PR_BRANCH/tket2/src/ops.rs:64

Copy link

codecov bot commented Nov 28, 2024

Codecov Report

Attention: Patch coverage is 88.28125% with 15 lines in your changes missing coverage. Please review.

Project coverage is 82.86%. Comparing base (cf73825) to head (abaf88e).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
tket2-hseries/src/extension/hseries.rs 75.47% 0 Missing and 13 partials ⚠️
tket2-hseries/src/extension/hseries/lower.rs 95.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #702      +/-   ##
==========================================
+ Coverage   82.80%   82.86%   +0.05%     
==========================================
  Files          62       62              
  Lines        7160     7255      +95     
  Branches     6907     7000      +93     
==========================================
+ Hits         5929     6012      +83     
  Misses        868      868              
- Partials      363      375      +12     
Flag Coverage Δ
python 82.35% <100.00%> (+0.13%) ⬆️
rust 82.88% <88.09%> (+0.05%) ⬆️

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.

.unwrap()
.out_wire(0);
b.finish_hugr_with_outputs([measured], &REGISTRY).unwrap();
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel a unit test should assert something, can we add some kind of assertion about the ops contained in the hugr?

Copy link
Member Author

Choose a reason for hiding this comment

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

it is effectively asserting that it validates, but sure I can add something

tket2-hseries/src/extension/hseries.rs Outdated Show resolved Hide resolved
)
.unwrap();
let [q0, angle] = func_builder.input_wires_arr();
let q1 = func_builder.add_qalloc().unwrap();
let q1 = func_builder.build_qalloc().unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be nice if these methods were consistently named to begin with add_, rather than some beginning with build_, unless there's a significant difference?

Copy link
Member Author

Choose a reason for hiding this comment

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

add is for primitives (following other add methods in builder traits) and build is for building in terms of primitives

tket2-exts/src/tket2_exts/data/tket2/hseries.json Outdated Show resolved Hide resolved
@ss2165 ss2165 mentioned this pull request Dec 2, 2024
@ss2165 ss2165 added this pull request to the merge queue Dec 2, 2024
Merged via the queue into main with commit a7a0201 Dec 2, 2024
17 checks passed
@ss2165 ss2165 deleted the ss/newops branch December 2, 2024 12:12
github-merge-queue bot pushed a commit that referenced this pull request Dec 2, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.2.0](tket2-exts-v0.1.1...tket2-exts-v0.2.0)
(2024-12-02)


### ⚠ BREAKING CHANGES

* all references to "hseries" including extension, modules and structs
renamed to "qsystem"
* hseries qalloc op replaced with fallible TryQalloc

### Features

* update measurement and alloc operations
([#702](#702))
([a7a0201](a7a0201))


### Code Refactoring

* rename hseries to qsystem
([#703](#703))
([1e90173](1e90173))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
github-merge-queue bot pushed a commit that referenced this pull request Dec 16, 2024
## 🤖 New release
* `tket2`: 0.6.0 -> 0.7.0 (⚠️ API breaking changes)
* `tket2-hseries`: 0.6.0 -> 0.7.0 (⚠️ API breaking changes)

### ⚠️ `tket2` breaking changes

```
--- failure auto_trait_impl_removed: auto trait no longer implemented ---

Description:
A public type has stopped implementing one or more auto traits. This can break downstream code that depends on the traits being implemented.
        ref: https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.37.0/src/lints/auto_trait_impl_removed.ron

Failed in:
  type Units is no longer UnwindSafe, in /tmp/.tmpfB4eOr/tket2/tket2/src/circuit/units.rs:62
  type Units is no longer RefUnwindSafe, in /tmp/.tmpfB4eOr/tket2/tket2/src/circuit/units.rs:62

--- failure enum_missing: pub enum removed or renamed ---

Description:
A publicly-visible enum cannot be imported by its prior path. A `pub use` may have been removed, or the enum 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.37.0/src/lints/enum_missing.ron

Failed in:
  enum tket2::serialize::guppy::CircuitLoadError, previously in file /tmp/.tmphWIpmA/tket2/src/serialize/guppy.rs:114

--- failure enum_no_repr_variant_discriminant_changed: enum variant had its discriminant change value ---

Description:
The enum's variant had its discriminant value change. This breaks downstream code that used its value via a numeric cast like `as isize`.
        ref: https://doc.rust-lang.org/reference/items/enumerations.html#assigning-discriminant-values
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.37.0/src/lints/enum_no_repr_variant_discriminant_changed.ron

Failed in:
  variant Tk2Op::QAlloc 17 -> 18 in /tmp/.tmpfB4eOr/tket2/tket2/src/ops.rs:61
  variant Tk2Op::QFree 18 -> 20 in /tmp/.tmpfB4eOr/tket2/tket2/src/ops.rs:63
  variant Tk2Op::Reset 19 -> 21 in /tmp/.tmpfB4eOr/tket2/tket2/src/ops.rs:64

--- failure enum_variant_missing: pub enum variant removed or renamed ---

Description:
A publicly-visible enum has at least one variant that is no longer available under its prior name. It 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.37.0/src/lints/enum_variant_missing.ron

Failed in:
  variant CircuitLoadError::ValError, previously in file /tmp/.tmphWIpmA/tket2/src/serialize/guppy.rs:156
  variant RewriterSerialisationError::OpaqueOp, previously in file /tmp/.tmphWIpmA/tket2/src/rewrite/ecc_rewriter.rs:221

--- failure function_missing: pub fn removed or renamed ---

Description:
A publicly-visible function cannot be imported by its prior path. A `pub use` may have been removed, or the function 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.37.0/src/lints/function_missing.ron

Failed in:
  function tket2::serialize::guppy::load_guppy_json_reader, previously in file /tmp/.tmphWIpmA/tket2/src/serialize/guppy.rs:32
  function tket2::serialize::load_guppy_json_reader, previously in file /tmp/.tmphWIpmA/tket2/src/serialize/guppy.rs:32
  function tket2::serialize::guppy::load_guppy_json_str, previously in file /tmp/.tmphWIpmA/tket2/src/serialize/guppy.rs:26
  function tket2::serialize::load_guppy_json_str, previously in file /tmp/.tmphWIpmA/tket2/src/serialize/guppy.rs:26
  function tket2::serialize::guppy::load_guppy_json_file, previously in file /tmp/.tmphWIpmA/tket2/src/serialize/guppy.rs:16
  function tket2::serialize::load_guppy_json_file, previously in file /tmp/.tmphWIpmA/tket2/src/serialize/guppy.rs:16
  function tket2::serialize::guppy::find_function, previously in file /tmp/.tmphWIpmA/tket2/src/serialize/guppy.rs:58

--- failure module_missing: pub module removed or renamed ---

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

Failed in:
  mod tket2::serialize::guppy, previously in file /tmp/.tmphWIpmA/tket2/src/serialize/guppy.rs:1

--- failure pub_module_level_const_missing: pub module-level const is missing ---

Description:
A public const is missing, renamed, or changed from const to static.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.37.0/src/lints/pub_module_level_const_missing.ron

Failed in:
  ROTATION_TYPE in file /tmp/.tmphWIpmA/tket2/src/extension/rotation.rs:39
  ROTATION_CUSTOM_TYPE in file /tmp/.tmphWIpmA/tket2/src/extension/rotation.rs:35

--- 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.37.0/src/lints/struct_missing.ron

Failed in:
  struct tket2::extension::REGISTRY, previously in file /tmp/.tmphWIpmA/tket2/src/extension.rs:37
```

### ⚠️ `tket2-hseries` breaking changes

```
--- failure auto_trait_impl_removed: auto trait no longer implemented ---

Description:
A public type has stopped implementing one or more auto traits. This can break downstream code that depends on the traits being implemented.
        ref: https://doc.rust-lang.org/reference/special-types-and-traits.html#auto-traits
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.37.0/src/lints/auto_trait_impl_removed.ron

Failed in:
  type FutureOp is no longer UnwindSafe, in /tmp/.tmpfB4eOr/tket2/tket2-hseries/src/extension/futures.rs:164
  type FutureOp is no longer RefUnwindSafe, in /tmp/.tmpfB4eOr/tket2/tket2-hseries/src/extension/futures.rs:164

--- failure enum_missing: pub enum removed or renamed ---

Description:
A publicly-visible enum cannot be imported by its prior path. A `pub use` may have been removed, or the enum 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.37.0/src/lints/enum_missing.ron

Failed in:
  enum tket2_hseries::extension::hseries::HSeriesOp, previously in file /tmp/.tmphWIpmA/tket2-hseries/src/extension/hseries.rs:79
  enum tket2_hseries::extension::hseries::LowerTk2Error, previously in file /tmp/.tmphWIpmA/tket2-hseries/src/extension/hseries/lower.rs:41
  enum tket2_hseries::HSeriesPassError, previously in file /tmp/.tmphWIpmA/tket2-hseries/src/lib.rs:38

--- failure function_missing: pub fn removed or renamed ---

Description:
A publicly-visible function cannot be imported by its prior path. A `pub use` may have been removed, or the function 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.37.0/src/lints/function_missing.ron

Failed in:
  function tket2_hseries::extension::hseries::lower_tk2_op, previously in file /tmp/.tmphWIpmA/tket2-hseries/src/extension/hseries/lower.rs:113
  function tket2_hseries::extension::hseries::check_lowered, previously in file /tmp/.tmphWIpmA/tket2-hseries/src/extension/hseries/lower.rs:153

--- failure function_parameter_count_changed: pub fn parameter count changed ---

Description:
A publicly-visible function now takes a different number of parameters.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#fn-change-arity
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.37.0/src/lints/function_parameter_count_changed.ron

Failed in:
  tket2_hseries::extension::futures::future_custom_type now takes 2 parameters instead of 1, in /tmp/.tmpfB4eOr/tket2/tket2-hseries/src/extension/futures.rs:59

--- failure method_parameter_count_changed: pub method parameter count changed ---

Description:
A publicly-visible method now takes a different number of parameters.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#fn-change-arity
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.37.0/src/lints/method_parameter_count_changed.ron

Failed in:
  tket2_hseries::lazify_measure::LazifyMeasurePass::run now takes 2 parameters instead of 3, in /tmp/.tmpfB4eOr/tket2/tket2-hseries/src/lazify_measure.rs:54

--- failure module_missing: pub module removed or renamed ---

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

Failed in:
  mod tket2_hseries::extension::hseries, previously in file /tmp/.tmphWIpmA/tket2-hseries/src/extension/hseries.rs:1

--- failure pub_module_level_const_missing: pub module-level const is missing ---

Description:
A public const is missing, renamed, or changed from const to static.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.37.0/src/lints/pub_module_level_const_missing.ron

Failed in:
  EXTENSION_VERSION in file /tmp/.tmphWIpmA/tket2-hseries/src/extension/hseries.rs:38
  EXTENSION_ID in file /tmp/.tmphWIpmA/tket2-hseries/src/extension/hseries.rs:36

--- 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.37.0/src/lints/struct_missing.ron

Failed in:
  struct tket2_hseries::extension::futures::REGISTRY, previously in file /tmp/.tmphWIpmA/tket2-hseries/src/extension/futures.rs:30
  struct tket2_hseries::extension::result::REGISTRY, previously in file /tmp/.tmphWIpmA/tket2-hseries/src/extension/result.rs:36
  struct tket2_hseries::extension::hseries::LowerTket2ToHSeriesPass, previously in file /tmp/.tmphWIpmA/tket2-hseries/src/extension/hseries/lower.rs:177
  struct tket2_hseries::extension::hseries::REGISTRY, previously in file /tmp/.tmphWIpmA/tket2-hseries/src/extension/hseries.rs:40
  struct tket2_hseries::extension::hseries::HSeriesOpIter, previously in file /tmp/.tmphWIpmA/tket2-hseries/src/extension/hseries.rs:73
  struct tket2_hseries::HSeriesPass, previously in file /tmp/.tmphWIpmA/tket2-hseries/src/lib.rs:31
  struct tket2_hseries::extension::hseries::EXTENSION, previously in file /tmp/.tmphWIpmA/tket2-hseries/src/extension/hseries.rs:40

--- failure trait_missing: pub trait removed or renamed ---

Description:
A publicly-visible trait cannot be imported by its prior path. A `pub use` may have been removed, or the trait 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.37.0/src/lints/trait_missing.ron

Failed in:
  trait tket2_hseries::extension::hseries::HSeriesOpBuilder, previously in file /tmp/.tmphWIpmA/tket2-hseries/src/extension/hseries.rs:131
```

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

## `tket2`
<blockquote>

##
[0.7.0](tket2-v0.6.0...tket2-v0.7.0)
- 2024-12-16

### New Features

- [**breaking**] Track circuit extensions and read/write packages (#680)
- [**breaking**] update measurement and alloc operations (#702)

### Refactor

- [**breaking**] update to hugr 0.14 (#700)
</blockquote>

## `tket2-hseries`
<blockquote>

##
[0.7.0](tket2-hseries-v0.6.0...tket2-hseries-v0.7.0)
- 2024-12-16

### New Features

- [**breaking**] update measurement and alloc operations (#702)

### Refactor

- [**breaking**] update to hugr 0.14 (#700)
- [**breaking**] rename hseries to qsystem (#703)
</blockquote>


</p></details>

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

---------

Co-authored-by: Agustín Borgna <agustin.borgna@quantinuum.com>
github-merge-queue bot pushed a commit that referenced this pull request Dec 16, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.6.0](tket2-py-v0.5.1...tket2-py-v0.6.0)
(2024-12-16)


### ⚠ BREAKING CHANGES

* Updated `hugr` rust dependency to `0.14.0` Extension are now defined
in `hugr 0.14` style. Replaced the `ROTATION_TYPE` with a method call,
and dropped the per-extension registry definitions.
* all references to "hseries" including extension, modules and structs
renamed to "qsystem"
* hseries qalloc op replaced with fallible TryQalloc

### Features

* update measurement and alloc operations
([#702](#702))
([a7a0201](a7a0201))


### Miscellaneous Chores

* Update to next version of hugr
([#720](#720))
([4a3a5a5](4a3a5a5))


### Code Refactoring

* rename hseries to qsystem
([#703](#703))
([1e90173](1e90173))

---
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 Dec 18, 2024
github-merge-queue bot pushed a commit that referenced this pull request Dec 18, 2024
## 🤖 New release
* `tket2`: 0.7.0 -> 0.7.1 (✓ API compatible changes)
* `tket2-hseries`: 0.7.0 -> 0.7.1 (✓ API compatible changes)

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

## `tket2`
<blockquote>

##
[0.7.0](tket2-v0.6.0...tket2-v0.7.0)
- 2024-12-16

### ⚠ BREAKING CHANGES

- Removed `load_guppy_*` methods. Use `Circuit::load_function_reader`
instead.
- Extension definitions and registries now use `Arc`s for sharing

### New Features

- [**breaking**] Track circuit extensions and read/write packages (#680)
- [**breaking**] update measurement and alloc operations (#702)

### Refactor

- [**breaking**] update to hugr 0.14 (#700)
</blockquote>

## `tket2-hseries`
<blockquote>

##
[0.7.1](tket2-hseries-v0.7.0...tket2-hseries-v0.7.1)
- 2024-12-18

### New Features

- Add monomorphization and constant folding to QSystemPass (#730)
</blockquote>


</p></details>

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

---------

Co-authored-by: Agustín Borgna <agustin.borgna@quantinuum.com>
@hugrbot hugrbot mentioned this pull request Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-ci-checks Special label to force running all checks in CI
Projects
None yet
3 participants