You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to get the best perf of a 'skinny' gemm on fp8 matrices on H100. My gemm MxNxK is 16x14336x4096 or 32x14336x4096 or 64x14336x4096 . This should obviously be heavily memory-bound.
I'm running cutlass profiler (I vary --m=16/32/64):
For the input shape of 64x14336x4096, you should not be bandwidth bound. M = 64 is a size that is natively supported by the Hopper tensor core, and your K dimension is large enough for the problem shape to be compute bound in the roofline. For any problem M shape smaller than 64, you are unfortunately going to be wasting a lot of FLOPs as the smallest supported shape for the Hopper fp8 tensor core is 64 along the M dimension.
Can you share which kernel nets you the best performance? How many of the candidate fp8 kernels in the profiler are you trying? You should be able to get pretty solid performance for at least the M=64 problem shape.
Regarding flops, I see a quite low number even on m=64: 286 TFLOP/sec, which has ~7x room to grow. nsight compute profiler corroborates w/ this finding.
It's fine to waste compute as long as I can get better memory b/w.
Can you try a larger cluster size of 1x4x1 for the two kernel recipes that are performing best? And can you also try running the same problem with cuBLAS and see what perf you get there?
hmm... seems like margin of error delta to me. Is this for the larger cluster size or the cuBLAS version? and which number corresponds to which kernel?
Firstly, I believe 64x14336x4096 is expected to be memory bound, since the flops/byte is too low. Also based on the comment above I just tried to run this specific test on latest CUTLASS 3.2.1 + CTK 12.2.2 :
Activity
thakkarV commentedon Oct 12, 2023
For the input shape of 64x14336x4096, you should not be bandwidth bound. M = 64 is a size that is natively supported by the Hopper tensor core, and your K dimension is large enough for the problem shape to be compute bound in the roofline. For any problem M shape smaller than 64, you are unfortunately going to be wasting a lot of FLOPs as the smallest supported shape for the Hopper fp8 tensor core is 64 along the M dimension.
Can you share which kernel nets you the best performance? How many of the candidate fp8 kernels in the profiler are you trying? You should be able to get pretty solid performance for at least the M=64 problem shape.
divchenko commentedon Oct 12, 2023
These seem to be the best:
cutlass3x_sm90_tensorop_s64x128x32gemm_e4m3_e4m3_f32_f32_e5m2_64x128x128_1x2x1_0_tnn_align16_warpspecialized_pingpong_fp8_fastaccum_epi_nosmem
cutlass3x_sm90_tensorop_s64x128x32gemm_e4m3_e4m3_f32_f32_e5m2_64x128x128_1x2x1_0_tnn_align16_warpspecialized_pingpong_fp8_fastaccum_epi_tma
Here's the full list: https://gist.github.com/divchenko/a32d50e5771190291a55efec9aaa814d
Regarding flops, I see a quite low number even on m=64: 286 TFLOP/sec, which has ~7x room to grow. nsight compute profiler corroborates w/ this finding.
It's fine to waste compute as long as I can get better memory b/w.
thakkarV commentedon Oct 12, 2023
Can you try a larger cluster size of 1x4x1 for the two kernel recipes that are performing best? And can you also try running the same problem with cuBLAS and see what perf you get there?
divchenko commentedon Oct 12, 2023
Tiny bit better
2241.57 GiB/s
2238.46 GiB/s
thakkarV commentedon Oct 12, 2023
hmm... seems like margin of error delta to me. Is this for the larger cluster size or the cuBLAS version? and which number corresponds to which kernel?
divchenko commentedon Oct 12, 2023
Larger cluster size. I will try cublas later today.
divchenko commentedon Oct 12, 2023
First and second kernels respectively, but yeah, seems like a margin of error
divchenko commentedon Oct 12, 2023
Tried cublas, it's a bit worse, ~65% of memory b/w. Here's the kernel it chooses : sm90_xmma_gemm_e4m3e4m3_e4m3f32_f32_tn_n_tilesize128x64x128_warpgroupsize2x1x1_algo2_execute_segment_k_off_kernel__5x_cublas
It's basically based on their example https://github.com/NVIDIA/CUDALibrarySamples/blob/master/cuBLASLt/LtFp8Matmul/sample_cublasLt_LtFp8Matmul.cu
hwu36 commentedon Oct 12, 2023
@ANIKET-SHIVAM @IonThruster
IonThruster commentedon Oct 13, 2023
Firstly, I believe 64x14336x4096 is expected to be memory bound, since the flops/byte is too low. Also based on the comment above I just tried to run this specific test on latest CUTLASS 3.2.1 + CTK 12.2.2 :
And I see :
Bytes: 62652416 bytes FLOPs: 7518027776 flops FLOPs/Byte: 119 Runtime: 0.0231348 ms Memory: 2539.16 GiB/s Math: 324966 GFLOP/sWhich is a bit better than than what you see. Some things to try :
CUtensorMapL2promotion tma_l2Promotion = CU_TENSOR_MAP_L2_PROMOTION_L2_256B;mnicely commentedon Oct 19, 2023
@divchenko is your issue resolved?
divchenko commentedon Nov 3, 2023
@mnicely yes, thank you!
divchenko commentedon Nov 3, 2023
resolved
examples: tune bf16 prefill hdim64 tile shape(perf improvement ~9.7%) (…