Repository navigation
Nemotron: shared rounds hold four rows a lane, up to 128, so 32 and 64 sessions scale - #518
BobClawblaw wants to merge 1 commit into
Conversation
…4 sessions scale The native server's shared round held at most 32 rows, so past 32 sessions it stopped scaling and at 32 drafting sessions it was already splitting rounds. batch_rows now follows --parallel: four rows a lane, 64 at least (what the engine always allocated for a lone stream's lanes) and 128 at most. state.max_rows goes to 128 for the forward's buffers; the startup sweep times shared rounds up to that width so the planner prices them from measurements. M5 Ultra, --parallel 64, main against this: 64 sessions 779-795 -> 968-1,033 tok/s on code and 740-753 -> 847-849 on chat; 32 sessions 780-795 -> 958-1,019 and 741-755 -> 821-843; 8 sessions and one stream unchanged. Every concurrent reply equaled its solo run and every solo run equaled "draft": false (4,076 replies over the runs). Each row past 64 costs a Mamba state slot, 47 MiB; --parallel 64 takes about 2.9 GiB more, --parallel 8 the same. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Thank you, @BobClawblaw. A three-line change measured with care, and the flat 64-row build you tried on the way showed It's on main as On an M3 Ultra, with distinct prompts, every concurrent reply equalled its solo run at We re-made the commits without their AI-tool trailer lines, which main's history doesn't carry, so GitHub shows this PR as closed rather than merged. The commit is yours. |
…'s per-stream arrays Lands ashhart#518 on main. Its wider timing caches went into 1.0.3's cached measure() when the commit applied. batch_rows now reaches st.max_rows (128), so verify's and draft's per-stream arrays have no headroom left. The lane core picks no more streams than rows, so no round asks for more today; now Metal.init refuses a batch_rows past st.max_rows, and verify and draft refuse more windows than their arrays hold instead of writing past them.
…hhart#518 Lands ashhart#502 on main beside ashhart#518: a shared round can now hold 128 rows, so the routed-expert checker bit-checks and times every pass shape at 128 rows too. Layer 0's routing copy is sized by the widest width.
…'s per-stream arrays Lands ashhart#518 on main. Its wider timing caches went into 1.0.3's cached measure() when the commit applied. batch_rows now reaches st.max_rows (128), so verify's and draft's per-stream arrays have no headroom left. The lane core picks no more streams than rows, so no round asks for more today; now Metal.init refuses a batch_rows past st.max_rows, and verify and draft refuse more windows than their arrays hold instead of writing past them.
…hhart#518 Lands ashhart#502 on main beside ashhart#518: a shared round can now hold 128 rows, so the routed-expert checker bit-checks and times every pass shape at 128 rows too. Layer 0's routing copy is sized by the widest width.
Help-list item 3 in ZIG-PREVIEW: the native Nemotron server's shared round held at most 32 rows, so past 32 sessions it stopped scaling, and at 32 drafting sessions it was already splitting rounds or starving them of draft rows.
What changes
zig/src/native/metal.zig:batch_rowsfollows--parallel: four rows a lane, 64 at least, 128 at most. Up to--parallel 16that is the 64-row forward the engine already allocated for (max_lanes), so nothing changes there, including memory. At 32 and 64 lanes each drafting stream keeps rows for its drafts.zig/src/families/nemotron/state.zig:max_rows64 → 128 (the forward's buffers, the per-forward host arrays).replay_rowsandmax_lanesstay 64: a lone stream's window is unchanged.zig/src/families/nemotron/timing.zig: the startup sweep times shared rounds up tobatch_rows(64 caches instead of 16), so the planner prices 64- and 128-row rounds from measurements instead of a straight line past 32.Three lines of code. No kernel changes; every kernel already took its row count from the dispatch.
Cost
Each row past 64 is one more Mamba state slot: 2 MiB a Mamba layer, 47 MiB across Lightning's 23.
--parallel 64takes about 2.9 GiB more than before;--parallel 8(the default) the same as before. The sweep adds a few 128-row forwards to startup.Speed
M5 Ultra (256 GB, macOS 27.0.1), Zig 0.17.0, Metal Toolchain 27A266a, Lightning at d9d758fb,
--context 32768 --prompt-cache-gib 0 --no-thinking --temperature 0, 256 tokens a reply,tools/bench_concurrent.py --alone --serial.main(f8fe17d) against this branch, servers alternated, two rounds each,--parallel 64on both:One stream (
tools/bench_openai.py): 505 / 347 tok/s onmain, 501-505 / 346-347 here.A flat 64-row cap, measured on the way as a separate build, gave 917-943 on code at 32 sessions but only 825-832 at 64 (chat 822-844 and 781-787): most of the 32-session gain, a quarter of the 64-session one. 64 sessions need two rows each to keep drafting, hence 128.
The final binary's own run (
--parallel 8,32,64in turn):--parallel 8948 / 718 tok/s at 8 sessions and 503 / 345 alone;--parallel 32979 / 821 at 32;--parallel 641,033 / 849 at 64 (code / chat).Exactness
"draft": false: 1,152 replies in the 32/64-row run, 2,496 in the three-way, 428 in the final binary's run, 0 unequal, 0 failed.zig build test test-golden -Dcpu=apple_m1: passes (312/319 golden, 0 unexpected differences, the same allocator leak traces from the golden checker asmain).Docs
ZIG-PREVIEW (sessions paragraph, known gaps, help item 3 now points past 128 rows at the slot pool and the expert kernels' cost per row), and a "Shared rounds on the Zig engine" section in the Nemotron recipe with the table above.
Independent of #497, #499 and #502 (no overlapping hunks; the recipe gets a new section at the end).
🤖 Generated with Claude Code