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
QEngine.get_measured() does not work when a QASM file is executed. #119
Comments
@DevelopDaily the measurements in OpenQASM are non-destructive. So, if you look at the circuit, |
Would it be helpful to see a list of the non-destructively measured qudits as well? The problem with that is that if you do e.g. |
Thanks for the clarifications, @vsoftco. I am not sure of the best approach to resolve the issue. I'd like to present my use case and hope to get some advice from you. The qpp may already have the feature I need. I run a Shor circuit (N=15, a=7) in QASM with 11 qubits and 8 classical bits. At the end, only the values in those 8 classical bits measured out of the inverse QFT are interesting. The qpp used to produce the values stored in the
The JSON structure does not tell me which 8 bits are my measurements. In QISKIT, the same Shor circuit produces something as follows. Does the qpp have something similar to the QISKIT |
One way of doing this is
Run with You'll also see the stats in the JSON file (so no real need to run the code above) I'll still think about an alternative solution to the non-destructive measurements |
Here is a test script:
The output of the code (repetitions of the engine = 100) you suggested:
That does not seem to tell me which four bits are the classical bits. I would have to use other tools to track the |
I see, you get the stats (and the measured ones only if they're measured destructively). We'll think of a solution... |
@DevelopDaily I pushed a quick fix, see 2f7c7c8 Basically, you can now choose destructive measurements in OpenQASM2 as a cmake option, via the I wonder if we should keep the flag |
Up to this point, the original problem I reported should be considered fixed. The subsequent discussions are about the new problem(s) that may have been introduced by the fix. Sorry for the confusions. |
Not very happy also with this solution, since many openqasm files allow for re-using qubits after measurement, like https://github.com/softwareQinc/qpp/blob/main/qasmtools/qasm/generic/ipea_3_pi_8.qasm So this won't execute on qpp if |
I see, you also want to know where (in those classical dits) the measurement results are being sent. Let's keep this open, and we'll fix (one way or another) soon |
@DevelopDaily One question: doesn't the |
Also, try |
I have corrected mistakes in some of my previous posts. Now, I think there are two related problems. The first one has been introduced by the fix. If the " Here is the second one. Not sure if it was introduced by the fix. Perhaps not. The
My hunch is that #120 may be the root cause of my trouble with the measurement results I presented here. I would be able to answer your questions better after the #120 is resolved. |
adding @meamy |
@DevelopDaily I've implemented 2 utility member functions,
Run with
|
Fixed also #120 , so let us know how it works now |
Awesome. Thanks! Everything works as expected now. It turns out I wouldn't have opened this issue if the issue #120 had not existed. That being said, this issue has led to some interesting discussions. Thanks for giving me a free brain workout:-) Sorry my first analysis misled you and myself. In hindsight, everything is crystal clear. When an 8 classical bit Shor circuit produces an 11 element Now, if I were you, I would revert 2f7c7c8 you mentioned above, because the OpenQASM feature ( Since #120 is fixed, my answers to your questions are unimportant now. But, I answer them anyway:
The (new/fixed) binary representation is what I want. Qiskit I cannot and do not need to retrieve those values from Qiskit. My original thought is wrong. All the answers have been taken care of by the #120. |
@DevelopDaily We reverted 2f7c7c8 , that is, there's no more destructive measurement choice in OpenQASM2, since (as we had it from beginning), the standard doesn't specify it. If those address all your issues, feel free to close this one. |
Perfect. Thanks. |
@DevelopDaily We've implemented some more utility functions that solve this issue more elegantly, please see https://github.com/softwareQinc/qpp/blob/main/CHANGES |
Here is a test script:
I load it to run in the
QEngine
by using the example programqpp_qasm
(which is appended with a few lines to runget_measured()
), but theget_measured()
returns an empty vector.For that matter, the
QEngine.to_JSON()
does not contain any information of the existence of themeasure
statement either.Did I miss something? I remember I could get the info about the
measure
statement in a QASM file from the engine a year ago. I guess things have changed. What should I do now to get that info?The text was updated successfully, but these errors were encountered: