Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion python/sglang/jit_kernel/dsv4/gemm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@

def linear_bf16_fp32(x: torch.Tensor, y: torch.Tensor) -> torch.Tensor:
if _use_aiter:
return tgemm.mm(x, y, otype=x.dtype).float()
# Request fp32 output directly instead of computing a bf16 GEMM and then
# casting with `.float()`. The explicit cast shows up as a separate
# `bfloat16tofloat32_copy` kernel per call in the DSV4 indexer
# (compute_kv_score) path; emitting fp32 from the GEMM epilogue removes
# that copy and also avoids rounding the result to bf16 first.
# Requires AITER to expose a native fp32-output tuned kernel for these
# shapes (companion AITER change); otherwise tgemm falls back internally.
return tgemm.mm(x, y, otype=torch.float32)
elif _linear_bf16_fp32_algo == "deep_gemm":
z = torch.empty(x.size(0), y.size(0), dtype=torch.float32, device=x.device)
deep_gemm_wrapper.gemm_nt_bf16bf16f32(x, y, z)
Expand Down
Loading