Commit cedb753
committed
test/desauty: user-side alias break in Enzyme init closure
The desauty SCC init test's Enzyme block was @test_broken because
`Enzyme.gradient(set_runtime_activity(Reverse), Const(closure), itunables)`
silently returned zero. Root cause:
* The closure captures `iprob` (an `SCCNonlinearProblem`).
* `irepack(t)` builds a new `MTKParameters` via `@set! p.tunable = t`,
which **shares the `caches` tuple** with the captured `iprob.p.caches`
(correct semantics for SciMLStructures' lightweight repack).
* The inner `solve!`'s SCC machinery mutates that aliased cache buffer.
* `Const(closure_capturing_iprob)` tells Enzyme not to allocate a
shadow for the captured state, so the derivative info carried by
those cache writes has no shadow buffer to land in and is silently
dropped. See EnzymeAD/Enzyme.jl#3124 for the minimal reproducer.
User-side fix (no source changes outside the test): explicitly copy the
caches tuple via `ConstructionBase.setproperties` before `remake`, so
the new `MTKParameters` carries fresh cache buffers and Enzyme's
`set_runtime_activity` reverse pass correctly produces non-zero
gradients. Verified locally: matches FiniteDiff to 8 significant
figures.
`@test_broken` → `@test`; the `use_scc = false` and `use_scc = true`
branches now both share the same test block.
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>1 parent 7896045 commit cedb753
1 file changed
Lines changed: 29 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
134 | 135 | | |
135 | 136 | | |
136 | 137 | | |
137 | | - | |
138 | | - | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
146 | 151 | | |
147 | 152 | | |
148 | | - | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
149 | 162 | | |
150 | 163 | | |
151 | 164 | | |
152 | 165 | | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
167 | | - | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
168 | 172 | | |
169 | 173 | | |
170 | 174 | | |
| |||
0 commit comments