Open notmgsk opened 5 years ago
I've encountered the same bug; the program
RY(0.6998761826627558) 0
RZ(-pi/4) 0
RY(0.6998761826627558) 1
RZ(-pi/4) 1
CNOT 0 1
S 0
H 0
S 0
cannot be executed on Aspen-4-2Q-A when using measure_and_run.
The issue appears to be in this line in run_and_measure
:
for i, q in enumerate(self.qubits()):
program.inst(MEASURE(q, ro[i]))
program.wrap_in_numshots_loop(trials)
executable = self.compile(program)
The device's qubits list doesn't have the right range; it should be the program's qubits that this is iterated over, not the devices (note the device compilation call is after the measurements are added. So till then we're in "program qubit space".). It should enumerate over program.get_qubits()
.
~ Johannes
In fact, wouldn't it make much more sense to also re-index the return dict as it comes from the program? The compiler is free to rearrange the order in there anyhow, so there's no extra information for the user gained by indexing by the device's qubits.
Try the example:
resulting in the error
The program that pyQuil sends to quilc is
which references three unique resources: more than are available on the chip (two).