-
Notifications
You must be signed in to change notification settings - Fork 1
Loading and running QASM2 files in Bloqade via PyQrack gives None
#262
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
Comments
At some point we had the first option implemented but it got removed in #242
This isn't modifying the return type because in QASM2 there is only a global scope while here we're mapping that global scope into a function scope so we have the freedom to return something if we want.
I am not sure what you mean here, the IR is already mutable. |
I think this is tricky, but we do decide to add back the support of inserting a return value that was removed in #242 I think @david-pl proposed the use case where one wants to return a classical register. Was there an issue tracking this? or not yet?
What's the use case? |
I'm confused: it seems that @johnzl-777 is still using the old API, which is on the latest release (v0.2.3). That's fine, since it's the one which was used for the hackathon. But: that one still has the You can just do The kwarg has been removed by @Roger-luo in the in the new API that is |
You're quite right, that is definitely still there and works on my end. Would have saved a great deal of pain during the hackathon, I accept responsibility for not seeing this functionality earlier. I know there's plenty of conversation about improving documentation, I feel like this is definitely something worth making very explicit when we get there.
I admit I didn't have something concrete, in fact I remember some issue (I can't seem to find it) that probably covers the use case I'm thinking of where you have some gates in your program you want to quickly replace with some other gate (say, take all instances of Hadamard and plug in Sqrt(Y)). I know we think of it as a rewrite on the SSA level but I wonder if there would be any benefit having an API on a higher level for users that don't want to touch the SSA IR and only want to deal with QASM2. For example, cirq has "transformers" (https://quantumcomputing.stackexchange.com/a/24069) that fall in line with what I was thinking of. At this case this is probably a separate issue and I don't feel too strongly about the matter (as of yet, at least). I only thought about this because I thought there would have to be some clever rewrite to do what I wanted to fix this issue but as David points out, it's been sitting under my nose the whole time 😅 I think the issue is addressed, perhaps some sub-issues might be worth it to remind us to make the |
I think having some rewrite rule like transformer would be nice. The question is what would be the design exactly? This should indeed be a separate issue (and will be a good one). |
FYI, added back |
Uh oh!
There was an error while loading. Please reload this page.
This something I noticed a couple times from ETH Zurich hackathon user workflows. I can see this being reflective of a greater user base as well.
One of the things users like to do is take a standard QASM2 file and load it into Bloqade, then apply our noise model onto it and pass it into PyQrack. The problem is, even if the QASM2 file has an explicit measure statement at the end, there's no real way of saying "return" the results.
To be a bit more precise, here's the code:
And the QASM2 file, measurement and all
In the resulting SSA from the QASM2 load, the
return
is set to None by default:So the result is just nothing on execution.
There would have to be some way to set the return to either a qreg or creg.
Some off-the-bat ideas that might fix this and my immediate feelings:
return q
orreturn c
...loadfile(path, return_obj: "q")
, where the string would have to line up with what's in the QASM fileThe text was updated successfully, but these errors were encountered: