pyquil icon indicating copy to clipboard operation
pyquil copied to clipboard

Cannot compile single qubit RESETs to ProtoQuil

Open teaguetomesh opened this issue 3 years ago • 0 comments

Pre-Report Checklist

  • [x] I am running the latest versions of pyQuil and the Forest SDK
  • [x] I checked to make sure that this bug has not already been reported

Issue Description

I'm trying to construct a circuit which uses mid-circuit resets. When I try to compile the program an error is thrown. I've found that the error is only thrown when trying to reset a single qubit, resetting all qubits works fine.

How to Reproduce

Code Snippet

lattice = '9q-generic-qvm'
qpu = get_qc(lattice)
program = Program(RESET(0))
qpu.compile(program)

Error Output

---------------------------------------------------------------------------
RPCError                                  Traceback (most recent call last)
<ipython-input-33-0381b1729762> in <module>
      2 qpu = get_qc(lattice)
      3 program = Program(RESET(0))
----> 4 qpu.compile(program)

/opt/conda/lib/python3.8/site-packages/pyquil/api/_error_reporting.py in wrapper(*args, **kwargs)
    249             global_error_context.log[key] = pre_entry
    250 
--> 251         val = func(*args, **kwargs)
    252 
    253         # poke the return value of that call in

/opt/conda/lib/python3.8/site-packages/pyquil/api/_quantum_computer.py in compile(self, program, to_native_gates, optimize, protoquil_positional, protoquil)
    491 
    492         if quilc:
--> 493             nq_program = self.compiler.quil_to_native_quil(program, protoquil=protoquil)
    494         else:
    495             nq_program = program

/opt/conda/lib/python3.8/site-packages/pyquil/api/_error_reporting.py in wrapper(*args, **kwargs)
    249             global_error_context.log[key] = pre_entry
    250 
--> 251         val = func(*args, **kwargs)
    252 
    253         # poke the return value of that call in

/opt/conda/lib/python3.8/site-packages/pyquil/api/_compiler.py in quil_to_native_quil(self, program, protoquil)
    498         self.connect()
    499         request = NativeQuilRequest(quil=program.out(), target_device=self.target_device)
--> 500         response = self.client.call("quil_to_native_quil", request, protoquil=protoquil).asdict()
    501         nq_program = parse_program(response["quil"])
    502         nq_program.native_quil_metadata = response["metadata"]

/opt/conda/lib/python3.8/site-packages/rpcq/_client.py in call(self, method_name, rpc_timeout, *args, **kwargs)
    203 
    204         if isinstance(reply, RPCError):
--> 205             raise utils.RPCError(reply.error)
    206         else:
    207             return reply.result

RPCError: Unhandled error in host program:
Misplaced or illegal instruction in ProtoQuil program:
  (BEGINNING OF PROGRAM)
>>>RESET 0
  (END OF PROGRAM)

Environment Context

Using the standard jupyterhub available at jupyterhub.qcs.rigetti.com. Based my code on the example tutorials found there.

teaguetomesh avatar Apr 01 '21 18:04 teaguetomesh