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
The hadamard_grad gradient transform requires an auxiliary wire. It can determine this auxiliary via manual gradient keyword arguments aux_wire and device_wires. If neither of these are found, it just uses the next largest integer.
For example, the device wires can be manually provided:
WireError: Cannot run circuit(s) on default.qubit as they contain wires not found on the device: {0}
This error provides no information about where wire 0 came from. It wasn't present in the original circuit, but added by the hadamard gradient transform.
The solution:
To improve our handling of auxiliary wires, we want to add logic to our workflow setup to automatically add the device_wires if they weren't present in the user-gradient keyword args.
We already have similar logic for adding the device to the gradient_keyword_arguments for qml.gradients.param_shift_cv:
This issue is reserved for internal use.
Problem:
The
hadamard_grad
gradient transform requires an auxiliary wire. It can determine this auxiliary via manual gradient keyword argumentsaux_wire
anddevice_wires
. If neither of these are found, it just uses the next largest integer.For example, the device wires can be manually provided:
If the device wires are not provided in such a situation, we will get an error, even when an extra wire exists.
This error provides no information about where wire
0
came from. It wasn't present in the original circuit, but added by the hadamard gradient transform.The solution:
To improve our handling of auxiliary wires, we want to add logic to our workflow setup to automatically add the
device_wires
if they weren't present in the user-gradient keyword args.We already have similar logic for adding the device to the
gradient_keyword_arguments
forqml.gradients.param_shift_cv
:pennylane/pennylane/workflow/resolution.py
Line 268 in 90dc57c
We can add a similar line to the same spot for the
qml.gradients.hadamard_grad
gradient method.If
dev_wires
oraux_wires
are already in the gradient keyword arguments, we do not need to add the device wires.Once we've made the above change we should be able to execute the following without error:
When running
The user should get:
instead of the current:
Solution Requirements:
Unit tests should be added to
test_resolve_execution_config.py
checking that:device_wires
oraux_wire
are already specifiedFor a similar test, see:
pennylane/tests/workflow/test_resolve_execution_config.py
Line 55 in 90dc57c
Integration tests should be added to
tests/gradients/core/test_hadamard_gradient.py
The PR should include a changelog entry, and follow black and pylint standards.
The text was updated successfully, but these errors were encountered: