7 ms·
For those with more experience how does (Num)Pyro compare with PyMC? I haven’t had the good fortune of working with any of these libraries since before Pyro (an
by diab0lic 2y ago
For those with more experience how does (Num)Pyro compare with PyMC? I haven’t had the good fortune of working with any of these libraries since before Pyro (and presumably numpyro), and with PyMC3 back when it used Theano under the hood.
Are the two libraries in competition? Or complimentary? I’ve been playing with PyMC for a personal project and am curious what I might gain from investigating (Num)Pyro?
- nsingh2 2y agoI tired both a while back, but nothing too big or serious. One thing that numpyro benefits from is JAX's speed, so it might be faster for larger models. Though PyTensor, which is the backend for PyMC can apparently also generate JAX code, so the difference might not be drastic. The PyMC API also seemed to me easier to get started with for those learning Bayesian stats. One thing I remember that I disliked about PyMC was the PyTensor API, it feels too much like Theano/TensorFlow. I much prefer using JAX for writing custom models.
- ailun 2y agoYou'll lose a lot of the PyMC convenience functions with Numpyro but gain a lot of control and flexibility over your model specification. If you're doing variational inference, Numpyro is the way to go. You can use the Numpyro NUTS sampler in PyMC with pm.sample(nuts_sampler="numpyro") and it will significantly speed up sampling. It is less stable in my experience.
- wthomp 2y agoThis is maybe not the place, but we did some apples to apples comparisons between PyMC, Dynesty, and the Julia Turing.jl package. A little to my surprise, despite being a Julia fan, Turing really outperformed both the Python solutions. I think JAX should be competitive in raw speed, so it might come down to the maturity of the samplers we used.
- sampo 2y agoI find the PyMC situation confusing. But PyMC should be able to use JAX in the backend: https://www.pymc.io/projects/examples/en/latest/samplers/fast_sampling_with_jax_and_numba.html https://www.pymc.io/projects/examples/en/latest/samplers/fas...
- srean 2y agoI agree with you on the PyMC situation. There has been many changes to the backend engine, from Theano, to TensorFlow, back to Theano, then JAX and so on, that it becomes a little confusing.
- szvsw 2y agoI would say that, at least for me, PyMC’s main advantage was in DX. I just found model construction much more straightforward and better aligned with how I wanted to assemble the model. This textbook/walkthrough is great: https://a.co/d/9dWXDTK https://a.co/d/9dWXDTK
- diab0lic 2y agoThanks for the textbook link, this looks right up my alley!
- tfehring 2y agoPyMC can use NumPyro as a backend. PyMC's syntax and primitives for declaring models are much nicer than (Num)Pyro's, as is the developer experience overall. But those come at the cost of having to deal with PyTensor (a fork of a fork of Theano), which is quite bad IMO, instead of just working with Numpy or PyTorch.