-
Notifications
You must be signed in to change notification settings - Fork 277
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
[offload] Add support for fp16 training #374
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
89451bf
initial fwd/bwd commit
c569679
checkpoint work
4e357cd
modify shard loop
510de2d
activation offloading and test to start with
c8df2a6
fix lint errors
6d53152
update comments
8bee0cc
fix lint
a825e96
remove unused var
29c8c34
remove commented out lines
a5d1c88
modify name
48e3e25
remove break
3befc5c
remove profiler comments
e10a874
add support for fp16
3c4e71d
add unit tests
901390f
fix lint errors
1df2619
fix test failure
702b402
fix merge conflicts
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
|
||
import torch | ||
from torch import nn | ||
from torch.cuda.amp import custom_bwd, custom_fwd | ||
|
||
|
||
def _split(modules: nn.Sequential, number_splits: int) -> List[List[nn.Module]]: | ||
|
@@ -125,7 +126,8 @@ class ShardSyncLayer(torch.autograd.Function): | |
""" | ||
|
||
@staticmethod | ||
def forward(ctx: Any, inputs: Any, index: int, model_slices: Any, model_instance: Any) -> Any: # type: ignore | ||
@custom_fwd | ||
def forward(ctx: Any, inputs: Any, index: int, model_slices: Any, model_instance: Any) -> Any: | ||
drop_index = index | ||
load_index = index + 1 | ||
max_slices = len(model_slices) | ||
|
@@ -147,6 +149,7 @@ def forward(ctx: Any, inputs: Any, index: int, model_slices: Any, model_instance | |
return inputs if isinstance(inputs, tuple) else (inputs,) | ||
|
||
@staticmethod | ||
@custom_bwd | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. could you elaborate on that ? it's new to me |
||
def backward(ctx, *grad_outputs): # type: ignore | ||
|
||
load_index = ctx.index | ||
|
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dummy thought earlier in the day: it would be great to add some ballpark computation of the expected size at some point (given the batch size + model/shards), just for comparison