-
Notifications
You must be signed in to change notification settings - Fork 139
Implement Numba VM #1604
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
base: main
Are you sure you want to change the base?
Implement Numba VM #1604
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left some comments; hope you don't mind
kwargs.setdefault("cache", config.numba__cache) | ||
kwargs.setdefault("no_cpython_wrapper", True) | ||
kwargs.setdefault("no_cfunc_wrapper", True) | ||
kwargs.setdefault("cache", True) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the numba currently can't detect changes in other modules, which could lead to outdated caches. I'm guessing that's why they've decided to make it opt-in
else: | ||
from pytensor.link.numba.dispatch.basic import numba_njit | ||
|
||
jitted_fn = numba_njit(fn, no_cpython_wrapper=False, no_cfunc_wrapper=False) | ||
return jitted_fn | ||
jitted_fn = numba_njit(fn, no_cpython_wrapper=False, no_cfunc_wrapper=False) | ||
return jitted_fn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose there's no need for this else
branch 🤷🏻
with open(filename, "wb") as f: | ||
f.write(src.encode()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with open(filename, "wb") as f: | |
f.write(src.encode()) | |
filename.write_bytes(src.encode()) |
@@ -598,6 +609,9 @@ def compile_function_src( | |||
|
|||
res = cast(Callable, local_env[function_name]) | |||
res.__source__ = src # type: ignore | |||
|
|||
global COMPILED_SRC_FUNCTIONS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs a global
global COMPILED_SRC_FUNCTIONS |
I don't, but it's still too early for that sort of feedback. I'm just thinkering around at this point. |
Description
Related Issue
Checklist
Type of change
📚 Documentation preview 📚: https://pytensor--1604.org.readthedocs.build/en/1604/