(pathfinder)=

Pathfinder Variational Inference

:::{post} Feb 5, 2023 :tags: variational inference, JAX :category: advanced, how-to :author: Thomas Wiecki :::

Pathfinder {cite:p}zhang2021pathfinder is a variational inference algorithm that produces samples from the posterior of a Bayesian model. It compares favorably to the widely used ADVI algorithm. On large problems, it should scale better than most MCMC algorithms, including dynamic HMC (i.e. NUTS), at the cost of a more biased estimate of the posterior. For details on the algorithm, see the arxiv preprint.

PyMC's implementation of Pathfinder is now natively integrated using PyTensor. The Pathfinder implementation can be accessed through pymc-extras, which can be installed via:

pip install git+https://github.com/pymc-devs/pymc-extras

First, define your PyMC model. Here, we use the 8-schools model.

Next, we call pmx.fit() and pass in the algorithm we want it to use.

Just like pymc.sample(), this returns an idata with samples from the posterior. Note that because these samples do not come from an MCMC chain, convergence can not be assessed in the regular way.

References

:::{bibliography} :filter: docname in docnames :::

Authors

  • Authored by Thomas Wiecki on Oct 11 2022 (pymc-examples#429)
  • Re-execute notebook by Reshama Shaikh on Feb 5, 2023
  • Bug fix by Chris Fonnesbeck on Jul 17, 2024
  • Updated to PyMC implementation by Michael Cao on Feb 13, 2025
  • Updated text by Chris Fonnesbeck on Feb 19, 2025

Watermark

:::{include} ../page_footer.md :::