[CB] Only auto-switch to flash attention for half-precision models (#51475)
* [CB] Only auto-switch to flash attention for half-precision models
Continuous batching switches a model loaded with sdpa or eager to flash
attention when a flash implementation is available, including the
`kernels-community/flash-attn2` hub kernel. It did not look at the
model's dtype, and flash attention only runs in float16 and bfloat16.
A float32 model was switched anyway and its first forward failed with
"FlashAttention only support fp16 and bf16 data type", which ends the
generation loop (`transformers serve --continuous-batching --dtype
float32` stops with "An engine died").
Since `kernels` is a default dependency and the hub kernel ships CPU
builds, this now happens on any machine with Hub access, CPU included.
Keep the attention implementation when the model is not in float16 or
bfloat16, and log why. This also skips the availability check, which
downloads the kernel.
* Fold the half-precision check into the flash auto-switch condition
Compute the dtype check before the auto-switch `if` so it is part of
the one condition, drop the info log for models not in half precision,
and cover float32 in the existing `test_switch_to_cb_friendly_attn`
instead of a separate test.
---------
Co-authored-by: Xiaoyuan Wang <174581044+XiaoyuanWang111@users.noreply.github.com>