Skip to content
This repository was archived by the owner on Aug 25, 2025. It is now read-only.

Commit c12dd3b

Browse files
add warning for sygote
1 parent fc257d9 commit c12dd3b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/cache.jl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,19 @@ function OptimizationCache(prob::SciMLBase.OptimizationProblem, opt;
4242

4343
num_cons = prob.ucons === nothing ? 0 : length(prob.ucons)
4444

45-
if !(prob.f.adtype isa DifferentiationInterface.SecondOrder) &&
45+
if !(prob.f.adtype isa DifferentiationInterface.SecondOrder ||
46+
prob.f.adtype isa AutoZygote) &&
4647
(SciMLBase.requireshessian(opt) || SciMLBase.requiresconshess(opt) ||
4748
SciMLBase.requireslagh(opt))
4849
@warn "The selected optimization algorithm requires second order derivatives, but `SecondOrder` ADtype was not provided.
4950
So a `SecondOrder` with $(prob.f.adtype) for both inner and outer will be created, this can be suboptimal and not work in some cases so
5051
an explicit `SecondOrder` ADtype is recommended."
52+
elseif prob.f.adtype isa AutoZygote &&
53+
(SciMLBase.requiresconshess(opt) || SciMLBase.requireslagh(opt) ||
54+
SciMLBase.requireshessian(opt))
55+
@warn "The selected optimization algorithm requires second order derivatives, but `AutoZygote` ADtype was provided.
56+
So a `SecondOrder` with `AutoZygote` for inner and `AutoForwardDiff` for outer will be created, for choosing another pair
57+
an explicit `SecondOrder` ADtype is recommended."
5158
end
5259

5360
f = OptimizationBase.instantiate_function(

0 commit comments

Comments
 (0)