Skip to content
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

adding flash attention and xformer memory efficient through PT SDPA #97

Merged
merged 9 commits into from
Aug 9, 2023

Conversation

HamidShojanazeri
Copy link
Contributor

@HamidShojanazeri HamidShojanazeri commented Aug 4, 2023

What does this PR do?

This PR adds the Flash Attention and Xformer mem-efficient kernel through PT SDPA, this work has been integrated with optimum library of HF, read more about here.

Tested on 7B for FSDP only had a nice 30% speed up, for FSDP+PEFT 5% and not much on PEFT+quantization/1 gpu.

Fixes # (issue)
No related issue.

Feature/Issue validation/testing

Please describe the tests that you ran to verify your changes and relevant result summary. Provide instructions so it can be reproduced.
Please also list any relevant details for your test configuration.

  • Test A : Logs/ perf number of with out this feature with 10 steps : avg epoch time 55.17s
    Logs for Test A

  • Test B : Logs/ perf number of with this feature with 10 steps : avg epoch time 42.44
    Logs for Test B

Before submitting

  • [x ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline,
    Pull Request section?
  • Was this discussed/approved via a Github issue? Please add a link
    to it if that's the case.
  • [x ] Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?

Thanks for contributing 🎉!

llama_finetuning.py Outdated Show resolved Hide resolved
Copy link
Contributor

@chauhang chauhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HamidShojanazeri Thanks for adding the BT optimizations. Please see the comments inline

llama_finetuning.py Outdated Show resolved Hide resolved
inference/inference.py Outdated Show resolved Hide resolved
Copy link
Contributor

@chauhang chauhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the issues and also attach the logs for the inference speedup.

@chauhang chauhang merged commit 3f1fef7 into main Aug 9, 2023
3 checks passed
@chauhang chauhang deleted the BT_integration branch August 26, 2023 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants