[AMD] Fix DeepSeek-V4 fused-RMS FP8 scale metadata on gfx950 (#31727)

This commit is contained in:
sonle5
2026-08-02 00:06:09 -07:00
committed by GitHub
parent 21d932069b
commit 1685d29f21
4 changed files with 116 additions and 0 deletions
@@ -112,6 +112,17 @@ def materialize_bpreshuffle_fp8_scale(scale: torch.Tensor) -> torch.Tensor:
return scale.t().contiguous().t() if scale.dim() == 2 else scale
def view_aiter_fused_rms_transposed_fp8_scale(scale: torch.Tensor) -> torch.Tensor:
"""Expose AITER fused-RMS ``transpose_scale=True`` storage logically.
The fused-RMS op returns transposed physical bytes through a row-major-looking
view. Restore logical ``[M, G]`` indexing without copying those bytes.
"""
if scale.dim() != 2:
return scale
return torch.as_strided(scale, scale.shape, (1, scale.shape[0]))
def materialize_bpreshuffle_fp8_scale_tuple(
value: Tuple[torch.Tensor, ...],
) -> Tuple[torch.Tensor, ...]:
+8
View File
@@ -84,6 +84,9 @@ from sglang.srt.layers.linear import ColumnParallelLinear, RowParallelLinear
from sglang.srt.layers.logits_processor import LogitsProcessor
from sglang.srt.layers.moe import get_moe_a2a_backend, should_use_dp_reduce_scatterv
from sglang.srt.layers.moe.fused_moe_triton import FusedMoE
from sglang.srt.layers.quantization.fp8_utils import (
view_aiter_fused_rms_transposed_fp8_scale,
)
from sglang.srt.layers.rotary_embedding import get_rope_wrapper
from sglang.srt.layers.utils import PPMissingLayer, get_layer_id
from sglang.srt.layers.utils.cp_utils import (
@@ -243,6 +246,11 @@ def _fused_rmsnorm_fp8_quant(hidden_states, weight, eps):
output_unquantized_inp1=True,
transpose_scale=_use_aiter_bpreshuffle_gfx95,
)
if _use_aiter_bpreshuffle_gfx95:
x_quant = (
x_quant[0],
view_aiter_fused_rms_transposed_fp8_scale(x_quant[1]),
)
return x_quant, x_bf16