Hello, I am trying to implement a quantum circuit that contains controlled CY gates. The circuit contains multiple layers. Following is the code snippet for a single layer.
def ansatz_2(n_qubits, y_weight):
for wire, y_weight in enumerate(y_weight):
qml.ctrl(op=qml.RY(y_weight, wires=wire), control=(wire-1)%n_qubits)
Other details are as follows:
dev = qml.device("default.qubit", wires=n_qubits)
interface = "torch"
When I run the ansatz on the CPU, it works well. However, on running the same ansatz on GPU, it throws the following error:
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0, CPU!
Also, If I replace the layer with the following code snippet, the operation happens on GPU without any error.
def ansatz_2(n_qubits, y_weight):
for wire, y_weight in enumerate(y_weight):
qml.RY(y_weight, wires=wire)
So, I assume that I am doing something wrong with qml.ctrl implementation. Any help here would be appreciated.