Optimizing a WebGPU Matmul Kernel for 1 TFLOP
zanussbaum.substack.com
Optimizing a WebGPU Matmul Kernel for 1 TFLOP
1–10 of 88 posts
Re: Optimizing a WebGPU Matmul Kernel for 1 TFLOP
#2Re: Optimizing a WebGPU Matmul Kernel for 1 TFLOP
#3WebGPU doesn't seem to talk about bank conflict, hiding some hardware details that might be necessary to write the best kernel. will it be able to match the perf of Cuda on the same hardware?
Re: Optimizing a WebGPU Matmul Kernel for 1 TFLOP
#4As you see, I have implemented 32×32 tiling, using thread groups of 32×8 threads, two groupshared buffers to load tiles of the input matrices, and I accumulate numbers into local variables, 32 / 8 = 4 accumulators per thread.
Re: Optimizing a WebGPU Matmul Kernel for 1 TFLOP
#5WebGPU doesn't seem to talk about bank conflict, hiding some hardware details that might be necessary to write the best kernel. will it be able to match the perf of Cuda on the same hardware?
Re: Optimizing a WebGPU Matmul Kernel for 1 TFLOP
#6WebGPU doesn't seem to talk about bank conflict, hiding some hardware details that might be necessary to write the best kernel. will it be able to match the perf of Cuda on the same hardware?
WebGPU cannot even come close unfortunately since they don't have support for hardware specific memory or warp-level primitives (like TMA or tensorcores). it's not like it gets 80% of perf, it gets < 30% of the peak perf for anything related to heavy compute matrix multiplications
it would be cool to see if there's some way to get better access to those lower-level primitives but would be surprised
it does seem like subgroup support are a step in the right direction though!
Re: Optimizing a WebGPU Matmul Kernel for 1 TFLOP
#7WebGPU doesn't seem to talk about bank conflict, hiding some hardware details that might be necessary to write the best kernel. will it be able to match the perf of Cuda on the same hardware?
WebGPU cannot even come close unfortunately since they don't have support for hardware specific memory or warp-level primitives (like TMA or tensorcores). it's not like it gets 80% of perf, it gets < 30% of the peak perf for anything related to heavy compute matrix multiplications
I have no experience with WebGPU but if you mean group shared memory, I think the support is available. See the demo: https://compute.toys/view/25
Re: Optimizing a WebGPU Matmul Kernel for 1 TFLOP
#8For context: this WebGPU version achieves ~17% of peak theoretical performance of M2. With CUDA (i.e. CuBLAS), you can reach ~75% of peak performance for same matrix config (without tensor core).
Re: Optimizing a WebGPU Matmul Kernel for 1 TFLOP
#9Earlier quoted context omitted.
WebGPU cannot even come close unfortunately since they don't have support for hardware specific memory or warp-level primitives (like TMA or tensorcores). it's not like it gets 80% of perf, it gets < 30% of the peak perf for anything related to heavy compute matrix multiplications
> don't have support for hardware specific memory I have no experience with WebGPU but if you mean group shared memory, I think the support is available. See the demo: https://compute.toys/view/25
i'm excited to try subgroups though: https://developer.chrome.com/blog/new-in-webgpu-128#experime...
Re: Optimizing a WebGPU Matmul Kernel for 1 TFLOP
#10WebGPU doesn't seem to talk about bank conflict, hiding some hardware details that might be necessary to write the best kernel. will it be able to match the perf of Cuda on the same hardware?
WebGPU cannot even come close unfortunately since they don't have support for hardware specific memory or warp-level primitives (like TMA or tensorcores). it's not like it gets 80% of perf, it gets < 30% of the peak perf for anything related to heavy compute matrix multiplications