[ROCm] Cut 69 wasted contiguous copies per decode step from the skinny GEMM path (#58566)
Signed-off-by: lifulu <fululi12@amd.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: Nick Hill <nickhill123@gmail.com>
fululi12 committed
Sep 24, 2026 at 20:00 UTC
4d79d5c6382b34ecb03eaa93c6229fd3073d69f4
1 file changed
+3
-1
vllm/model_executor/layers/utils.py
+3
-1
@@ -346,12 +346,14 @@ def rocm_unquantized_gemm_impl(
346
if use_skinny:
347
# The skinny kernels assume contiguous K elements. A shape-preserving
348
# reshape can retain a transposed activation's non-contiguous strides.
349
- x_view = x.reshape(-1, x.size(-1)).contiguous()
349
+ # Note: Only build that view inside the branches that consume it.
350
if (m == 1 or m > 8) and 0 < n <= 5:
351
+ x_view = x.reshape(-1, x.size(-1)).contiguous()
352
cu_count = num_compute_units()
353
out = ops.wvSplitK(weight, x_view, cu_count, bias)
354
return out.reshape(*x.shape[:-1], weight.shape[0])
355
elif m % 4 == 0 and n == 1 and k <= 8192 and bias is None:
356
+ x_view = x.reshape(-1, x.size(-1)).contiguous()
357
out = ops.LLMM1(weight, x_view, 4)
358
return out.reshape(*x.shape[:-1], weight.shape[0])
359