# Warning secondorder ADtype in optimization.jl

**URL:** <https://discourse.julialang.org/t/warning-secondorder-adtype-in-optimization-jl/122539>\
**Category:** New to Julia\
**Tags:** differentiation, optimization\
**Created:** [November 12, 2024, 10:04am UTC](https://discourse.julialang.org/t/warning-secondorder-adtype-in-optimization-jl/122539 "2024-11-12T10:04:19Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [November 12, 2024, 10:14am UTC](https://discourse.julialang.org/t/warning-secondorder-adtype-in-optimization-jl/122539/2 "2024-11-12T10:14:49Z")

</div>

The code that governs AD backend selection seems to be here:

> <https://github.com/SciML/OptimizationBase.jl/blob/2ffab7e93197c1fc8d9ed6a39857e301a71a474e/src/adtypes.jl#L222-L236>

By default, when you provide a backend `adtype`, it will use `soadtype = DifferentiationInterface.SecondOrder(adtype, adtype)` to compute the Hessian. You can make this choice yourself by providing `adtype = SecondOrder(adtype_outer, adtype_inner)`, in which case `adtype_inner` will be used for the gradient.

Note that I deduced this from the code but if it is not documented then it is subject to change. @Vaibhavdixit02 is the right person to ask.

---

_[View the full topic](https://discourse.julialang.org/t/warning-secondorder-adtype-in-optimization-jl/122539)._
