Repository navigation
perf(qwen-flash): fence each K block in the W8A8 WMMA GEMM - #255
Conversation
The scheduler hoisted the next K block's LDS operand reads above the current block's WMMAs, which pushed every W8A8BlockedWmmaGEMMKernel instantiation to 256 VGPRs plus 128-140 bytes of scratch on gfx1151. One sched_barrier per K block removes the spills (176-184 VGPRs, no scratch) and roughly triples occupancy. Strix Halo, Qwen3.8-Flash-Next UD-Q4_K_XL, pp2048: - W8A8 GEMM: 45-51% less time per call (HC-down 1073 -> 525 us) - prefill: 1459.99 -> 1535.02 t/s (+5.1%) A captured replay of the HC-down dispatch is bitwise identical, and qwen38_flash_next_projection_ops_test passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
I'm trying to verify the claims but I'm straggling to see the spill. Would you mind sharing your setup and how you run gufo? toolbox? I'm not saying your change is not worth, only curious about the differences generating the problem in the first place. Comparison table
|
|
Maybe some toolbox overhead? 🤔 |
|
Interesting. IOMMU setting maybe? I don't have IOMMU off (since I'm testing stuff on the NPU), maybe that's the reason? |
|
Okay, I found it - apparently it's the compiler. On clang23 it spills, on lower it doesn't (I'm building with the newest ROCm). Weird result, but apart from gating on clang version I don't know how to properly account for it. |
ROCm 7.2.3 (LLVM 22) schedules W8A8BlockedWmmaGEMMKernel without spills (157-180 VGPRs), and there the fence costs about 3% per call. The spills come from LLVM 23 (TheRock ROCm 7.14 and 10.0 nightlies), so keep the fence only for that compiler. Checked with the ROCm 10.0 compiler: the real __clang_major__ (23) gives 159/159/178/173 VGPRs and no scratch; forcing it to 22 brings back 256 VGPRs and 128-264 bytes of scratch. qwen38_flash_next_projection_ops_test passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Great findings. Let's merge it 🚀 and congrats for being the first contributor to Gufo :yay: |
|
The Qwen3.8-27B copy of this kernel has the same spill with clang 23 #459 adds the fence to the Qwen copy, without the version test. With clang 22, the fence changes |
You had a spill in the WMMA kernel, this gets a bit of extra performance :) Quoting my silicon friend:
Strix Halo, Qwen3.8-Flash-Next UD-Q4_K_XL, pp2048: