Repository navigation
Unthunk cotangent components in findnz pullbacks - #843
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@oxinabox can we merge this? CI failures appear unrelated |
|
I'm surprised about this issue in the first place - if
|
Indexing a `Tangent` unthunks only the accessed field, whereas destructuring via `indexed_iterate` does not unthunk at all. Test with thunked components, using erroring thunks for the unused ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Based on my gut feeling, I looked into this issue together with Claude. A So rather than unthunking |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #843 +/- ##
=======================================
Coverage 96.57% 96.57%
=======================================
Files 28 28
Lines 3618 3618
=======================================
Hits 3494 3494
Misses 124 124 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The
findnzpullbacks destructure the incoming tangent and pass the values component straight tosparse/sparsevec, but that component can itself be a thunk —unthunkon the outer tangent doesn't unthunk its components. For example:This unthunks the component in both the matrix and vector pullbacks and adds tests that call them with thunked components. With the fix, the gradient above returns the expected
SparseMatrixCSC.