-
Notifications
You must be signed in to change notification settings - Fork 347
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
Running empty program puts QC object in bad state #1034
Comments
Is this still open and what are some suggested modules to look at in order to fix this? |
Yes, as far as I know this is still an issue. I'm actually not sure what correct fix here is though. I'd recommend starting in the Let us know if you have questions. Happy to review a PR or discuss in this thread. |
Cool cool, off the top of my head, sounds like some state is cached or not cleared. Will check it out. |
So here's what I found. As suspected, some state is not being reset. When What should probably be happening is that when # https://sourcegraph.com/github.com/rigetti/pyquil/-/blob/pyquil/api/_qam.py#L58
def load(self, executable: Union[BinaryExecutableResponse, PyQuilExecutableResponse]) -> "QAM":
"""
Initialize a QAM into a fresh state.
:param executable: Load a compiled executable onto the QAM.
"""
self.status: str
if self.status == "loaded":
warnings.warn("Overwriting previously loaded executable.")
assert self.status in ["connected", "done", "loaded"]
# ^^^ this AssertionError should be handled ^^^ Or better still, status should only be set to Here's my version of the snippet from the first comment on this issue: from pyquil import get_qc, Program
qvm = get_qc('9q-qvm')
try:
qvm.run(Program())
except:
print("bad happened")
# set my debugger to watch the qvm variable and saw that qvm.qam.status remained 'running'
qvm.reset() # will revert status to 'connected'
qvm.run(Program('X 0'))
print(qvm)
# prints 9q-qvm Those are my thoughts and there are probably better solutions. But it all centers around resetting the status of the machine. |
I'm not sure I like the idea of calling Personally, I think a better approach would be to change all the assert self.status in ["connected", "done", "loaded"] would change to something like if self.status not in ["connected", "done", "loaded"]:
raise QAMStateTransitionError(current=self.status, expected= ["connected", "done", "loaded"]) or something like that. Another option would be to add a check at the top of the There is a larger (philosophical) question of why attempting to run an empty program should be an error, but it seems we've already made that choice, so I'm happy to stick with it. |
I may have spoken too soon! It seems there is some debate about this very topic: #1182 (comment) |
Yes, I prefer this approach too.
Along the lines of what I was thinking when I wrote
What would the next steps be
|
I think a two-pronged approach makes sense, namely:
Regarding (1), I think adding a check near the top of Regarding (2), maybe a new exception class is overkill and we can just pass a helpful error message to the existing So next steps might be something like:
|
Hello, has this issue been resolved? If not, I'd like to work on it. |
Hey, @CaineArdayfio. This is still an open issue. Take a look at #1034 (comment) for some suggestions on how to tackle this. :D |
Pre-Report Checklist
Issue Description
Running an empty
Program
results in an error and then puts theQuantumComputer
in a bad state.How to Reproduce
Code Snippet
then
Error Output
then
Environment Context
Operating System: Debian Buster
Python Version (
python -V
): 3.6.9Quilc Version (
quilc --version
): 1.12.0QVM Version (
qvm --version
): 1.12.0The text was updated successfully, but these errors were encountered: