I have a the following sequence of gates that form a generalized U4
gate as part of my circuit:
qml.U3(params[0], params[1], params[2], wires=wires[i])
qml.U3(params[3], params[4], params[5], wires=wires[i+1])
qml.CNOT(wires=[wires[i], wires[i+1]])
qml.RY(params[6], wires=wires[i])
qml.RZ(params[7], wires=wires[i+1])
qml.CNOT(wires=[wires[i+1], wires[i]])
qml.RY(params[8], wires=wires[i])
qml.CNOT(wires=[wires[i], wires[i+1]])
qml.U3(params[9], params[10], params[11], wires=wires[i])
qml.U3(params[12], params[13], params[14], wires=wires[i+1])
But in a bizarre turn of things, when I package these into a function and call it while building the circuit, I get a much different(worse) accuracy than if I directly put the gates in the circuit. I’m using jax
to optimize my code if that makes a difference. Is there something going on behind the scenes that’s different in the two methods?