Commit 66a76ac
committed
Annotate @test_broken Enzyme blocks with Const(loss) + set_runtime_activity
The three `@test_broken Enzyme.gradient` blocks (`mtk.jl` line 168,
`parameter_initialization.jl` "Adjoint through Prob (Enzyme)",
`desauty_dae_mwe.jl` "Enzyme through init") previously called
`Enzyme.gradient(Enzyme.Reverse, loss, tunables)` — i.e. relied on
`Enzyme.gradient` to infer annotations on a closure that captures a
mutable `ODEProblem`/`NonlinearProblem`. That triggers
`EnzymeMutabilityException` on a captured-mutable, which per Billy Moses
(EnzymeAD/Enzyme.jl#3117 close) is correct Enzyme behavior, not a bug:
`Enzyme.gradient` can't annotate captures, so the user must do it.
Apply the documented user-side pattern in all three blocks:
Enzyme.gradient(
Enzyme.set_runtime_activity(Enzyme.Reverse),
Enzyme.Const(loss),
tunables,
)
Plus, for `desauty_dae_mwe.jl`, pin `solve(iprob2, NewtonRaphson())` so
Enzyme's type analysis does not trip on the polyalgorithm Union the
default NonlinearSolve dispatch would otherwise emit. (`mtk.jl` already
uses `Rodas5P()`; `parameter_initialization.jl` uses an `ODEProblem`
solve with `GaussAdjoint` sensealg, no NonlinearSolve polyalg in the AD
hot path.)
These tests **stay `@test_broken`** — the activity layer is correct
after this change, but the chain still hits a `MixedDuplicated` /
`Core.SimpleVector` MethodError further down in Enzyme's
runtime-activity wrapping for MTK-`System` / `NonlinearSolution` types.
Tracked in #1359, with one upstream piece
already filed at SciML/ModelingToolkit.jl#4553 (declare `AbstractSystem`
as `inactive_type`). When the remaining upstream lifts, flipping
`@test_broken` → `@test` is the only change needed in these blocks.
Refs #1323, #1359; EnzymeAD/Enzyme.jl#3117.
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>1 parent 8b08de3 commit 66a76ac
3 files changed
Lines changed: 61 additions & 34 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
120 | 121 | | |
121 | 122 | | |
122 | 123 | | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
142 | 149 | | |
143 | | - | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
144 | 154 | | |
145 | 155 | | |
146 | 156 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
168 | 176 | | |
169 | 177 | | |
170 | 178 | | |
| |||
185 | 193 | | |
186 | 194 | | |
187 | 195 | | |
188 | | - | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
189 | 200 | | |
190 | 201 | | |
191 | 202 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
80 | 83 | | |
81 | 84 | | |
82 | 85 | | |
| |||
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
92 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
93 | 99 | | |
94 | 100 | | |
95 | 101 | | |
| |||
0 commit comments