Skip to content

Add nuts-rs's metric adaptation #311

Open
@sethaxen

Description

@sethaxen

nuts-rs is a Rust implementation of NUTS that is wrapped by nutpie for use in PyMC. It has a novel metric adaptation approach, described as:

In a first window we sample using the identity as mass matrix and adapt the step size using the normal dual averaging algorithm. After discard_window draws we start computing a diagonal mass matrix using an exponentially decaying estimate for sqrt(sample_var / grad_var). After 2 * discard_window draws we switch to the entimated mass mass_matrix and keep adapting it live until stop_tune_at.

On Mastodon, @aseyboldt shared the following plot:

On Slack, he explained:

This shows the effective sample size divided by the total number of gradient evals (during warmup + sampling), for 200 and 1000 warmup steps and nutpie and stan (with a diagonal mass matrix), for different models

The models were selected from posteriordb. In general, this seems to outperform Stan's metric adaptation and also work well for more models. It also seems to allow for much shorter warm-up phases.

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