Repository navigation
Nemotron: two members a pass at 8 rows a simdgroup for wide M1 windows - #1466
Conversation
|
Thanks for this, and for the bit checks on your M1 Max. We read the arithmetic as bit-exact too: Two things before it can land:
On our side I'll run |
|
Thanks for the review. Item 2 is in 4921cb9. Metal rejects
Item 1, the served receipt, is next. I'll post the single-stream and concurrent numbers and the token hashes from the Nemotron checkpoint when I have them. If single-stream regresses, I'll switch to picking the kernel by the rows the round actually verifies. |
|
A follow-up on the kernel contract point: the trouble registering |
|
Thanks @mrv777. The offline limit search fix (#1493) and Nemotron's routed-expert pipelines in the contract (#1494) have both landed, so this branch now needs a rebase. After it, the offline run should record the real limits of |
4921cb9 to
947cef7
Compare
|
Thanks @mrv777 for bringing this up to date with main, and for going back to plain instantiations now that #1493 is in: the records carry the offline limits (448 on M1 and M2), and the 64-thread workaround is gone. CI's The served receipt on M1 is still the main thing we need: |
|
Our M5 Ultra A/B is done, with Nemotron 3.5 Lightning, main against this branch, alternating main, branch, branch, main:
So nothing changes on an M5, as expected for a change aimed at M1's wide windows. What's left is on your side, from our last comment: the CI fix in |
|
Item 1, the served receipt from an M1 Max (32 GB). The branch is rebased, and Setup: checkpoint
Token hashes are identical in every session.
Thinking-on greedy chat, 512 tokens. I added this because it's the path that drafts. On prompts 0 and 1, drafted hashes equal The branch's small lead also shows on Two things showed up that are the same on main as on this branch, so they're separate from this PR:
I can open an issue for these two, or dig into either if that helps. |
|
Thanks @mrv777, that's a thorough receipt. Our side, alternating main and this branch with Nemotron 3.5 Lightning 4-bit:
One thing left before it lands: CI's On the two things you found on main, yes please: open an issue for each, starting with greedy drafted output that doesn't match serial. That's an exactness failure, so it's our top priority, and we have no M1 to reproduce it on. For that one, please include:
Our M3 Ultra and M5 Ultra runs hold drafted == serial and concurrent == alone on our prompts, so we'll replay your exact requests on both to see whether it's specific to M1. The slow no-draft greedy rounds (about 95 ms against 12 ms a token) can go in a second issue. |
…windows On applegpu_g13, windows of 16 or more rows take the routed experts through tf_experts_rows at RPS 8, SG 2, MB 2 (tf_xup_rows2r8 / tf_xdown_rows2r8) instead of tf_experts_w's three members a pass. Each member row's dot keeps tf_qdot16's order and its single-member tail, so the bits are unchanged. Other chips, one-row decode, MTP and windows under 16 rows keep their kernels. tf-nemotron-experts' rows2r8 variant now checks the shipped instantiation. (cherry picked from commit 33bc47c9401a51523bb8224eac99cc1b0aba9a95)
… kernel contract Both join the routed-expert cases as replacements that must equal tf_x*_w3's bytes, and their records carry the M1/M2 limits the offline search compiled (448 threads on both). The cases' completeness check needs a larger eval quota. (cherry picked from commit d4ff9b7618ce762c844e0d3e66b355cdb4affd68)
…census The census now expects 22 entries and 20 plain pipelines, and the fp32-sum control is found by its fault rather than by index. Doc comments name the rows2r8 pipelines. (cherry picked from commit 87016e0bf7e6f45d99b968f4cefddb569da2225b)
(cherry picked from commit 52733daf28ff9bf5b7b979eb4aa73daf103d7583)
947cef7 to
bd662ec
Compare
(cherry picked from commit 52733daf28ff9bf5b7b979eb4aa73daf103d7583)
|
Thank you @mrv777. This is in TensorFold 1.2.0, released today: https://github.com/ashhart/TensorFold/releases/tag/v1.2.0 It landed with your commits under your own name, so you're listed as a TensorFold contributor, and it's credited to you in the release notes and the changelog. |
On M1-family GPUs (
applegpu_g13), Nemotron's windowed forward runs routed experts differently for windows of 16 or more rows. They now take two members a pass at 8 rows a simdgroup, through two new instantiations of the existingtf_experts_rowstemplate:tf_xup_rows2r8andtf_xdown_rows2r8(RPS 8, SG 2, MB 2). Until now they tooktf_experts_w's three members a pass. No kernel body changes.The following keep their kernels: every other GPU generation, one-row decode, the MTP head (
members0) and windows under 16 rows.tf-nemotron-experts'rows2r8variant now checks the shipped instantiation instead of compiling its own copy.The outputs cannot change.
tf_rowdot_rowskeepstf_rowdot's per-lane chunk order: thetf_load16sums, the 4×4accum,scale * accum + sum * bias, thensimd_sum. RPS and SG only choose which outputs a simdgroup owns. An odd member left over takes the same single-membertf_rowdottail asw3. Both grids divide exactly (1856 / 16 and 2688 / 16).The windowed forward meets 16 or more rows in three places:
copy_max30).GPU rounds choose by
verify_rows, the most rows the round could take. A round that priced a copy but verified fewer rows can therefore takerows2r8at a narrow width, where it is 2–8% slower at 2–5 rows and level at 8.This is not the M5 Ultra result in "Don't bother" ("Six or eight members a pass, or four at two simdgroups, lose 5-40%"). Here it is still two members a pass, with 8 output rows a simdgroup. On this M1 Max,
w4r8(four members) loses too. The gate is M1-only, so the M5 Ultra path is untouched.On M1 Max I measured the engine's own loaded pipelines on synthetic 4-bit weights: 4 layers × 128 experts, each layer's up then down as the engine encodes them. Each round ran
w3,rows2r8andw3again in rotated order, for 30–40 rounds of about 4 ms samples. Routing was three Zipf routings a width. I report the median of paired per-round ratios.rows2r8is slower at 2–4 rows (1.03–1.08) and level at 8–12. Concentrated routing favours it even at 8 rows (0.81–0.94). I kept 16 as the conservative floor.tf-nemotron-experts, run alone, shows the same trend: at 32 rows 3,271.8 againstw3's 3,508.2 µs a layer, and at 128 rows 13,103.2 against 16,392.7.These are single-kernel GPU timings. Model throughput was not measured because no checkpoint was available on this machine. The shared expert's down projection runs
alongsidethe routed up in the real encoder, and these timings don't include that overlap.Validated on M1 Max, macOS 26.7, Zig 0.17.0,
-Dcpu=apple_m1, againstb30d5b9d:rows2r8equals the engine'sw3for every output, up and down. That covers three routings a width, widths 2–128 including 3, 5, 7, 9, 15, 17 and 31 (odd member tails), and Zipf s = 1, 2 and 3. About 121 million values were compared, all equal.tf-nemotron-experts:every kernel: bits == the engine's, rows exact.zig build test test-golden: both trees report 7215/7261 passed, 45 skipped, 1 failed. The failure is the same on both:families.glm.eh_check"eh_proj on the tensor units: fp64 error no worse than the row kernel, decode and prompt apart".zig build nativesucceeds on both.zig fmt --checkpasses. The lean checker reports 428 problems on both trees, with identical output (zero added).tf-kernel-contractdoes not cover these launches. The new launches use 64 threads a group, againstw3's 128.Untested: M1, M1 Pro and M1 Ultra (the same generation, assumed alike); M2–M5 (unchanged by design); a real checkpoint, decode and serving throughput; CUDA (not affected).