# DifferentiationInterface not generating correct shadow

**URL:** <https://discourse.julialang.org/t/differentiationinterface-not-generating-correct-shadow/131868>\
**Category:** Optimization (Mathematical)\
**Tags:** question, optimization, enzyme\
**Created:** [August 26, 2025, 7:42pm UTC](https://discourse.julialang.org/t/differentiationinterface-not-generating-correct-shadow/131868 "2025-08-26T19:42:11Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [August 27, 2025, 8:09am UTC](https://discourse.julialang.org/t/differentiationinterface-not-generating-correct-shadow/131868/7 "2025-08-27T08:09:52Z")

</div>

At the moment this will yield the same behavior for second-order optimization algorithms inside Optimization.jl.

```julia
julia> result = Optimization.solve(optprob, Optimization.Sophia(); maxiters=10)
┌ Warning: The selected optimization algorithm requires second order derivatives, but `SecondOrder` ADtype was not provided. 
│ So a `SecondOrder` with AutoEnzyme(mode=ReverseMode{false, true, false, FFIABI, false, false}()) for both inner and outer will be created, this can be suboptimal and not work in some cases so 
│ an explicit `SecondOrder` ADtype is recommended.
└ @ OptimizationBase ~/.julia/packages/OptimizationBase/Lc8sB/src/cache.jl:49
ERROR: MethodError: no method matching Duplicated(::ComponentVector{Float32, Vector{Float32}, Tuple{Axis{…}}}, ::Vector{Float32})
The type `Duplicated` exists, but no method is defined for this combination of argument types when trying to construct it.

```

See also:

- [Choice of second-order AD and warnings · Issue #970 · SciML/Optimization.jl · GitHub](https://github.com/SciML/Optimization.jl/issues/970)
- [Warning secondorder ADtype in optimization.jl - #3 by JADekker](https://discourse.julialang.org/t/warning-secondorder-adtype-in-optimization-jl/122539/3)

---

_[View the full topic](https://discourse.julialang.org/t/differentiationinterface-not-generating-correct-shadow/131868)._
