Would it be possible to see the gradient and every leapfrog of RStan?

Yes, that’s right this saves each iteration, not each leapfrog. That’s why I suggested setting max treedepth to 1, so you’d actually get each leapfrog.

I’ve seen something like this before, and I have a guess (but it’s just a guess) about the behavior. My guess is that when the likelihood surface, far from the typical set, has a steep hill and then a large flat region, the sampler’s initial exploration can send it hurtling down the hill and then out a long way onto the flat region, sort of like riding a sled down a hill and then across a flat field. If the problematic region resides way out on that flat region somewhere, then a large treedepth allows the chain to coast across the flat region far enough to reach the problematic area, whereas a small max treedepth causes the momentum to get resampled before the exploration has a chance to coast too far out onto the flat region.

More discussion of this (hypothetical) phenomenon here:

2 Likes