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

Integrate Habana flash attention to Llama2-70B finetune #596

Merged
merged 2 commits into from
Dec 14, 2023

Conversation

mandy-li
Copy link
Collaborator

As title

@mandy-li mandy-li requested a review from regisss as a code owner December 13, 2023 01:06
@mandy-li mandy-li added the run-test Run CI for PRs from external contributors label Dec 13, 2023
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Collaborator

@regisss regisss left a comment

Choose a reason for hiding this comment

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

LGTM!

I ran the command line from the example with and without --use_flash_attention:

  • Without:
    max_memory_allocated (GB)   =      73.87
    memory_allocated (GB)       =       21.6
    
  • With:
    max_memory_allocated (GB)   =      76.01
    memory_allocated (GB)       =      26.91
    

Memory consumption should be lower with flash attention no?

@mandy-li mandy-li requested a review from a user December 13, 2023 21:32
@mandy-li
Copy link
Collaborator Author

@regisss , that is a good observation. With recompute in flash attention disabled, we are supposed to have better performance, but memory consumption is more. I made another commit to add recompute arg to the script to allow user to configure that option.

Here are performance and memory usage comparisons:

Configuration Performance Memory
wo/ Habana Flash Attention 'train_runtime': 2669.7156, 'train_samples_per_second': 2.458, max_memory_allocated (GB):  73.99 memory_allocated (GB): 21.6
w/ Habana Flash Attention + recompute=False 'train_runtime': 2625.176, 'train_samples_per_second': 2.499, max_memory_allocated (GB): 76.39  memory_allocated (GB):  26.91
w/ Habana Flash Attention + recompute=True 'train_runtime': 2839.2379, 'train_samples_per_second': 2.358, max_memory_allocated (GB): 67.42 memory_allocated (GB):  21.53
w/ Habana Flash Attention + recompute=True + PT_HPU_SDPA_BATCH_NUMHEADS_SLICE=0 'train_runtime': 2675.4069, 'train_samples_per_second': 2.45, max_memory_allocated (GB):  77.83 memory_allocated (GB):  31.93

Copy link
Collaborator

@regisss regisss left a comment

Choose a reason for hiding this comment

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

LGTM!

@regisss regisss merged commit 28a9646 into main Dec 14, 2023
9 checks passed
@regisss regisss deleted the mandy/llama2_fa branch December 14, 2023 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run-test Run CI for PRs from external contributors
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants