Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradients transforms update #4595

Merged
merged 59 commits into from
Oct 13, 2023
Merged

Gradients transforms update #4595

merged 59 commits into from
Oct 13, 2023

Conversation

rmoyard
Copy link
Contributor

@rmoyard rmoyard commented Sep 14, 2023

Description of the Change:

  • Update the gradients transforms to the new system

Benefits:

  • Parameter shift
  • Parameter shift CV
  • Finite diff
  • Hadamard
  • SPSA
  • Pulse gradient
  • Pulse ode
  • Metric tensor
  • Adjoint metric tensor
  • Quantum Fisher

Classical fisher no tape equivalent
Hessian param shift Separate PR

Major changes:

  • The full program is constructed in the QNode because we need to access the QNode when building classical jacobians.
  • Update drawer
  • Two private methods to construct argnums and classical jacobians in the transform program
  • Metric tensor raises errors instead of warnings
  • Remove the spy for gradient transforms

Possible Drawbacks:

Related GitHub Issues:

@github-actions
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

Copy link
Contributor

@mudit2812 mudit2812 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only failure is coverage. I'm approving. Coverage needs to be added before merging anyway 🚀

Copy link
Contributor

@lillian542 lillian542 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple minor comments/questions. Looks great 🚀

pennylane/gradients/pulse_gradient.py Outdated Show resolved Hide resolved
pennylane/optimize/qnspsa.py Outdated Show resolved Hide resolved
Copy link
Contributor

@lillian542 lillian542 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks @rmoyard! 🎉

@rmoyard rmoyard enabled auto-merge (squash) October 13, 2023 20:59
@rmoyard rmoyard merged commit e68a56f into master Oct 13, 2023
39 checks passed
@rmoyard rmoyard deleted the gradients_transforms_update branch October 13, 2023 21:42
timmysilv added a commit that referenced this pull request Oct 26, 2023
**Context:**
This is already being done in the text drawer, I'm just copying it over
for consistency.

**Description of the Change:**
If expansion_strategy is _not_ "device" but we're drawing a QNode with a
new device, run the QNode transform program on the tape before drawing
it. This is for draw_mpl, it's already present for `draw`

**Benefits:**
Parity between the two draw tools

**Possible Drawbacks:**
N/A

**Related GitHub Issues:**
done in #4595 for the text drawer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants