Skip to content

Commit e65d05c

Browse files
Add DifferentiationInterface.Prep support to anyeltypedual
This commit adds support for DifferentiationInterface.Prep types to opt out of dual number checking. This fixes issue #718 in NonlinearSolve.jl where Prep objects in parameters were incorrectly triggering automatic differentiation detection. Changes: - Added DifferentiationInterface to weakdeps and extensions in Project.toml - Created new extension SciMLBaseDifferentiationInterfaceExt with anyeltypedual overloads for Prep types, following the same pattern as ForwardDiff.AbstractConfig Fixes SciML/NonlinearSolve.jl#718 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent f2bfd53 commit e65d05c

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

Project.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ SymbolicIndexingInterface = "2efcf032-c050-4f8e-a9bb-153293bab1f5"
3737
[weakdeps]
3838
ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2"
3939
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
40+
DifferentiationInterface = "a0c0ee7d-e4b9-4e03-894e-1c5f64a51d63"
4041
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
4142
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
4243
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
@@ -55,6 +56,7 @@ Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
5556

5657
[extensions]
5758
SciMLBaseChainRulesCoreExt = "ChainRulesCore"
59+
SciMLBaseDifferentiationInterfaceExt = "DifferentiationInterface"
5860
SciMLBaseDistributionsExt = "Distributions"
5961
SciMLBaseEnzymeExt = "Enzyme"
6062
SciMLBaseForwardDiffExt = "ForwardDiff"
@@ -80,6 +82,7 @@ ChainRules = "1.58.0"
8082
ChainRulesCore = "1.18"
8183
CommonSolve = "0.2.4"
8284
ConstructionBase = "1.5"
85+
DifferentiationInterface = "0.6, 0.7"
8386
Distributed = "1.10"
8487
Distributions = "0.25"
8588
DocStringExtensions = "0.9"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module SciMLBaseDifferentiationInterfaceExt
2+
3+
using SciMLBase, DifferentiationInterface
4+
5+
import SciMLBase: anyeltypedual
6+
7+
# Opt out since these are using for preallocation, not differentiation
8+
function anyeltypedual(x::DifferentiationInterface.Prep,
9+
::Type{Val{counter}} = Val{0}) where {counter}
10+
Any
11+
end
12+
function anyeltypedual(x::Type{T},
13+
::Type{Val{counter}} = Val{0}) where {counter} where {T <:
14+
DifferentiationInterface.Prep}
15+
Any
16+
end
17+
18+
end

0 commit comments

Comments
 (0)