I have a simple reuploading test model, i.e.
@qml.qnode(dev, diff_method='adjoint') # 'adjoint' or 'parameter-shift'
def qnn_model(params, x):
for l in range(n_layers):
for q in range(n_qubits):
qml.RY(x, wires=q)
qml.StronglyEntanglingLayers([params[l]], wires=range(n_qubits))
return qml.expval(qml.PauliZ(0))
Which I trains with default.qubit and parameter-shift differential method. However, there is no way of training it with lightning.qubit and adjoint differentiation. I am getting “TypeError: Rot(): incompatible function arguments“.
TypeError: Rot(): incompatible function arguments. The following argument types are supported:
1. (self: pennylane_lightning.lightning_qubit_ops.StateVectorC128, arg0: list[int], arg1: bool, arg2: list[float]) -> None
2. (self: pennylane_lightning.lightning_qubit_ops.StateVectorC128, arg0: list[int], arg1: list[bool], arg2: list[int], arg3: bool, arg4: list[float]) -> None
Invoked with: <pennylane_lightning.lightning_qubit_ops.StateVectorC128 object at 0x7956b30f97b0>, [0], False, [array(<autograd.numpy.numpy_boxes.ArrayBox object at 0x7956b1b9f000>,
dtype=object), array(<autograd.numpy.numpy_boxes.ArrayBox object at 0x7956b1b9c600>,
dtype=object), array(<autograd.numpy.numpy_boxes.ArrayBox object at 0x7956b1b9f340>,
dtype=object)]
I think the problem is that adjoint of the model is incorrect, as it separates and blocks all encoded data from inversed entangling layers. Is there a way of using lightning.qubit (which does not accept ‘parameter-shift’ diff_method) with this type of model?
My system is (the same problem is with version 0.44+):
$qml.about()
Name: pennylane
Version: 0.42.3
Summary: PennyLane is a cross-platform Python library for quantum computing, quantum machine learning, and quantum chemistry. Train a quantum computer the same way as a neural network.
Home-page:
Author:
Author-email:
License-Expression: Apache-2.0
Location: /home/jacob/venv/pl/lib/python3.11/site-packages
Requires: appdirs, autograd, autoray, cachetools, diastatic-malt, networkx, numpy, packaging, pennylane-lightning, requests, rustworkx, scipy, tomlkit, typing_extensions
Required-by: pennylane_lightning
Platform info: Linux-6.8.0-107-generic-x86_64-with-glibc2.35
Python version: 3.11.4
Numpy version: 2.4.4
Scipy version: 1.17.1
Installed devices:
- lightning.qubit (pennylane_lightning-0.42.0)
- default.clifford (pennylane-0.42.3)
- default.gaussian (pennylane-0.42.3)
- default.mixed (pennylane-0.42.3)
- default.qubit (pennylane-0.42.3)
- default.qutrit (pennylane-0.42.3)
- default.qutrit.mixed (pennylane-0.42.3)
- default.tensor (pennylane-0.42.3)
- null.qubit (pennylane-0.42.3)
- reference.qubit (pennylane-0.42.3).

