[AG-GEMM] Add warp specialized ag-gemm that supports KDA and MLA up projections - #41
Conversation
WIP first implementation chore: add notation on todos feat: passes on nice shapes benchmark against baseline fix: use deprecated function Perf is no good, not sure if it is the GEMM or the AG that is bad M=2048 local_m=256 N=6284 padded_n=6400 cuBLAS + NCCL 0.751 ms (1.000x, 100.0%) ag_gemm_kda_mla 1.882 ms ( 0.399x, 39.9% of baseline) M=4096 local_m=512 N=6284 padded_n=6400 cuBLAS + NCCL 1.380 ms (1.000x, 100.0%) ag_gemm_kda_mla 3.891 ms ( 0.355x, 35.5% of baseline) M=8192 local_m=1024 N=6284 padded_n=6400 cuBLAS + NCCL 2.546 ms (1.000x, 100.0%) ag_gemm_kda_mla 7.991 ms ( 0.319x, 31.9% of baseline) M=16384 local_m=2048 N=6284 padded_n=6400 cuBLAS + NCCL 5.057 ms (1.000x, 100.0%) ag_gemm_kda_mla 18.892 ms ( 0.268x, 26.8% of baseline) M=32768 local_m=4096 N=6284 padded_n=6400 cuBLAS + NCCL 10.487 ms (1.000x, 100.0%) ag_gemm_kda_mla 44.726 ms ( 0.234x, 23.4% of baseline) oddly enough, this does even worse on a 4 device node try memcpy feat: minor optimizations on a 4 device setup: M=2048 local_m=512 N=12440 padded_n=12544 cuBLAS + NCCL 0.280 ms (1.000x, 100.0%) ag_gemm_kda_mla 0.236 ms ( 1.190x, 119.0% of baseline) M=4096 local_m=1024 N=12440 padded_n=12544 cuBLAS + NCCL 0.507 ms (1.000x, 100.0%) ag_gemm_kda_mla 0.420 ms ( 1.208x, 120.8% of baseline) M=8192 local_m=2048 N=12440 padded_n=12544 cuBLAS + NCCL 0.972 ms (1.000x, 100.0%) ag_gemm_kda_mla 0.823 ms ( 1.181x, 118.1% of baseline) M=16384 local_m=4096 N=12440 padded_n=12544 cuBLAS + NCCL 1.906 ms (1.000x, 100.0%) ag_gemm_kda_mla 1.680 ms ( 1.135x, 113.5% of baseline) M=32768 local_m=8192 N=12440 padded_n=12544 cuBLAS + NCCL 3.780 ms (1.000x, 100.0%) ag_gemm_kda_mla 3.516 ms ( 1.075x, 107.5% of baseline) feat: update benchmarking code to use padded because cublas does badly on non padded shapes faet: add cutlass comparison add cutlass bench feat: add autotuned TK feat: add TFLOPS calculation feat: add MLA comparison round up TK feat: add deeper pipeline chore: added SUPERGROUP_WIDTH as tuning parameter feat: add autotuned config chore: revert back pipeline chore: reduce nanosleep poll feat: add nasty shapes give cutlass a wider autotune feat: add 1 CTA instructions to kernel for tuning update benching script only tune odd shapes feat: added tuned configurations for odd shapes
6cf45e2 to
277ef7a
Compare
|
@ShawnWeiChew Great work! " In our case, I also think it's because the bulk memcpy's are done in a per device manner, so it imposes some sort of restriction on the way we can traverse the A matrix." Could you elaborate on this point? |
|
@MaoZiming Because my implementation handles the copies serially, we have to work on device n's SP chunk before device n + 1's SP chunk. (I tried adjusting the number of copy streams that were running at once but that, at best, did not have a negative impact on performance) For example, in a TP=8, global_m = 2048 case, we handle tile A in (256, K) chunk, rather than a (2048, K) chunk
Whereas in a regular GEMM, we could potentially make use of a traversal pattern like this:
I mentioned this because relative to a regular GEMM, the traversal pattern imposed by our implementation reduces the opportunity for reuse of the same chunk of B-tile in L2 cache, since we have to traverse the full B tile for each device's SP chunk. |
ee35c62 to
1de2386
Compare
a644651 to
c529bca
Compare
2907864 to
5325095
Compare
fix: pdl and tmem alloc syncs


This PR implements AG-GEMM for KDA and MLA up projection specific shapes.
09/09 Findings
We initially had results where TK did much worse than it does now. I think it was because I was running the kernels in succession with TK last. After reverting back to the old commit and adding a timeout between different kernels, the TK timings remained within ~5% of previous measurements
Notes:
cudaAsyncMemcpyoperationKDA projection shapes (updated 09/09)

MLA projection shapes (updated 09/09)

logs