Description
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 forsqrt(sample_var / grad_var)
. After2 * discard_window
draws we switch to the entimated mass mass_matrix and keep adapting it live untilstop_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.