Add PSIS k-hat diagnostic for variational inference#2139
Open
michaelellis003 wants to merge 1 commit intopyro-ppl:masterfrom
Open
Add PSIS k-hat diagnostic for variational inference#2139michaelellis003 wants to merge 1 commit intopyro-ppl:masterfrom
michaelellis003 wants to merge 1 commit intopyro-ppl:masterfrom
Conversation
Implement Pareto Smoothed Importance Sampling (PSIS) diagnostic to evaluate variational approximation quality, as requested in pyro-ppl#1804. The k-hat statistic is the shape parameter of a Generalized Pareto Distribution fitted to the upper tail of importance weights. It indicates whether the guide is a reliable approximation: k < 0.5: good (finite variance) 0.5 <= k < 0.7: marginal (finite mean) k >= 0.7: unreliable GPD fitting uses Zhang & Stephens (2009) with prior regularization from Vehtari et al. (2024), matching Pyro's implementation and Vehtari's reference code to ~1e-15.
3618dc0 to
a69fd18
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the Pareto Smoothed Importance Sampling (PSIS) k-hat diagnostic for evaluating variational approximation quality, as requested in #1804.
psis_diagnostic(rng_key, param_map, model, guide, *args)computes the k-hat statistic by fitting a Generalized Pareto Distribution to the upper tail of importance weightspsis_diagnosticand Vehtari's reference implementation to ~1e-15Changes
numpyro/infer/importance.py(new): GPD fitting (_fit_generalized_pareto), PSIS tail extraction (_psis_khat), and public API (psis_diagnostic) with batched evaluation viachunk_sizetest/infer/test_importance.py(new): 36 tests covering GPD parameter recovery, cross-implementation reference values (precomputed from Vehtari's gpdfitnew and Pyro 1.9.1), regime classification against paper thresholds, batching correctness, edge cases, and SVI integrationnumpyro/infer/__init__.py: Exportpsis_diagnosticdocs/source/utilities.rst: Add API documentation entryReferences
Fixes #1804