-
Notifications
You must be signed in to change notification settings - Fork 9
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
Support arithmetic on measurement results #10
Comments
Hello @rmshaffer, thank you for adding this issue to UnitaryHack! I am trying to tackle this as part of the challenge. I have a quick question: if I understand correctly, a call to Instead of using a call to
Thank you for your time! |
@abidart Thanks, this is a very good point. So the AutoQASM/AutoGraph model for this would be to: This allows keeping the Pythonic syntax (where the user can just code as if they are dealing with native Python types), but also keeps the implementation code clean and doesn't force us to write a custom Let me know if I can clarify any of this - although this change might touch several files, there should hopefully be enough existing examples to follow. |
Thank you very much! I have a follow-up question. In the current AQ version,
compiles to:
I am trying to get
Also, the original three lines still compile to the same instructions and all unit tests pass ( Do you think I should move the transformer to (or towards) the end of the transformer calls? Otherwise, given that I followed the steps from your previous message, do the instructions resulting from the operator
converter
Thanks again for your time and patience 🙏 |
Hey @abidart, thanks for looking into this! The easiest way for me to help would be if you push your changes to a branch or even open a draft PR here so that I can easily pull your code and run it - would you mind doing that? |
I just opened a draft PR! |
@abidart Thanks! I've left a few comments on the PR, we can continue the discussion there. |
Users may commonly want to do arithmetic on measurement results (for example: syndrome calculation in quantum error correction). Today
measure()
returns aBitVar
which cannot be operated on without explicitly casting toIntVar
, like:We should make this easier so that users can simply do something like:
which implicitly does the same thing as above.
As a bonus, we should also allow conversion of a
BitVar
register to anIntVar
simply by using a Pythonic conversion toint
, such as:which is an even simpler way to express the same as above.
The text was updated successfully, but these errors were encountered: