[Attention][DSA] Enable W4A16 DSA (#51724)

Signed-off-by: Shiyang Chen <shiychen@nvidia.com>
This commit is contained in:
sychen52
2026-09-01 12:37:47 +08:00
committed by GitHub
parent ce2e343be1
commit 7c5dc571cb
17 changed files with 824 additions and 22 deletions
+12 -1
View File
@@ -505,7 +505,10 @@ def create_and_prepopulate_kv_cache(
block_table = common_attn_metadata.block_table_tensor
slot_mapping = common_attn_metadata.slot_mapping
fp8_attention = kv_cache_dtype and kv_cache_dtype.startswith("fp8")
use_nvfp4_ds_mla = kv_cache_dtype == "nvfp4_ds_mla"
fp8_attention = (
bool(kv_cache_dtype and kv_cache_dtype.startswith("fp8")) or use_nvfp4_ds_mla
)
use_fp8_ds_mla = kv_cache_dtype == "fp8_ds_mla"
if fp8_attention:
@@ -515,6 +518,14 @@ def create_and_prepopulate_kv_cache(
# 4 * 4: 4 float32 scale values for 128-element tiles
# 2 * rope_dim: 16-bit RoPE values
kv_entry_size = kv_lora_rank + 4 * 4 + 2 * rope_dim
elif use_nvfp4_ds_mla:
kv_lora_rank = kv_c_contexts[0].shape[-1]
rope_dim = k_pe_contexts[0].shape[-1]
# e2m1-packed NoPE + unscaled e4m3 rope + per-16 e4m3 NoPE SFs,
# padded to 16B
kv_entry_size = (
cdiv(kv_lora_rank // 2 + rope_dim + kv_lora_rank // 16, 16) * 16
)
else:
kv_entry_size = head_size