[Bugfix][Kernel][ROCm] Fix triton_w4a16 scales mismatch when BLOCK_K > group_size (#39705)
Signed-off-by: JartX <sagformas@epdcenter.es>
This commit is contained in:
@@ -235,6 +235,14 @@ def triton_w4a16_gemm(
|
|||||||
else:
|
else:
|
||||||
BLOCK_M, BLOCK_N, BLOCK_K = 128, 128, 32
|
BLOCK_M, BLOCK_N, BLOCK_K = 128, 128, 32
|
||||||
|
|
||||||
|
# The kernel loads scales/zeros for a single group per BLOCK_K tile
|
||||||
|
# (one g_idx per iteration). If BLOCK_K > group_size, rows at the tail
|
||||||
|
# of the tile dequantize with the wrong group's scales, silently
|
||||||
|
# corrupting the output. Clamp BLOCK_K to group_size to keep one
|
||||||
|
# scale group per tile.
|
||||||
|
if group_size < BLOCK_K:
|
||||||
|
BLOCK_K = group_size
|
||||||
|
|
||||||
grid = (triton.cdiv(M, BLOCK_M), triton.cdiv(N, BLOCK_N))
|
grid = (triton.cdiv(M, BLOCK_M), triton.cdiv(N, BLOCK_N))
|
||||||
|
|
||||||
triton_w4a16_gemm_kernel[grid](
|
triton_w4a16_gemm_kernel[grid](
|
||||||
|
|||||||
Reference in New Issue
Block a user