Skip to content

HIP: a measured tuning table for gfx1201, and the step that measures one - #1527

Merged
ashhart merged 2 commits into
ashhart:mainfrom
laudney:hip-gfx1201-tuning
Oct 28, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
laudney:hip-gfx1201-tuning

Conversation

@laudney

@laudney laudney commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

zig build hip-affine-tune times every MLX affine prompt tile the GPU has on the served shapes and proposes table rows; zig build hip-affine-tune-build compiles it without a GPU. Neither is part of zig build test; both need -Dhip=true. RDNA4 now takes its own table, gfx1201.zon, with gfx1100's rows: the step proposed raising mlx.routed.prefill.kp3 to 545 items, but served checks on Qwen3.6 and Nemotron Lightning found Nemotron up to 1.7 times slower above 300 items, so 1ce4440 keeps 300 and no choice changes. gfx1200 takes the table unmeasured. Closes #1506.

Update: the receipt below measured the 545-item row on an earlier base; it is superseded by the per-model results in the comments, which led to 1ce4440.

Receipt

  • Environment: this branch on main at 886cc717, Zig 0.17.0, HIP 7.16 (AMD clang 24.0.0git), one Radeon AI PRO R9700 (gfx1201) that nothing else was using, Linux. Checkpoint mlx-community/Qwen3.6-35B-A3B-4bit at 38740b84 (MLX affine 4-bit, groups of 64; no MTP head). The tuner and the served benches ran on these three commits over an earlier main; the tests below were rerun on this branch's head.
  • The step's result: six runs agreed. The only accepted move is mlx.routed.prefill.kp3 items 300 to 545 (12 timed cells change, none slower); 833 items (257 to 512 tokens) is refused because the 128-row tile wins at 512 tokens. Every other prompt bound keeps gfx1100's value: the per-cell veto refused each move, mostly on K-parallel cells whose noise passed 5%. Decode rows are gfx1100's, verbatim.
  • Exactness: greedy and seeded sampled replies are equal between the two builds in every round: token_sha of every tools/bench_openai.py reply (temperatures 0 and 1.0, seeds 1234 to 1236) and token_sha256 of every tools/bench_cache.py reply, all cold.
  • Decode speed before and after, tools/bench_openai.py --tokens 128 --reps 3, tok/s per round in run order base, new, base, new, base, new, then a reversed pair new, base:
prompt temperature per round mean before mean after
fibonacci-raw 1.0 145.6 145.0 145.5 145.3 145.5 145.0 / 145.7 145.3 145.5 145.3
gpu-chat-no-think 1.0 145.1 144.8 144.4 144.5 145.4 145.1 / 145.0 144.7 144.9 144.9
fibonacci-raw 0 150.1 148.7 150.1 150.0 150.4 150.1 / 150.3 150.1 150.2 149.8
gpu-chat-no-think 0 149.5 149.4 149.4 149.5 149.8 149.5 / 149.7 149.5 149.5 149.5

The decode kernels are the same in both builds. The second process of a pair was a little slower in every pair, whichever build it ran, as the reversed pair shows.

  • Prompt speed before and after: cold first-request ttft_s from tools/bench_cache.py --require-cold --tokens 16 --repeats 3 --streams 1, server with --prompt-cache-gib 0, a fresh process each round, median ms per round in the same order:
prompt tokens per round prompt tok/s before after time
48 125.1 65.1 124.9 65.2 124.5 65.3 / 64.6 125.0 384 738 x0.521
100 132.1 95.7 132.0 95.6 131.6 95.5 / 95.1 132.8 757 1047 x0.723
200 172.0 154.4 172.9 155.5 170.8 154.2 / 152.8 171.7 1164 1297 x0.898
256 193.9 185.2 193.5 184.9 193.1 185.5 / 183.6 193.6 1323 1385 x0.955
1000 426.1 424.7 424.5 425.1 421.9 423.7 / 421.7 427.0 2354 2360 x0.997
2048 870.0 868.2 868.5 868.8 862.8 866.0 / 863.0 867.2 2362 2364 x0.999
8192 3715.4 3718.5 3720.8 3719.7 3710.1 3709.7 / 3704.9 3715.5 2205 2206 x0.999
  • Tests run: hip-kernel-test 103 passed, 0 failed; hip-affine-test 30 passed, 0 failed; tf-qwen35-test check 42 passed, 0 failed, 5 skipped (the four drafted-equals-serial checks, as the checkpoint has no draft head, and radix memory, too few ids), all on the R9700. zig build test test-kernel-contract test-golden fuzz-cortheon, zig build test -Dhip=true and a plain zig build pass; hip-affine-tune-build builds with no GPU visible; the lean check finds no new problem.
  • Not run: gfx1200 (no card; it takes this table unmeasured). gfx1030, gfx1100 and gfx1151 keep their tables. No kernel changed, so no kernel-contract SUMMARY changes. Drafted equals "draft": false is not checked here, as the checkpoint has no draft head. The changed row also serves Flash Next's and Nemotron's routed prompts, whose plans the step did not time and which I did not serve.

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (Resumed and concurrent pass in tf-qwen35-test check; drafted is not checked, no draft head.)
  • No precision traded for speed. If the bits change, the description says which sums change and why. (The two tiles are of one family; replies are equal.)
  • A new or changed GPU kernel is registered with the kernel contract (docs/kernel-contract.md); each backend's SUMMARY line is in the receipt. (No kernel changed.)
  • Prompt processing is no slower than the last release.
  • The description says which platforms I ran, Metal M1 to M5 and CUDA, and which I could not. (HIP gfx1201 only; Metal and CUDA are unchanged.)
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. (No new test; the step is a measurement.)
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.
The step's raw times: median us a launch (noise when above 5%), from its last run; U marks a cell whose table copies could not reach 512 MiB a rotation
product count items kp0 kp1 kp2 kp3 gemm block
1001x2112 4b g64 1 rows 18.0 14.9 19.7 9.6 96.3 216.2
1001x2112 4b g64 2 rows 18.8 14.5 19.2 9.3 92.5 208.9
1001x2112 4b g64 3 rows 14.4 19.2 10.9 92.0 208.8
1001x2112 4b g64 4 rows 14.4 19.3 10.8 92.4 208.7
1001x2112 4b g64 5 rows 17.3 19.3 14.6 92.8 208.9
1001x2112 4b g64 6 rows 17.2 19.4 14.6 93.2 208.9
1001x2112 4b g64 8 rows 17.3 19.4 16.1 95.8 208.8
1001x2112 4b g64 12 rows 27.7 28.0 26.6 96.0 208.6
1001x2112 4b g64 16 rows 28.9 28.2 28.3 96.4 208.9
1001x2112 4b g64 24 rows 44.2 44.6 40.4 97.1 210.2
1001x2112 4b g64 32 rows 47.1 49.5 52.5 97.5 210.3
1001x2112 4b g64 33 rows 60.1 61.3 98.1 209.6
1001x2112 4b g64 48 rows 65.4 76.5 98.4 211.1
1001x2112 4b g64 64 rows 85.0 100.4 98.7 212.1
1001x2112 4b g64 96 rows 122.8 148.2 113.1 217.3
1001x2112 4b g64 128 rows 162.3 196.6 116.9 222.6
1001x2112 4b g64 256 rows 314.7 392.1 117.8 225.2
1001x2112 4b g64 1000 rows 1213.2 1528.6 185.3 275.2
1024x2048 4b g64 1 rows 11.5 11.7 13.1 7.8 94.7 213.7
1024x2048 4b g64 2 rows 12.1 11.5 12.9 7.6 91.0 206.2
1024x2048 4b g64 3 rows 11.3 12.9 8.4 90.1 205.8
1024x2048 4b g64 4 rows 11.4 13.0 8.4 90.5 205.9
1024x2048 4b g64 5 rows 13.3 13.0 10.5 90.9 206.1
1024x2048 4b g64 6 rows 13.3 13.0 10.5 91.3 205.9
1024x2048 4b g64 8 rows 13.3 13.1 11.1 93.4 205.9
1024x2048 4b g64 12 rows 21.5 21.8 16.9 93.2 205.8
1024x2048 4b g64 16 rows 22.2 21.9 18.0 94.0 206.1
1024x2048 4b g64 24 rows 32.1 30.7 25.5 94.5 206.3
1024x2048 4b g64 32 rows 33.5 34.7 32.3 95.1 206.3
1024x2048 4b g64 33 rows 42.5 37.5 95.3 206.4
1024x2048 4b g64 48 rows 45.6 46.4 96.2 206.7
1024x2048 4b g64 64 rows 57.5 60.4 96.6 208.5
1024x2048 4b g64 96 rows 82.0 88.5 109.7 213.1
1024x2048 4b g64 128 rows 107.5 116.5 112.1 216.1
1024x2048 4b g64 256 rows 203.9 228.0 115.8 220.5
1024x2048 4b g64 8192 rows 6940.2 7252.3 1358.2 1788.2
1024x2048 4b g64 35b served gate_up 1 tokens U 9 57.9 48.5 75.6 23.5 195.0 321.1
1024x2048 4b g64 35b served gate_up 2 tokens U 162 133.5 85.9 141.7 47.9 226.2 514.2
1024x2048 4b g64 35b served gate_up 4 tokens U 162 157.6 265.7 89.4 429.4 864.4
1024x2048 4b g64 35b served gate_up 8 tokens U 162 286.4 474.2 165.9 787.8 1515.6
1024x2048 4b g64 35b served gate_up 16 tokens 162 514.5 860.2 285.1 1375.5 2723.9
1024x2048 4b g64 35b served gate_up 32 tokens 293 847.9 1381.1 487.1 2171.0 4341.2
1024x2048 4b g64 35b served gate_up 33 tokens 329 883.2 1436.0 506.9 2233.5 4463.2
1024x2048 4b g64 35b served gate_up 63 tokens 329 1225.8 1863.0 768.7 2885.7 5737.1
1024x2048 4b g64 35b served gate_up 64 tokens 329 1201.8 770.7 2803.0 5567.9
1024x2048 4b g64 35b served gate_up 65 tokens 401 1225.8 792.4 2846.1 5631.7
1024x2048 4b g64 35b served gate_up 128 tokens 401 1687.0 1255.2 3191.3 6262.2
1024x2048 4b g64 35b served gate_up 256 tokens 545 2647.3 2246.9 3368.4 6471.4
1024x2048 4b g64 35b served gate_up 257 tokens 833 2696.9 2308.5 3372.3 6494.4
1024x2048 4b g64 35b served gate_up 258 tokens 833 2701.0 2315.4 3372.2 6495.6
1024x2048 4b g64 35b served gate_up 260 tokens 833 2718.7 2329.9 3374.3 6494.5
1024x2048 4b g64 35b served gate_up 264 tokens 833 2758.5 2365.2 3375.1 6494.5
1024x2048 4b g64 35b served gate_up 272 tokens 833 2815.0 2423.3 3378.8 6498.1
1024x2048 4b g64 35b served gate_up 288 tokens 833 2905.2 2535.7 3383.7 6504.3
1024x2048 4b g64 35b served gate_up 320 tokens 833 3162.1 2780.2 3395.7 6511.8
1024x2048 4b g64 35b served gate_up 384 tokens 833 3623.9 3215.8 3414.4 6546.2
1024x2048 4b g64 35b served gate_up 512 tokens 833 4494.4 4150.2 3449.6 6607.3
1024x2048 4b g64 35b served gate_up 1024 tokens 1409 7655.2 7957.4 3602.6 6874.5
1024x2048 4b g64 35b served gate_up 2048 tokens 2561 14237.1 15422.0 4654.6 7356.8
12288x4096 4b g64 1 rows 164.2 115.3 186.9 62.8 384.6 677.2
12288x4096 4b g64 2 rows 211.5 120.7 193.5 64.7 385.0 678.0
12288x4096 4b g64 3 rows 123.1 194.4 94.9 386.3 678.3
12288x4096 4b g64 4 rows 124.8 196.7 95.4 387.1 677.5
12288x4096 4b g64 5 rows 166.4 197.4 136.3 388.5 678.3
12288x4096 4b g64 6 rows 168.1 (5%) 198.8 136.6 390.2 679.3
12288x4096 4b g64 8 rows 170.7 201.0 177.8 393.2 680.0
12288x4096 4b g64 12 rows 237.8 292.9 263.4 393.4 680.6
12288x4096 4b g64 16 rows 297.5 (6%) 300.1 336.7 396.7 684.7
12288x4096 4b g64 24 rows 436.4 (6%) 411.4 498.7 398.4 673.2
12288x4096 4b g64 32 rows 556.6 533.5 661.5 398.6 677.5
12288x4096 4b g64 33 rows 630.6 710.7 405.2 698.5
12288x4096 4b g64 48 rows 800.6 980.9 404.9 709.5
12288x4096 4b g64 64 rows 1049.4 1297.5 410.7 721.8
12288x4096 4b g64 96 rows 1569.4 1919.1 526.2 738.5
12288x4096 4b g64 128 rows 2094.9 2548.9 571.3 752.6
12288x4096 4b g64 256 rows 4253.2 5068.0 1053.3 1440.6
12288x4096 4b g64 8192 rows 142200.8 165792.5 32120.5 42198.5
12288x5120 4b g64 1 rows 209.6 139.6 243.5 82.0 471.2 837.6
12288x5120 4b g64 2 rows 285.0 143.6 253.2 83.5 471.7 838.9
12288x5120 4b g64 3 rows 143.4 256.2 132.6 472.6 840.9
12288x5120 4b g64 4 rows 147.4 258.1 132.8 472.8 839.1
12288x5120 4b g64 5 rows 212.0 260.5 190.9 474.4 840.2
12288x5120 4b g64 6 rows 214.7 261.6 191.4 475.8 842.4
12288x5120 4b g64 8 rows 218.4 (5%) 263.2 251.4 479.4 841.1
12288x5120 4b g64 12 rows 314.2 (7%) 395.0 369.8 479.1 841.9
12288x5120 4b g64 16 rows 393.0 (7%) 405.1 478.6 480.6 845.8
12288x5120 4b g64 24 rows 597.2 (7%) 574.6 714.7 482.5 832.6
12288x5120 4b g64 32 rows 751.0 744.9 940.9 482.5 846.1 (5%)
12288x5120 4b g64 33 rows 852.2 1011.2 492.0 871.2
12288x5120 4b g64 48 rows 1098.3 1399.3 492.1 879.8
12288x5120 4b g64 64 rows 1449.4 1852.4 500.7 892.2
12288x5120 4b g64 96 rows 2160.2 2754.3 646.8 911.3
12288x5120 4b g64 128 rows 2882.8 3645.5 694.8 928.3
12288x5120 4b g64 256 rows 5792.3 7227.0 1305.5 1812.9
12288x5120 4b g64 8192 rows 194309.4 239034.9 39846.4 54329.6
17408x5120 4b g64 1 rows 290.9 188.6 328.4 109.8 706.4 1348.7
17408x5120 4b g64 2 rows 397.8 194.2 341.9 110.9 706.5 1358.9
17408x5120 4b g64 3 rows 194.7 347.5 184.6 708.5 1355.3
17408x5120 4b g64 4 rows 197.8 349.5 184.1 708.6 1359.2
17408x5120 4b g64 5 rows 292.4 (5%) 354.1 268.2 710.9 1348.6
17408x5120 4b g64 6 rows 294.6 (6%) 358.2 268.1 714.0 1364.2
17408x5120 4b g64 8 rows 299.4 (6%) 360.7 351.6 720.0 1362.2
17408x5120 4b g64 12 rows 436.9 (6%) 557.6 520.9 719.3 1364.6
17408x5120 4b g64 16 rows 562.7 (8%) 571.6 679.4 721.2 1370.2
17408x5120 4b g64 24 rows 829.6 (6%) 800.9 1007.2 724.7 1348.7
17408x5120 4b g64 32 rows 1060.2 1041.1 1322.7 725.5 1361.8
17408x5120 4b g64 33 rows 1197.0 1417.6 743.8 1391.2
17408x5120 4b g64 48 rows 1548.5 1973.7 744.6 1405.5
17408x5120 4b g64 64 rows 2046.7 2615.1 750.4 1423.8
17408x5120 4b g64 96 rows 3052.3 3876.3 991.9 1455.2
17408x5120 4b g64 128 rows 4069.9 5140.4 1063.3 1479.5
17408x5120 4b g64 256 rows 8199.6 10191.6 1908.5 2623.2
17408x5120 4b g64 2048 rows 66426.5 82036.1 14193.0 19594.2
2048x4096 4b g64 1 rows 33.5 29.2 38.5 17.6 185.2 423.3
2048x4096 4b g64 2 rows 42.8 29.0 38.2 17.6 180.9 412.3
2048x4096 4b g64 3 rows 28.7 38.1 21.6 178.7 406.6
2048x4096 4b g64 4 rows 28.7 38.0 21.8 176.4 404.4
2048x4096 4b g64 5 rows 38.7 38.2 27.7 177.1 404.1
2048x4096 4b g64 6 rows 38.7 38.2 27.8 177.7 404.4
2048x4096 4b g64 8 rows 38.9 38.4 34.2 178.8 404.7
2048x4096 4b g64 12 rows 48.8 57.9 53.4 178.7 404.8
2048x4096 4b g64 16 rows 58.2 59.0 62.0 178.9 406.0
2048x4096 4b g64 24 rows 83.7 81.5 90.2 181.7 408.6
2048x4096 4b g64 32 rows 98.7 102.9 118.8 183.3 413.3
2048x4096 4b g64 33 rows 118.8 135.0 187.7 414.0
2048x4096 4b g64 48 rows 141.4 (6%) 174.7 189.3 417.1
2048x4096 4b g64 64 rows 189.1 (6%) 229.3 188.8 422.4
2048x4096 4b g64 96 rows 283.1 (6%) 340.7 218.5 436.1
2048x4096 4b g64 128 rows 372.4 (6%) 451.3 220.1 438.0
2048x4096 4b g64 256 rows 748.6 903.3 224.5 440.1
2048x4096 4b g64 2048 rows 6110.5 7255.6 1353.9 1828.4
2048x4096 4b g64 8192 rows 25164.4 29506.0 5300.8 7009.8
2048x512 4b g64 1 rows 9.8 10.6 10.7 5.7 27.7 58.9
2048x512 4b g64 2 rows 9.7 10.6 10.5 5.7 27.3 57.3
2048x512 4b g64 3 rows 10.4 10.3 5.7 27.0 56.5
2048x512 4b g64 4 rows 10.5 10.3 5.7 27.4 56.5
2048x512 4b g64 5 rows 10.8 10.3 6.1 27.9 56.5
2048x512 4b g64 6 rows 10.8 10.4 6.1 28.8 56.4
2048x512 4b g64 8 rows 10.8 10.4 6.7 31.2 56.4
2048x512 4b g64 12 rows 11.5 12.1 9.1 31.1 56.6
2048x512 4b g64 16 rows 12.5 12.1 9.2 31.1 56.5
2048x512 4b g64 24 rows 17.8 16.4 12.1 31.4 56.9
2048x512 4b g64 32 rows 17.9 20.6 15.0 31.4 57.0
2048x512 4b g64 33 rows 22.7 17.3 31.6 57.1
2048x512 4b g64 48 rows 22.9 21.0 31.7 57.4
2048x512 4b g64 64 rows 28.2 26.6 31.9 58.3
2048x512 4b g64 96 rows 39.2 38.3 35.5 60.1
2048x512 4b g64 128 rows 49.9 49.7 37.0 61.9
2048x512 4b g64 256 rows 92.5 95.8 37.8 63.0
2048x512 4b g64 35b served down 1 tokens U 9 31.2 28.5 43.1 14.6 82.2 145.6
2048x512 4b g64 35b served down 2 tokens U 162 73.0 49.1 78.7 29.9 137.3 248.2
2048x512 4b g64 35b served down 4 tokens U 162 82.9 134.8 48.6 230.3 431.6
2048x512 4b g64 35b served down 8 tokens U 162 154.1 253.7 86.2 440.1 831.4
2048x512 4b g64 35b served down 16 tokens 162 247.9 409.6 133.8 730.2 1335.1
2048x512 4b g64 35b served down 32 tokens 293 403.0 656.1 226.9 1154.9 2118.5
2048x512 4b g64 35b served down 33 tokens 329 411.6 665.0 234.9 1174.7 2153.7
2048x512 4b g64 35b served down 63 tokens 329 600.5 910.2 348.9 1639.1 2953.1
2048x512 4b g64 35b served down 64 tokens 329 609.6 348.0 1593.9 2880.1
2048x512 4b g64 35b served down 65 tokens 401 619.4 357.6 1606.0 2900.8
2048x512 4b g64 35b served down 128 tokens 401 843.1 547.6 1890.5 3243.7
2048x512 4b g64 35b served down 256 tokens 545 1275.1 922.5 2078.1 3308.5
2048x512 4b g64 35b served down 257 tokens 833 1302.7 950.4 2084.8 3312.9
2048x512 4b g64 35b served down 258 tokens 833 1308.6 954.2 2086.2 3317.5
2048x512 4b g64 35b served down 260 tokens 833 1313.2 961.1 2087.6 3314.8
2048x512 4b g64 35b served down 264 tokens 833 1327.1 974.7 2092.4 3313.2
2048x512 4b g64 35b served down 272 tokens 833 1354.1 1001.5 2095.6 3321.0
2048x512 4b g64 35b served down 288 tokens 833 1418.3 1050.2 2107.7 3324.0
2048x512 4b g64 35b served down 320 tokens 833 1526.6 1135.4 2121.9 3330.6
2048x512 4b g64 35b served down 384 tokens 833 1688.3 1307.7 2148.4 3343.7
2048x512 4b g64 35b served down 512 tokens 833 2125.2 1664.7 2173.3 3382.1
2048x512 4b g64 35b served down 1024 tokens 1409 3577.5 3156.0 2278.9 3548.8
2048x512 4b g64 35b served down 2048 tokens 2561 6547.0 6116.6 2746.4 3888.5
24576x4096 4b g64 1 rows 308.3 216.3 343.1 115.6 638.8 1294.5
24576x4096 4b g64 2 rows 403.3 222.1 357.2 116.6 639.9 1295.1
24576x4096 4b g64 3 rows 223.6 362.8 183.2 642.4 1294.1
24576x4096 4b g64 4 rows 225.5 371.8 183.5 643.3 1292.1
24576x4096 4b g64 5 rows 320.4 372.3 266.3 645.2 1297.1
24576x4096 4b g64 6 rows 322.9 378.1 266.1 649.2 1295.7
24576x4096 4b g64 8 rows 328.2 382.6 350.4 656.0 1297.3
24576x4096 4b g64 12 rows 463.3 (6%) 566.3 515.9 655.8 1297.7
24576x4096 4b g64 16 rows 601.6 579.5 674.9 656.3 1305.0
24576x4096 4b g64 24 rows 864.4 804.4 990.5 661.0 1330.5 (6%)
24576x4096 4b g64 32 rows 1088.4 1047.5 1305.2 661.8 1341.1
24576x4096 4b g64 33 rows 1221.4 1393.2 677.3 1347.2
24576x4096 4b g64 48 rows 1575.1 1937.0 682.3 1374.5
24576x4096 4b g64 64 rows 2073.8 2570.2 721.9 1388.1
24576x4096 4b g64 96 rows 3109.8 3803.4 997.1 1421.6
24576x4096 4b g64 128 rows 4159.4 5058.4 1069.6 1449.6
24576x4096 4b g64 256 rows 8458.7 10077.5 2076.5 2803.3
24576x4096 4b g64 2048 rows 68774.5 81631.7 16163.0 21497.6
248320x2048 4b g64 1 rows 1445.9 1090.0 1883.9 509.3 2965.7 5990.4
248320x2048 4b g64 2 rows 1804.6 1099.8 1955.7 513.5 2977.4 5989.6
248320x2048 4b g64 3 rows 1104.8 2021.9 904.5 2997.2 6006.9
248320x2048 4b g64 4 rows 1113.2 2022.8 908.6 3005.1 6012.3
248320x2048 4b g64 5 rows 1851.0 2035.0 1338.9 3026.5 6022.6
248320x2048 4b g64 6 rows 1867.1 2052.6 1342.6 3056.3 6024.4
248320x2048 4b g64 8 rows 1887.0 2064.5 1767.0 3112.3 6040.7
248320x2048 4b g64 12 rows 2773.0 2986.6 2533.8 3112.2 6081.8
248320x2048 4b g64 16 rows 3680.4 3005.9 3294.2 3115.0 6099.1
248320x2048 4b g64 24 rows 4769.3 4189.9 4778.6 3135.4 6165.7
248320x2048 4b g64 32 rows 6084.2 5456.4 6342.3 3134.2 6233.3
248320x2048 4b g64 33 rows 6680.2 6713.2 3310.8 6249.8
248320x2048 4b g64 48 rows 8690.1 9308.4 3347.7 6336.2
248320x2048 4b g64 64 rows 11418.6 12340.4 3540.1 6446.9
248320x2048 4b g64 96 rows 16610.3 18421.9 4871.4 6636.4
248320x2048 4b g64 128 rows 22079.8 24416.2 5253.6 6772.9
248320x2048 4b g64 256 rows 43348.8 48576.4 10479.6 13414.2
4096x12288 4b g64 1 rows 160.1 102.2 167.1 66.1 553.8 1305.0
4096x12288 4b g64 2 rows 217.6 102.3 172.8 68.4 552.3 1302.2
4096x12288 4b g64 3 rows 103.1 170.4 100.5 552.3 1305.7
4096x12288 4b g64 4 rows 104.0 171.1 100.7 552.3 1304.8
4096x12288 4b g64 5 rows 142.8 (6%) 174.6 139.6 553.9 1312.5
4096x12288 4b g64 6 rows 144.2 (6%) 174.7 140.0 555.9 1310.5
4096x12288 4b g64 8 rows 147.3 (6%) 176.5 181.1 556.8 1312.8
4096x12288 4b g64 12 rows 198.0 278.7 (5%) 283.2 557.0 1310.1
4096x12288 4b g64 16 rows 253.3 285.2 348.0 558.1 1314.8
4096x12288 4b g64 24 rows 392.3 (5%) 407.9 514.2 560.6 1314.5
4096x12288 4b g64 32 rows 481.3 528.8 687.0 560.8 1315.2
4096x12288 4b g64 33 rows 579.5 (6%) 757.1 571.4 1312.8
4096x12288 4b g64 48 rows 745.9 (7%) 1022.0 571.4 1318.3
4096x12288 4b g64 64 rows 1004.0 (6%) 1339.7 565.1 1322.3
4096x12288 4b g64 96 rows 1495.0 2002.1 646.0 1338.0
4096x12288 4b g64 128 rows 1961.8 2657.1 666.6 1358.5
4096x12288 4b g64 256 rows 3933.2 5307.3 1054.3 1617.3
4096x12288 4b g64 2048 rows 32092.5 43248.2 7902.5 10996.1
4096x12288 4b g64 8192 rows 134571.7 175573.9 31411.2 43100.5
4096x2048 3b g64 1 rows 14.1 26.1 34.2 15.3 95.7 223.6
4096x2048 3b g64 2 rows 16.4 26.2 34.6 15.3 93.7 219.7
4096x2048 3b g64 3 rows 26.2 34.8 19.0 93.0 219.1
4096x2048 3b g64 4 rows 26.6 34.9 19.1 93.2 218.6
4096x2048 3b g64 5 rows 37.5 35.3 25.1 93.7 219.1
4096x2048 3b g64 6 rows 37.8 35.4 25.2 94.6 219.2
4096x2048 3b g64 8 rows 38.3 35.7 31.6 96.3 219.9
4096x2048 3b g64 12 rows 49.2 52.3 47.5 97.1 220.7
4096x2048 3b g64 16 rows 63.6 52.9 56.6 97.6 223.0
4096x2048 3b g64 24 rows 88.2 69.7 81.6 99.0 225.1
4096x2048 3b g64 32 rows 107.0 (5%) 87.0 107.1 100.7 226.1
4096x2048 3b g64 33 rows 122.6 118.4 102.2 224.9
4096x2048 3b g64 48 rows 152.1 (6%) 157.8 102.2 225.2
4096x2048 3b g64 64 rows 196.6 206.0 101.6 225.8
4096x2048 3b g64 96 rows 286.3 305.5 115.8 232.1
4096x2048 3b g64 128 rows 376.4 404.6 118.0 233.6
4096x2048 3b g64 256 rows 734.9 809.6 185.7 286.0
4096x2048 3b g64 2048 rows 6358.2 6386.6 1365.8 1864.7
4096x2048 4b g128 1 rows 27.5 26.7 37.9 16.8 95.6 193.0
4096x2048 4b g128 2 rows 35.1 26.6 38.0 17.3 94.5 190.5
4096x2048 4b g128 3 rows 26.6 38.0 19.1 94.0 189.6
4096x2048 4b g128 4 rows 26.6 38.1 19.3 93.8 189.2
4096x2048 4b g128 5 rows 34.4 38.5 22.6 94.7 190.0
4096x2048 4b g128 6 rows 34.7 38.5 22.8 95.4 190.5
4096x2048 4b g128 8 rows 35.0 38.5 27.4 96.8 191.3
4096x2048 4b g128 12 rows 42.1 57.4 41.9 97.3 192.4
4096x2048 4b g128 16 rows 49.1 58.4 48.2 97.9 193.6
4096x2048 4b g128 24 rows 69.7 75.7 69.3 99.9 194.2
4096x2048 4b g128 32 rows 81.3 (6%) 91.0 90.6 99.9 194.3
4096x2048 4b g128 33 rows 97.9 (6%) 102.2 102.1 194.6
4096x2048 4b g128 48 rows 119.0 (6%) 132.7 102.2 194.7
4096x2048 4b g128 64 rows 155.7 (6%) 173.8 100.5 196.5
4096x2048 4b g128 96 rows 226.1 257.0 117.6 198.2
4096x2048 4b g128 128 rows 297.3 339.4 117.8 200.2
4096x2048 4b g128 256 rows 586.8 676.6 180.9 248.4
4096x2048 4b g128 2048 rows 4745.0 5357.6 1318.4 1645.1
4096x2048 4b g32 1 rows 49.2 36.3 58.1 21.2 107.9 280.9
4096x2048 4b g32 2 rows 59.1 36.4 58.1 21.3 106.8 276.3
4096x2048 4b g32 3 rows 37.0 58.4 26.9 105.8 273.5
4096x2048 4b g32 4 rows 38.3 58.9 26.9 105.8 271.3
4096x2048 4b g32 5 rows 49.4 59.3 34.6 105.6 270.4
4096x2048 4b g32 6 rows 49.7 59.4 35.3 106.0 270.3
4096x2048 4b g32 8 rows 50.3 59.9 44.5 106.9 270.8
4096x2048 4b g32 12 rows 62.0 79.7 68.4 108.8 272.5
4096x2048 4b g32 16 rows 80.2 80.7 82.5 109.4 275.0
4096x2048 4b g32 24 rows 111.5 105.4 120.0 110.9 277.9
4096x2048 4b g32 32 rows 133.9 (6%) 130.0 157.8 112.4 281.3
4096x2048 4b g32 33 rows 156.6 173.5 113.0 281.4
4096x2048 4b g32 48 rows 196.5 (6%) 232.8 113.4 281.8
4096x2048 4b g32 64 rows 255.5 (6%) 305.3 114.2 283.7
4096x2048 4b g32 96 rows 370.4 453.8 127.5 291.8
4096x2048 4b g32 128 rows 488.4 608.8 130.4 295.6
4096x2048 4b g32 256 rows 954.4 1201.1 203.8 324.1
4096x2048 4b g32 2048 rows 8056.2 9599.2 1453.9 2129.8
4096x2048 6b g64 1 rows 34.5 34.3 37.9 18.8 95.0 226.1
4096x2048 6b g64 2 rows 42.0 34.3 37.9 20.6 94.5 223.4
4096x2048 6b g64 3 rows 34.7 37.8 22.6 93.9 222.2
4096x2048 6b g64 4 rows 35.5 38.0 22.9 94.2 221.5
4096x2048 6b g64 5 rows 44.9 38.4 27.5 94.5 221.5
4096x2048 6b g64 6 rows 45.4 38.5 27.6 95.5 222.7
4096x2048 6b g64 8 rows 46.1 39.1 33.9 97.7 223.4
4096x2048 6b g64 12 rows 57.4 47.5 50.2 98.8 226.2
4096x2048 6b g64 16 rows 71.9 48.0 60.0 99.1 226.3
4096x2048 6b g64 24 rows 94.9 60.1 86.2 99.7 228.7
4096x2048 6b g64 32 rows 113.3 75.1 112.2 99.8 228.9
4096x2048 6b g64 33 rows 131.6 (7%) 125.6 (5%) 100.6 229.2
4096x2048 6b g64 48 rows 161.3 (6%) 165.3 100.7 229.4
4096x2048 6b g64 64 rows 212.2 (6%) 218.4 100.7 230.4
4096x2048 6b g64 96 rows 308.9 322.8 115.5 234.0
4096x2048 6b g64 128 rows 404.4 426.1 119.6 235.9
4096x2048 6b g64 256 rows 799.6 844.3 186.9 288.0
4096x2048 6b g64 2048 rows 6940.4 6648.5 1380.8 1878.8
4096x2048 8b g64 1 rows 32.9 42.3 55.7 32.0 99.1 227.8
4096x2048 8b g64 2 rows 38.8 42.6 55.6 32.0 98.2 225.3
4096x2048 8b g64 3 rows 43.5 55.5 37.8 97.6 223.5
4096x2048 8b g64 4 rows 44.5 55.6 37.8 97.1 221.9
4096x2048 8b g64 5 rows 56.2 55.9 40.9 97.0 221.9
4096x2048 8b g64 6 rows 59.2 56.1 40.9 97.3 221.2
4096x2048 8b g64 8 rows 60.6 56.4 44.8 98.2 221.8
4096x2048 8b g64 12 rows 67.2 76.5 59.1 99.1 223.0
4096x2048 8b g64 16 rows 81.9 77.9 69.8 100.4 225.2
4096x2048 8b g64 24 rows 103.6 101.9 97.6 101.8 227.3
4096x2048 8b g64 32 rows 130.1 128.0 125.9 102.6 228.8
4096x2048 8b g64 33 rows 138.5 (6%) 135.8 104.1 228.9
4096x2048 8b g64 48 rows 172.5 (6%) 184.3 104.5 229.1
4096x2048 8b g64 64 rows 222.8 239.2 104.5 230.7
4096x2048 8b g64 96 rows 318.8 353.6 119.7 236.9
4096x2048 8b g64 128 rows 415.2 464.7 122.3 238.6
4096x2048 8b g64 256 rows 828.4 916.1 188.5 291.1
4096x2048 8b g64 2048 rows 7138.9 7397.1 1381.8 1875.8
5120x17408 4b g64 1 rows 287.0 163.6 323.8 109.3 890.4 2090.8
5120x17408 4b g64 2 rows 395.1 163.2 333.6 111.9 887.8 2087.8
5120x17408 4b g64 3 rows 164.2 334.9 177.2 890.0 2090.2
5120x17408 4b g64 4 rows 165.5 338.1 177.3 889.8 2088.1
5120x17408 4b g64 5 rows 237.2 (8%) 340.9 255.2 890.8 2089.0
5120x17408 4b g64 6 rows 239.2 343.2 255.7 891.9 2090.0
5120x17408 4b g64 8 rows 239.2 (9%) 345.4 330.1 893.4 2088.6
5120x17408 4b g64 12 rows 343.7 (5%) 511.8 512.2 893.1 2085.3
5120x17408 4b g64 16 rows 450.1 (6%) 519.4 644.5 894.8 2084.6
5120x17408 4b g64 24 rows 696.5 736.8 948.5 897.6 2085.6
5120x17408 4b g64 32 rows 888.9 (6%) 954.9 1255.6 898.8 2089.5
5120x17408 4b g64 33 rows 1057.2 (6%) 1372.5 914.6 2093.5
5120x17408 4b g64 48 rows 1358.9 (7%) 1865.9 915.2 2090.8
5120x17408 4b g64 64 rows 1808.7 2472.6 911.2 2106.3
5120x17408 4b g64 96 rows 2671.3 3704.3 1316.5 2128.5
5120x17408 4b g64 128 rows 3559.0 4921.3 1330.4 2142.8
5120x17408 4b g64 256 rows 7099.9 9773.1 2173.8 2860.1
5120x17408 4b g64 2048 rows 58541.4 80060.3 14093.8 19691.2
8192x2048 4b g64 1 rows 56.8 47.1 75.7 25.0 118.0 253.9
8192x2048 4b g64 2 rows 71.8 47.6 76.5 25.4 117.7 251.2
8192x2048 4b g64 3 rows 48.5 76.9 32.9 (6%) 117.8 251.2
8192x2048 4b g64 4 rows 50.9 77.1 33.1 (6%) 118.2 251.4
8192x2048 4b g64 5 rows 67.3 77.7 46.7 (6%) 119.7 253.4
8192x2048 4b g64 6 rows 67.3 78.1 46.9 (6%) 121.3 254.1
8192x2048 4b g64 8 rows 68.7 78.9 60.1 (7%) 123.0 254.4
8192x2048 4b g64 12 rows 94.0 118.7 88.0 123.4 254.6
8192x2048 4b g64 16 rows 123.7 (6%) 118.2 109.5 123.8 254.8
8192x2048 4b g64 24 rows 166.4 153.1 158.2 127.3 256.1
8192x2048 4b g64 32 rows 205.6 191.4 209.9 128.4 (90%) 270.9 (172%)
8192x2048 4b g64 33 rows 218.3 (6%) 225.6 130.3 258.5 (30%)
8192x2048 4b g64 48 rows 291.6 (54%) 311.4 131.7 (112%) 257.4
8192x2048 4b g64 64 rows 378.4 410.6 128.2 267.3
8192x2048 4b g64 96 rows 557.2 611.6 178.6 276.2
8192x2048 4b g64 128 rows 725.2 809.1 191.3 282.4
8192x2048 4b g64 256 rows 1420.9 1598.4 358.9 521.1
8192x2048 4b g64 2048 rows 12763.8 12827.4 2721.2 3500.9
8192x2048 4b g64 8192 rows 53106.7 51949.9 10875.7 13810.8
8192x4096 4b g64 1 rows 115.5 81.6 129.5 45.9 221.9 500.9
8192x4096 4b g64 2 rows 148.8 86.4 131.4 47.1 222.2 501.5
8192x4096 4b g64 3 rows 89.7 132.1 65.4 224.1 504.6 (5%)
8192x4096 4b g64 4 rows 92.1 133.1 65.6 224.5 507.4
8192x4096 4b g64 5 rows 116.4 (5%) 134.5 92.0 225.3 505.2
8192x4096 4b g64 6 rows 117.2 135.4 92.4 226.1 505.6
8192x4096 4b g64 8 rows 120.0 136.7 120.2 227.6 505.3
8192x4096 4b g64 12 rows 162.0 205.0 178.4 228.2 507.4
8192x4096 4b g64 16 rows 202.6 (5%) 210.4 225.9 228.4 508.3
8192x4096 4b g64 24 rows 297.1 (5%) 280.7 332.0 231.4 508.1
8192x4096 4b g64 32 rows 367.9 362.4 438.3 232.7 518.3
8192x4096 4b g64 33 rows 420.3 474.1 236.0 522.2
8192x4096 4b g64 48 rows 532.9 658.5 237.3 527.4
8192x4096 4b g64 64 rows 704.3 870.8 248.9 534.5
8192x4096 4b g64 96 rows 1048.0 1280.0 345.4 556.9
8192x4096 4b g64 128 rows 1397.3 1701.8 371.9 568.4
8192x4096 4b g64 256 rows 2829.2 3385.0 713.3 1062.5
8192x4096 4b g64 2048 rows 22998.8 27526.5 5364.6 7036.2

@ashhart

ashhart commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Thanks @laudney. The new gfx1201 table differs from gfx1100's in one row, routed.prefill.kp3 items 300 → 545. The kernels keep the same per-group dot2 chains and ordered scale and bias folds, so outputs stay the same bytes, and the tuner is opt-in.

The changed default reaches more than the model you measured: gfx1200 too, and other routed MLX models, Flash Next and Nemotron among them. We have no RDNA4 card, so could you run these for each of them around the selector's new boundary?

  1. Output bytes against main.
  2. Cold prefill, alternating main and this branch on fresh server boots.

If one of them comes out slower, keep the old selector for that one. Please also list the exact model revisions you ran.

@laudney

laudney commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks @ashhart. I ran both models I could fit on the one free R9700 (gfx1201) here: fresh server boots, --prompt-cache-gib 0, alternating main at e4cc630f and main plus this PR's three commits, six boots each (the last pair reversed).

Models: mlx-community/Qwen3.6-35B-A3B-4bit at 38740b847e4cb78f352aba30aa41c76e08e6eb46 and TensorFold/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-MLX-4bit at d9d758fb83953437f7263256b0d96157e2a348b8.

  1. Output bytes: equal for both models in every boot, by token_sha256 of each cold tools/bench_cache.py reply below and token_sha of each greedy and seeded (1234 to 1236) tools/bench_openai.py reply.

  2. Cold prefill, median ttft_s over the six boots, time with this PR over main (items is the count the selector sees):

Qwen3.6 tokens items time Nemotron tokens items time
32 293 x1.004 128 224 x1.006
33 329 x0.562 129 320 x0.816
48 329 x0.532 200 320 x1.020
100 401 x0.761 256 320 x1.188
200 545 x0.946 384 512 x1.479
256 545 x1.023 512 512 x1.695
257 833 x1.023 513 896 x1.034
1000 to 8192 x1.000 to x1.003 1000 to 8192 x1.000 to x1.002

(257 and 513 tokens run as 256 or 512 rows and one more.) Decode is within 2% either way for both.

Nemotron's plans above 300 items get slower on the K-parallel tile, and its first count above 300 (320) sits below Qwen3.6's 329 and 401, so no single item bound gives Qwen3.6 its gain without the Nemotron loss. Following your rule, 1ce4440 puts the bound back to 300: gfx1201.zon now has gfx1100's prompt rows, so this PR adds the step and RDNA4's own table without changing any choice. The step timed the K-parallel tile faster on Qwen3.6's 256-token plans in isolation, while served it is 2.3% slower on current main, so its proposals need served checks like these before a bound moves.

Not run: Flash Next (TensorFold/Qwen3.8-Flash-Next-MLX-4bit-MTP, 73.3 GiB) needs three of these 32 GB cards, and the others here serve other work. No gfx1200 card. With gfx1100's rows, neither sees a change.

