[BUG] output shape and type of gradient_transform
applied to QNodes depend on classical processing
#4940
Closed
1 task done
Labels
bug 🐛
Something isn't working
Expected behavior
When applying a
gradient_transform
to a QNode, the output shape and type should not differ whether or not there is classical processing.Actual behavior
If there is no classical processing (and other conditions apply, such as "there is only one QNode argument"), the output shape and type differs from cases where there is classical processing:
Another example, this time causing a transpose, is
Additional information
This is due to a special branch in
_contract_qjac_with_cjac
ingradients/gradient_transform.py
, which is activated whenever the classical Jacobian is the identity.While it is correct that no numerics have to be performed in this case, the contraction that would be performed without this branch (and yields the correct behaviour) also leads to transposing the output. As the contraction is skipped, the transpose is as well, leading to the observed behaviour.
Source code
No response
Tracebacks
No response
System information
pl dev; master
Existing GitHub issues
The text was updated successfully, but these errors were encountered: