Skip to content

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

@cqc-alec

Description

@cqc-alec

Problem Statement

At runtime, measurements (and any quantum gates preceding them) are only actually performed when the result is needed. The real result of a measurement operation is a future bool, which can later be read to instantiate the value. We want these semantics to be reflected in guppy.

Proposed Solution

We should therefore make the return type of measure() a new type (e.g. MeasureResult, or just Measurement?) with a read() method. We can implement __bool__() on this type as syntactic sugar for read() (so that code like if measure(q) will continue to work as before).

We may want to introduce more general Future[T] types when implementing this. (EDIT: This already exists.)

Component

Guppy Compiler

Effort Estimate

Hard - Significant effort required

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: A feature requestS-breaking-changeStatus: Need a breaking change release to progressS-needs-triageStatus: Needs to be labelled

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions