Open sefffal opened 1 month ago
I think I see the issue: https://github.com/TuringLang/AdvancedHMC.jl/blob/2b3814ccbb36806eb0f21c2c937146606a873884/src/sampler.jl#L198C1-L199C62
percentage_divergent_transitions = num_divergent_transitions / I
percentage_divergent_transitions_during_adaption =
num_divergent_transitions_during_adaption / i
should instead be:
percentage_divergent_transitions = num_divergent_transitions / I
percentage_divergent_transitions_during_adaption =
num_divergent_transitions_during_adaption / min(i, n_adapts)
This is difficult to demonstrate, but I believe the value of
ratio_divergent_transitions_during_adaption
printed during sampling whenprogress=true
is currently incorrect.The behaviour I've seen is:
ratio_divergent_transitions_during_adaption
to increaseratio_divergent_transitions
stays zero.ratio_divergent_transitions_during_adaption
starts to drop (even though adaptation is now finished!) until it reaches a lower value, eg 50% lower if there are equal numbers of samples during and after adaptation.I couldn't find the right location in the code, but I believe that
ratio_divergent_transitions_during_adaption
might be calculating the ratio using the total number of samples so far, and not stopping updating after adaptation completes.