Skip to content

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Jan 23, 2025

Also make linker and optimizer non-mutable config as the mode is cached after using them for the first time.

Due to some silly string based logic for the comparison, pytensor was not respecting config.mode changes for NUMBA/JAX/PYTORCH, since these linkers class name is Mode just like the default.


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

@ricardoV94 ricardoV94 added bug Something isn't working backend compatibility labels Jan 23, 2025
@ricardoV94 ricardoV94 force-pushed the respect_predefined_modes branch 2 times, most recently from 70eec3c to 3aa4a4d Compare January 23, 2025 14:16
@ricardoV94 ricardoV94 force-pushed the respect_predefined_modes branch 2 times, most recently from 4bb1be8 to 837f98e Compare January 23, 2025 15:40
@codecov
Copy link

codecov bot commented Jan 23, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 11 lines in your changes missing coverage. Please review.

Project coverage is 82.27%. Comparing base (450efff) to head (ff68d22).
Report is 165 commits behind head on main.

Files with missing lines Patch % Lines
pytensor/compile/mode.py 50.00% 7 Missing and 4 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1166   +/-   ##
=======================================
  Coverage   82.27%   82.27%           
=======================================
  Files         186      186           
  Lines       48004    48000    -4     
  Branches     8624     8621    -3     
=======================================
- Hits        39493    39490    -3     
- Misses       6352     6353    +1     
+ Partials     2159     2157    -2     
Files with missing lines Coverage Δ
pytensor/configdefaults.py 73.46% <ø> (ø)
pytensor/compile/mode.py 84.72% <50.00%> (+0.17%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ricardoV94 ricardoV94 requested a review from Armavica January 23, 2025 16:40
@ricardoV94 ricardoV94 marked this pull request as ready for review January 23, 2025 16:41
@ricardoV94 ricardoV94 force-pushed the respect_predefined_modes branch from 837f98e to 530ddf6 Compare January 23, 2025 17:43
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.

left small comments, but looks great

else:
default_mode_class = string
default_mode_class = string
# FIXME: This is flawed, we should use proper object comparison.
Copy link
Member

Choose a reason for hiding this comment

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

What needs to happen for this to happen? We need a __hash__ method in the mode class?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure, I think I would just stop caching the debug modes and avoid the concern

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah we would need to check the class matches

Copy link
Member

Choose a reason for hiding this comment

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

is an isinstance enough?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a string to Class match. I'll think about it but get the fix merged already

Copy link
Member

Choose a reason for hiding this comment

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

It can be merged as-is IMO I'm just asking : )

Copy link
Member Author

@ricardoV94 ricardoV94 Jan 24, 2025

Choose a reason for hiding this comment

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

I am always worried about rabbit holes when I touch some of these arcane parts of the codebase. It makes complete sense to question them!

Copy link
Member Author

Choose a reason for hiding this comment

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

Cleaned it up by just caching the 3 possible modes and avoiding the silly check. Please re-review

Also allow arbitrary capitalization of the modes.

Also make linker and optimizer non-mutable config as the mode is cached after using them for the first time.
@ricardoV94 ricardoV94 force-pushed the respect_predefined_modes branch from 530ddf6 to ff68d22 Compare January 24, 2025 08:11
@ricardoV94 ricardoV94 merged commit cddf588 into pymc-devs:main Jan 24, 2025
62 of 64 checks passed
@ricardoV94 ricardoV94 deleted the respect_predefined_modes branch January 24, 2025 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend compatibility bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants