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

Keep stack trace in random_make_inplace #735

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

ricardoV94
Copy link
Member

Description

We should keep the stack trace during our rewrites, so that when the Op fails to perform we can point to the moment where the node was created. We do this very patchily at the moment.

This discourse issue revolves around this very problem: https://discourse.pymc.io/t/debug-mode-in-pytensor/14348

After these changes, the traceback ends like this:

  File "<ipython-input-2-9b04c63d3b82>", line 7, in <module>
    s = pm.HalfNormal('s', sigma=-1)
  File "/home/ricardo/Documents/Projects/pymc/pymc/distributions/distribution.py", line 555, in __new__
    rv_out = cls.dist(*args, **kwargs)
  File "/home/ricardo/Documents/Projects/pymc/pymc/distributions/continuous.py", line 846, in dist
    return super().dist([0.0, sigma], **kwargs)
  File "/home/ricardo/Documents/Projects/pymc/pymc/distributions/distribution.py", line 635, in dist
    rv_out = cls.rv_op(*dist_params, size=create_size, **kwargs)

Whereas before there was no idea as to where this RV came from.

Related Issue

Checklist

Type of change

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

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.

Looks straightforward enough. Is this something that should be done in more places?

@ricardoV94
Copy link
Member Author

Looks straightforward enough. Is this something that should be done in more places?

Yes, there's even a flag to make it raise if a variable doesn't have stack trace, we should try to enable it in the CI at some point

Copy link

codecov bot commented Jul 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.05%. Comparing base (e4606f1) to head (bfaaa0c).
Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #735   +/-   ##
=======================================
  Coverage   81.05%   81.05%           
=======================================
  Files         170      170           
  Lines       46992    46995    +3     
  Branches    11510    11511    +1     
=======================================
+ Hits        38088    38091    +3     
+ Misses       6697     6695    -2     
- Partials     2207     2209    +2     
Files Coverage Δ
pytensor/tensor/random/rewriting/basic.py 93.37% <100.00%> (+0.13%) ⬆️

... and 2 files with indirect coverage changes

@ricardoV94 ricardoV94 merged commit db1c161 into pymc-devs:main Jul 8, 2024
57 checks passed
@ricardoV94 ricardoV94 deleted the keep_rv_stack_trace branch July 8, 2024 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants