Skip to content

Commit 1ddc132

Browse files
Merge pull request #4553 from ChrisRackauckas-Claude/cc/system-inactive-type
Declare AbstractSystem as Enzyme inactive_type
2 parents d039e53 + 01cff42 commit 1ddc132

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

lib/ModelingToolkitBase/src/ModelingToolkitBase.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,13 @@ function EnzymeCore.EnzymeRules.inactive_noinl(
363363
)
364364
return true
365365
end
366+
# Declare the type itself inactive so Enzyme's runtime-activity dispatch
367+
# (e.g. `MixedDuplicated`-wrapping) never tries to track a `System` as a
368+
# differentiable value. Without this, `Enzyme.gradient(set_runtime_activity(Reverse),
369+
# Const(loss), p)` over a closure capturing an MTK-generated problem
370+
# (which transitively carries the symbolic `System`) trips a
371+
# `MethodError MixedDuplicated(::System, ::System)` in `create_activity_wrapper`.
372+
EnzymeCore.EnzymeRules.inactive_type(::Type{<:AbstractSystem}) = true
366373

367374
function __init__()
368375
SU.hashcons(unwrap(t_nounits), true)

0 commit comments

Comments
 (0)