-
Notifications
You must be signed in to change notification settings - Fork 31.3k
extend FA2 and other cases to XPU, #42536
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
Open
yao-matrix
wants to merge
7
commits into
huggingface:main
Choose a base branch
from
yao-matrix:fa2-xpu
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.
+150
−93
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8d14174
extend FA2 and other cases to XPU, we expect all model cases except C…
yao-matrix b7a366f
Merge branch 'main' into fa2-xpu
yao-matrix d54f907
fix style
yao-matrix 40d694a
Merge branch 'main' into fa2-xpu
yao-matrix ac8c6b8
Merge branch 'main' into fa2-xpu
yao-matrix ec05093
Merge branch 'main' into fa2-xpu
yao-matrix e5692c7
Merge branch 'main' into fa2-xpu
yao-matrix 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 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,6 @@ | |
| require_kernels, | ||
| require_read_token, | ||
| require_torch_accelerator, | ||
| require_torch_gpu, | ||
| slow, | ||
| torch_device, | ||
| ) | ||
|
|
@@ -315,36 +314,47 @@ def test_continuous_batching_parity_gemma_sdpa(self) -> None: | |
| # GPT-OSS is not compatible with SDPA because it has an attention sink. TODO: is this fixable? | ||
|
|
||
| # Flash attention test | ||
| @require_torch_gpu | ||
| @require_torch_accelerator | ||
| @require_kernels | ||
| @slow | ||
| def test_continuous_batching_parity_llama_flash(self) -> None: | ||
| expected_outputs = Expectations({ | ||
| ("cuda", (9, 0)): { | ||
| "req_1": " 3 bolts of blue fiber and 1.5 bolts of white fiber. The total number of bolts is 4.5 bolts. The total number of bolts is 4.5 bolts.", | ||
| } | ||
| }, | ||
| ("xpu", None): { | ||
| "req_1": " 3 bolts of blue fiber and 1.5 bolts of white fiber. The total number of bolts is 4.5 bolts. The total number of bolts is 4.5 bolts.", | ||
| }, | ||
| }).get_expectation() # fmt: skip | ||
| self._continuous_batching_parity("meta-llama/Llama-3.1-8B", "paged|flash_attention_2", expected_outputs) | ||
|
|
||
| @require_torch_gpu | ||
| @require_torch_accelerator | ||
| @require_kernels | ||
| @slow | ||
| def test_continuous_batching_parity_gemma_flash(self) -> None: | ||
| expected_outputs = Expectations({ | ||
| ("cuda", (9, 0)): { | ||
| "req_1": " \n \n 2 + 1 = 3 bolts \n \n \n \n \n \n \n \n \n \n \n \n \n ", | ||
| } | ||
| }, | ||
| ("xpu", None): { | ||
| "req_0": "\n\n**$128**\n\n**Here's how to solve it:**\n\n* **Eggs eaten:** 3\n* **Eggs left:** 16 - 3 = 1", | ||
| "req_1": "\n\n**Answer:** 3 bolts\n\n**Solution:**\n\n* **White fiber:** The robe needs half as much white fiber as blue fiber, so it needs 2 bolts / 2 =", | ||
| }, | ||
| }).get_expectation() # fmt: skip | ||
| self._continuous_batching_parity("google/gemma-2-2b-it", "paged|flash_attention_2", expected_outputs) | ||
|
|
||
| @require_torch_gpu | ||
| @require_torch_accelerator | ||
| @require_kernels | ||
| @slow | ||
| def test_continuous_batching_parity_qwen_flash(self) -> None: | ||
| expected_outputs = {} | ||
| expected_outputs = Expectations({ | ||
| ("xpu", None): { | ||
| "req_1": " 3.5 bolts.\n\nLet's break it down step by step:\n\n- Blue fiber: 2 bolts\n- White fiber: half of 2 bolts = 1 bolt\n\nTotal = ", | ||
| }, | ||
| }).get_expectation() # fmt: skip | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i need to check why this was |
||
| self._continuous_batching_parity("Qwen/Qwen3-4B-Instruct-2507", "paged|flash_attention_2", expected_outputs) | ||
|
|
||
| @require_torch_gpu | ||
| @require_torch_accelerator | ||
| @require_kernels | ||
| @slow | ||
| def test_continuous_batching_parity_gpt_oss_flash(self) -> None: | ||
|
|
||
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
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
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
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
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
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
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
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
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
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
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
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
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
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 you explain this part?
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.
@ydshieh , sure. in latest design, when users set
attn_implementation == "flash_attention_2", there will be 2 branches:flash_attnpackage is available, it will go directly to use itattn_implementationwill be updated to"kernels-community/flash-attn2", as in code hereFor XPU, we go with the kernels path in transformers for FA support, so we need this key.
Thx very much.
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.
I'd rather not do this, even tho you are correct here. We should rather refactor mimi here with the attention interface and not have these manual registrations. We could infinitely extend these edge cases in the future to FA3 etc which makes this not scalable (without using/refactoring to the interface).
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.
@yao-matrix
Let's revert this line 🙏 . We can skip the relevant FA tests if necessary.