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

Compute pushforward (Rop) via double application of pullback (Lop) and fix Scan and Max gradient bugs #1207

Merged
merged 5 commits into from
Feb 17, 2025

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Feb 14, 2025

Extracted this from #788 as it's a pretty nice feature to have. This should allow Rop of basically any graph, whereas the specialized support of Rop was pretty patchy.

Also fixes bugs in Scan L_op and Max R_op revealed by the changes / new tests.

Related to #182
Closes #6

Not using the new grad names yet on user facing functions and docs, let's do that for the next major release


📚 Documentation preview 📚: https://pytensor--1207.org.readthedocs.build/en/1207/

@ricardoV94 ricardoV94 added bug Something isn't working enhancement New feature or request gradients scan labels Feb 14, 2025
@ricardoV94 ricardoV94 force-pushed the rop_through_lop branch 3 times, most recently from 0836022 to 9221d2e Compare February 14, 2025 15:28
@ricardoV94 ricardoV94 force-pushed the rop_through_lop branch 2 times, most recently from 9e640a6 to 03e29d2 Compare February 14, 2025 15:34
@ricardoV94 ricardoV94 marked this pull request as ready for review February 14, 2025 15:36
@ricardoV94
Copy link
Member Author

float32 tests fail, shocker...

@ricardoV94 ricardoV94 changed the title Compute pushforward (Rop) via double application of pullback (Lop) Compute pushforward (Rop) via double application of pullback (Lop) (and fix Scan gradient bugs) Feb 14, 2025
@ricardoV94 ricardoV94 changed the title Compute pushforward (Rop) via double application of pullback (Lop) (and fix Scan gradient bugs) Compute pushforward (Rop) via double application of pullback (Lop) and fix Scan gradient bugs Feb 14, 2025
@ricardoV94 ricardoV94 changed the title Compute pushforward (Rop) via double application of pullback (Lop) and fix Scan gradient bugs Compute pushforward (Rop) via double application of pullback (Lop) and fix Scan and Max gradient bugs Feb 14, 2025
@ricardoV94 ricardoV94 force-pushed the rop_through_lop branch 2 times, most recently from a31d5a6 to 8031d33 Compare February 14, 2025 17:54
Also fixes bug in Scan L_op and Max R_op

Co-authored-by: Adrian Seyboldt <aseyboldt@users.noreply.github.com>
Copy link

codecov bot commented Feb 14, 2025

Codecov Report

Attention: Patch coverage is 85.07463% with 10 lines in your changes missing coverage. Please review.

Project coverage is 82.28%. Comparing base (2aecb95) to head (4136161).
Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
pytensor/tensor/math.py 46.15% 4 Missing and 3 partials ⚠️
pytensor/gradient.py 90.90% 2 Missing and 1 partial ⚠️

❌ Your patch status has failed because the patch coverage (85.07%) is below the target coverage (100.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1207      +/-   ##
==========================================
+ Coverage   82.25%   82.28%   +0.03%     
==========================================
  Files         186      186              
  Lines       47981    47987       +6     
  Branches     8630     8629       -1     
==========================================
+ Hits        39465    39486      +21     
+ Misses       6356     6347       -9     
+ Partials     2160     2154       -6     
Files with missing lines Coverage Δ
pytensor/compile/builders.py 88.66% <100.00%> (ø)
pytensor/scan/op.py 84.62% <100.00%> (-0.08%) ⬇️
pytensor/gradient.py 78.55% <90.90%> (+0.92%) ⬆️
pytensor/tensor/math.py 92.00% <46.15%> (+0.12%) ⬆️

... and 2 files with indirect coverage changes

Copy link
Member

@aseyboldt aseyboldt 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 :-)

@ricardoV94 ricardoV94 merged commit b5a64c7 into pymc-devs:main Feb 17, 2025
63 of 64 checks passed
@ricardoV94 ricardoV94 deleted the rop_through_lop branch February 17, 2025 06:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request gradients scan
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scan requires random variables to be referenced as non sequences
2 participants