It seems you called sersic2d by passing everything as a positional argument, instead of only the first two? Perhaps you forgot the semicolon ; that is meant to separate keyword arguments?
In order for ForwardDiff.jl to work it passes a special number (Dual) through your function. So if you restrict your function to only accept Float64 it won’t work with the Dual type that ForwardDiff passes to it. To solve this you could:
Remove the types from the function signature entirely
Relax the type assertions to <:Real
Use a different autodiff backend such as Mooncake.jl
I would recommend doing #1 unless the types are actually used for dispatch.