-
Notifications
You must be signed in to change notification settings - Fork 1
predicates for MeasurementResult #599
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
Changes from 12 commits
600a48a
62769e7
e4acbca
24665b9
b48128e
1ebd3ba
1470029
57eeead
644d0dc
d96905d
db556de
78a1a37
165c4a8
a14dba9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| from enum import Enum | ||
| from typing import final | ||
| from dataclasses import dataclass | ||
|
|
||
|
|
@@ -8,8 +9,15 @@ | |
| SimpleMeetMixin, | ||
| ) | ||
|
|
||
|
|
||
| class Predicate(Enum): | ||
| IS_ZERO = 1 | ||
| IS_ONE = 2 | ||
| IS_LOST = 3 | ||
|
|
||
|
|
||
| # Taken directly from Kai-Hsin Wu's implementation | ||
| # with minor changes to names and addition of CanMeasureId type | ||
| # with minor changes to names | ||
|
|
||
|
|
||
| @dataclass | ||
|
|
@@ -57,18 +65,25 @@ def is_subseteq(self, other: MeasureId) -> bool: | |
|
|
||
| @final | ||
| @dataclass | ||
| class MeasureIdBool(MeasureId): | ||
| class RawMeasureId(MeasureId): | ||
| idx: int | ||
|
|
||
| def is_subseteq(self, other: MeasureId) -> bool: | ||
| if isinstance(other, MeasureIdBool): | ||
| if isinstance(other, RawMeasureId): | ||
| return self.idx == other.idx | ||
| return False | ||
|
|
||
|
|
||
| # Might be nice to have some print override | ||
| # here so all the CanMeasureId's/other types are consolidated for | ||
| # readability | ||
| @final | ||
| @dataclass | ||
| class MeasureIdBool(MeasureId): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so, I did a
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wait, is this PR a backport candidate anyway? I guess so, right? Please add the label :)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this should be backported ): Now that I think about this would definitely be something of a breaking change because on the SquinToStim side I've now gone ahead and enforced the following syntax to be necessary: qs = squin.qalloc(5)
ms = squin.broadcast.measure(qs)
one_meas_result = squin.is_one(ms[0])
if one_meas_result:
squin.x(qs[1])
# This can become:
# CX rec[-1] 1Whereas historically you didn't need |
||
| idx: int | ||
| predicate: Predicate | ||
|
|
||
| def is_subseteq(self, other: MeasureId) -> bool: | ||
| if isinstance(other, MeasureIdBool): | ||
| return self.predicate == other.predicate and self.idx == other.idx | ||
| return False | ||
|
|
||
|
|
||
| @final | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,7 @@ | ||
| from bloqade.qubit.stdlib.broadcast import ( | ||
| reset as reset, | ||
| is_one as is_one, | ||
| is_lost as is_lost, | ||
| is_zero as is_zero, | ||
| measure as measure, | ||
| ) |
Uh oh!
There was an error while loading. Please reload this page.