Live data from Hacker News

Optimizing a WebGPU Matmul Kernel for 1 TFLOP

zanussbaum.substack.com

11–20 of 88 posts

Re: Optimizing a WebGPU Matmul Kernel for 1 TFLOP

#11
post #8

Great article! For 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).

thanks! and yes definitely not at CUDA levels :)

Re: Optimizing a WebGPU Matmul Kernel for 1 TFLOP

#13
post #12

WebGPU will make Web maps even more competitive than they are already. The smoothness of an iPhone map zoom, on any device.

> The smoothness of an iPhone map zoom, on any device.

Any device except an iPhone, until Apple finally gets around to shipping WebGPU in Safari. Any year now...

Re: Optimizing a WebGPU Matmul Kernel for 1 TFLOP

#14
post #4

Couple years ago, I wanted about the same thing in HLSL language, for a Direct3D 11.0 compute shader. Here’s the fastest version I managed to make back then: https://github.com/Const-me/Cgml/blob/master/Mistral/Mistral... As 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 =…

[deleted]

Re: Optimizing a WebGPU Matmul Kernel for 1 TFLOP

#15
post #14
post #4

Couple years ago, I wanted about the same thing in HLSL language, for a Direct3D 11.0 compute shader. Here’s the fastest version I managed to make back then: https://github.com/Const-me/Cgml/blob/master/Mistral/Mistral... As 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 =…

[deleted]

[deleted]

Re: Optimizing a WebGPU Matmul Kernel for 1 TFLOP

#18
post #8

Great article! For 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).

75% can't be the best we can do. What would reach 100% or nearly 100%? Handcoded assembly?

Re: Optimizing a WebGPU Matmul Kernel for 1 TFLOP

#19
post #8

Great article! For 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).

75% can't be the best we can do. What would reach 100% or nearly 100%? Handcoded assembly?

With GPUs it's not uncommon to run out of memory bandwidth before you max out the theoretical FLOPS. They may have a ton of bandwidth but it's never enough.

That can lead you to some pretty counter-intuitive optimizations because it's often faster to do more compute work if it means you touch less memory in the process.

Re: Optimizing a WebGPU Matmul Kernel for 1 TFLOP

#20
post #13
post #12

WebGPU will make Web maps even more competitive than they are already. The smoothness of an iPhone map zoom, on any device.

> The smoothness of an iPhone map zoom, on any device. Any device except an iPhone, until Apple finally gets around to shipping WebGPU in Safari. Any year now...

Safari is officially enabling support for WebGPU in iOS 18.2, which is rolling out within the first weeks of December.
Post reply on HN