I created a quantum node with this circuit:
def single_input_circuit(params, x):
qml.Displacement(x[0], 0, wires=0)
qml.RY(params[0], wires=0)
return qml.expval.PauliZ(0)

but I got this error
QuantumFunctionError: Continuous and discrete operations are not allowed in the same quantum circuit.
I don’t understand why??


Hi @EMY91,

In PennyLane, we support two main models of quantum computation:

There are several important things to note here:

  • You cannot mix continuous and discrete operations in the same QNode.
    In your case, you are using qml.Displacement (a continuous operation) as well as qml.RY (a discrete operation) and qml.expval.PauliZ (a discrete expectation)

  • If the QNode device is a continuous device, you must use only continuous operations. Likewise, if your QNode device is a discrete device, you must use only discrete operations.
    For example, default.qubit can use qml.RY, but not qml.Displacement.

I hope that helps, let me know if you have any other questions.