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

Add warning if a Minibatched variable is used without total_size #7742

Merged
merged 4 commits into from
Apr 1, 2025

Conversation

zaxtax
Copy link
Contributor

@zaxtax zaxtax commented Mar 30, 2025

Description

This should help catch a well-known Minibatch footgun where a user forgets to include the total_size argument

Checklist

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

📚 Documentation preview 📚: https://pymc--7742.org.readthedocs.build/en/7742/

…tten

This should help catch a well-known Minibatch footgun
@zaxtax zaxtax requested a review from ricardoV94 March 30, 2025 14:20
Copy link

codecov bot commented Mar 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.82%. Comparing base (fb4b201) to head (e10511a).
Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #7742   +/-   ##
=======================================
  Coverage   92.82%   92.82%           
=======================================
  Files         107      107           
  Lines       18324    18326    +2     
=======================================
+ Hits        17010    17012    +2     
  Misses       1314     1314           
Files with missing lines Coverage Δ
pymc/model/core.py 92.99% <100.00%> (+0.01%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zaxtax zaxtax requested a review from jessegrabowski March 31, 2025 22:03
Copy link
Member

@jessegrabowski jessegrabowski left a comment

Choose a reason for hiding this comment

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

LGTM. My only suggestion is that we have some way for a user who knows he doesn't want to set total_size to somehow avoid the warning. I can't think of a case where anyone would want to do this, but something like total_size=False to silence the warning might be nice?

Might also be too convoluted.

@zaxtax
Copy link
Contributor Author

zaxtax commented Apr 1, 2025 via email

@zaxtax zaxtax merged commit 4185b7b into pymc-devs:main Apr 1, 2025
25 checks passed
@@ -1241,6 +1241,15 @@ def register_rv(
self.add_named_variable(rv_var, dims)
self.set_initval(rv_var, initval)
else:
if (
Copy link
Member

Choose a reason for hiding this comment

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

this should have checked if minibatch is anywhere in the ancestors of value not just immediately

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we need to do that? This check is only for observed random variables. I thought for those we don't allow the value to depend on another node

@zaxtax zaxtax mentioned this pull request Apr 3, 2025
9 tasks
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