[AMD] Accelerate AITER unified-attention decode with scaled FP8 Q (#31856)

Co-authored-by: jacky.cheng <yichiche@amd.com>
Co-authored-by: YC Yen-Ching Tseng <yctseng@amd.com>
This commit is contained in:
zijiec
2026-08-13 23:42:25 -07:00
committed by GitHub
co-authored by jacky.cheng YC Yen-Ching Tseng
parent 46d84f4b48
commit ba1d980b35
2 changed files with 315 additions and 2 deletions
@@ -65,7 +65,10 @@ from sglang.kernels.ops.attention.utils import (
launch_reshape_and_cache_flash,
pad_sequence_with_mask,
)
from sglang.kernels.ops.quantization.fp8_kernel import fp8_dtype
from sglang.kernels.ops.quantization.fp8_kernel import (
fp8_dtype,
scaled_fp8_quant,
)
from sglang.srt.configs.model_config import AttentionArch
from sglang.srt.layers.attention.aiter_utils import (
forward_decode_vectorized_5d,
@@ -2605,6 +2608,12 @@ class AiterAttnBackend(AttentionBackend):
page_table = self.forward_metadata.swa_page_table
max_kv_len = page_table.shape[1] * self.page_size
q_descale = None
if self.kv_cache_dtype == fp8_dtype:
q_descale = (
layer.k_scale if layer.k_scale is not None else self.k_scale
)
q, _ = scaled_fp8_quant(q, q_descale)
unified_attention(
q=q.view(-1, layer.tp_q_head_num, layer.qk_head_dim),
@@ -2624,7 +2633,7 @@ class AiterAttnBackend(AttentionBackend):
window_size=window_size,
block_table=page_table,
softcap=0,
q_descale=None,
q_descale=q_descale,
k_descale=k_descale,
v_descale=v_descale,
sinks=sinks,