Are you referring to the way Dynare computes derivatives for computing the perturbation solution? Here we use analytic derivatives computed by our C++ preprocessor (so similar to say Matlab’s symbolic toolbox). We don’t use automatic differentiation techniques for that.
Or, as Johannes mentioned, do you want to provide an analytically computed gradient to the optimizer? analytic_derivation
is then the way to go. What we do under the hood is explained for a first-order approximation in Ratto and Iskrev (2011); the relevant code is in get_perturbation_params_derivs.m
which can also compute parameter derivatives of the perturbation solution matrices up to a third-order approximation. I will release a technical note soon, how we do that.