From 68468fc9573ebd31808111900d7116c4a085b260 Mon Sep 17 00:00:00 2001 From: orca Date: Tue, 27 Oct 2026 17:18:12 +0100 Subject: [PATCH] test(gemm): cover incomplete W4A8 prefill M tiles The row was only ever run at M = 256, which is a whole number of tile heights, so no test entered the guarded epilogue. Every tile height the prefill arms dispatch (64, 96, 128, 256 -- tile_bmbn) now gets the rows just past its tile and one row past that, which is the shape that reads Ascale[M]. Smoke coverage: the harness checks the return code and the stream sync, not the numbers, so this catches a fault or a rejected launch, not a wrong tail. --- libr4d/r4d_selftest.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libr4d/r4d_selftest.cpp b/libr4d/r4d_selftest.cpp index 50b596b1..15025816 100644 --- a/libr4d/r4d_selftest.cpp +++ b/libr4d/r4d_selftest.cpp @@ -29561,6 +29561,13 @@ static void device_phase(const Plugin& pl) { gemm_case(pl, "gemm_w4a8_tiled", "w4a8", 256, 256, K, RAD_I8, 1, 0, 0, 256*K/2, 256*(K/128)*4); gemm_case(pl, "gemm_w8a8_tiled", "w8a8", 256, 256, K, RAD_I8, 1, 0, 0, 256*K, 256*(K/128)*2); gemm_case(pl, "gemm_w4a8_prefill", "w4a8", 256, 256, K, RAD_I8, 1, 0, 0, 256*K/2, 256*(K/128)*4); + /* The rows past the last full M tile: the tile heights the prefill arms dispatch are 64, + * 96, 128 and 256 (tile_bmbn), so every one of them gets a row count one past its tile and + * the row count of a tile plus one row. A scale read that escapes the store guard reads + * Ascale[M], which the buffer does not have. */ + for (const int64_t m : { 1, 7, 63, 64, 65, 95, 96, 97, 127, 128, 129, 255, 256, 257 }) + gemm_case(pl, "gemm_w4a8_prefill", "w4a8", m, 256, K, RAD_I8, 1, 0, 0, 256*K/2, + 256*(K/128)*4); /* Block-scaled fp8. The matvec runs at every point of its space (each `rb` is a different * instantiation of the K loop). The shapes give the narrow W8A8 row K a multiple of 256