diff --git a/libr4d/r4d_gemm_fp8a8.hip b/libr4d/r4d_gemm_fp8a8.hip index a179235d..086c6327 100644 --- a/libr4d/r4d_gemm_fp8a8.hip +++ b/libr4d/r4d_gemm_fp8a8.hip @@ -726,6 +726,11 @@ void gemm_8a8_prefill_kernel(const uint8_t* __restrict__ A, const float* __restr bn = r / gm; } const uint32_t m0 = bm * kPBM, n0 = bn * kPBN; + // The last band costs a whole band however few of its rows are live (676 rows cost what 768 + // do). When every row the upper four waves own lies past M, they leave here, before the first + // barrier, which then waits only for the waves still running; the lower four stage rows 0..63 + // themselves (threads 0..127) and write every s_as entry, so nothing they read is theirs. + if (wa == 1u && m0 + kPTA * 16u >= M) return; const uint32_t ksuper = K / kSuperK, nkb = K / kBlock; // Staging: two threads a row, 32 bytes each. Rows past M re-read row M-1, and every load is diff --git a/libr4d/r4d_selftest.cpp b/libr4d/r4d_selftest.cpp index 419c0bb4..c1ed83ef 100644 --- a/libr4d/r4d_selftest.cpp +++ b/libr4d/r4d_selftest.cpp @@ -29917,7 +29917,11 @@ static void device_phase(const Plugin& pl) { fp8_gemm_case(pl, "gemm_fp8a16_nt_m1", "fp8a16", 1, N, K, 0, &tp); fp8_gemm_case(pl, "gemm_fp8a8_nt_m16", "fp8a8", 8, N, K, 1); fp8_gemm_case(pl, "gemm_fp8a8_nt_m16", "fp8a8", 16, N, K, 1); - fp8_gemm_case(pl, "gemm_fp8a8_tiled", "fp8a8", 256, 256, K, 1); + /* The last 128-row band at every kind of tail: one band with its upper four waves gone + * (1, 36, 64), one band with them staying (65, 127), two bands with each (129, 200), and + * whole bands (256). */ + for (const int64_t m : { 1, 36, 64, 65, 127, 129, 200, 256 }) + fp8_gemm_case(pl, "gemm_fp8a8_tiled", "fp8a8", m, 256, K, 1); } /* --- the fp8 activation quantiser and the device sampler --- */