Skip to content

perf(flashnext): 6- and 8-bit row products take 2 outputs a simdgroup - #2593

Merged
ashhart merged 2 commits into
ashhart:mainfrom
abm9111:pr/flashnext-q8-two-outputs
Nov 9, 2026
Merged

ashhart merged 2 commits into
ashhart:mainfrom
abm9111:pr/flashnext-q8-two-outputs

Conversation

@abm9111

@abm9111 abm9111 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2553

Products that read 8 values a lane step (6 and 8 bits) ran 4 outputs a simdgroup in the loop and four-row kernels
(the MMA twin does not read it). At 2–4 rows that left a 6144 → 2560 product at 640 simdgroups, about 11 a core on a
60-core M3 Ultra, too few to hide DRAM latency. This gives those widths 2 outputs a simdgroup (1 at an odd width), as
suggested in #2553 (vpt(p.bits) == 8). Each output's sum is computed the same way at any count, so output bits are
unchanged; 4/32 products keep 4 and other widths keep rps. No kernel source changes: the kernels already ran these
widths at 2 outputs for n % 4 == 2.

rows_load.zig now references rows_w from a test block, so rows_w.zig's tests run in the engine suite. Before
this, the existing merge test there was not compiled into any test binary (a planted failing assertion in that file
still passed zig build test); it passes now. rows-time also times the 2560 × 6144 product at 8 bits.

Exactness

  • tf-flashnext-widths in full, main a07e56f and this branch: PASS 4486 checks: every product within 0.9947 of its float64 bound, every row's bits equal in every window on both, the two outputs identical line for line. Its
    RESULT lines include windows of 1, 2, 3, 4, 5, 8, 9, 16, 17 and 33 rows for every width.
  • New unit test (rows_w.zig): passes here; with main's line, or with the change limited to 8 bits, it fails
    expected 2, found 4.
  • Served decode, below: token hashes equal to main on every prompt and run.

Kernel timing

tf-flashnext-widths rows-time with the GPU free, main → branch → branch → main, rows µs (both runs each):

product width 1 row 2 rows 4 rows
2,560 × 6,144 q6/g32 24.9, 25.0 → 24.4, 24.4 (-2.2%) 41.0, 41.2 → 30.9, 30.8 (-24.9%) 41.3, 41.7 → 31.2, 31.2 (-24.8%)
16,480 × 2,560 q6/g32 55.7, 54.7 → 55.5, 54.0 (-0.8%) 77.2, 77.0 → 64.0, 64.0 (-17.0%) 78.4, 78.6 → 65.4, 65.5 (-16.6%)
2,560 × 6,144 q6/g64 25.5, 24.8 → 24.2, 24.1 (-4.0%) 40.7, 40.7 → 31.1, 31.2 (-23.5%) 41.1, 41.4 → 31.3, 31.4 (-24.0%)
13,952 × 2,560 q6/g64 45.2, 45.3 → 45.7, 45.9 (+1.2%) 66.8, 66.9 → 55.7, 55.7 (-16.7%) 68.1, 68.2 → 56.9, 56.8 (-16.6%)
2,560 × 6,144 q8/g64 27.3, 26.5 → 26.7, 28.0 (+1.7%) 41.6, 41.4 → 29.6, 29.6 (-28.7%) 42.0, 42.8 → 29.9, 30.2 (-29.1%)
79,616 × 2,560 q8/g64 287.7, 289.2 → 286.0, 289.3 (-0.3%) 322.6, 322.0 → 287.8, 288.6 (-10.6%) 327.6, 327.9 → 298.4, 291.8 (-10.0%)
248,320 × 2,560 q8/g64 888.2, 877.0 → 884.7, 877.4 (-0.2%) 974.3, 974.3 → 876.7, 876.3 (-10.0%) 998.5, 986.5 → 891.3, 889.7 (-10.3%)

Every other row count (8, 9, 16: the MMA twin) and every other width moved at most 1.2% (median 0.0%). The 1-row 16,480 × 2,560 6/32 product that ran 3–7% slower in #2553 is level here.

Served decode and concurrency

tools/bench_openai.py --tokens 256 --reps 3 --temperatures 0, main → branch → branch → main, medians in tok/s:

