Skip to content

Amortized VI ignores vi_method #2073

Closed

Description

@janfb

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 warning

I checked this for all four methods.

I see two options:

  • Option 1: train_amortized() raises an error when vi_method is 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.

Activity

  1. BHARATH0153 commented on Oct 17, 2026

    @BHARATH0153
    Contributor

    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.

  2. BHARATH0153 commented on Oct 20, 2026

    @BHARATH0153
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions