Skip to content

Pin that mul! into a Float64 buffer throws instead of zeroing the gradient (#171) - #305

Merged
devmotion merged 1 commit into
masterfrom
dmw/issue-171
Sep 24, 2026
Merged

devmotion merged 1 commit into
masterfrom
dmw/issue-171

Conversation

@devmotion

Copy link
Copy Markdown
Member

Closes #171.

The zero gradient came from convert(Float64, ::TrackedReal) silently returning the value up to v1.6.0, which severed the tape when mul! wrote into a Float64 buffer. #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

… 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

codecov Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.21%. Comparing base (68c5a56) to head (247f814).
⚠️ Report is 1 commits behind head on master.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@devmotion
devmotion merged commit c70d2ae into master Sep 24, 2026
8 checks passed
@devmotion
devmotion deleted the dmw/issue-171 branch September 24, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect zero gradient with no error thrown

1 participant