Skip to content

Use NoTangent instead of nothing in @grad - #332

Draft
devmotion wants to merge 1 commit into
masterfrom
dmw/notangent-in-grad
Draft

devmotion wants to merge 1 commit into
masterfrom
dmw/notangent-in-grad

Conversation

@devmotion

Copy link
Copy Markdown
Member

Tangents returned by @grad pullbacks now use the ChainRulesCore types throughout:

  • nothing returned by a @grad pullback is converted to NoTangent() right after the pullback (and after _check_tangents), so _add_to_deriv! only handles AbstractZero, thunks and plain values.
  • The internal fill rule returns NoTangent() for the dimensions.
  • The @grad docstring lists the accepted tangents.

Existing pullbacks returning nothing keep working. The internal deriv buffers are unchanged (dense and preallocated).

Adds a test for a @grad pullback returning NoTangent(); the existing nothing tests cover the conversion.

🤖 Generated with Claude Code

`nothing` returned by a `@grad` pullback is converted to `NoTangent()`,
so only ChainRulesCore tangent types reach `_add_to_deriv!`. The `fill`
rule returns `NoTangent()` directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.78%. Comparing base (fdf1b3d) to head (facd8ef).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #332   +/-   ##
=======================================
  Coverage   94.77%   94.78%           
=======================================
  Files          19       19           
  Lines        1703     1706    +3     
=======================================
+ Hits         1614     1617    +3     
  Misses         89       89           

☔ 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.

This branch has not been deployed

No deployments
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.

1 participant