-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Revamp batch mode for pushforward
, pullback
and hvp
#412
Merged
Conversation
This file contains 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
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #412 +/- ##
==========================================
- Coverage 97.33% 93.63% -3.71%
==========================================
Files 104 102 -2
Lines 4922 4885 -37
==========================================
- Hits 4791 4574 -217
- Misses 131 311 +180
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
gdalle
changed the title
Simplify batched mode
Revamp batch mode for Aug 28, 2024
pushforward
, pullback
and hvp
pushforward
, pullback
and hvp
This was referenced Aug 29, 2024
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.
Overview
Before this PR:
Batch
type which stores several seeds at once, allowing batch modepushforward
,pullback
andhvp
.pushforward_batched
,pullback_batched
andhvp_batched
(not part of the public API) resolve what would otherwise be a method ambiguity betweenAfter this PR
Batch{B}
is nowTangents{B}
(that's a detail).Long-term vision
Changes
This PR is non-breaking because batch mode was never part of the public API.
Main files to look at:
src/utils/tangents.jl
for the typesrc/fallbacks/no_tangents.jl
for the fallbackssrc/first_order/pushforward.jl
for the new seeded operatorssrc/first_order/derivative.jl
for the non-seeded operators which are also modifiedext/DIFastDifferentiationExt
for a clean example of extension adaptationDI source
Tangents
as anNTuple
wrapper. The second type parameter is the tuple typeT
: if it I had used the tuple'seltype
, it wouldnt be well-defined for empty tuples (Aqua complained about that).pushforward
,pullback
andhvp
to handleTangents
by defaultTangents
themselvesFromPrimitive
backends.DI extensions
Tangents
directly.Tangents{1}
.Warning
For several extensions, this part is suboptimal and may lead to type instabilities that weren't present before. To create a
Tangents
output, I often needmap
orntuple
which requires a closure. An easy fix is to specialize onTangents{1}
every time, I haven't done it yet.DI docs
Tangents
is still not part of the public API while it matures.DIT source
_batched
special case.AutoZero
backends.DIT tests
AutoZero
tests.Warning
This needs to be reactivated before the PR is merged.