I am able to run the Quanvolutional Neural Network example at
with lightning.qubit. However when I switch in lightning.gpu I get the following output:
Quantum pre-processing of train images:
Traceback (most recent call last):
File “quanvolutional_nn.py”, line 81, in
q_train_images.append(quanv(img))
File “quanvolutional_nn.py”, line 62, in quanv
q_results = circuit(
File “/home/arthurlobo/.conda/envs/qml_py38_b/lib/python3.8/site-packages/pennylane/qnode.py”, line 660, in call
res = qml.execute(
File “/home/arthurlobo/.conda/envs/qml_py38_b/lib/python3.8/site-packages/pennylane/interfaces/execution.py”, line 443, in execute
res = _execute(
File “/home/arthurlobo/.conda/envs/qml_py38_b/lib/python3.8/site-packages/pennylane/interfaces/tensorflow.py”, line 89, in execute
res, jacs = execute_fn(tapes, **gradient_kwargs)
File “/home/arthurlobo/.conda/envs/qml_py38_b/lib/python3.8/site-packages/pennylane/interfaces/execution.py”, line 197, in wrapper
res = fn(execution_tapes.values(), **kwargs)
File “/home/arthurlobo/.conda/envs/qml_py38_b/lib/python3.8/site-packages/pennylane/interfaces/execution.py”, line 122, in fn
return original_fn(tapes, **kwargs)
File “/home/arthurlobo/.conda/envs/qml_py38_b/lib/python3.8/contextlib.py”, line 75, in inner
return func(*args, **kwds)
File “/home/arthurlobo/.conda/envs/qml_py38_b/lib/python3.8/site-packages/pennylane/_qubit_device.py”, line 576, in batch_execute
res = self.execute(circuit)
File “/home/arthurlobo/.conda/envs/qml_py38_b/lib/python3.8/site-packages/pennylane/_qubit_device.py”, line 323, in execute
results = self.statistics(circuit.observables)
File “/media/arthurlobo/QML/pennylane_lightning_gpu_38/pennylane-lightning-gpu/pennylane_lightning_gpu/lightning_gpu.py”, line 149, in statistics
return super().statistics(observables, shot_range, bin_size, circuit)
TypeError: statistics() takes from 2 to 4 positional arguments but 5 were given
I can see that we made a change in the statistics (in the dev version) method due to an API change.
If you’re using v0.25 you can install the development version by using python -m pip install git+https://github.com/PennyLaneAI/pennylane-lightning-gpu.git#egg=pennylane-lightning-gpu.
You can install it by using python -m pip install pennylane-lightning[gpu]==0.25.0
the above line did not work for me. qml.about() still shows v0.26.0.dev0.
For my aarch64 install @mlxd had suggested the following steps
which builds from source and installs lightning_gpu_qubit_ops.cpython-38-aarch64-linux-gnu.so in the pennylane-lightning-gpu sub-folder:
Hi @art
The issue here is that for a manual build from lightning.gpu v0.26, you also need the up-to-date master branch of pennylane
Maybe keep the lightning.gpu (PennyLane-Lightning-GPU-0.26.0.dev0) version, and on-top of it install pennylane as python -m pip install git+https://github.com/PennyLaneAI/pennylane.git@master.
That should hopefully fix the issue, until the next release version in a few weeks.
@CatalinaAlbornoz that worked. I am able to use lightning.gpu and lightning.qubit with PyTorch and TensorFlow CUDA versions. Note that if I specify default.qubit I get an error as shown:
lightning.qubit (PennyLane-Lightning-0.25.1)
Traceback (most recent call last):
File “quanvolutional_nn.py”, line 39, in
dev = qml.device(“default.qubit”, wires=4)
File “/home/arthurlobo/.conda/envs/qml_py38_b/lib/python3.8/site-packages/pennylane/init.py”, line 314, in device
raise DeviceError(
pennylane._device.DeviceError: The default.qubit plugin requires PennyLane versions 0.26.0-dev, however PennyLane version 0.26.0-dev is installed.
Hi @art, thank you for pointing this out. This looks like a bug in our development version. v0.26 should be released in 2 weeks so it should be fixed by then.