[Kernel] Resubmit PR 48666 - Gemma4 FP8 KV FA4 head dim 512 backend selection (#53175)
Signed-off-by: Jhao-Ting Chen <jhaotingc@nvidia.com>
This commit is contained in:
@@ -434,6 +434,14 @@ def flash_attn_varlen_func(
|
||||
|
||||
from vllm.vllm_flash_attn.cute.interface import _flash_attn_fwd
|
||||
|
||||
# SM90 FA4 fp8-KV path: fp8 e4m3 paged K/V dequantized and the K/V descale folded
|
||||
# in-kernel; accepts bf16/fp16 Q and writes O in its native dtype (no Q cast, no
|
||||
# output copy). Only the (batch, num_kv_heads) f32 K/V descales are forwarded.
|
||||
fa4_fp8_kv_dequant = (
|
||||
k.dtype == torch.float8_e4m3fn
|
||||
and torch.cuda.get_device_capability()[0] == 9
|
||||
)
|
||||
|
||||
out, softmax_lse, _, _ = _flash_attn_fwd(
|
||||
q,
|
||||
k,
|
||||
@@ -458,10 +466,11 @@ def flash_attn_varlen_func(
|
||||
block_sparse_tensors=block_sparse_tensors,
|
||||
aux_tensors=aux_tensors,
|
||||
aux_tensor_leading_dims=aux_tensor_leading_dims,
|
||||
q_descale=q_descale,
|
||||
q_descale=None if fa4_fp8_kv_dequant else q_descale,
|
||||
k_descale=k_descale,
|
||||
v_descale=v_descale,
|
||||
output_scale=output_scale,
|
||||
fp8_kv_dequant=fa4_fp8_kv_dequant,
|
||||
)
|
||||
else:
|
||||
raise ValueError(f"Unsupported FA version: {fa_version}")
|
||||
|
||||
Reference in New Issue
Block a user