-
Notifications
You must be signed in to change notification settings - Fork 603
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**Context:** `param_shift` uses the internal method `_evaluate_gradient`, which mostly consists of logic to take the contraction of tape execution results with the parameter-shift rule coefficients and map it over tuple axes. It also needs to respect batching of execution results if `broadcast=True` is used in `param_shift`. **Description of the Change:** This PR cleans up `_evaluate_gradient`, extends it to multi-measurement and shot vector scenarios when broadcasting is used, and recycles helper methods from `gradient_transform.py` to reduce the code. We also add unit tests for this method, allowing to reduce integration test count in the future. **Benefits:** Prepare `_evaluate_gradient` for multi-measurement and shot vector support with `broadcast=True`. Improve testing and code quality. **Possible Drawbacks:** **Related GitHub Issues:** prepares a bug fix for #5598 [sc-62283] --------- Co-authored-by: Mudit Pandey <mudit.pandey@xanadu.ai> Co-authored-by: Astral Cai <astral.cai@xanadu.ai> Co-authored-by: Vincent Michaud-Rioux <vincentm@nanoacademic.com> Co-authored-by: lillian542 <38584660+lillian542@users.noreply.github.com>
- Loading branch information
1 parent
df2abfa
commit 58668d7
Showing
4 changed files
with
263 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.