[AMD] Support ds3.2 on gfx942 platform (#17504)

Co-authored-by: Hubert Lu <55214931+hubertlu-tw@users.noreply.github.com>
This commit is contained in:
wufann
2026-01-22 13:57:08 -08:00
committed by GitHub
co-authored by Hubert Lu
parent 15b511771d
commit a921029b97
4 changed files with 135 additions and 78 deletions
@@ -8,6 +8,7 @@ import torch
from einops import rearrange
from sglang.srt.layers.layernorm import LayerNorm
from sglang.srt.layers.quantization.fp8_kernel import is_fp8_fnuz
from sglang.srt.layers.utils import MultiPlatformOp
from sglang.srt.utils import add_prefix, ceil_align, is_cuda, is_hip, is_npu
@@ -15,6 +16,7 @@ global _use_multi_stream
_is_cuda = is_cuda()
_is_hip = is_hip()
_is_npu = is_npu()
_is_fp8_fnuz = is_fp8_fnuz()
if _is_cuda:
try:
import deep_gemm
@@ -504,8 +506,10 @@ class Indexer(MultiPlatformOp):
)
k_fp8_list.append(k_fp8)
k_scale_list.append(k_scale)
k_fp8 = torch.cat(k_fp8_list, dim=0).view(torch.float8_e4m3fn)
if _is_fp8_fnuz:
k_fp8 = torch.cat(k_fp8_list, dim=0).view(torch.float8_e4m3fnuz)
else:
k_fp8 = torch.cat(k_fp8_list, dim=0).view(torch.float8_e4m3fn)
k_scale = torch.cat(k_scale_list, dim=0).view(torch.float32).squeeze(-1)
kv_fp8 = (k_fp8, k_scale)
ks, ke = metadata.get_indexer_kvcache_range()
@@ -569,9 +573,9 @@ class Indexer(MultiPlatformOp):
from aiter.ops.triton.fp8_mqa_logits import fp8_mqa_logits
kv, scale = kv_fp8
logits = fp8_mqa_logits(
logits_chunk = fp8_mqa_logits(
q_fp8[start:end],
kv_fp8,
kv,
scale,
weights[start:end],
ks[start:end],
@@ -1001,11 +1005,12 @@ class Indexer(MultiPlatformOp):
.view(m, ng, group)
.mul_(x_s.to(torch.float32).unsqueeze(-1))
.view(m, n)
.to(torch.bfloat16)
)
else:
x_for_gate = x_q.to(torch.float32)
x_for_gate = x_q.to(torch.bfloat16)
else:
x_for_gate = x_q.to(torch.float32)
x_for_gate = x_q.to(torch.bfloat16)
else:
x_for_gate = x