Checking if used fwd or reverse mode AD?

Is there a way to check (in cmdstanr) whether your Stan model was run using reverse-mode or forward-mode autodiff?

Furthermore is there a way to force one method or the other?

Stan’s algorithms all use reverse mode. There’s currently no way to use forward mode instead, and not all of the functions supported by Stan are currently useable in forward mode

1 Like

To put a slightly finer point on it, we have forward mode implemented in Stan, but it’s not nearly as efficiently coded. We only use it for higher-order derivatives. Unless your problems is very small dimensional, reverse mode is much more efficient. Turing.jl in Julia lets you swap between forward- and reverse-mode autodiff.

1 Like