Skip to content

Core8: Enzyme-native DAE-init gradient crashes on MTK __apply_copy_template (BoundsError); upstream Enzyme#3259 #1514

Description

@ChrisRackauckas-Claude

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions