Repository navigation
native hip: skip dead-row stream folds on gfx1151 single-round routed 4-bit 3-4 row items (stacked on #3774) - #3559
Conversation
23c4159 to
0c43cd0
Compare
|
Thanks @gilby, and for settling #3305's device items with a full main-against-branch receipt.
One thing on order: this branch is stacked on #3774, which is not on main yet. Its diff therefore also carries #3774's two changes: exact plan rows for RDNA3.5 lane rounds ( It applies to current main apart from the CHANGELOG line, which we settle when it lands. Before landing it still needs CI green at this head and a device check on gfx1151.
|
0c43cd0 to
ff7f656
Compare
|
Thanks @gilby. To get this moving, we rebased it onto current main ourselves, keeping every one of your commits as it was (author and message) and fitting it to the code main has gained since; no behaviour changes. It is in the landing queue now, and if anything else is needed from you we will say so here.
|
…, not synthetic percentages # Conflicts: # CHANGELOG.md
… with the thank-you Drop the older synthetic M5 Max line that the served-results line replaced and the blank line it left before 1.2.9, and end the kept line with "Thanks to @gilby." as ashhart#2973's line and main's lines for his work do. # Conflicts: # CHANGELOG.md
… 4-bit 3-4 row items
ff7f656 to
ee47661
Compare
|
Thank you @gilby. This is merged into main with your commits under your own name, so you're listed as a TensorFold contributor. It ships in the next release, credited to you in the changelog and the release notes. |
What this changes
On Strix Halo (
gfx1151), single-round (K <= 1024,single_round_k = 32 * 32) plain fp32-output routed 4-bit stream launches whose largest item holds 3 or 4 rows setRouting.item_rows = 1, so rows past an item's count skip the epilogue lane fold instream_body(zig/kernels/hip/tiles/stream.hpp) while writing identical bytes toitem_rows = 0. Multi-round (K > 1024) and fused epilogues (pair,relu2, fp16 output) keepitem_rows = 0:work()already skips dead-row dot work, sorounds >= 2already amortize the epilogue fold below2%while shifting small-window cost ratios inlanes/depth.zig. Limiting to single-round plain routed 4-bit plans leaves339of the341dot2_tilesfunctions unchanged (gfx1151 plain stream tile 4-bit4x2and4x4add0VGPRs and+1SGPR each, with0extra HIP 7.1 limit lines).6315cdc37, which sizes RDNA3.5 lane-round routed MoE plan buffers to exact window rows and pools rising added-row window costs within four-row regimes). Adds180f52497(12-file code commit, tree-identical to qualifiedb4fe2f74eoutsideCHANGELOG.md) and0c43cd0d6(CHANGELOG.md).atc overlap --json: incomplete (complete: false, API/PR limits) across15changed files againstmain. Across all100open PRs on GitHub against the 12 code files changed in#3559:0overlapzig/kernels/hip/**orzig/src/hip/launches/**;8touchdocs/kernel-contract.mdorzig/tests/hip/contract_main.zig(#3575,#3613,#3676,#3689,#3694,#3734,#3735,#3736), and29touchCHANGELOG.mdonly.git merge-tree --write-tree origin/main b4fe2f74e(code changes on8cbef9777) merges cleanly (0conflicts);git merge-tree --write-tree origin/main HEADconflicts inCHANGELOG.mdonly.Checks on this head
0c43cd0d6(180f52497code plus0c43cd0d6changelog), stacked on#3774(6315cdc37) onmain3f1290ffe. All GPU binaries, kernel contract runs, microbenches, and#2984served benchmarks ran onb4fe2f74e(git diff b4fe2f74e 180f52497 -- ':!CHANGELOG.md'is empty).python3 tools/zig/lean_check.py, on the base (6315cdc37and3f1290ffe) and on this head:221and221,0new findings.python3 tools/pr_check.py --base 6315cdc37 --pr 3559:0 error(s), 0 warning(s).python3 tools/pr_check.py --base 3f1290ffe --pr 3559:0 error(s), 0 warning(s). Upstream publish check across3f1290ffe..HEAD: clean.zig fmt --check: clean across all changed Zig files.zig build test test-kernel-contract test-golden fuzz-cortheon --summary allon RDNA3.5 host:756/758steps succeeded (762/777tests passed,14skipped,1pre-existing failure instage_hip_test.test.every staged call on HIP memory equals the reference, whole and in parts, matchingmain).zig build test -Dhip=true --summary allon RDNA3.5 host:769/771steps succeeded (576/591tests passed,14skipped, same pre-existingstage_hip_testfailure).zig testonzig/src/hip/root.zig):119/119passed (stream_pick,stream_variant,moe, etc.).zig build hip-kernel-test -Dhip=true -Dhip-arch=gfx1151 --summary all:22/22steps succeeded (224/231tests passed,7skipped,0failed;#3774base had220/227passed,7skipped,0failed — the+4new tests arestream_pick,stream_variant, andaffine/items.zigchecks).stream_pick.zigandstream_variant.zig): covers every chip inCaps, widths2..8, rows1..64,kin{512, 640, 1024, 1056, 1856, 2048, 2688}, dense and routed, plain vs fused (pair/relu2). Removingor m > 4failslaunches.stream_variant.test.item_rows stays off ...atstream_variant.zig:48(TestUnexpectedResult) andlaunches.stream_pick.test.only RDNA3.5's single-round ...atstream_pick.zig:107(expected .none, found .items). Removingor k > single_round_kfailsstream_variant.zig:53(TestUnexpectedResult) andstream_pick.zig:107(expected .none, found .items).zig/src/hip/kernel_tests/affine/items.zig): covers windows of1..8random rows,16and17rows withcap=4, and8rows atcap=4vscap=5across all 6 served routed shapes (Lightning fc1/fc2,Flash Next gate+up/down,Qwen3.6-35B-A3B gate+up/down), checking byte equality againstitem_rows = 0and against each pair alone, with random inputs plus-0/+inf/-inf/NaNplanted inx, scales, and biases. Removingor m > 4instream_pick.zigfails withFlash Next down: largest item 5 of cap 5, item_rows true; removingor k > single_round_kfails withLightning fc2: largest item 4 of cap 4, item_rows true; moving theRouting.item_rowsfold exit one row early (row0 + r + 1 >= a.mintiles/stream.hpp) fails withitem rows: 1279488 words differ from the tile, 1279488 from each pair aloneacross15Flash Next downandQwen3.6-35B-A3B downcases (randomandspecial).strix/k2-stream-item-rows.gfx1030,gfx1100, andgfx1201hardware (no such cards; thestream_pickhost test andhip-kernel-contract-limitscheck those generations).Qwen3.8-27Bwas not served: it is dense (num_expertsdefaults to0, checkpoint reader returns.denseatzig/src/families/qwen3_5/config.zig/checkpoint.zig) and cannot reach a routed launch.Receipt
0two-series losses (LOSSES_TOTAL=0) across all 64 cells (16cells x4routed MoE checkpoints) both stacked (#3559vs#3774) and cumulative (#3559vsmain) under#2984's noise rule. Full Group 2 (merged12.md,served12.md,rerun12.md), Cumulative (cum12_merged.md,cum12.md,cum12_rerun_L4.md), narrowed microbench (mb-k2n-v6.txt), and runners: https://gist.github.com/gilby/0afb93436834f38d94c67fb674ddb3dd.K <= 1024) plain fp32-output routed 4-bit launches (Routing.item_rows) on RDNA3.5 (gfx1151) holding 3 or 4 rows in their largest item:Flash Next down(K = 640, group32) andQwen3.6-35B-A3B down(K = 512, group64).b4fe2f74e(code-identical to180f52497) vs#3774(a4f62edf5/6315cdc37) andmain(3f1290ffe), with#3242(be9fe6237) merged onto both arms forLightning oQ4eonly. Zig0.17.0, HIP7.1runtime, one Strix Halo (Radeon 8060S,gfx1151, 128 GB unified, stock12.3 GiBreserve viaenv -u TENSORFOLD_MEMORY_RESERVE_GIB,performancepower mode). Checkpoints:Qwen3.8-Flash-Next oQ4e;Nemotron 3.5 Lightning 30B-A3B MLX 4-bit;Qwen3.6-35B-A3B MLX 4-bit with MTP;Nemotron 3.5 Lightning oQ4e(user3892 r4).flashnext,qwen3_5MoE, andnemotronongfx1151, plus host rule tests and contract limits overgfx1030/gfx1100/gfx1151/gfx1201; could not execute ongfx1030/gfx1100/gfx1201GPUs (verified off instream_pick.variantandstream_variant.Table.load).tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false:57/57token_sha256equality,alone[42, 0],serial[24, 0]in every arm and rerun across all 4 checkpoints for both stacked (#3559vs#3774) and cumulative (#3559vsmain, includingCK2_L4).1-discardthenbase/head/head/baseon fresh servers (--context 131072 --parallel 4 --prompt-cache-gib 0, page cache dropped each arm);bench_openai --tokens 256 --reps 3,bench_concurrent --levels 1,2,4 --reps 3 --alone --serial --temperatures 1.0,0,bench_cache --require-coldat2K/8K/32K. Any single-seriesSLOWERcell got one full rerun series per#2984:#3559vs#3774):Lightning stock 4-bithad 1 first-series flag (openai fibonacci-raw T0 -0.93%/-1.53%), passing on rerun (+1.60%/+0.29%);Lightning oQ4ehad 1 first-series flag (conc T1 x4 -1.16%/-1.22%), passing on rerun (+0.37%/-0.87%).Flash Nextgained>=2%oncold 8k ttft_s(+13.82%/+3.27%) and stayed+0.87%to+1.89%across solo/OpenAI cells. Result:0two-series losses.#3559vsmain):Lightning stock 4-bithad 1 cross-series flag (openai gpu-chat-no-think T0 -4.50%/-4.11%); dedicated 5-armCK2_L4rerun passed (+3.67%/+0.03%).Qwen3.6-35B-A3Bkept all10>=2%decode gains (+2.58%to+15.68%). Result:0two-series losses.tools/bench_openai.py(in tok/s; fullbench_concurrentandbench_cachedecode tables in the gist):Stacked (
#3559vs#3774, Group 2 —0two-series losses):Cumulative (
#3559vsmain,LOSSES_TOTAL=0):Qwen3.8-Flash-Next(fib T1 +1.41%/+0.80%,chat T1 +0.44%/+0.41%,fib T0 +1.35%/+1.52%,chat T0 +0.66%/+0.73%),Lightning stock 4-bit(fib T1 -0.76%/+0.44%,chat T1 -1.22%/-1.71%,fib T0 +0.25%/-0.30%,chat T0 -4.50%/-4.11%-> rerunCK2_L4+3.67%/+0.03%),Qwen3.6-35B-A3B(fib T1 +2.98%/+3.11%,chat T1 +4.82%/+4.88%,fib T0 +3.34%/+3.45%,chat T0 +15.68%/+5.96%, plusconc T1 x2 +6.81%/+6.72%,conc T0 x1 +3.93%/+3.93%,conc T0 x2 +4.58%/+3.97%,cold 2k +6.80%/+6.94%,cold 8k +5.35%/+5.44%,cold 32k +3.18%/+2.58%), andLightning oQ4e +#3242(fib T1 -0.98%/+0.02%,chat T1 +3.88%/+0.57%,fib T0 +0.12%/+0.04%,chat T0 -0.73%/-0.61%).Narrowed microbench (
mb-k2n-v6.txt, warm per-launch microseconds, single-round plain routed 4-bit shapes whereCB4is picked):bench_cache --require-coldttft_s): in stacked Group 2 (#3559vs#3774), all 12 coldttft_scells stay within or faster than#2984:Flash Next8Kgains (10.887 -> 9.565+13.82%,9.583 <- 9.896+3.27%),2K(3.225->3.259-1.04%/2.975<-2.962-0.43%),32K(-0.39%/-0.18%), and acrossLightning 4-bit,Qwen3.6-35B-A3B, andLightning oQ4eall pairs lie between-0.99%and+1.08%. Cumulative (#3559vsmain) coldttft_shas0losses (-0.70%to+1.42%, exceptFlash Next 2Ksingle-pair-8.15%/+0.62%within rule).Kernel contract, only when a GPU kernel is new or changed
hip affine_dot2_stream item-rows (4-bit, group 64, fp32 out)andhip affine_dot2_stream item-rows (4-bit, group 32, fp32 out)(zig/tests/hip/contract_stream_items.zig), gated insidestream_body(tiles/stream.hpp) viaRouting.item_rowsrather than adding separate_itemskernel entry points. Each replacesaffine_dot2_stream with item_rows off on the same planand Gate 3 (shapes) checks byte equality (worst 0.000 of the bound) at served single-round routed shapes (3x2048x512,4x2048x512,3x2560x640,4x2560x640)."control: the item-rows tile with every item one row short"(tf_ctl_items_short_plain_2andtf_ctl_items_short_plain_4inzig/kernels/hip/contract_controls.hip) is red at Gate 3 (shapes) on both specs (differing from byte49152at3x2048x512and from byte61440at3x2560x640).SUMMARYline and exit status (gfx1151):hipcc:SUMMARY gfx1151 164 kernels: 164 pass gates 1-4, 0 fail, 2 known findings; 45 controls: 45 red as planted, 0 missed; 2 limit problems; gates 371256 ms, limits 2272 ms, exit1(identical2pre-existing limit problemstf_moe_combine_gateandtf_vl_resizeasmainand#3774).hipcc:SUMMARY gfx1151 164 kernels: 164 pass gates 1-4, 0 fail, 2 known findings; 45 controls: 45 red as planted, 0 missed; 175 limit problems; gates 379290 ms, limits 2270 ms, exit1— identical175limit problems as#3774/main(0extra HIP 7.1 limit lines). Under HIP 7.1, the two changedplain stream tile 4-bitvariants report126/124(4x2) and184/182(4x4) VGPRs against their ROCm 10.1 records, the same HIP 7.1 register delta already onmain; gating viaRouting.item_rowsinsidestream_bodyavoided spawning 6 separate_itemssymbols.zig build hip-kernel-contract-limits -Dhip=true -Dhip-relax-branches=truewith ROCm 10.1:FAIL kernel-contract-limits: 30 problems(1230log lines, identical count to#3774/main). Comparing all1230lines shows onlygfx1151plain stream tile 4-bit 4x2(124VGPRs, SGPRs71 -> 72) and4x4(182VGPRs, SGPRs73 -> 74) updated inzig/src/core/contract/hip_records_stream_plain.zig, with0VGPR, LDS, or scratch changes on any kernel or chip.gfx1030,gfx1100, andgfx1201(ROCm 10.1 compiler records checked on all 4 chips viahip-kernel-contract-limits; rule keepsitem_rows = 0off RDNA3.5).Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.--drafter, no slower than without it, greedy and sampled.