qm.expval(H) not working with default.mixed

qml.expval(H) only works with default.qubit and not default.mixed device.

I tried test qml.expval(qml.PauliZ(0)) and the code ran with default.mixed.

I’m unsure as to why the Hamiltonian operator doesn’t work with default.mixed but manages to run with default.qubit. The hamiltonian is only composed to combinations of I, X, Y, and Z gates so I don’t know where the problem might lie.

The error I’m getting is: ValueError: shapes (256,) and (512,) not aligned: 256 (dim 0) != 512 (dim 0).


Thanks @Niranjan_Bhatia!

Please could you share a minimal example of the code that generates this error? I just did a quick try of qml.expval(H) on default.mixed and it worked, but it might be that the error occurs for a certain type of Hamiltonian, or with a different interface (JAX, TensorFlow, etc), so your code would really help us identify the issue.