Shift Computation of PaddingFree Variable CuSeqLen from Flash Attention Forward to DataCollatorWithFlattening#65
Closed
achew010 wants to merge 2 commits intofoundation-model-stack:mainfrom
Conversation
CuSeqLen from Flash Attention Forward to DataCollatorWithFlattening
Signed-off-by: 1000850000 user <aaron.chew1@ibm.com>
Signed-off-by: 1000850000 user <aaron.chew1@ibm.com>
4e42420 to
e6f4856
Compare
Contributor
|
closing this PR for now because there are issues identified with this impl. |
This file contains hidden or 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
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.
Description
To save on repeated computation of the same input across all the flash attention forward layers, this PR shifts the computation of arguments
cu_seq_lenandmax_lengthto the data collator.Running the same benchmark on ORCA Math from Transformers Padding Free, there is approx 2% improvement in train runtime from this implementation change.
Transformers < 4.43) - Computation of Arguments at FA ForwardTransformers < 4.43) - Computation of Arguments at Data CollatorReproduce
NOTE: The top level model's forward method had to be patched with a wrapper function to accept the additional kwargs from the data collator. Due to the change in method signature, HFTrainer will remove unused columns not detected from the model's forward method signature, causing it To avoid the removal, additional arg,
remove_unused_columns=Falseneeds to be passed to the Trainer.TODO: