Closed
Description
With vi_method, users choose how VI fits q to the posterior. Some methods cover all modes of the posterior, others fit only one mode. This choice matters for multimodal posteriors.
train() uses the chosen method. train_amortized() ignores it and always fits the reverse KL, without a warning. So a user who chooses IW or fKL for an amortized posterior can miss modes without knowing it.
For example:
posterior = VIPosterior(potential_fn, prior, q="maf", vi_method="IW")
posterior.train_amortized(theta, x) # fits the reverse KL, no warningI checked this for all four methods.
I see two options:
- Option 1:
train_amortized()raises an error whenvi_methodis not"rKL", and the docstrings say that amortized VI supports only the reverse KL. - Option 2:
train_amortized()supports all four methods. Each method then needs a loss for batches of observations.
I suggest option 1 now. Option 2 can follow when someone needs amortized VI that covers all modes.
Found while reviewing PR #2067.
Metadata
Metadata
Assignees
Labels
No labels
Activity
BHARATH0153 commentedon Oct 17, 2026
Option 1 looks right to me. The check fits best at the top of train_amortized() so it fails fast: raise if self.vi_method != "rKL" (before the flow/optimizer is built), and add a line to the docstring saying amortized training is rKL-only. train() keeps all four methods, so the only behavior change is that amortized stops silently fitting reverse KL.
I'd also add a small test that the other three methods raise.
BHARATH0153 commentedon Oct 20, 2026
#2074
fix: restrict amortized VI to rKL only, raise otherwise (#2074)