Non-reversibility of naive stopping criterion for HMC

Hello to everyone!

I am not sure this is the right forum to ask this question, so let me know if it is an inappropriate question. I have been stuck on something which I am sure shouldn’t be too complex, but somehow I cannot wrap my head around it in any way.

In the original paper by Hoffmann and Gelman on NUTS, they present the rationale for defining an automatic stopping for the number of steps L for the leapfrog method. Before presenting the NUTS algorithm, they present the first idea on how to do so, i.e. monitoring the distance from the original point, and stop with the dynamics once the distance from it starts decreasing. We can do this by just monitoring the derivative of the distance from the starting point, which has a very easy form(equation 1 in the paper).

They then claim though that this would not preserve time-reversibility of the algorithm, which I guess would imply that we violate detailed balance. Can anyone tell me why we would violate detailed balance? Is it because this stopping criterion uses some information on the parameters of the Hamiltonian, and hence conditioning on it creates some problems? To me it seems that even with this algorithm, once I stop, I can reverse momentum and proceeding for the same number of leapfrog steps would bring me back to the original point.



@betanalpha @nhuurre

Consider the trajectory that begins at the origin, and then proceeds to (1, 0), then (1, 1), then (1.5, 0.5). Each step takes this trajectory farther from it’s beginning at the origin. Now go in reverse, starting from (1.5, 0.5), and the stopping criterion is triggered on the second step (from (1,1) to (1,0)).

1 Like

Dear @jsocolar, first of all thanks for the quick answer.

Not sure I understood the example, the first coordinate is the position p and the second is the momentum q, or are they to be considered 2D coordinates on the cartesian plane. Also I think you swapped the coordinates when you start with “go in reverse” right?

If I understood correctly(please correct me if this is not the case), your point is that if I define as a stopping criterion that I stop when the distance stops increasing, I have to do so also when going back. I cannot just say, when I go back I anyhow do the same number of leapfrog steps as when I was coming forward?


These are 2D coordinates on the cartesian plane (e.g. for a 2-parameter model)

Yes. Edited.

Exactly. In the reverse case, you don’t know where the starting point was. You have to be able to reach any starting point that might itself have reached the ending point where you find yourself.

1 Like

Ok, thank you so much!

Makes sense, I was just getting confused by the fact that I could still reach the starting point by doing the same amount of steps backward, but as you said this cannot be used and I hence can get that the stopping criterion gets triggered before reaching the original starting point when going back.


1 Like