Closed waelitani closed 5 months ago
Hi @waelitani ,
The order in which you add the decorators is very important. The @qml.qnode(dev)
decorator should always be placed immediately above your quantum function. Then you can add other transforms above the QNode decorator. I tried it and it fixed the issue. let me know if it works for you!
Placing the the qml.qnode decorator closest to the function definition seems to render the transform decorator ineffective. For example, adding @qml.transforms.broadcast_expand
above it, would still throw the error:
ValueError: Broadcasting with MottonenStatePreparation is not supported. Please use the qml.transforms.broadcast_expand transform to use broadcasting with MottonenStatePreparation.
when using, say AmplitudeEmbedding
, with the the lightning.qubit
device.
I am not certain if this would be fixed by preserving the call signature, as fixed by 5857.
This would tie into Issue #4460, which is a separate long standing issue we are needing to solve.
This may also tie into the fact we do gradient preprocessing before user transforms. I'll look into that.
Expected behavior
The torchlayer should be created successfully without any errors. This works fine if the broadcast expand function decorator "@qml.transforms.broadcast_expand" is commented out from the minimal code provided.
Actual behavior
Torchlayer fails to detect the inputs argument to the circuit function under the qnode and broadcast expand decorators.
Additional information
The versions of the relevant packages are as below:
Name Version Build Channel
pennylane 0.36.0 pypi_0 pypi python 3.11.9 h955ad1f_0 torch 2.3.1+cu121 pypi_0 pypi
Source code
Tracebacks
System information
Existing GitHub issues