Commit 6e09c37
Fix Enzyme reverse rule tangent accumulation for structured parameters
When parameters are SciMLStructure types (e.g. MTKParameters), use the
SciMLStructures interface (canonicalize/replace!) to accumulate tangents
into the parameter shadow instead of raw broadcasting.
The tangent from SciMLSensitivity may be:
- A tunable gradient vector (EnzymeOriginator path)
- Another SciMLStructure
- A broadcastable array (plain Vector parameters)
All cases are handled through SciMLStructures.canonicalize to extract
and accumulate the tunable portion.
Fixes the tangent accumulation portion of #878.
Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 1ce693f commit 6e09c37
1 file changed
+35
-2
lines changedLines changed: 35 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
8 | 41 | | |
9 | 42 | | |
10 | 43 | | |
| |||
57 | 90 | | |
58 | 91 | | |
59 | 92 | | |
60 | | - | |
| 93 | + | |
61 | 94 | | |
62 | | - | |
| 95 | + | |
63 | 96 | | |
64 | 97 | | |
65 | 98 | | |
| |||
0 commit comments