A bound on rows per item instead of items would separate Qwen3.6's 33 to 128-token plans from Nemotron's. That needs a new tuning field, so I'd open it as its own issue if you want it.

ashhart and others added 2 commits October 28, 2026 16:10
…MLX affine prompt tiles

RDNA4 shared gfx1100's table, so its prompt bounds could not be set for its dot2 tiles without changing RDNA3's.
gfx1201.zon starts as gfx1100's rows, Kernels.tableFor maps RDNA4 to it, and the host tests take their table from
tableFor, so the family-rule test covers gfx1201 as the runtime sees it. The opt-in step `hip-affine-tune` (built
without a GPU by `hip-affine-tune-build`) times every prefill entry on dense rows and served routed tokens, refines
where a table's choice changes, and proposes prompt rows no timed cell would lose against gfx1100's choice beyond
its noise. Served on a Radeon AI PRO R9700 with fresh boots, a 545-item routed bound made Qwen3.6-35B-A3B's short
prompts faster but Nemotron Lightning's 200 to 513-token prompts up to 1.7 times slower, so gfx1201's rows keep
gfx1100's bounds and no choice changes today.

Co-authored-by: laudney <[email protected]>
@ashhart

ashhart commented Oct 29, 2026

Copy link
Copy Markdown
Owner

Thanks @laudney: the gfx1201 tuning table and hip-affine-tune shipped in TensorFold 1.1.9.

@laudney

laudney commented Oct 29, 2026 via email

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HIP: a measured tuning table for gfx1201 (RDNA4)

2 participants