From 02b81bd8683a0d6675344f23cb5eb0c896c85658 Mon Sep 17 00:00:00 2001 From: Enrico Degregori Date: Tue, 20 Jan 2026 14:31:18 +0000 Subject: [PATCH] Fix LDS read/write for 16/8 bit case Both A and B are using 128 bit instructions --- .../gemm_bquant_quantgrouped_bf16mxbf8.cpp | 15 +++++++-------- .../ck_tile/38_block_scale_gemm/gemm_utils.hpp | 18 ++++++++++++++++++ include/ck_tile/ops/gemm/warp/warp_gemm.hpp | 12 ++++++++++++ .../ops/gemm/warp/warp_gemm_dispatcher.hpp | 1 + 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/example/ck_tile/38_block_scale_gemm/gemm_bquant_quantgrouped_bf16mxbf8.cpp b/example/ck_tile/38_block_scale_gemm/gemm_bquant_quantgrouped_bf16mxbf8.cpp index 30d65edd47..2e09af2724 100644 --- a/example/ck_tile/38_block_scale_gemm/gemm_bquant_quantgrouped_bf16mxbf8.cpp +++ b/example/ck_tile/38_block_scale_gemm/gemm_bquant_quantgrouped_bf16mxbf8.cpp @@ -3,13 +3,12 @@ #include "run_gemm_quant_example.inc" -template -using GemmConfig = GemmConfigQuantPrefill; +using GemmConfig = GemmConfigMixedPrecision; -#define RUN_GEMM_EXAMPLE_PREC_TYPE \ - run_gemm_example_prec_type, \ - TypeConfig, \ - QuantGroupSize, \ +#define RUN_GEMM_EXAMPLE_PREC_TYPE \ + run_gemm_example_prec_type(arg_parser); void bquant_quantgrouped_mx_bf16bf8_instance_factory( @@ -21,9 +20,9 @@ void bquant_quantgrouped_mx_bf16bf8_instance_factory( ck_tile::e8m0_t>{}); lut[hash_multiple_strings( - {"bf16bf8", "bquant", "non-preshuffleb", "non-preshufflequant", "1x1x32"})] = + {"bf16bf8", "bquant", "non-preshuffleb", "non-preshufflequant", "1x1x128"})] = [](const ck_tile::ArgParser& arg_parser) { - using QuantGroupSize = ck_tile::QuantGroupShape>; + using QuantGroupSize = ck_tile::QuantGroupShape>; return RUN_GEMM_EXAMPLE_PREC_TYPE; }; lut[hash_multiple_strings( diff --git a/example/ck_tile/38_block_scale_gemm/gemm_utils.hpp b/example/ck_tile/38_block_scale_gemm/gemm_utils.hpp index 3048a01bbb..deee211d81 100644 --- a/example/ck_tile/38_block_scale_gemm/gemm_utils.hpp +++ b/example/ck_tile/38_block_scale_gemm/gemm_utils.hpp @@ -271,6 +271,24 @@ struct GemmConfigABQuantPrefill : public GemmConfigQuantPrefill static constexpr bool TransposeC = true; }; +// Used for A=16bit and B=8bit. The warp tile has KPack=16 +// Matrix A: Vectorsize = 8, KPack=16 -> LDS read/write vectorsize = 8 (128bit) +// Matrix B: Vectorsize = 16, KPack=16 -> LDS read/write vectorsize = 16 (128bit) +struct GemmConfigMixedPrecision : public GemmConfigBase +{ + static constexpr ck_tile::index_t M_Tile = 128; + static constexpr ck_tile::index_t N_Tile = 128; + static constexpr ck_tile::index_t K_Tile = 128; + + static constexpr ck_tile::index_t M_Warp = 1; + static constexpr ck_tile::index_t N_Warp = 4; + static constexpr ck_tile::index_t K_Warp = 1; + + static constexpr ck_tile::index_t M_Warp_Tile = 16; + static constexpr ck_tile::index_t N_Warp_Tile = 16; + static constexpr ck_tile::index_t K_Warp_Tile = 64; +}; + template struct GemmConfigPreshuffleBQuantPrefill : public GemmConfigQuantPrefill { diff --git a/include/ck_tile/ops/gemm/warp/warp_gemm.hpp b/include/ck_tile/ops/gemm/warp/warp_gemm.hpp index 0051242475..d00fa58731 100644 --- a/include/ck_tile/ops/gemm/warp/warp_gemm.hpp +++ b/include/ck_tile/ops/gemm/warp/warp_gemm.hpp @@ -189,12 +189,24 @@ template using WarpGemmMfmaBf16Bf16F32M16N16K32 = WarpGemmImpl< WarpGemmAttributeMfma, AttrNumAccess>>; + +template +using WarpGemmMfmaBf16Bf16F32M16N16K64 = WarpGemmImpl, + 2, + AttrNumAccess>>; #else template using WarpGemmMfmaBf16Bf16F32M16N16K32 = WarpGemmImpl, 2, AttrNumAccess>>; + +template +using WarpGemmMfmaBf16Bf16F32M16N16K64 = WarpGemmImpl, + 4, + AttrNumAccess>>; #endif using WarpGemmMfmaBf16Bf16F32M32N32K8SwizzleA = WarpGemmImpl struct Dispatcher { using template<> struct Dispatcher { using Type = WarpGemmMfmaBf16Bf16F32M32N32K16; }; template<> struct Dispatcher { using Type = WarpGemmMfmaBf16Bf16F32M32N32K16TransposedCDistribution; }; template<> struct Dispatcher { using Type = WarpGemmMfmaBf16Bf16F32M16N16K32<>; }; +template<> struct Dispatcher { using Type = WarpGemmMfmaBf16Bf16F32M16N16K64<>; }; template<> struct Dispatcher { using Type = WarpGemmMfmaBf16Bf16F32M16N16K32TransposedCDistribution<>; }; template<> struct Dispatcher { using Type = WarpGemmMfmaBf16Bf16F32M16N16K32; }; template<> struct Dispatcher { using Type = WarpGemmMfmaBf16Bf16F32M16N16K32TransposedCDistribution; };