Skip to content

Commit 5744f8f

Browse files
Merge pull request #1137 from ChrisRackauckas-Claude/add-enzyme-sensealg-inactive
Add Enzyme extension to make AbstractSensitivityAlgorithm inactive
2 parents 820ddfb + 171940b commit 5744f8f

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
ChainRules = "082447d4-558c-5d27-93f4-14fc19e9eca2"
3838
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
3939
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
40+
EnzymeRules = "b2b7a20a-8ddc-4497-9a0a-d49b80ff0020"
4041
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
4142
MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078"
4243
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
@@ -54,6 +55,7 @@ Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
5455
[extensions]
5556
SciMLBaseChainRulesCoreExt = "ChainRulesCore"
5657
SciMLBaseDistributionsExt = "Distributions"
58+
SciMLBaseEnzymeExt = "EnzymeRules"
5759
SciMLBaseForwardDiffExt = "ForwardDiff"
5860
SciMLBaseMLStyleExt = "MLStyle"
5961
SciMLBaseMakieExt = "Makie"
@@ -80,6 +82,7 @@ ConstructionBase = "1.5"
8082
Distributed = "1.10"
8183
Distributions = "0.25"
8284
DocStringExtensions = "0.9"
85+
EnzymeRules = "0.1"
8386
EnumX = "1"
8487
ForwardDiff = "0.10.36, 1"
8588
FunctionWrappersWrappers = "0.1.3"

ext/SciMLBaseEnzymeExt.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module SciMLBaseEnzymeExt
2+
3+
using SciMLBase
4+
import EnzymeRules
5+
6+
# Enzyme rules for SciMLBase abstract types
7+
#
8+
# Sensitivity algorithms define HOW to compute derivatives, not WHAT to differentiate.
9+
# They should be treated as inactive (constant) during Enzyme differentiation to prevent
10+
# errors when they are stored in problem structures that Enzyme differentiates through.
11+
#
12+
# This fixes issues like SciMLSensitivity.jl#1225 where passing `sensealg` to ODEProblem
13+
# constructor would fail with Enzyme.
14+
15+
# All sensitivity algorithm types should be inactive for Enzyme differentiation
16+
EnzymeRules.inactive_type(::Type{<:AbstractSensitivityAlgorithm}) = true
17+
18+
end

0 commit comments

Comments
 (0)