With the latest release of PyMC 5.19.0: Release v5.19.0 · pymc-devs/pymc · GitHub it is now possible to pass compile_kwargs=dict(mode="NUMBA")
to pm.sample
to use the Numba backend with the PyMC samplers. For some models this can lead to big speedups in sampling (although possibly offset by longer compilation times).
For the eight school model benchmarked here: Speedup `sample` and allow specifying `compile_kwargs` (several major changes related to step samplers) by ricardoV94 · Pull Request #7578 · pymc-devs/pymc · GitHub sampling was roughly 2x faster in the Numba backend than the default C backend.
Sampling with the default backend should itself also be roughly 2x faster than in previous versions, due to some optimizations we did. In case you need an excuse to update…
And if you are already willing to play with the Numba backend, you can also install nutpie
and try nuts_sampler="nutpie"
. Due to smarter initialization and full focus on NUTS sampling, it can run in a breeze compared to the PyMC NUTS sampler. GitHub - pymc-devs/nutpie: Python wrapper for nuts-rs
Let us know if you have any questions or find any problems!