What is the difference between qml.Rot and qml.U3?

How are these two gates different?
qml.U3 is called the “Arbitrary single qubit unitary”. This is the same gate as the U3 gate in Qiskit where it is called the “Generic single-qubit rotation”.
qml.Rot is called the “Arbitrary single qubit rotation” in PennyLane.

Can these gates be interchanged? What is the difference fundamentally?

Hi @ankit27kh, very good question. They are equivalent but not interchangeable.

Both in PennyLane and in Qiskit this operation performs a generalized rotation. However, on the backend the decomposition into RX, RY and RZ rotations is different as you can see from the qiskit docs and the PennyLane docs.

You can notice from these docs that the unitary matrices for each are slightly different so you would need to use a conversion, based on these matrices, in order to convert the angles from one framework to the other.

Please let me know if this helped!

Yes, I understand they have different implementation and are different unitaries. But if they are both generalized rotations, then why have two different ones?
Also, why is qml.U3 named ‘arbitrary unitary’ and qml.Rot named ‘arbitrary rotation’?

Hi @ankit27kh, both gates perform an arbitrary rotation which is given by a unitary matrix. The main difference is that qml.U3 includes an additional phase shift with respect to the Rot gate. Since the Rot gate can be decomposed into Z-Y-Z rotations it’s called an arbitrary rotation. Instead, the U3 gate (which is the same as in Qiskit) is called an arbitrary unitary.

It’s useful to have both operations because some devices support U3 gates and some devices support Rot gates. Remember that PennyLane interfaces with many kinds of devices.

If you want to chose between one and the other I would suggest on choosing according to the hardware that it’s going to run on. In any case, both gates should run on most hardware, but additional decompositions might be needed if you choose the option that’s not supported in the hardware.

Please let me know if this answers your question better.

1 Like