pyquil
pyquil copied to clipboard
Memory Declaration are sometimes moved to the top of the program
from pyquil.quil import Program
print(Program("DEFGATE DDXX_184:\n 1.0, 0.0\n 0.0, 1.0\n\nDDXX_184 2\nCPHASE(0.1) 0 1\nDECLARE ro BIT[3]\nMEASURE 0 ro[0]\nMEASURE 1 ro[1]\nMEASURE 2 ro[2]\n").out())
Yields:
DECLARE ro BIT[3]
DEFGATE DDXX_184 AS MATRIX:
1, 0
0, 1
DDXX_184 2
CPHASE(0.1) 0 1
MEASURE 0 ro[0]
MEASURE 1 ro[1]
MEASURE 2 ro[2]
Possibly related to #1666
For now at least, this is intended behavior on the part of quil-rs.
The problem here is that this seems to be non-deterministic. Sometimes the declarations are at the top, sometimes they are not.