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

Support differentiable coefficients for observables #6598

Merged
merged 26 commits into from
Jan 15, 2025

Conversation

albi3ro
Copy link
Contributor

@albi3ro albi3ro commented Nov 19, 2024

Context:

With legacy operator arithmetic, we supported trainable coefficients using the hadamard_grad transform. This doesn't really work anymore with generic operator arithmetic.

Description of the Change:

Uses the split_to_single_terms transform in gradient preprocessing if any of the observables have trainable coefficients.

In order to get this to pass tests, various bugs in split_non_commuting needed fixing.

Benefits:

Possible Drawbacks:

Related GitHub Issues:

[sc-71490]

tests/interfaces/test_jax.py Outdated Show resolved Hide resolved
@albi3ro albi3ro marked this pull request as ready for review November 19, 2024 14:13
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.

pennylane/gradients/vjp.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jan 2, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.60%. Comparing base (2147813) to head (9f0a1a1).
Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6598      +/-   ##
==========================================
- Coverage   99.60%   99.60%   -0.01%     
==========================================
  Files         476      476              
  Lines       45237    45215      -22     
==========================================
- Hits        45060    45035      -25     
- Misses        177      180       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@albi3ro albi3ro requested a review from astralcai January 6, 2025 22:37
@astralcai
Copy link
Contributor

With legacy operator arithmetic, we supported trainable coefficients using the hadamard_grad transform. This doesn't really work anymore with generic operator arithmetic.

Should we deprecate/remove hamiltonian_grad?

@albi3ro
Copy link
Contributor Author

albi3ro commented Jan 7, 2025

With legacy operator arithmetic, we supported trainable coefficients using the hadamard_grad transform. This doesn't really work anymore with generic operator arithmetic.

Should we deprecate/remove hamiltonian_grad?

Potentially worth considering now.

Co-authored-by: Astral Cai <astral.cai@xanadu.ai>
@albi3ro albi3ro requested a review from astralcai January 14, 2025 14:33
Co-authored-by: Andrija Paurevic <46359773+andrijapau@users.noreply.github.com>
@albi3ro albi3ro enabled auto-merge (squash) January 15, 2025 16:31
@albi3ro albi3ro merged commit 14c61a6 into master Jan 15, 2025
45 checks passed
@albi3ro albi3ro deleted the derivatives-observables branch January 15, 2025 17:17
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.

3 participants