Sampling speeding up

Hey! I’ve done a lot of work on the tuning side for these algorithms, and you’ve got it mostly exactly right. NUTS will keep on doubling in length until it hits a certain dynamic criterion (a U-turn), and then do some book keeping to maintain detailed balance. Part of the U-turn criterion is “is this the 10th doubling?” (I think 8th doubling during tuning). so @daniel-saunders-phil spotted this well – note that the number of steps is always 2^n - 1 (I see a 31, two 15’s, a bunch of 7’s, and so on), corresponding to the number of doublings.

PyMC will constantly update the step size during tuning to try to get an acceptance rate of 80% (using stochastic optimization!). It also updates the mass matrix, which is by default diagonal, and every 101st step. This is why in @daniel-saunders-phil’s first plot, there appears to be a discontinuity at step 101: the mass matrix adaptation kicks in, and then it is updated live after that with a windowed approach.

Tuning in PyMC3 is a talk from a few years ago on how PyMC and Stan do tuning. I’m not sure if they’re both true any more! There are a bunch of gifs on the page that don’t autoplay anymore, but do spark joy: I had to right click: “Show Controls”.

7 Likes