Commit b0860b8
fix Enzyme HVP returning zeros instead of correct Hessian-vector product
The Enzyme extension's Hessian-vector product (HVP) implementation was
incorrectly using `Enzyme.make_zero(x)` which zeroed out the tangent
direction vector `v`, causing the forward-mode AD to have no direction
to differentiate in. This resulted in HVP always returning zeros.
Fixed by using the correct forward-over-reverse AD approach with the
existing `inner_grad` function, which properly computes H*v by taking
the gradient ∇f(θ) in reverse mode and differentiating it in forward
mode along direction v.
Fixes both in-place (OptimizationFunction{true}) and out-of-place
(OptimizationFunction{false}) versions.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 6839663 commit b0860b8
1 file changed
+24
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
206 | | - | |
207 | | - | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
208 | 213 | | |
209 | 214 | | |
210 | 215 | | |
| |||
553 | 558 | | |
554 | 559 | | |
555 | 560 | | |
| 561 | + | |
556 | 562 | | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
563 | 575 | | |
564 | 576 | | |
565 | 577 | | |
| |||
0 commit comments