Skip to content

feat!: Add a Measurement type as the return type for measurement functions#1707

Open
tatiana-s wants to merge 10 commits intomainfrom
ts/future-measure
Open

feat!: Add a Measurement type as the return type for measurement functions#1707
tatiana-s wants to merge 10 commits intomainfrom
ts/future-measure

Conversation

@tatiana-s
Copy link
Copy Markdown
Contributor

@tatiana-s tatiana-s commented Apr 30, 2026

Closes #1485

Requires a breaking tket release with the extension changes in #1558 before this can be merged

BREAKING CHANGE: (guppylang.std.quantum): measure (and measure_array by extension) now return Measurement instead of bool
BREAKING CHANGE: (guppylang.std.qsystem/qsystem.functional): measure and measure_reset (and by extension the array versions) now return Measurement instead of bool (this matches the behaviour of lazy_measure/lazy_measure_and_reset)
BREAKING CHANGE: (guppylang_internals): bool is now lowered to ht.Bool again instead of tket.bool

The deferred_measurement.ipynb notebook has been adjusted to explain the motivation for the lazy behaviour instead of contrasting measure and lazy_measure

@tatiana-s tatiana-s requested a review from a team as a code owner April 30, 2026 10:36
@tatiana-s tatiana-s requested a review from mark-koch April 30, 2026 10:36
@hugrbot
Copy link
Copy Markdown
Collaborator

hugrbot commented May 5, 2026

This PR contains breaking changes to the public Python API.

Breaking changes summary
guppylang/src/guppylang/std/qsystem/__init__.py:0: collect_measurements:
Public object was removed

guppylang-internals/src/guppylang_internals/definition/custom.py:0: BoolOpCompiler:
Public object was removed

guppylang-internals/src/guppylang_internals/compiler/expr_compiler.py:0: ARRAY_READ_BOOL:
Public object was removed

guppylang-internals/src/guppylang_internals/compiler/expr_compiler.py:0: ARRAY_MAKE_OPAQUE_BOOL:
Public object was removed

guppylang-internals/src/guppylang_internals/compiler/expr_compiler.py:0: array_read_bool:
Public object was removed

guppylang-internals/src/guppylang_internals/compiler/expr_compiler.py:0: array_make_opaque_bool:
Public object was removed

guppylang-internals/src/guppylang_internals/compiler/expr_compiler.py:0: apply_array_op_with_conversions:
Public object was removed

guppylang-internals/src/guppylang_internals/tys/builtin.py:214: bool_type_def:
Attribute value was changed:
Old: OpaqueTypeDef(id=(DefId.fresh()), name='bool', defined_at=None, params=[], never_copyable=False, never_droppable=False, to_hugr=(lambda args, ctx: OpaqueBool))
New: OpaqueTypeDef(id=(DefId.fresh()), name='bool', defined_at=None, params=[], never_copyable=False, never_droppable=False, to_hugr=(lambda args, ctx: ht.Bool))


@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

🐰 Bencher Report

Branchts/future-measure
TestbedLinux
Click to view all benchmark results
Benchmarkhugr_bytesBenchmark Result
bytes x 1e3
(Result Δ%)
Upper Boundary
bytes x 1e3
(Limit %)
hugr_nodesBenchmark Result
nodes
(Result Δ%)
Upper Boundary
nodes
(Limit %)
tests/benchmarks/test_big_array.py::test_big_array_compile📈 view plot
🚷 view threshold
158.28 x 1e3
(-0.31%)Baseline: 158.77 x 1e3
160.36 x 1e3
(98.71%)
📈 view plot
🚷 view threshold
6,630.00
(-0.17%)Baseline: 6,641.00
6,707.41
(98.85%)
tests/benchmarks/test_ctrl_flow.py::test_many_ctrl_flow_compile📈 view plot
🚷 view threshold
26.98 x 1e3
(-2.00%)Baseline: 27.53 x 1e3
27.81 x 1e3
(97.02%)
📈 view plot
🚷 view threshold
1,051.00
(-2.14%)Baseline: 1,074.00
1,084.74
(96.89%)
tests/benchmarks/test_queue_push_pop.py::test_queue_push_benchmark_compile📈 view plot
🚷 view threshold
10.08 x 1e3
(-7.61%)Baseline: 10.91 x 1e3
11.02 x 1e3
(91.48%)
📈 view plot
🚷 view threshold
300.00
(-2.60%)Baseline: 308.00
311.08
(96.44%)
tests/benchmarks/test_queue_push_pop.py::test_queue_push_pop_benchmark_compile📈 view plot
🚷 view threshold
13.88 x 1e3
(-6.44%)Baseline: 14.84 x 1e3
14.99 x 1e3
(92.64%)
📈 view plot
🚷 view threshold
423.00
(-2.76%)Baseline: 435.00
439.35
(96.28%)
🐰 View full continuous benchmarking report in Bencher

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 5, 2026

Congrats! CodSpeed is installed 🎉

🆕 9 new benchmarks were detected.

You will start to see performance impacts in the reports once the benchmarks are run from your default branch.

Detected benchmarks


Open in CodSpeed

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.

[Feature]: Change measure() to return a future bool

3 participants