Skip to content

Conversation

@ss2165
Copy link
Member

@ss2165 ss2165 commented May 7, 2025

Closes #853
Closes #865

Blocked by hugr release including InsertCut

Barriers exist across arbitrary types.
To make sure scheduling respects this at runtime, when lowering we follow it with a RuntimeBarrier across a generically sized array of qubits.

To do this the lowering unpacks qubits from the barrier type row, applies the runtime barrier, then repacks them in to the original types.

Arrays and tuples containing qubits are recursively unpacked.

Sums of qubits are ignored except in the special case of arrays of option of qubits, wherein it is assumed all qubits are present (when generated by guppy this is guaranteed).

For each concrete container type a temporary extension is used to add unpacking and re-packing operations. These are later lowered to calls to functions that implement the operations.

BREAKING CHANGE: QSystemOpBuilder gained supertrait ArrayOpBuilder

} else if let Some((size, elem_ty)) = ty.as_extension().and_then(array_args) {
// Special case for Option[Qubit] since it is used in guppy qubit arrays.
// Fragile - would be better with dedicated guppy array type.
// Not sure how this can be improved without runtime barrier being able to
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe worth making an issue for this?

Copy link
Member Author

Choose a reason for hiding this comment

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

Base automatically changed from update-hugr-202505 to main May 16, 2025 14:01
@ss2165 ss2165 enabled auto-merge May 16, 2025 16:46
@hugrbot
Copy link
Collaborator

hugrbot commented May 16, 2025

This PR contains breaking changes to the public Rust API.

cargo-semver-checks summary

--- failure trait_added_supertrait: non-sealed trait added new supertraits ---

Description:
A non-sealed trait added one or more supertraits, which breaks downstream implementations of the trait
      ref: https://doc.rust-lang.org/cargo/reference/semver.html#generic-bounds-tighten
     impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.41.0/src/lints/trait_added_supertrait.ron

Failed in:
trait tket2_hseries::extension::qsystem::QSystemOpBuilder gained ArrayOpBuilder in file /home/runner/work/tket2/tket2/PR_BRANCH/tket2-hseries/src/extension/qsystem.rs:221

@ss2165 ss2165 disabled auto-merge May 16, 2025 16:49
@ss2165 ss2165 changed the title feat(tket2-hseries): insert RuntimeBarrier across qubits in a Barrier feat(tket2-hseries)!: insert RuntimeBarrier across qubits in a Barrier May 16, 2025
@ss2165 ss2165 added this pull request to the merge queue May 19, 2025
Merged via the queue into main with commit 6bcc9d6 May 19, 2025
18 checks passed
@ss2165 ss2165 deleted the ss/barr branch May 19, 2025 12:43
This was referenced May 19, 2025
github-merge-queue bot pushed a commit that referenced this pull request May 22, 2025
🤖 I have created a release *beep* *boop*
---


##
[0.8.0](tket2-exts-v0.7.0...tket2-exts-v0.8.0)
(2025-05-22)


### ⚠ BREAKING CHANGES

* (`tket2.bool` extension) `BoolOp::bool_to_sum` / `BoolOp::sum_to_bool`
renamed to `BoolOp::read` / `BoolOp::make_opaque` `Tk2Op::MeasureFree`
now returns a `tket2.bool` (`tket2-hseries.qsystem` extension)
`QSystemOp:Measure` and `QSystemOp:MeasureReset` now return
`tket2.bool`s
* **tket2-hseries:** `QSystemOpBuilder` gained supertrait
`ArrayOpBuilder`

### Features

* Add `ReplaceBoolPass`
([#854](#854))
([5ae0ab9](5ae0ab9))
* **tket2-hseries:** insert RuntimeBarrier across qubits in a Barrier
([#866](#866))
([6bcc9d6](6bcc9d6))

---
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: Seyon Sivarajah <[email protected]>
github-merge-queue bot pushed a commit that referenced this pull request May 22, 2025
## 🤖 New release

* `tket2`: 0.10.0 -> 0.11.0 (✓ API compatible changes)
* `tket2-hseries`: 0.13.0 -> 0.14.0 (⚠ API breaking changes)

### ⚠ `tket2-hseries` breaking changes

```text
--- 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.41.0/src/lints/enum_missing.ron

Failed in:
  enum tket2_hseries::lazify_measure::LazifyMeasurePassError, previously in file /tmp/.tmpd3CB3X/tket2-hseries/src/lazify_measure.rs:63
  enum tket2_hseries::lazify_measure::LazifyMeasureRewrite, previously in file /tmp/.tmpd3CB3X/tket2-hseries/src/lazify_measure.rs:110

--- 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.41.0/src/lints/enum_variant_missing.ron

Failed in:
  variant QSystemPassError::LazyMeasureError, previously in file /tmp/.tmpd3CB3X/tket2-hseries/src/lib.rs:58

--- 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.41.0/src/lints/function_missing.ron

Failed in:
  function tket2_hseries::lazify_measure::replace_measure_ops, previously in file /tmp/.tmpd3CB3X/tket2-hseries/src/lazify_measure.rs:79

--- 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.41.0/src/lints/module_missing.ron

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

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

Failed in:
  struct tket2_hseries::lazify_measure::LazifyMeasurePass, previously in file /tmp/.tmpd3CB3X/tket2-hseries/src/lazify_measure.rs:46

--- failure trait_added_supertrait: non-sealed trait added new supertraits ---

Description:
A non-sealed trait added one or more supertraits, which breaks downstream implementations of the trait
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#generic-bounds-tighten
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.41.0/src/lints/trait_added_supertrait.ron

Failed in:
  trait tket2_hseries::extension::qsystem::QSystemOpBuilder gained ArrayOpBuilder in file /tmp/.tmpYKdcGW/tket2/tket2-hseries/src/extension/qsystem.rs:222
```

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

## `tket2`

<blockquote>

##
[0.11.0](tket2-v0.10.0...tket2-v0.11.0)
- 2025-05-22

### New Features

- [**breaking**] Add `ReplaceBoolPass`
([#854](#854))

### Refactor

- Use black_box from standard library.
([#878](#878))
</blockquote>

## `tket2-hseries`

<blockquote>

##
[0.14.0](tket2-hseries-v0.13.0...tket2-hseries-v0.14.0)
- 2025-05-22

### Bug Fixes

- *(tket2-hseries)* ensure deterministic lowering using maps
([#884](#884))

### New Features

- *(tket2-hseries)* [**breaking**] insert RuntimeBarrier across qubits
in a Barrier ([#866](#866))
- [**breaking**] Add `ReplaceBoolPass`
([#854](#854))
- *(tket2-hseries)* Remove `static_array<tket2.bool>` before
`replace_bool`ing. ([#885](#885))

### Refactor

- *(tket2-hseries)* use smaller angle decompositions for CZ and CCX
([#883](#883))
</blockquote>


</p></details>

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

---------

Co-authored-by: Seyon Sivarajah <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(hseries): Insert runtime barriers on qubits hseries: use NodeTemplate for lowering

7 participants