mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #3001] [CLOSED] perf(prefill): use single LDS-only barrier per stage in native_w11_kernel #4391
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#4391
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/3001
Author: @bsorensen110
Created: 10/18/2026
Status: ❌ Closed
Base:
main← Head:perf/rdna4-p2-native-w11-prefill📝 Commits (1)
96c9a81perf(prefill): use single LDS-only barrier per stage in native_w11_kernel (P2)📊 Changes
1 file changed (+15 additions, -7 deletions)
View changed files
📝
src/prefill/moe_fused_iq.cu(+15 -7)📄 Description
Summary
Optimizes
native_w11_kernel(src/prefill/moe_fused_iq.cu), the defaultgfx12(RDNA4) and opt-ingfx11(STRATA_PF_FUSED=1) int8-WMMA fused MoE prefill kernel:src/prefill/moe_fused_iq.cu:913, 964):0's decoded weights (wt[0],ws[0]) are written byput(raw, 0)before the prologue barrier (line 882), and each subsequent stages + 1's decoded weights (wt[(s + 1) & 1],ws[(s + 1) & 1]) are written byput(raw, (s + 1) & 1)before the end-of-stage barrier added in#1180(line 964).wtandwsare double-buffered (wt[2][NW_ROWS][WLD],ws[2][NW_ROWS][4]), buffer(s + 1) & 1is only read in stages - 1(before the barrier at the end of stages - 1). Keeping both the top-of-loop barrier (line 913) and the end-of-stage barrier (line 964) executed two workgroup barriers per stage (80barriers inGUacrossNS = 40,20indownacrossNS = 10) with onlyload_unit(s + 2)and register moves between them.__syncthreads()with an LDS-only barrier (nw_sync_lds()):native_w11_kernelonly synchronizes LDS (wt,ws,srow,hs).__syncthreads()lowers to a workgroup acquire/release fence over all memory (s_wait_loadcnt_dscnt 0x0; s_barrier; global_inv scope:SCOPE_SEongfx1200/gfx1201, ands_waitcnt vmcnt(0) lgkmcnt(0); s_barrierongfx11).loadcnt(0)/vmcnt(0)at every barrier forcedload_unit(s + 2)andfetch_b(s + 1)global loads to complete at the barrier instead of overlapping the next stage's 16v_wmma_i32_16x16x16_iu8instructions, andglobal_inv scope:SCOPE_SEongfx12flushed the L0 vector cache on every stage even though 4 consecutiveGUstages (s >> 2) read sub-blocks from the same 256-value weight superblock.nw_sync_lds()usess_waitcnt lgkmcnt(0); s_barrieronSTRATA_NAT_W11(matchinggw_lds_barrier()insrc/prefill/kernels.cu:1572) ands_wait_dscnt 0x0; s_barrier_signal -1; s_barrier_wait -1onSTRATA_NAT_W12.Root cause
In
src/prefill/moe_fused_iq.cu:880–976:3b499f17(#1180) added__syncthreads()afterput(raw, (s + 1) & 1)at line 964 while leaving the original__syncthreads()at the top offor (int s = 0; s < NS; ++s)(line 913).gfx1201disassembly ofnative_w11_kernel<T_IQ3_S, true, true, 8>:s,put(raw, (s + 1) & 1)stored to LDS and executeds_wait_loadcnt_dscnt 0x0; s_barrier_signal -1; s_barrier_wait 0xffff; global_inv scope:SCOPE_SE(line 964).load_unit(s + 2)issued 5global_loadinstructions for stages + 2's compressed weights, and the loop backedge immediately hit the second__syncthreads()(line 913), emittings_wait_loadcnt 0x0; s_barrier_signal -1; s_barrier_wait 0xffff; global_inv scope:SCOPE_SE— stalling onload_unit(s + 2)and invalidating the L0 vector cache before stages + 1's WMMAs began.The change
src/prefill/moe_fused_iq.cu:nw_sync_lds()(s_waitcnt lgkmcnt(0)\n\ts_barrieronSTRATA_NAT_W11,s_wait_dscnt 0x0\n\ts_barrier_signal -1\n\ts_barrier_wait -1onSTRATA_NAT_W12,__syncthreads()fallback).for (int s = 0; s < NS; ++s)and replace the remaining__syncthreads()calls innative_w11_kernelwithnw_sync_lds().Evidence
1.
gfx1201Disassembly Verification (llvm-objdump -d)global_inv scope:SCOPE_SEinstructions fromnative_w11_kernel(previously82L0 cache invalidations per 64-row tile inGUand22indown).80 → 39inGU,20 → 9indown).s = 1..NS-2),fetch_b(s + 1)'s 10global_load_b64instructions execute concurrently with all 16v_wmma_i32_16x16x16_iu8instructions of stageswith zeros_wait_loadcntinstructions inside the WMMA loop body.2. Bitwise Parity & Single-Layer Prefill Benchmark (
hip_prefill_fused_iq,S20_NOMMQ=1, 3 alternating rounds × 8 back-to-back runs per round ongfx1201)All 21 FNV-1a 64-bit output hashes (
7format pairs ×3chunk sizes) are 100% bit-for-bit identical betweenorigin/main(477ac13c) and this PR:GU / down)T × top 10,512experts)477ac13c) median (range)IQ2_S / Q2_020485.924 ms(5.876..5.981)5.733 ms(5.701..5.739)-0.191 ms(-3.2%)a00480861b802319IQ2_S / Q2_0409610.053 ms(9.960..10.102)9.763 ms(9.743..9.784)-0.290 ms(-2.9%)aee2d4d83555ed14IQ2_S / Q2_0819217.087 ms(16.955..17.259)16.580 ms(16.580..16.602)-0.507 ms(-3.0%)00e028dc81b0f8adIQ2_XXS / Q2_020485.193 ms(5.142..5.229)5.168 ms(5.144..5.195)-0.025 ms(-0.5%)5d683c2b3687e30bIQ2_XXS / Q2_040968.805 ms(8.693..8.809)8.662 ms(8.646..8.701)-0.143 ms(-1.6%)989bce78f95d1314IQ2_XXS / Q2_0819215.053 ms(14.983..15.093)14.930 ms(14.926..14.982)-0.123 ms(-0.8%)13e842c9319ee999IQ2_XS / IQ4_NL20485.920 ms(5.915..5.956)5.802 ms(5.789..5.804)-0.118 ms(-2.0%)bdaafb7393e0eba7IQ2_XS / IQ4_NL40969.964 ms(9.959..9.975)9.775 ms(9.748..9.779)-0.189 ms(-1.9%)d5fe1b375e1c0a51IQ2_XS / IQ4_NL819216.963 ms(16.947..16.979)16.738 ms(16.686..16.746)-0.225 ms(-1.3%)30a69a735319617aIQ3_S / IQ4_NL20485.600 ms(5.573..5.604)5.577 ms(5.563..5.586)-0.023 ms(-0.4%)2facbc39b2f3ccd6IQ3_S / IQ4_NL40969.388 ms(9.363..9.396)9.283 ms(9.249..9.298)-0.105 ms(-1.1%)c3656c1659ed6fc9IQ3_S / IQ4_NL819216.095 ms(16.060..16.152)15.807 ms(15.743..15.820)-0.288 ms(-1.8%)2b9894f699b0d225IQ3_XXS / IQ4_NL20485.458 ms(5.441..5.487)5.381 ms(5.360..5.409)-0.077 ms(-1.4%)51f5c4d34bc14422IQ3_XXS / IQ4_NL40969.312 ms(9.257..9.339)9.095 ms(9.094..9.098)-0.217 ms(-2.3%)523b47c2778f2f67IQ3_XXS / IQ4_NL819215.595 ms(15.531..15.609)15.397 ms(15.311..15.404)-0.198 ms(-1.3%)ebcc0b6618e1fefaIQ4_XS / Q2_020485.009 ms(4.987..5.070)4.969 ms(4.942..4.976)-0.040 ms(-0.8%)b9b1de12520448fbIQ4_XS / Q2_040968.478 ms(8.458..8.508)8.350 ms(8.340..8.355)-0.128 ms(-1.5%)60bc8a0be37c16f2IQ4_XS / Q2_0819214.389 ms(14.380..14.408)14.191 ms(14.180..14.200)-0.198 ms(-1.4%)954126a6868b77c0Q4_K / Q5_120486.485 ms(6.472..6.516)6.183 ms(6.181..6.215)-0.302 ms(-4.7%)1088e4f56d22033eQ4_K / Q5_1409610.903 ms(10.869..10.920)10.292 ms(10.289..10.304)-0.611 ms(-5.6%)47cb583723e30c68Q4_K / Q5_1819219.256 ms(19.161..19.300)18.546 ms(18.543..18.565)-0.710 ms(-3.7%)3b8f0ec84cbb4490What this does NOT fix
native_kernel(sm_75/sm_80+) or HIPnative_f16_kernel(STRATA_PF_F16=1).gfx1100/gfx1151: Device code was compiled and verified forgfx1100,gfx1151,gfx1200, andgfx1201; runtime parity and timing were executed ongfx1201, whilegfx11hardware runtime remains unrun on this host.Test plan
hip_prefill_fused_iq --chunks=2048,4096,8192passes reference + MMQ parity ongfx1201(prefill fused MoE (native formats) parity passed)(format_pair, chunk_size)combinations ongfx1201--offload-arch=gfx1100,gfx1151,gfx1200,gfx1201)Reproduction
Environment: AMD Radeon AI PRO R9700 (
gfx1201, 32 GB), Linux7.2.9-2-cachyos-server, ROCm10.2.0a20260914, basev0.1.45(477ac13c).🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.