Skip to content

Commit bfdc321

Browse files
authored
HIP: fattn-mma: use fp32 accumulation on MFMA devices (ggml-org#28576)
use fp32 accumulators in fattn-mma on CDNA
1 parent 391fac1 commit bfdc321

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

‎ggml/src/ggml-cuda/fattn-mma-f16.cuh‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ static constexpr __host__ __device__ fattn_mma_config ggml_cuda_fattn_mma_get_co
181181
GGML_CUDA_FATTN_MMA_CONFIG_CASE( 64, 64, 8, 128, 1, 64, 32, 32, 32, 1, true);
182182
GGML_CUDA_FATTN_MMA_CONFIG_CASE( 64, 64, 16, 256, 2, 64, 32, 32, 32, 1, true);
183183
GGML_CUDA_FATTN_MMA_CONFIG_CASE( 64, 64, 32, 256, 2, 64, 32, 32, 32, 1, true);
184-
GGML_CUDA_FATTN_MMA_CONFIG_CASE( 64, 64, 64, 256, 4, 64, 32, 32, 32, 1, true);
184+
GGML_CUDA_FATTN_MMA_CONFIG_CASE( 64, 64, 64, 256, 3, 64, 32, 32, 32, 1, true);
185185

186186
GGML_CUDA_FATTN_MMA_CONFIG_CASE( 80, 80, 8, 256, 2, 64, 40, 40, 40, 1, true);
187187
GGML_CUDA_FATTN_MMA_CONFIG_CASE( 80, 80, 16, 256, 2, 64, 40, 40, 40, 1, true);
@@ -1141,7 +1141,7 @@ template<int DV, int ncols> struct mma_tile_sizes {
11411141
using T_C_KQ = tile<16, 16, float>; // column-major
11421142
using T_A_VKQ = tile<16, 8, half2>; // row-major
11431143
using T_B_VKQ = tile<16, 8, half2>; // column-major
1144-
using T_C_VKQ = tile<16, 8, half2>; // column-major
1144+
using T_C_VKQ = tile<16, 16, float>; // column-major
11451145
};
11461146
#else // Volta
11471147
template<int DV, int ncols> struct mma_tile_sizes {
@@ -1227,7 +1227,9 @@ static __device__ __forceinline__ void flash_attn_ext_f16_process_tile(
12271227
T_C_VKQ VKQ_C[cols_per_warp == 8 ? DV/T_C_VKQ::I : DV/(2*T_C_VKQ::J)];
12281228
#elif defined(AMD_WMMA_AVAILABLE) && defined(RDNA3)
12291229
T_C_VKQ VKQ_C[DV % 32 != 0 ? DV/T_C_VKQ::J : DV/(2*T_C_VKQ::J)];
1230-
#elif defined(AMD_WMMA_AVAILABLE) || defined(AMD_MFMA_AVAILABLE)
1230+
#elif defined(AMD_MFMA_AVAILABLE)
1231+
T_C_VKQ VKQ_C[ DV/T_C_VKQ::J];
1232+
#elif defined(AMD_WMMA_AVAILABLE)
12311233
T_C_VKQ VKQ_C[ DV/(2*T_C_VKQ::J)];
12321234
#else // Volta
12331235
T_C_VKQ VKQ_C[ DV/(2*T_C_VKQ::J)];

0 commit comments

Comments
 (0)