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

Fix bug from too strict type check in _sum_grad_over_bcasted_dims #1036

Merged
merged 1 commit into from
Oct 26, 2024

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Oct 17, 2024

@ricardoV94 ricardoV94 added bug Something isn't working gradients labels Oct 17, 2024
@ricardoV94 ricardoV94 changed the title Fix too strict type check in _sum_grad_over_bcasted_dims Fix bug from too strict type check in _sum_grad_over_bcasted_dims Oct 17, 2024
@ricardoV94 ricardoV94 force-pushed the fix_set_subtensor_grad_bug branch 4 times, most recently from 055af4d to 52d7254 Compare October 17, 2024 09:40
@ricardoV94 ricardoV94 removed the request for review from twiecki October 17, 2024 09:42
@ricardoV94 ricardoV94 force-pushed the fix_set_subtensor_grad_bug branch from 52d7254 to 372abc9 Compare October 17, 2024 09:52
@ricardoV94 ricardoV94 removed the request for review from lucianopaz October 17, 2024 12:53
@ricardoV94 ricardoV94 force-pushed the fix_set_subtensor_grad_bug branch 3 times, most recently from 4897961 to abccb01 Compare October 25, 2024 12:01
@ricardoV94 ricardoV94 force-pushed the fix_set_subtensor_grad_bug branch from abccb01 to 636cdca Compare October 25, 2024 14:26
Copy link

codecov bot commented Oct 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.93%. Comparing base (4c7b494) to head (636cdca).
Report is 97 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1036   +/-   ##
=======================================
  Coverage   81.93%   81.93%           
=======================================
  Files         182      182           
  Lines       47890    47889    -1     
  Branches     8617     8617           
=======================================
+ Hits        39239    39240    +1     
+ Misses       6481     6480    -1     
+ Partials     2170     2169    -1     
Files with missing lines Coverage Δ
pytensor/tensor/subtensor.py 89.48% <100.00%> (+0.17%) ⬆️

Copy link
Contributor

@lucianopaz lucianopaz left a comment

Choose a reason for hiding this comment

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

In all honesty, I don’t understand what was wrong with the past asserts and why the new conditionals are better, but the test you added looks convincing so I’ll approve

@ricardoV94
Copy link
Member Author

The old assert assumed you had the same knowledge about broadcastability of the input and the gradient wrt to the input.

The new ones assert you have the same or more (but not less, because if you knew the input was broadcastable, you should also know the gradient will be)

Broadcastable just means static shape = 1 along that dim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working gradients shape inference
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants