pyro-ppl / pyro

Deep universal probabilistic programming with Python and PyTorch
http://pyro.ai
Apache License 2.0
8.5k stars 981 forks source link

Recommend an external normalizing flow library #3297

Open francois-rozet opened 9 months ago

francois-rozet commented 9 months ago

Hello :wave: As the development of Pyro's normalizing flow API has stopped for quite some time, I have been discussing with @fritzo about recommending an external normalizing flow library that would be compatible with Pyro.

I believe that Zuko would be a great recommendation, but disclaimer I am its maintainer.

Why Zuko?

I have extensively used and developed normalizing flows for my research and I always preferred the approach Pyro takes to define parametrized and conditional transformations over other libraries (nflows, FrEIA, FlowTorch, ...). In particular, I liked that Pyro's distributions/transformations shared the interface of PyTorch distributions/transformations, which is not the case of other libraries.

Hence, I started (2 years ago) coding my own normalizing flows for my research and at some point (1 year ago) decided to publish it as an open-source library: Zuko. The project has grown and now features many flow architectures (MAF, NSF, CNF, NAF, UMNN, GF, ...), automatic tests, a fully documented API and tutorials. The repository does not have as many stars as other libraries (mainly because I never advertised it), but actually has many users.

Most importantly, Zuko is very compatible with Pyro as it relies heavily on PyTorch's distributions interface. In Zuko, a flow is a distribution, with sample, log_prob, even_shape, etc.

Zuko is a reference to a powerful firebender (pyromancer) in the Avatar cartoon.

Roadmap

If the Pyro team agrees with recommending Zuko, I propose to

WDYT?

martinjankowiak commented 9 months ago

i don't think we have any strong preferences about any particular normalizing flow library: the more the merrier (provided they're well designed and more-or-less maintained). the issue with all open source contribution is that it's generally easier to add code than it is to maintain it over a long period of time. for example, afaik flowtorch isn't being very actively maintained, and indeed as the tutorial title "Normalizing Flows - Introduction (Part 1)" indicates, a second tutorial was planned but was not forthcoming.

your plan sounds reasonable to me but i'd probably instead rename the above-mentioned tutorial to something like "Normalizing Flows with FlowTorch" and then add a second tutorial named something like "Normalizing Flows with Zuko". i don't see any particular reason to have an exclusive allegiance to one normalizing flows library

francois-rozet commented 9 months ago

Hello @martinjankowiak, thank you for your answer. If I am not mistaken, the current tutorial does not mention FlowTorch and does not make use of its components. It only uses the built-in components of Pyro. It is still a great introduction to Normalizing Flows though, so I think renaming it "Normalizing Flows - Introduction", or "Normalizing Flows - The basics", would fit well.

I agree that the more libraries, the better, but since the built-in flow API is not developed anymore, I think recommending a few compatible alternatives would be nice.

francois-rozet commented 9 months ago

Hello @fritzo, @martinjankowiak, I have submitted a PR (#3302) which adds two tutorials (SVI and VAE) using normalizing flows. The PR also updates the current normalizing flow tutorial. WDYT?

By the way, I tried to write a tutorial about Zuko itself, but I ended up with a copy-paste of the learning the basics tutorial of Zuko, which felt out-of-place within the Pyro tutorials.