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

Slow initialization running PyMC model #115

Open
ghost opened this issue May 26, 2024 · 4 comments
Open

Slow initialization running PyMC model #115

ghost opened this issue May 26, 2024 · 4 comments

Comments

@ghost
Copy link

ghost commented May 26, 2024

I am trying to run a PyMC model with the nutpie sampler, but initialization seems to be very slow and sampling does not start with these Warning statements:

C:\Users\TsubasaTakaya\miniconda3\envs\pymc_env\Lib\site-packages\pytensor\link\numba\dispatch\basic.py:379: UserWarning: Numba will use object mode to run AdvancedSetSubtensor's perform method
  warnings.warn(
C:\Users\TsubasaTakaya\miniconda3\envs\pymc_env\Lib\site-packages\pytensor\link\numba\dispatch\basic.py:379: UserWarning: Numba will use object mode to run AdvancedSetSubtensor's perform method
  warnings.warn(
C:\Users\TsubasaTakaya\miniconda3\envs\pymc_env\Lib\site-packages\nutpie\compile_pymc.py:416: NumbaWarning: Cannot cache compiled function "numba_funcified_fgraph" as it uses dynamic globals (such as ctypes pointers and large global arrays)
  return inner(x)
C:\Users\TsubasaTakaya\miniconda3\envs\pymc_env\Lib\site-packages\nutpie\compile_pymc.py:416: NumbaWarning: Cannot cache compiled function "numba_funcified_fgraph" as it uses dynamic globals (such as ctypes pointers and large global arrays)
  return inner(x)

How can I fix this issue? I am using nutpie==0.10.0, numba==0.59.1, pymc==5.13.0.

@twiecki
Copy link
Member

twiecki commented May 26, 2024

Yeah if it's using objmode it'll be very slow. Here seems to be the relevant issue: pymc-devs/pytensor#772 Pull requests are welcome, we're happy to help :).

@ghost
Copy link
Author

ghost commented May 26, 2024

Just to understand the problem, is nopython mode for Numba not used for some operations (e.g. AdvancedSetSubtensor) of PyMC?

@twiecki
Copy link
Member

twiecki commented May 27, 2024

Yes.

@ricardoV94
Copy link
Member

The slow starting is probably just known compilation times in Numba. Should get better with pymc-devs/pytensor#765 which is part of PyTensor 2.21.0. The next PyMC release should be compatible with it

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