Pin that mul! into a Float64 buffer throws instead of zeroing the gradient (#171) - #305
Merged
Merged
Conversation
… gradient (#171) The MWE in #171 fills a preallocated buffer with 5-arg `mul!` on views, and ReverseDiff returned an all-zero gradient. With a `Float64` buffer, storing the tracked products fell through to `convert(Float64, ::TrackedReal)`, which up to v1.6.0 silently returned the value and severed the tape. #170 (v1.7.0) made that conversion throw, a week before the issue was filed; with a buffer that can hold tracked reals, the gradients were correct. Nothing pinned either behaviour for this pattern. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #305 +/- ##
=======================================
Coverage 88.21% 88.21%
=======================================
Files 19 19
Lines 1934 1934
=======================================
Hits 1706 1706
Misses 228 228 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #171.
The zero gradient came from
convert(Float64, ::TrackedReal)silently returning the value up to v1.6.0, which severed the tape whenmul!wrote into aFloat64buffer. #170 (v1.7.0) made it throw. This adds a test pinning both the correct gradients (with a buffer that can hold tracked reals, incl. tape replay) and the error.🤖 Generated with Claude Code