-
Notifications
You must be signed in to change notification settings - Fork 69
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
[WIP] Adding support for FP8 training #218
Open
shahromil16
wants to merge
27
commits into
main
Choose a base branch
from
feature/fp8
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
7e4dc10
Adding support for FP8 training
romilshahtri e8cad2a
Linter changes
shahromil16 0514087
Converting all Linears to TE Linears except output Linear
shahromil16 ff8e8c8
Fix linter errors
shahromil16 298471f
Merge remote-tracking branch 'origin/main' into feature/fp8
shahromil16 9224b0e
Rebase from main and update FP8 changes
shahromil16 4563be2
Linter changes
shahromil16 937927a
Adding asserts for FP8
shahromil16 1594b9f
Asserts for FP8
shahromil16 740f2b1
Predefine all_gpus for TE
shahromil16 ccc7eef
Merge remote-tracking branch 'origin/main' into feature/fp8
shahromil16 3713f61
Remove if/else for fp8 checks
shahromil16 14e8278
Remove extra asserts
shahromil16 e572510
Removing unused deps
shahromil16 8350cb9
Update routine for converting NN layers to TE equivalents
shahromil16 a907b3c
Merge remote-tracking branch 'origin/main' into feature/fp8
shahromil16 4e582a0
Update FP8 flags and checks for layers
shahromil16 cdb0cf7
Linter checks
shahromil16 afb46cb
Add checks for autocast function
shahromil16 00c9e5b
Minor edit to model
shahromil16 40c7a6d
Adding default args as Params to SwiGLUTorch
shahromil16 8dbd1d8
Linter fixes
shahromil16 ec91746
Adding Torch Attention TE
shahromil16 afb7a66
Merge remote-tracking branch 'origin/main' into feature/fp8
shahromil16 29000f3
Fixing FP8+FSDP memory issues by removing FP8 from all activations un…
shahromil16 936cd9a
Merge remote-tracking branch 'origin/main' into feature/fp8
shahromil16 aca1b75
Updating deps and config
shahromil16 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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Could we also support fp8 for swiglu above? We can make a copy of the Swiglu class in this file. Here's the source for Swiglu https://github.com/facebookresearch/xformers/blob/7f8c290183344343771f4e1d945a8ce10a9500ff/xformers/ops/swiglu_op.py#L430
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.
@rams16592 seems like the recursive replace linear patten should take care of this automatically. a function like this seems like it would be great and we can exclude certain linears that need to be higher precision for stability. this function has an include field instead of exclude, but hopefully that's easy to flip:
https://github.com/mlfoundations/open_clip/blob/73fa7f03a33da53653f61841eb6d69aef161e521/src/open_clip/utils.py#L65
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.
Applied this change in the latest commit. Excluding the last output Linear layer from the conversion to TE Linear as its running into errors.