ITADN

Continuous batching auto-switches to flash_attention_3 on unsupported GPUs (Turing/T4), crashing — regression from 5.14.1

#47926Openalbertvillanova 创建于 9 天前
A
albertvillanovacommented
### System Info - Affected: `transformers==5.15.0` (also current `main` / `5.16.0.dev0`). **Not** reproduced on the `v5.14.1` release. - Same environment also moved `kernels==0.15.2` → `kernels==0.16.0`, and the `kernels-community/vllm-flash-attn3` Hub kernel is now pulled. - GPU: NVIDIA **T4** (Turing, SM 7.5), i.e. **pre-Ampere**. `flash_attn` is not pip-installed (only `transformers[kernels]`). - Container: `pytorch/pytorch:2.8.0-cuda12.8-cudnn9-devel`. ### Who can help? cc @remi-or @IlyasMoutawwakil (continuous batching) ### Information - [ ] The official example scripts - [x] My own modified scripts ### Tasks - [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...) - [x] My own task or dataset (give details below) ### Reproduction Running generation with continuous batching (`generate_batch` / `use_transformers_continuous_batching=True`) on a **pre-Ampere** GPU (NVIDIA T4). On `5.15.0`, continuous batching auto-switches the attention implementation from `sdpa` to `flash_attention_3` and loads the `kernels-community/vllm-flash-attn3` Hub kernel: ``` ContinuousBatchingLogger - WARNING - Continuous batching is much better when using flash attention. Switching from sdpa to flash_attention_3. If you need to use eager or sdpa, use paged|eager or paged|sdpa as the `attn_implementation`. transformers.modeling_utils - WARNING - You do not have `flash_attn` installed, using `paged|kernels-community/vllm-flash-attn3` from the `kernels` library instead! ``` The generation loop then crashes, because that kernel requires newer hardware: ``` ContinuousBatchingLogger - ERROR - Error in generation loop: mha_fwd, /build/source/flash-attn/flash_api_stable.cpp:716, FlashAttention only supports Ampere GPUs or newer. ContinuousBatchingLogger - ERROR - Generation thread terminated unexpectedly. ContinuousBatchingLogger - ERROR - Requests ['req_0', 'req_1', 'req_2'] not found in results. ``` Because the generation thread dies, no completions are returned, which then breaks downstream code that assumes at least one completion. The same code runs fine on `v5.14.1` (with `kernels==0.15.2`): continuous batching does **not** switch to `flash_attention_3`, and generation completes normally. Observed in CI on a single-GPU T4 runner (downstream project TRL): - Passing: `transformers==5.14.1` / `kernels==0.15.2` — https://github.com/huggingface/trl/actions/runs/31371150907/job/93400203818 - Failing: `transformers==5.15.0` / `kernels==0.16.0` — https://github.com/huggingface/trl/actions/runs/31582787840/job/94069521759 Workaround: pass `attn_implementation="paged|sdpa"` (or `paged|eager`). ### Expected behavior Continuous batching should not switch to `flash_attention_3` on GPUs that cannot run it. The auto-switch should be gated on device capability (or fall back to `sdpa`) instead of hard-crashing the generation thread, as was the case on `v5.14.1`. > Note: I don't yet have a minimal non-CI reproduction on non-Ampere hardware; the above is from CI logs plus a version bisect (`model_runner.py` is byte-identical between `v5.14.1` and `v5.15.0`, so the change is in the attention/kernel default selection). I'll add the exact regressing change — and whether it originates in `transformers` or in the `kernels` default resolution — as a follow-up once pinned.
1 条评论