Open CatalinaAlbornoz opened 3 months ago
Given the error
/usr/local/lib/python3.10/dist-packages/pennylane/gradients/gradient_transform.py in assert_no_trainable_tape_batching(tape, transform_name)
95 for idx in range(len(tape.trainable_params)):
96 if tape.get_operation(idx)[0].batch_size is not None:
---> 97 raise NotImplementedError(
98 "Computing the gradient of broadcasted tapes with respect to the broadcasted "
99 f"parameters using the {transform_name} gradient transform is currently not "
Would this imply there is some behavior not implemented for diff_method='parameter-shift?
@mews6 yep that's correct! We never updated the parameter-shift rule to support broadcasting, however it seems that the torch layer is providing the parameter-shift rule with a broadcasted tape, which is breaking. @dwierichs may have more technical details here.
As @josh146 and the error message say, if trainable parameters are batched/broadcasted, param_shift
can not handle that.
However, oftentimes the training data is batched, whereas the trainable parameters are not batched. Could this be the case here, and the batched parameters can actually be marked as non-trainable? Non-trainable batched parameters are supported by param_shift
.
Expected behavior
The TorchLayer demo should work with diff_method='parameter-shift'
Actual behavior
It throws an error.
Additional information
This question originated from Forum thread 4940.
Source code
Tracebacks
System information
Existing GitHub issues