The performance of Hamiltonian Monte Carlo simulations crucially depends on both the integration timestep and the number of integration steps. We present an adaptive general-purpose framework to automatically tune such parameters based on a local loss function that promotes the fast exploration of phase space. We show that a good correspondence between loss and autocorrelation time can be established, allowing for gradient-based optimization using a fully differentiable set-up. The loss …