mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #1180] STRATA_PF_FUSED on gfx1100: missing __syncthreads() in native_w11_kernel + waves_per_eu(8) wrong on clang 22 / ROCm 7.10 #492
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#492
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?
Originally created by @zhhhn on GitHub (Oct 6, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/1180
STRATA_PF_FUSED=1on gfx1100: a missing__syncthreads()innative_w11_kernel, andwaves_per_eu(8)computes wrong on ROCm 7.10 / clang 22Problem
With
STRATA_PF_FUSED=1(+ STRATA_PF_GEMM=1), some prompts come back as nothing but!— the model confidentlypredicts
!, MTP drafts agree (2 of 2 accepted), the engine logs no error and the prefill speed looks normal.The same prompts are correct with
STRATA_PF_FUSED_NATIVE=0(MMQ), so the native gfx11 fused expert kernels(
src/prefill/moe_fused_iq.cu) are the culprit.There are two independent defects; both must be fixed:
put(raw, (s + 1) & 1)(the double-buffered weight LDS write) has no barrier after it__syncthreads()waves_per_eu(8)occupancy variant (LB=8) computes wrong results on this toolchainLB=8→LB=1(or gate it on the toolchain)They are unrelated:
LB=8plus the barrier is still 0/20, whileLB=1plus the barrier is 20/20.Reproduction
The repository's own test is the oracle, and it fails in seconds:
--no-timingkeeps it to part 1 (256 tokens, 64 experts) — that is where it fails;--chunks=only affects thetimed part 2.
Cause A: the missing barrier
In
native_w11_kernel(src/prefill/moe_fused_iq.cu, ~line 816):The comment says the readers of that buffer already passed the loop-top barrier, but the write still races with them.
Interleaved rounds (control and patched binaries alternated in the same session, 15 rounds each,
--no-timing):putRe-run alone, the barrier is 20/20 (if the true failure rate were 45 %, 20/20 has probability ≈ 6e-6).
Cause B:
waves_per_eu(8)is wrong on clang 22 / ROCm 7.10native_w11_kernel<WT, GU, ALIAS=true, LB=8>caps VGPRs via__attribute__((amdgpu_waves_per_eu(LB > 0 ? LB : 1))). The source comment justifies it with measured spill counts("gate/up IQ2_* / IQ3_* / IQ4_XS 0-5 regs") — that measurement is toolchain-dependent:
--only=IQ3_XXSLB=8(as shipped)LB=1(ALIAS kept)-DSTRATA_W_NO_OCC(LB=0, no ALIAS)LB=8+ the barrierSo the LDS alias (
hson the weight buffers) is fine — only the VGPR cap breaks.STRATA_PF_OCC=1/4(grid size) anddisabling ASLR do not change the failure rate, and the test's own synchronisation is complete (stream sync +
synchronous
cudaMemcpy; the CPU model uses a fixed seed and does not read the GPU).Fix
For B I would not hard-code
1: the "does not spill under 192 VGPRs" assumption is what needs to be verified percompiler (or the variant simply disabled for AMD clang 22 / ROCm 7.10). The extra barrier costs one sync per stage
(40 per work item) and is not measurable in the run time.
After the fix
Engine-level, with
STRATA_PF_FUSED=1 STRATA_PF_GEMM=1 STRATA_PF_SWITCH_MIN_T=4096:17*23) / tool call391/finish_reason=tool_callsPF_FUSED+PF_GEMM(patched)Environment
-DSTRATA_ENABLE_HIP=ON -DCMAKE_HIP_ARCHITECTURES=gfx1100 -DSTRATA_PREFILL_MMQ=ON).v0.1.40.1 changes no engine file (verified with the compare API and
diff -rqonsrc/andinclude/), so thisapplies to 0.1.40.1 unchanged.
IQ2_XXS / IQ2_XS / IQ3_XXS / IQ3_S / IQ2_Sgate-up withQ2_0 / IQ4_NLdown; 512K context, int8 KV,--resident-experts,--prefill auto:16384@Niko1221 commented on GitHub (Oct 7, 2026):
Fixed in 0.1.40.2. The weight buffer write in the fused gfx11 kernel now has the barrier after it, and the waves_per_eu(8) variant is switched off when the compiler is clang 22 or newer (the cap is 1 there; -DSTRATA_W_LB=N overrides it). It is an opt-in path (STRATA_PF_FUSED=1), so default output is unchanged. I could only compile it for gfx1100 here, not run it, so please retest your 20-run loop on the 0.1.40.2 engine.
@alexdns1 commented on GitHub (Oct 7, 2026):
The 0.1.40.2 fix works here; this is only about the compiler condition for defect B.
__clang_major__ >= 22alsoturns the
waves_per_eu(8)cap off on clang 23, where on gfx1151 the capped variant is correct and faster.Measured on a Ryzen AI Max+ 395 (Radeon 8060S, gfx1151, 128 GB), Fedora 44, kernel 7.2.8, ROCm 7.14.1
(
AMD clang version 23.0.0git), engine 0.1.40.2 (e8ca9af) built per docs/STRIX_HALO.md,STRATA_PF_FUSED=1(docs/STRIX_HALO.md section 5), UD-IQ4_XS:
Bisect. Prompt speed dropped ~5% between 0.1.40 (
82f46a8) and 0.1.40.2.git bisectover the 69 engine commits,8K prompt median per step: first slow commit
3b499f1(1,298 tok/s; the good steps before it 1,389).Same tree, two builds, only the cap differs: stock (NW_LB = 1 on clang 23) and
-DSTRATA_W_LB=8, both with thenew barrier.
hip_prefill_fused_iq: both pass, same worst error against the FP64 reference (2.942e-02), 0 failures.Fused kernel time per layer, cap 1 -> cap 8, 8192 tokens: IQ2_S/Q2_0 41.92 -> 40.21 ms (-4.1%),
IQ2_XXS/Q2_0 38.29 -> 32.44 (-15.3%), IQ3_S/IQ4_NL 40.48 -> 34.99 (-13.6%), IQ3_XXS/IQ4_NL 39.88 -> 33.63 (-15.7%);
2048 and 3584 tokens similar (-3% to -16%).
hip_prefill_fused_moe: both pass.STRATA_PF_SWITCH_MIN_T=4096), conversation cache and prompt cache off, each prompt twice: identical within eachbuild and between the two builds.
cooled machine, power mode performance), 8K / 91K tok/s:
So on gfx1151 with clang 23 the cap is most of the 0.1.40.2 prompt slowdown at 91K (+3.6% with cap 8), and cap 8 shows
none of the wrong results reported here for gfx1100 with clang 22. Would it be enough to apply
NW_LB = 1only forclang 22, or only on gfx1100? @zhhhn, does your gfx1100 also compute wrong results with cap 8 on a clang 23 ROCm?
@afterthought325 commented on GitHub (Oct 8, 2026):
0.1.40.2 fix verified working on RX 7900 XT (gfx1100, single GPU, IQ3_XXS native pack): with STRATA_PREFILL_MMQ=1 (default) + STRATA_PF_FUSED=1 the fused path engages ('prompt experts on the fused int8 kernels' in log), 6/6 test prompts return coherent on-topic prose (no '!!!' degeneration), and prefill goes 1628 -> 1849 tok/s @32K (+13.6% over our MMQ=0 champion) and 1272 -> ~1700 @5K. Attribution arm (STRATA_PF_FUSED_NATIVE=0, MMQ path only): 1254 @32K, so the win is the gfx11 native fused experts, not MMQ. One gotcha worth a docs line: PF_FUSED is silently inert under STRATA_PREFILL_MMQ=0 (mmq_plan empty -> fused_l false, no log line) — I burned an arm discovering that.
@Niko1221 commented on GitHub (Oct 13, 2026):
Thanks for the report. To keep the tracker current we are closing issues older than three days: 0.1.44 is out with a long list of fixes, and many older reports are covered by it or by 0.1.43.1.
If this still happens on 0.1.44, please leave a comment here with your engine log (and the version line it prints), and we will reopen it. A new issue that links this one works too.