-
Notifications
You must be signed in to change notification settings - Fork 267
Align MLlama code with Transformers 4.55 #2319
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
base: main
Are you sure you want to change the base?
Align MLlama code with Transformers 4.55 #2319
Conversation
|
The code quality check failed, please run |
9710363 to
a270769
Compare
|
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. |
f5c5287 to
939e520
Compare
|
The code quality check failed, please run |
939e520 to
720f6a7
Compare
After the Transformers 4.55 update, one of the attention classes failed to compute the attention scores due to mismatches between arguments in the `torch.matmul` op. This commits updates the whole `Mllama` code base to be fully aligned with the code in Transformers 4.55. In particular, it: - uses the `_attn_implementation` instead of custom classes, - applies the changes from PR [1] - handles `_attn_implementation` passed to the model - fix argument preparation in `gaudi_fused_sdpa_attention` [1] huggingface/transformers#40083
720f6a7 to
79a9ebc
Compare
| ] | ||
| args.prompt = processor.apply_chat_template(conversation, add_generation_prompt=True) | ||
|
|
||
| if model_type == "mllama" and args.use_flash_attention: |
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.
why not just allow user to select attn_implementation + add readme section about it?
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.
This is done, because this script is also used by other models (such as llava), which are not yet aligned with the attn_implementation interface.
| ) -> tuple[torch.Tensor, None]: | ||
| bsz, num_heads, tgt_len, head_dim = query.shape | ||
|
|
||
| softmax_mode = "fast" if os.getenv("FLASH_ATTENTION_FAST_SOFTMAX") == "1" else "None" |
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.
since attention implementation is now separated from model we don't have to use env vars, can you explore if it's possible to use kwargs instead of env vars?
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.
Makes sense - I will have a look at it
What does this PR do?
After the Transformers 4.55 update, one of the attention classes failed to compute the attention scores due to mismatches between arguments in the
torch.matmulop. This commits updates the wholeMllamacode base to be fully aligned with the code in Transformers 4.55. In particular, it uses the_attn_implementationinstead of custom classes.