Pennylane coding challenge "Returning expectation values" doesnt support lightning.qubit

In Returning expectation values | PennyLane Challenges, using dev = qml.device("lightning.qubit", wires=1) results in

Failure message: Runtime Error: Failed to execute run() function: 'numpy.ndarray' object has no attribute 'numpy'

Changing it to default.qubit causes all the tests to pass.

The other lines of code i wrote are:

@qml.qnode(dev)
.
.
qml.RY(angle, wires=0)
return qml.expval(qml.PauliX(0))

Side note: it might be nice to consider creating a category for the challenges

1 Like

Hi @Kamal_Mohamed,

Welcome back to the Forum and thank you very much for the feedback!
We’ve now created a new PennyLane Challenges category :heart:. Thanks for the suggestion!

Regarding your question about changing the device, for this particular challenge you’re expected to use default.qubit but let me investigate to see why lightning might be failing for you.

Hi @Kamal_Mohamed, I can replicate the issue you’re getting with lightning.qubit. Is there a reason why you wanted to try using lightning in this case? Are you experiencing this issue somewhere other than the challenges?

Hi Catalina! I haven’t tried this in another place. The reason I was trying with the lightning qubit is that I have been using it as my default qubit after learning from your talk during QHack that it is faster :smiley: .

The reason for opening this ticket is because it was not clear from the error that it was due to the choice of qubit.

Hi @Kamal_Mohamed,

Yes, that’s right. In general I always recommend using Lightning!

In this case however the tests for this challenge were designed to work with default.qubit, this is why you were getting an error. I agree that the error doesn’t indicate that the issue is the choice of device, which can be very confusing. I’ve let our Challenge experts know about this to see if this can be improved.

Thank you for making this post!

Let us know if you have any other ideas or suggestions. And keep enjoying the challenges!

Hello Catalina, could you provide the slack link again?

Hi @tchau0091, welcome to the Forum!

The Forum is the recommended place for questions, especially those involving code. However the Xanadu Slack is a great place to chat with other members of the community and learn about the latest things happening all around.

Here’s the link to the Slack!