checkpoint prompt main branch change token hashes
bu7umaid/Qwen3.8-Flash-Next-Uncensored-TensorFold-MTP at 0447bba (out_proj and most non-expert weights 6-bit) fibonacci-raw 148.9, 149.0 157.3, 157.6 +5.69% equal
gpu-chat-no-think 127.1, 127.1 134.7, 134.9 +6.04% equal
bis-sh4 layout of jedisct1/Qwen3.8-Flash-Next-Uncensored-oQ4e-100K-MTP at 7d92e74f (36 out_proj at 8 bits; not published) fibonacci-raw 160.4, 159.3 163.9, 164.0 +2.57% equal
gpu-chat-no-think 142.0, 141.8 145.7, 145.0 +2.40% equal

tools/bench_concurrent.py --levels 1,4 --alone --serial on the published pack: code 148.7 → 157.3 tok/s at one stream and 137.7 → 145.3 aggregate at four; chat 126.8 → 134.4 and 117.4 → 123.5; every reply equal to its run alone (30 and 30) and to "draft": false (4 and 4), 0 unequal or failed.

Checks

  • python3 tools/zig/lean_check.py: 116 problems on main and here, 0 new.
  • python3 tools/pr_check.py --base origin/main --pr 2593: 0 errors and 1 warning, for the missing Unreleased line; 1.2.5 renamed that section after this branch was cut, so the line is left for the release notes. It ran with git's stdin fed from a temp file: on this Mac the script as written hangs in git cat-file --batch, with git blocked writing a full stdout pipe while Python waits to write the rest of its stdin.
  • atc overlap --json --base origin/main: incomplete on this repository (over 200 open PRs, timeLimit), with no overlap
    found; checked directly as well: none of the 201 open PRs touches these three files, and the branch merges cleanly into
    main at 8be9c40.
  • zig build test test-golden -Dcpu=apple_m1: on this commit Zig re-ran the 1,821 tests the change reaches: 1,785 passed, 35 skipped, 1 failed; the full suite on an earlier revision of this branch passed 11,660 of 11,753 (7 more than main, rows_w's tests now compiled in) with the same failure. That one failure also fails on main a07e56f on this Mac: families.nemotron.prefill_kernels.test.every prompt-chunk source compiles at this macOS's Metal language (use of undeclared identifier 'nemo_paged_row').

Setup

Mac Studio, Apple M3 Ultra (60-core GPU), 256 GB, macOS 27.2 (26B123), Zig 0.17.0, zig build native -Dcpu=apple_m1. Server: serve <checkpoint> --host 127.0.0.1 --port 18234 --name local-model --no-thinking --prompt-cache-gib 0 --no-update-check, one model process, nothing else on the GPU. Only this M3 Ultra was measured.

@ashhart

ashhart commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Neither blocks: it goes on our landing queue now, and the CHANGELOG line is ours.

abm9111 and others added 2 commits November 9, 2026 05:50
Products that read 8 values a lane step (6 and 8 bits) ran 4 outputs
a simdgroup in the loop and four-row kernels (the MMA twin does not
read it). At 2-4 rows that left a 6144 -> 2560 product at 640
simdgroups, about 11 a core on a 60-core M3 Ultra, too few to hide
DRAM latency. At 2 outputs each sum is computed the same way, so
output bits are unchanged; 4/32 products keep 4 and other widths keep
rps. The kernels already ran these widths at 2 outputs when
n % 4 == 2.

rows_load references rows_w from a test block so rows_w's tests run
in the engine suite; before this the existing merge test there was
not compiled into any test binary. rows-time also times the
2560 x 6144 product at 8 bits.

Refs ashhart#2553
@ashhart
ashhart force-pushed the pr/flashnext-q8-two-outputs branch from 82d9d1c to c855416 Compare November 9, 2026 05:50
@ashhart
ashhart merged commit c15d800 into ashhart:main Nov 9, 2026
2 of 10 checks passed
@ashhart

ashhart commented Nov 9, 2026

Copy link
Copy Markdown
Owner

Thank you @abm9111. 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.

@abm9111

abm9111 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the review and for landing it. Glad it's useful.

ashhart added a commit that referenced this pull request Nov 10, 2026
Figures corrected to the PRs' measured ones (#2699 head runs, #2509,
#2633, #2436, #2644, #2593, #2430, #2568), scope fixed (#2253, #2287,
#2511, #2569, #2337, #2627, #2351, #2626), unsourced figures dropped
(#2181, #2606, #2257's pricing clauses), the shipped #2176, #2565,
#2548 and gfx12 silu entries and the first #2625 copy removed, and
the #2568 and #2352 entries unwrapped to one line each.
@ashhart

ashhart commented Nov 10, 2026

Copy link
Copy Markdown
Owner

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.

Flash Next on Metal: 8-bit row products at 4 outputs a simdgroup underfill the GPU; 2 outputs is faster with the same bits

2 participants