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

Simplify elemwise perform method and don't fallback to C-impl #1050

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ricardoV94
Copy link
Member

@ricardoV94 ricardoV94 commented Oct 25, 2024

There was some convoluted logic in Elemwise perform method to create the python perform callable.

In old times, Theano tried to fallback to the C-impl when the number of operands exceeds those supported by Numpy (32), but this doesn't make sense when the C-backend is not available. I don't think this was even working recently with the C backend around.

Either way, it led to strange errors for users with an invalid C-setup (recently reported by many MacOS users), that read something like Scratchpad object has no attribute 'ufunc'. This situation usually arises when PyTensor thinks the C backend is properly setup and fuses many Elemwise operations into large Composite that can easily surpass 32 operands. Then it figures out C is not compiling, and ends up having to use the python perform method. This finally, checked the number of operands was less than 32 and if not tried to fallback to the C implementation that had already failed!

https://discourse.pymc.io/search?q=object%20has%20no%20attribute%20%27ufunc%27

There is now an informative warning explaining users how it might have arrived at this situation and offering working solutions.


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

@ricardoV94 ricardoV94 force-pushed the simplify_elemwise branch 4 times, most recently from bf3af90 to 0ee777a Compare October 25, 2024 14:16
…umber of operands is too large.

This also clears a hard to debug error when perform method attempted to falback to the C-implementation.
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.

1 participant