[AMD] DeepSeek-V4 MI355X: eliminate bpreshuffle fp8-scale relayout copy in dense w8a8 linear (#33165)

This commit is contained in:
karverma-amd
2026-08-19 03:02:40 -07:00
committed by GitHub
parent f22442d3a4
commit ce1830c59b
3 changed files with 273 additions and 3 deletions
@@ -1163,15 +1163,24 @@ def aiter_w8a8_block_fp8_linear(
# On ROCm >= 7.2, scale is in bpreshuffle's transposed layout.
# Triton needs a row-major view, so adjust strides only. No copy.
elif use_triton and _use_aiter_bpreshuffle_gfx95:
x_scale = torch.as_strided(x_scale, x_scale.shape, (1, x_scale.shape[0]))
x_scale = view_aiter_fused_rms_transposed_fp8_scale(x_scale)
else:
materialize_bpreshuffle_scale = _use_aiter_bpreshuffle_gfx95 and not use_triton
# No-copy bpreshuffle scale: emit it already transposed and stride-reinterpret
# to the column-major bpreshuffle layout, instead of a .t().contiguous().t()
# copy. Bit-identical for M>=2; M==1 keeps materialize (there the [1,G] and
# [G,1] byte orders coincide, so materialize is a no-op view anyway).
emit_bpreshuffle_scale = (
materialize_bpreshuffle_scale and input_2d.shape[0] >= 2
)
q_input, x_scale = aiter_per1x128_quant(
input_2d,
quant_dtype=aiter.dtypes.fp8,
transpose_scale=False,
transpose_scale=emit_bpreshuffle_scale,
)
if materialize_bpreshuffle_scale:
if emit_bpreshuffle_scale:
x_scale = view_aiter_fused_rms_transposed_fp8_scale(x_scale)
elif materialize_bpreshuffle_scale:
x_scale = materialize_bpreshuffle_fp8_scale(x_scale)
if use_triton: