feat!: Use borrow_array instead of value_array for array lowering#1166
Merged
feat!: Use borrow_array instead of value_array for array lowering#1166
borrow_array instead of value_array for array lowering#1166Conversation
borrow_array instead of value_array for array loweringborrow_array instead of value_array for array lowering
tatiana-s
commented
Sep 3, 2025
guppylang-internals/src/guppylang_internals/std/_internal/compiler/array.py
Show resolved
Hide resolved
…op) - break*2" This reverts commit f284ad6fc62b531474033d2a4b96a886569d232d.
Collaborator
|
This PR contains breaking changes to the public Python API. Breaking changes summary |
Contributor
Contributor
|
| Branch | ts/borrow-arrays |
| Testbed | Linux |
🚨 2 Alerts
| Benchmark | Measure Units | View | Benchmark Result (Result Δ%) | Upper Boundary (Limit %) |
|---|---|---|---|---|
| tests/benchmarks/test_big_array.py::test_big_array_compile | hugr_nodes nodes x 1e3 | 📈 plot 🚷 threshold 🚨 alert (🔔) | 6.59 x 1e3(+33.89%)Baseline: 4.92 x 1e3 | 4.97 x 1e3 (132.56%) |
| tests/benchmarks/test_big_array.py::test_big_array_compile | hugr_bytes bytes x 1e3 | 📈 plot 🚷 threshold 🚨 alert (🔔) | 135.90 x 1e3(+5.14%)Baseline: 129.26 x 1e3 | 130.55 x 1e3 (104.10%) |
Click to view all benchmark results
| Benchmark | hugr_bytes | Benchmark Result bytes x 1e3 (Result Δ%) | Upper Boundary bytes x 1e3 (Limit %) | hugr_nodes | Benchmark Result nodes (Result Δ%) | Upper Boundary nodes (Limit %) |
|---|---|---|---|---|---|---|
| tests/benchmarks/test_big_array.py::test_big_array_compile | 📈 view plot 🚷 view threshold 🚨 view alert (🔔) | 135.90 x 1e3(+5.14%)Baseline: 129.26 x 1e3 | 130.55 x 1e3 (104.10%) | 📈 view plot 🚷 view threshold 🚨 view alert (🔔) | 6,590.00(+33.89%)Baseline: 4,922.06 | 4,971.28 (132.56%) |
| tests/benchmarks/test_ctrl_flow.py::test_many_ctrl_flow_compile | 📈 view plot 🚷 view threshold | 19.77 x 1e3(-9.85%)Baseline: 21.92 x 1e3 | 22.14 x 1e3 (89.26%) | 📈 view plot 🚷 view threshold | 606.00(-12.24%)Baseline: 690.51 | 697.42 (86.89%) |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1166 +/- ##
==========================================
- Coverage 93.50% 93.44% -0.06%
==========================================
Files 123 123
Lines 11522 11432 -90
==========================================
- Hits 10774 10683 -91
- Misses 748 749 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This was referenced Oct 20, 2025
acl-cqc
added a commit
that referenced
this pull request
Oct 21, 2025
github-merge-queue bot
pushed a commit
that referenced
this pull request
Oct 21, 2025
Part of quantinuum-dev/hugrverse#175 depends on: - Quantinuum/tket2#1170 - #1166
github-merge-queue bot
pushed a commit
that referenced
this pull request
Oct 22, 2025
fixes #1306 The first part of the fix is to make affine-bounded type parameters (declared `[T : Drop]`) compile to Hugr TypeParams bounded by linear rather than Copyable; this fixes the error in the issue (invalid instantiation of Copyable-bounded function with type-arg `borrow_array<....>`), but raises a different problem: guppy does not insert the necessary `drop` operations, thus leading to `UnconnectedPort` validation errors (as the ports are now linear). This was because the `requires_drop` function used when inserting drops (#1090) inspects the `hugr_bound` property of type variables which also needs updating that affine-in-guppy things should become linear-in-Hugr. In this area, update some docs (RIP equatable), refactor using `super()`, and standardize use of `ht` for `hugr.tys`. Note that (contrary to python-semver-checks) this is not breaking: the APIs removed (optional extra parameter to TypeParam, and settable TypeParam::is_affine field) were only added in #1166, which has not yet been released.
github-merge-queue bot
pushed a commit
that referenced
this pull request
Oct 29, 2025
🤖 I have created a release *beep* *boop* --- ## [0.25.0](guppylang-internals-v0.24.0...guppylang-internals-v0.25.0) (2025-10-28) ### ⚠ BREAKING CHANGES * (guppy-internals) Arrays are now lowered to `borrow_array`s instead of `value_array`s so elements do no longer need to be wrapped in options during lowering. * `checker.core.requires_monomorphization` renamed into `require_monomorphization` and now operating on all parameters simultaneously `tys.subst.BoundVarFinder` removed. Instead, use the new `bound_vars` property on types, arguments, and consts. `tys.parsing.parse_parameter` now requires a `param_var_mapping`. ### Features * compiler for modifiers ([#1287](#1287)) ([439ff1a](439ff1a)) * modifiers in CFG and its type checker (experimental) ([#1281](#1281)) ([fe85018](fe85018)) * Turn type parameters into dependent telescopes ([#1154](#1154)) ([b56e056](b56e056)) * update hugr, tket-exts and tket ([#1305](#1305)) ([6990d85](6990d85)) * Use `borrow_array` instead of `value_array` for array lowering ([#1166](#1166)) ([f9ef42b](f9ef42b)) ### Bug Fixes * compilation of affine-bounded type variables ([#1308](#1308)) ([49ecb49](49ecb49)) * Detect unsolved generic parameters even if they are unused ([#1279](#1279)) ([f830db0](f830db0)), closes [#1273](#1273) * Fix bug in symbolic pytket circuit loading with arrays ([#1302](#1302)) ([e6b90e8](e6b90e8)), closes [#1298](#1298) * Improve track_hugr_side_effects, adding Order edges from/to Input/Output ([#1311](#1311)) ([3c6ce7a](3c6ce7a)) * multiline loop arguments ([#1309](#1309)) ([836ef72](836ef72)) --- 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 <seyon.sivarajah@quantinuum.com>
github-merge-queue bot
pushed a commit
that referenced
this pull request
Oct 30, 2025
🤖 I have created a release *beep* *boop* --- ## [0.21.6](guppylang-v0.21.5...guppylang-v0.21.6) (2025-10-29) ### Features * implement str() for PartialVector ([d85efc9](d85efc9)), closes [#1225](#1225) * **qsystem:** add `RNG.random_advance()` ([#1295](#1295)) ([f6271a2](f6271a2)) * Use `borrow_array` instead of `value_array` for array lowering ([#1166](#1166)) ([f9ef42b](f9ef42b)) --- 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 <seyon.sivarajah@quantinuum.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1072
BREAKING CHANGE: (guppy-internals) Arrays are now lowered to
borrow_arrays instead ofvalue_arrays so elements do no longer need to be wrapped in options during lowering.Requires a tket2 release with Quantinuum/tket2#975 for the execution tests to passRequires a hugr-llvm release for the lowering + hugr with copy discard handler + tket2 with adjustments + hugr-qis compiler with adjustments