Repository navigation
Nemotron on Metal without tensor units skips the lane tiles no kernel reads: about 1 GiB less - #3375
Conversation
|
FIXES. @jschmied, the native and Metal builds pass, and the row-only loader tests pass. One edit path still needs fixing. P2 at weights.zig:507: Builder.tiled() now permits a 4/64 projection with rows present and tiles absent, but retile still unwraps tiles. TF_SLIDE_EDIT=1 with --slide reaches this through the shared down projection's commit. An actual-function host regression compiles and crashes at that unwrap. Please skip missing tiles while updating the row copy, and keep a row-only commit regression.
|
|
@jschmied DEVICE. The row-only retile regression now passes. On M5, all 80 full 64-token replies match main, greedy and seeded, plain and four-stream MTP. The sampled four-stream hash-map cell is 138.589 -> 133.908 tok/s, 3.38% slower, with disjoint ranges. The no-tensor-unit memory and inference check still needs M1-M4 hardware; the M5 control cannot qualify it.
|
|
@jschmied, to make the ask above explicit: this change is meant to leave tensor-unit Macs alone, but on our M5 Ultra the sampled four-stream cell drops 3.4% (138.6 to 133.9 tok/s, with no overlap between runs). Please find what reaches the M5 path. If the retile is meant for Macs without tensor units only, gating it on
|
|
@ashhart Fixed in ff5bf5a. Two things in this PR still reached tensor-unit Macs, although every changed branch evaluated as on main there: The no-tensor-unit numbers are from an M3 Pro 36 GB, not an M4 Pro. Against main d6c4cce: 18.9 GiB kept wired instead of 19.9 (peak GPU 19 GB vs 20). Replies are byte-identical: greedy and seeded at 7.8K and 26.6K, resumed == fresh, c1 == c4, and four-stream MTP sampled and greedy in all 12 A-B-B-A runs. Four-stream MTP speed is level: sampled median 44.08 vs 44.30 tok/s (-0.5 %, the head's range inside main's), greedy 44.73 vs 44.85. Body updated to the new head. |
|
DEVICE. @jschmied, the restored Linear layout and MTP build order check out, and the row-only retile and allocation regressions pass. On an M5 Ultra, all 80 full replies remain exact across greedy and sampled requests, plain solo and four-stream MTP. The previously slower sampled four-stream cell is now 137.912 versus 137.295 tok/s, a 0.45% difference with overlapping ranges. No measured decode cell has disjoint slower ranges. We will run the row-only memory, long-prompt, MTP and resume checks on an M3 Ultra on our side. CI is green at this head; those checks remain before landing.
|
|
@jschmied, the M3 Ultra check is in, at head ff5bf5a against its base, on a 60-core M3 Ultra (no tensor units) with the Nemotron 3.5 Lightning 4-bit checkpoint. Prompt passes from 2K to 64K tokens at starts 0, 5,000 and 10,000, the stream sweep and the chat cells with resumed turns all read level, and the token rows are equal across every run (0 of 20 differ). The two builds sit within 0.1% of each other in every prompt cell. With the M5 result from our last reply and CI green, this is READY: it goes in the landing queue.
|
… reads: about 1 GiB less Every 4/64 dense projection got lane tiles, and their CPU tile jobs, on every Mac. Without tensor units every linear also has its row layout, and each tile reader tries the row kernels first, so the tiles were never read. The exception is the MTP head's eh, which coopParts reads directly. - Linear.lane marks a projection the lane kernels can take. The kernel choices that keyed on tiles (simd_bits pipelines, prompt chunks' MLX qmm, the mixers' qkv) now key on it, so every path picks the kernel it did before. - Builder.tiled() builds tiles only with tensor units, or for the pinned eh. On Nemotron 3.5 Lightning the load keeps 17.8 GiB wired, not 18.8; replies are unchanged.
…ites its rows and skips the tiles Without tensor units a 4/64 projection has rows and no tiles (Builder.tiled), but retile unwrapped them, so TF_SLIDE_EDIT=1 --slide crashed committing the shared down projection. retile now writes tiles only where they exist. A device test commits to a row-only projection and checks its row copy; on the old retile it crashes.
…ly as on main Linear.lane was a field, so every Linear grew by a word on every Mac, and the MTP eh was built before the head's norms to set pin, so tensor-unit chips allocated and queued its tiles in a new order. lane() is now derived (tiles first, then 4/64 rows where none are built), and eh is built in main's place with pin set around it. A device test pins the tensor-unit build: three 4/64 projections give three tile jobs, six tile buffers and no row copy.
ff5bf5a to
b0a48cc
Compare
|
Thank you @jschmied. 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. |
Branch
nemotron-metal-rows@ ff5bf5a (b3b1dd6 + the slide-commit fix and the tensor-unit fix below), on main d6c4cce. Don't land yet: the M5 sampled four-stream cell needs a re-run at ff5bf5a. Family-only.Problem, measured
weights.Builder.linearandpickedbuilt lane tiles for every 4/64 dense projection on every Mac: new buffersplus CPU tile jobs (
weights.zig:175,:225). On a Mac without tensor units, every linear also gets the rowlayout (
Builder.rows = !tensorUnits), and every kernel that reads tiles first tries the row kernels(
forward.zig:89coop,layers.zig:411upRelu2), which always succeed there. So the tiles were never read,with one exception: the MTP head's
eh, whichmtp.zig:91coopPartsreads directly.The audit (#488) estimated "up to 3x". Measurement corrected that, and this PR is sized by the measurement. The
routed experts (15.39 GiB) and the embed/head (0.37 GiB) are read in place. The dense 4/64 matrices are 0.80 GiB,
so the waste was about 1 GiB, not a multiple of the model.
Change
Linear.lane: a 4/64 projection the lane kernels can take. Every decision that keyed ontiles != nullnowkeys on
lane:model.zig:125(simd_bits pipelines),prefill.zig:152-153(MLX qmm on raw rows for chunksover 128 rows), and
prefill_mixers.zig:116-118. So each prompt and decode path picks exactly the kernel it didbefore.
splitsAtstill checks the tiles, sincecoopPartsreads them.Builder.tiled(): lane tiles and their tile jobs only with tensor units, or for the pinned MTPeh.lanebut have no tiles,queue no tile job and make no buffer, and the row kernels read the checkpoint's own rows.
Evidence (M3 Pro 36 GB; against main: base = main d6c4cce built here)
TensorFold/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-MLX-4bit (17.3 GiB of weights):
footprintGPU (whole GB), 4K windowReplies equal base (token_sha256):
Speed, A-B-B-A, 2 rounds, a fresh server per run, 128 greedy tokens:
No slower cell beyond run spread. The 8K decode gain comes mostly from one slow base run; the paths are the same.
Load time is level at server granularity: the tile jobs were CPU work during load.
Checks:
zig build testexit 0; the new host test passes.zig fmtclean; files 600 lines or fewer. No kernel changes.No refusal test: the change adds no refusal; nothing new is refused, and no path is taken away.
Not run here: a tensor-unit Mac. Its path is unchanged, since
tiled()is true there.x86 CI (Linux,
-Dfixed-cpufull set on b3b1dd6): 742/745 steps, 9,597 of 9,674 tests pass. The one failure iscli_config_test(serve --config: expand reads the file...), which fails the same way on main on that box (see #3350); this PR touches no server code.tools/pr_check.py: lean 341 vs 341, 0 new;zig fmt --checkclean.Proposed CHANGELOG line
GPU memory for Nemotron 3.5 Lightning. Replies and speed are unchanged.
3d57a76 (review fix):
retilewrites lane tiles only when the Linear has them and always rewrites the row copy, so a slide commit (TF_SLIDE_EDIT=1 --slide, shared down projection) on a Mac without tensor units no longer unwraps absent tiles. Regression: a device test (host-stub guarded,weights_test.zig) commits to a row-only 4/64 Linear and checks its row buffer equals the edited codes; with b3b1dd6'sretileit crashes (SIGSEGV, 861/863 steps), with the fix 863/863 steps, 9,110 passed / 94 skipped. lean 341 vs 341;zig fmtclean. The x86 CI row above is on b3b1dd6; the fix touches onlyweights.zig's retile and a device test.ff5bf5a (review fix, tensor-unit Macs on main's path): on M5 every changed branch already evaluated as on main (
Builder.rows=false, sotiled()holds and every 4/64 projection has tiles), but two things still differed:Linearhad a newlanefield (one word more on every Linear, passed by value through each encode call), and the MTPehwas built ahead ofenorm/hnorm, so its tile buffers and tile job were allocated and queued in a new order.lane()is now derived (tiles != nullfirst, the old test),Linearhas exactly main's fields, andehis built in main's place withpinset and reset around it. With tensor units the struct layout, allocation order, tile jobs and every branch are main's; theretileguard only addsif (lin.tiles), always true there. Pin test (device, host-stub guarded):rows=falseon the 4/64 fixture gives 3 tile jobs, 6 tile buffers, tiles on every projection, no row copy. We have no tensor-unit Mac, so the M5 cell's recovery is not shown here, and we can't say which of the two caused the 3.4 %.No-tensor-unit receipts (M3 Pro 36 GB, not an M4 Pro), Nemotron 3.5 Lightning 30B-A3B MLX 4-bit, main d6c4cce vs ff5bf5a:
--parallel 4);footprintpeak GPU 20 -> 19 GB in all 12 MTP runs.--parallel 4, 128 tokens) sampled (T=1, seed 7+i) and greedy: one set of 4 hashes a mode over all 12 runs, main and head identical.-Dfixed-cpu; lean 0 new;zig fmtclean.