Summary
Core8 (test/Core8/mtk.jl, "MTK Forward Mode") fails because reverse-mode Enzyme crashes differentiating MTK's DAE-initialization parameter promotion (ModelingToolkitBase.__apply_copy_template) on the DefaultInit setup — CI shows BoundsError: attempt to access MemoryRef{Float64} at index [6/7].
Triggered by #1498 (3907835), which restored an Enzyme-native init-sensitivity gradient: _init_originator_gradient(::EnzymeOriginator) (src/concrete_solve.jl:384) → Enzyme.gradient(set_runtime_activity(Reverse), Const(init_loss), tunables). That nested Enzyme.gradient is what hits the Enzyme bug.
Upstream
Filed: EnzymeAD/Enzyme.jl#3259 (reverse-mode over __apply_copy_template's Union-typed-index mapreduce/vcat → undersized shadow Memory{Float64} BoundsError / TypeAnalysis hang / symbol-multiply-defined, depending on compile state). CheckInit/BrownFullBasicInit work; only DefaultInit breaks.
Options
Per @ChrisRackauckas's call, currently filing upstream and leaving the Enzyme-native path; the ForwardDiff stopgap is available if we want Core8 green before Enzyme lands the fix.
Summary
Core8(test/Core8/mtk.jl, "MTK Forward Mode") fails because reverse-mode Enzyme crashes differentiating MTK's DAE-initialization parameter promotion (ModelingToolkitBase.__apply_copy_template) on theDefaultInitsetup — CI showsBoundsError: attempt to access MemoryRef{Float64} at index [6/7].Triggered by #1498 (
3907835), which restored an Enzyme-native init-sensitivity gradient:_init_originator_gradient(::EnzymeOriginator)(src/concrete_solve.jl:384) →Enzyme.gradient(set_runtime_activity(Reverse), Const(init_loss), tunables). That nestedEnzyme.gradientis what hits the Enzyme bug.Upstream
Filed: EnzymeAD/Enzyme.jl#3259 (reverse-mode over
__apply_copy_template'sUnion-typed-indexmapreduce/vcat→ undersized shadowMemory{Float64}BoundsError / TypeAnalysis hang / symbol-multiply-defined, depending on compile state).CheckInit/BrownFullBasicInitwork; onlyDefaultInitbreaks.Options
ForwardDiffinstead ofEnzyme.gradientin_init_originator_gradient(::EnzymeOriginator)(the init nonlinear solve already runs onAutoForwardDiff). This routes around the Enzyme bug for users + tests without reintroducing the old Zygote workaround (Enzyme: route MTK DAE init gradient through Zygote; enable Enzyme-outer mtk.jl test #1467). Changes Restore Enzyme-native init-sensitivity gradient (revert #1467 Zygote workaround) #1498's choice for the init sub-gradient.Per @ChrisRackauckas's call, currently filing upstream and leaving the Enzyme-native path; the ForwardDiff stopgap is available if we want Core8 green before Enzyme lands the fix.