You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sv1_device_arn = "arn:aws:braket:::device/quantum-simulator/amazon/sv1"
dm1_device_arn = "arn:aws:braket:::device/quantum-simulator/amazon/dm1"
dev = qml.device("braket.aws.qubit", device_arn=sv1_device_arn, wires=nqubits)
nqubits = 4
@qml.qnode(dev)
def quantum_circuit(input, weights):
# Prepare circuit here
for i in range(nqubits):
qml.H(i)
# Measurement layer
return [qml.expval(qml.PauliZ(i)) for i in range(nqubits)]
When SV1 is used, this line is triggered. This will compute parameter-shifted derivatives even on the forward pass, when they should not be computed. This makes running with SV1 ~10x slower (and incurs extra costs) compared to DM1.
To reproduce
Run above code snippet.
Expected behavior
The Braket-PL device should only compute the gradient if it's "really" requested.
Screenshots or logs
N/A
System information
A description of your system. Please provide:
The problem is execute_and_gradients being automatically called if the device supports its own gradient computation method and the execution is analytic (shots = 0); this is decided upstream by PennyLane, and isn't controlled in the plugin. However, I've added a warning to the parameter-shift fallback path.
Describe the bug
Consider a circuit like:
When SV1 is used, this line is triggered. This will compute parameter-shifted derivatives even on the forward pass, when they should not be computed. This makes running with SV1 ~10x slower (and incurs extra costs) compared to DM1.
To reproduce
Run above code snippet.
Expected behavior
The Braket-PL device should only compute the gradient if it's "really" requested.
Screenshots or logs
N/A
System information
A description of your system. Please provide:
Additional context
One other solution would be to avoid calling
execute_and_gradients
entirely in this case.The text was updated successfully, but these errors were encountered: