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

Numba integration #362

Open
pckroon opened this issue Nov 16, 2022 · 3 comments
Open

Numba integration #362

pckroon opened this issue Nov 16, 2022 · 3 comments
Milestone

Comments

@pckroon
Copy link
Collaborator

pckroon commented Nov 16, 2022

If numba is installed, we should @jit(nopython=True, fastmath=True) compile the model when we lambdify them. This should of course be optional. If numba is not installed everything should work out of the box, and if it is installed everything should work faster. In addition, there should be a flag/option somewhere to never jit the models, just in case there's issues. Finally, the arguments to the jit function should be user-providable.

@pckroon pckroon added this to the 1.0.0 milestone Nov 16, 2022
@tBuLi
Copy link
Owner

tBuLi commented Nov 17, 2022

I agree, this would be awesome. In principle the code we generate with sympy uses numpy, and thus should be compatible in most typical cases. I would propose to add a numba argument to either fit itself, or Fit.execute, which could be a boolean, or a dict of options which is passed to numba.njit.

@pckroon
Copy link
Collaborator Author

pckroon commented Nov 18, 2022

I'd argue passing it to Model makes more sense. There's more ways of calling a model besides Fit.
e.g.

model_dict = {...}
model = Model(model_dict, numba=True)  # Default, use default numba.jit arguments we decide on
model = Model(model_dict, numba={})  # Use default numba.jit default arguments
model = Model(model_dict, numba=False)  # Don't jit at all
model = Model(model_dict, numba={'fastmath': False})  # Provide jit arguments explicitely. 

And note that anything we sympify should be jitted: not just the model itself, but also the jacobian

@tBuLi
Copy link
Owner

tBuLi commented Nov 18, 2022

Good point, fair enough! Model does make more sense indeed.

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

No branches or pull requests

2 participants