Hello! Glad to contact you!
The Snapshot function can work if my dev was “default.qubit”, but it cannot work for the “lightning.qubit”, and here is the ERROR info:
/home/shaolun/PYTHON/QEncoderVis/venv_test/lib/python3.10/site-packages/pennylane/debugging/snapshot.py:247: UserWarning: Snapshots are not supported for the given device. Therefore, a tape will be created for each snapshot, resulting in a total of n_snapshots + 1 executions.
warnings.warn(
Traceback (most recent call last):
File "/home/shaolun/PYTHON/QEncoderVis/4.py", line 29, in <module>
print(qml.snapshots(circuit)()['1'].tolist())
File "/home/shaolun/PYTHON/QEncoderVis/venv_test/lib/python3.10/site-packages/pennylane/workflow/qnode.py", line 1164, in __call__
return self._impl_call(*args, **kwargs)
File "/home/shaolun/PYTHON/QEncoderVis/venv_test/lib/python3.10/site-packages/pennylane/workflow/qnode.py", line 1150, in _impl_call
res = self._execution_component(args, kwargs, override_shots=override_shots)
File "/home/shaolun/PYTHON/QEncoderVis/venv_test/lib/python3.10/site-packages/pennylane/workflow/qnode.py", line 1103, in _execution_component
res = qml.execute(
File "/home/shaolun/PYTHON/QEncoderVis/venv_test/lib/python3.10/site-packages/pennylane/workflow/execution.py", line 650, in execute
tapes, post_processing = transform_program(tapes)
File "/home/shaolun/PYTHON/QEncoderVis/venv_test/lib/python3.10/site-packages/pennylane/transforms/core/transform_program.py", line 515, in __call__
new_tapes, fn = transform(tape, *targs, **tkwargs)
File "/home/shaolun/PYTHON/QEncoderVis/venv_test/lib/python3.10/site-packages/pennylane/devices/preprocess.py", line 490, in validate_measurements
raise DeviceError(
pennylane._device.DeviceError: Measurement state(wires=[0, 1]) not accepted for analytic simulation on adjoint + lightning.qubit.
The original code is shown here:
import pennylane as qml
from pennylane import numpy as np
import torch
dev = qml.device('lightning.qubit', wires=2)
@qml.qnode(dev)
def circuit():
qml.Hadamard(wires=0)
qml.Snapshot("1")
qml.CNOT(wires=[0, 1])
return qml.expval(qml.X(0))
circuit()
print(qml.snapshots(circuit)()['1'].tolist())
Can you help me with this?
The basic version info is as follows:
Python: 3.10.12
pennylane: 0.37.0
CUDA: 12.6
Here is the info for qml.about()