Hi, I am trying to simulate large-scale quantum circuit (e.g. 30 qubits) with Lightning.gpu device. However, I failed to run the lightning.gpu example introduced on page: Lightning-fast simulations with PennyLane and the NVIDIA cuQuantum SDK. The error information is
/home/xx/.local/lib/python3.10/site-packages/autograd/tracer.py:14: UserWarning: Output seems independent of input.
warnings.warn("Output seems independent of input.")
Traceback (most recent call last):
File "/home/xx/.local/lib/python3.10/site-packages/pennylane/_grad.py", line 330, in _jacobian_function
jac = tuple(_jacobian(func, arg)(*args, **kwargs) for arg in _argnum)
File "/home/xx/.local/lib/python3.10/site-packages/pennylane/_grad.py", line 330, in <genexpr>
jac = tuple(_jacobian(func, arg)(*args, **kwargs) for arg in _argnum)
File "/home/xx/.local/lib/python3.10/site-packages/autograd/wrap_util.py", line 20, in nary_f
return unary_operator(unary_f, x, *nary_op_args, **nary_op_kwargs)
File "/home/xx/.local/lib/python3.10/site-packages/autograd/differential_operators.py", line 62, in jacobian
jacobian_shape = ans_vspace.shape + vspace(x).shape
TypeError: can only concatenate list (not "tuple") to list
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/xx/Documents/quantum/MG-QAOA/lightning_gpu.py", line 32, in <module>
jac = qml.jacobian(circuit)(weights)
File "/home/xx/.local/lib/python3.10/site-packages/pennylane/_grad.py", line 333, in _jacobian_function
raise ValueError(
ValueError: PennyLane has a new return shape specification that may not work well with autograd and more than one measurement. That may be the source of the error.
And the test code is as follows.
import pennylane as qml
from timeit import default_timer as timer
# To set the number of threads used when executing this script,
# export the OMP_NUM_THREADS environment variable.
# Choose number of qubits (wires) and circuit layers
wires = 20
layers = 3
# Set number of runs for timing averaging
num_runs = 5
# Instantiate CPU (lightning.qubit) or GPU (lightning.gpu) device
dev = qml.device('lightning.gpu', wires=wires)
# Create QNode of device and circuit
@qml.qnode(dev, diff_method="adjoint")
def circuit(parameters):
qml.StronglyEntanglingLayers(weights=parameters, wires=range(wires))
return [qml.expval(qml.PauliZ(i)) for i in range(wires)]
# Set trainable parameters for calculating circuit Jacobian
shape = qml.StronglyEntanglingLayers.shape(n_layers=layers, n_wires=wires)
weights = qml.numpy.random.random(size=shape)
# Run, calculate the quantum circuit Jacobian and average the timing results
timing = []
for t in range(num_runs):
start = timer()
jac = qml.jacobian(circuit)(weights)
end = timer()
timing.append(end - start)
print(qml.numpy.mean(timing))
The details after running qml.about()
is
Name: PennyLane
Version: 0.30.0
Summary: PennyLane is a Python quantum machine learning library by Xanadu Inc.
Home-page: https://github.com/XanaduAI/pennylane
Author:
Author-email:
License: Apache License 2.0
Location: /home/yqia7342/.local/lib/python3.10/site-packages
Requires: appdirs, autograd, autoray, cachetools, networkx, numpy, pennylane-lightning, requests, rustworkx, scipy, semantic-version, toml
Required-by: PennyLane-Lightning, PennyLane-Lightning-GPU, PennyLane-qiskit
Platform info: Linux-5.15.0-58-generic-x86_64-with-glibc2.35
Python version: 3.10.6
Numpy version: 1.23.4
Scipy version: 1.9.3
Installed devices:
- default.gaussian (PennyLane-0.30.0)
- default.mixed (PennyLane-0.30.0)
- default.qubit (PennyLane-0.30.0)
- default.qubit.autograd (PennyLane-0.30.0)
- default.qubit.jax (PennyLane-0.30.0)
- default.qubit.tf (PennyLane-0.30.0)
- default.qubit.torch (PennyLane-0.30.0)
- default.qutrit (PennyLane-0.30.0)
- null.qubit (PennyLane-0.30.0)
- lightning.qubit (PennyLane-Lightning-0.30.0)
- lightning.gpu (PennyLane-Lightning-GPU-0.30.0)
- qiskit.aer (PennyLane-qiskit-0.28.0)
- qiskit.basicaer (PennyLane-qiskit-0.28.0)
- qiskit.ibmq (PennyLane-qiskit-0.28.0)
- qiskit.ibmq.circuit_runner (PennyLane-qiskit-0.28.0)
- qiskit.ibmq.sampler (PennyLane-qiskit-0.28.0).
The version of cuquantum
and cuquantum-python
is 22.7.1, and my GPU is GeForce RTX 2080 Ti with CUDA12.0.
Looking forward to your advice.
Thanks!