-
Notifications
You must be signed in to change notification settings - Fork 3
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
Speed up solver instantiation #5
Comments
With current Numba (0.51.2) the following code: import numba as nb
@nb.njit(cache=True)
def func(t, y):
return y
@nb.njit(cache=True)
def stepper(f, a, b):
return 3 * f(a, b)
print(stepper(func, 4., 2.)) fails with the following error:
due to If this works in the near future, instantiation time can drop dramatically as compilation will be done once. This might require some code reorganization. For example, right now the stepper is organized in two layers: def step_builder(*outer_args):
"""Build a stepper.
This outer function should only contains attributes
associated with the solver class not with the solver instance.
"""
@numba.njit
def _step(*inner_args):
"""Perform a single step.
This inner function should only contains attributes
associated with the solver instance not with the solver class.
"""
# code to step
return _step The @numba.njit
def _step(*inner_args, *outer_args):
"""Perform a single step.
This outer function should only contains attributes
associated with the solver class not with the solver instance.
""" |
Some other cache-related maybe-relevant numba issues:
Some are quite old, and might be duplicates from newer issues as the ones mentioned above. |
The failing example appears to work now: import numba as nb
@nb.njit(cache=True)
def func(t, y):
return y
@nb.njit(cache=True)
def stepper(f, a, b):
return 3 * f(a, b)
print(f"{nb.__version__ = }")
print(stepper(func, 4., 2.))
nb.__version__ = '0.56.4'
6.0 |
But it is still producing a different cached version of
Environment:
|
Instantiating the solver takes quite long due to compilation. It would be interesting to improve de code (without loosing clarity) so that numba is able to use the compiled code cache.
The text was updated successfully, but these errors were encountered: