[AMD] DeepSeek-V4 MI355X: eliminate bpreshuffle fp8-scale relayout copy in dense w8a8 linear (#33165)
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user