You’re right, Zygote does reverse-mode differentiation, so the argument to the pullback of f
is actually df/df
, which is just one. In your case, I would suggest looking into forward-mode AD using ForwardDiff
instead because it should be much more efficient for differentiating K
and it will be easier to implement this custom adjoint for f
.