Repository navigation
Narrow the pre-Ampere continuous batching guard to kernels<0.16.1 - #6976
behroozazarkhalili wants to merge 8 commits into
Conversation
The skip added in #6712 was a hotfix. It kept the T4 CI runner green after transformers 5.15.0 started auto-switching continuous batching to Flash Attention 3, which Turing cannot run, but it also dropped every pre-Ampere GPU from the test's coverage. kernels 0.16.1 removes the trigger. Its only functional commit adds an architecture compatibility check to get_kernel, and both is_flash_attn_3_available and is_flash_attn_2_available reach that function through their kernels fallback inside a bare except. On a Turing card the check now raises, the helper returns False, and switch_to_cb_friendly_attn leaves the implementation at paged sdpa instead of selecting a kernel the GPU cannot execute. The import is dropped with the decorator because this was its only use in the file. Refs #6711
|
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. |
qgallouedec
left a comment
There was a problem hiding this comment.
Thanks @behroozazarkhalili. The skip isn't inert for everyone: kernels 0.16.1 fixes it (huggingface/kernels#774, confirmed in huggingface/transformers#47926 (comment)), but transformers still allows 0.16.0. Could you replace the skip with a strict xfail on pre-Ampere + kernels < 0.16.1, with a comment pointing to both and saying it can go once transformers requires kernels>=0.16.1?
| @pytest.mark.skipif( | ||
| not is_ampere_or_newer() and torch_device != "xpu", | ||
| reason="transformers continuous batching switches attention to Flash Attention, which requires an Ampere or " | ||
| "newer GPU, or XPU (see https://github.com/huggingface/transformers/issues/47926)", | ||
| ) |
There was a problem hiding this comment.
| @pytest.mark.skipif( | |
| not is_ampere_or_newer() and torch_device != "xpu", | |
| reason="transformers continuous batching switches attention to Flash Attention, which requires an Ampere or " | |
| "newer GPU, or XPU (see https://github.com/huggingface/transformers/issues/47926)", | |
| ) | |
| # Continuous batching auto-switches to Flash Attention 3 on pre-Ampere GPUs and crashes | |
| # (huggingface/transformers#47926). Fixed by the arch check in kernels 0.16.1 (huggingface/kernels#774); remove | |
| # once transformers requires `kernels>=0.16.1`. | |
| @pytest.mark.xfail( | |
| not is_ampere_or_newer() | |
| and torch_device != "xpu" | |
| and Version(importlib.metadata.version("kernels")) < Version("0.16.1"), | |
| reason="Flash Attention 3 on pre-Ampere with kernels<0.16.1 (huggingface/transformers#47926)", | |
| strict=True, | |
| ) |
|
|
||
| from .testing_utils import ( | ||
| TrlTestCase, | ||
| is_ampere_or_newer, |
There was a problem hiding this comment.
| is_ampere_or_newer, | |
| is_ampere_or_newer, |
…4-coverage # Conflicts: # tests/test_grpo_trainer.py
kernels<0.16.1
|
Thanks @behroozazarkhalili. After a closer look, keeping the skip: the only broken setup is pre-Ampere with transformers 5.15-5.17 and kernels 0.16.0 (transformers 5.18 requires kernels>=0.17, and 0.16.1 has the architecture check, huggingface/kernels#774), and our CI never runs it. Narrowing the guard to that exact combination isn't worth the extra conditions. Closing along with #6711. |
Replaces the pre-Ampere skip on
test_train_with_transformers_continuous_batchingwith a strictxfailon the exact failing condition: pre-Ampere GPU andkernels < 0.16.1.Continuous batching auto-switched to Flash Attention 3 on pre-Ampere GPUs and crashed (huggingface/transformers#47926). The architecture check in kernels 0.16.1 (huggingface/kernels#774) fixes it, but transformers still allows 0.16.0, so the mark stays until transformers requires
kernels>=0.16.1.Refs #6711.
Note
Low Risk
Test-only change to pytest marks; no production training or runtime behavior is modified.
Overview
test_train_with_transformers_continuous_batchingno longer skips all pre-Ampere (non-XPU) runs. It now uses a strictxfailonly when the GPU is pre-Ampere, thekernelspackage is installed, andkernels < 0.16.1—the combo that still triggers Flash Attention 3 crashes during continuous batching.Pre-Ampere environments with
kernels>=0.16.1(architecture check from huggingface/kernels#774) can execute the test as a normal pass/fail. Importsimportlib.metadataandimportlib.utilwere added to read the installedkernelsversion at collection time.Reviewed by Cursor Bugbot for commit 0afee22. Bugbot is set up for automated code reviews on this repo. Configure here.