Repository navigation
nemotron: a prompt segment's buffers read the owner's shared-expert plans and pair ids - #996
Conversation
…lans and pair ids Buffers.sibling gave each extra prompt segment its own `shared` and `sids` from fresh scratch, but only the owner's load writes them (initShared), so a segment of a latent MoE planned its shared expert from pair ids nothing wrote. On Super with `--segments 2` an 8,186-token prompt's reply differed from `--segments 1`. A sibling now points both at the owner's. `tf-cuda-test prompt-segments MODEL IDS_FILE` checks a prompt run as 2 to 4 segments a call against one uncut pass: caches and states, the MTP head's caches, the logits, the last hidden row and the first token.
cwschroeder
left a comment
There was a problem hiding this comment.
Source approval for the three-file change at 57418b92 against 6ee828c2, with Astra checking the segment and training callers. The owner initializes and synchronizes these tables before creating siblings. Subsequent paths read them, while mutable plans and activations remain private to each sibling. Cleanup frees the sibling's own arena before the owner goes away. I found no blocking issue in this scope.
Locally, Zig 0.17.0 passes whole-tree zig fmt --check build.zig zig, whitespace checks, and zig build install -Dtarget=aarch64-linux-gnu -Doptimize=fast -j2 --summary all (12/12 steps). That cross-compiles the CUDA test driver; it does not run it. All four current-head remote checks are green.
I also checked the published records pinned at receipt commit 84888dcf: the baseline two-segment token hash differs, while both patched segment settings, drafted and plain, match baseline one-segment. The four speed arms carry matching reply hashes. These checks confirm consistency of the author's records, not independent GPU measurements. The reported 8,186-token latent-MoE case covers the full segment test; the small guard improvement below would preserve that coverage for future inputs. No model, CUDA device, training, or Metal execution was performed here.
| var ids = try readIds(gpu, ids_path); | ||
| defer ids.deinit(gpa); | ||
| const n = ids.items.len; | ||
| try check.expect(n > R, "prompt-segments: the prompt needs more than {d} tokens, has {d}", .{ R, n }); |
There was a problem hiding this comment.
[P3] Require enough tokens to exercise all four active segments
The current n > R guard accepts 2,049 tokens. That creates only two chunks, so settings 3 and 4 still pass without exercising their extra segments. Consider requiring n > (cuda.segments.MAX - 1) * R (6,144 here), or reporting how many segments were active. Your published 8,186-token input already meets the stronger guard. The negative control also needs a latent-MoE checkpoint whose prompt path reads sids.
There was a problem hiding this comment.
Done in 7edd928: the guard is now n > (cuda.segments.MAX - 1) * R (6,144 here), and its message names the segment count. On the GB10 the receipt's 8,186-token prompt still prints PASS prompt-segments: a 8186-token pass as 2 to 4 segments a call equals the uncut pass, and its first 3,000 tokens now stop at FAIL prompt-segments: 4 segments need more than 6144 tokens, has 3000.
There was a problem hiding this comment.
Confirmed at 7edd9282: the guard requires more than 6,144 tokens before Engine.init, so accepted inputs have enough chunks for all four active segments. This resolves my P3. The new GPU pass/fail control remains author-reported; I have not rerun it independently.
…drafts a round, with the Mamba scan in stages of 32 The branch builds on #999's earlier commits and on #997, which come in with it. Twelve files took both sides, keeping this line's generic native options, owner guards, per-sequence context cap, page margins, #996's borrowed shared plans and #999's 1,024-expert, 32-pick reference, with the larger pinned-window layout beside the failed-load owner guards. The Mamba scan's record joins #999's records in the registry.
|
Thank you, @plotarmordev, for the segmented 8,186-token prompt and concurrent/solo comparisons. We merged the fix for 1.1.0 in eab8028. Each sibling prompt buffer gets the initialized shared-expert plans and pair IDs its sequence owns, preserving the current page owners and scratch path. NVIDIA GB10: 8,193-token Super VL/Lightning NVFP4 passes split into two to four segments equalled uncut passes. Posted by Ash's AI Assistant Synthena |
…'s shared-expert plans and pair ids
…31 MTP drafts a round, with the Mamba scan in stages of 32 The branch builds on ashhart#999's earlier commits and on ashhart#997, which come in with it. Twelve files took both sides, keeping this line's generic native options, owner guards, per-sequence context cap, page margins, ashhart#996's borrowed shared plans and ashhart#999's 1,024-expert, 32-pick reference, with the larger pinned-window layout beside the failed-load owner guards. The Mamba scan's record joins ashhart#999's records in the registry.
What this changes
With
--segments 2(orTF_CUDA_SEGMENTS=2), Nemotron 3.5 Super VL on CUDA gives a different greedy reply to an8,186-token prompt than with
--segments 1.Buffers.siblingcarves every scratch field of an extra segment fromthat segment's own new allocation,
sharedandsidsincluded. Only the owner's load (initShared) writes thosetwo, so the second segment's latent MoE plans its shared expert from pair ids that were never written. A sibling now
points
sharedandsidsat the owner's buffers (training passes get their scratch from the same function and nowread the owner's too). The new
tf-cuda-test prompt-segments MODEL IDS_FILEruns a prompt as 2, 3 and 4 segments acall and compares it with one uncut pass, byte for byte. It fails on main and passes with the fix.
Bug report
nvidia/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-NVFP4at revision82d93699acd3be9e4617c53360fe5b3f5dbeb1b3.tensorfold-native serve MODEL --name super --context 18432 --parallel 1 --prompt-cache-gib 0 --segments 2against the same command with
--segments 1.segments/long_document.request.jsonin the receipt (a synthetic field log with a question, thinking off,temperature0,max_tokens256,ignore_eos), sent to/v1/chat/completions. Its prompt is 8,186 tokens.--segmentstoken_sha256"draft": falsetoken_sha256857f11a3163c…857f11a3163c…376584461f3c…376584461f3c…857f11a3163c…857f11a3163c…857f11a3163c…857f11a3163c…Full hashes:
857f11a3163c107f8e12864988d1dc6ba065bf279c0db94c63ee608b881b92e6,376584461f3c1ac840f375481fc3628040b6421160d44324a7b58cda94f36f70. Main's rows are the same on two boots each.Receipt
Raw files:
receipts/nemotron/segment-shared-plans(segments/,plain/,speed/,prompt-cuts/,host-checks.txt).Environment, with the TensorFold commit, MLX or PyTorch version, machine and GPU, checkpoint and revision:
this branch at 57418b9 against main 6ee828c, each built with
zig build nativeandzig build install(
-Doptimize=fast -Dsm=121, the same fatbins; the change touches no kernel). A DGX Spark (GB10, sm_121, 48 SMs),driver 580.173.02, CUDA 13.0.
nvidia/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-NVFP4@82d93699acd3be9e4617c53360fe5b3f5dbeb1b3.Segment arms:
serve MODEL --name super --context 18432 --parallel 1 --prompt-cache-gib 0 --segments 1|2.Speed arms:
serve MODEL --name super(defaults: 16,384-token window, 8 streams), on a second DGX Spark.TF_HEAT_HIGH=85 TF_HEAT_LOW=75throughout.Exactness, from
tools/bench_concurrent.py --alone --serialortoken_shaagainst"draft": false:"draft": falseequals--segments 1at--segments 2.tf-cuda-test prompt-segments MODEL long_document.ids.txt(the request's 8,186 rendered ids): main with only thetest added:
FAIL prompt-segments: a pass as 2 segments a call differs from the uncut pass(exit 1). This PR:PASS prompt-segments: a 8186-token pass as 2 to 4 segments a call equals the uncut pass(exit 0).tools/bench_concurrent.py --alone --serial(4 streams, 256 tokens, 3 reps, temperatures 1.0 and 0, code andchat) on this PR: every reply equals its request alone (12 of 12 in each of the four rows) and the alone runs equal
"draft": false(4 of 4 sampled, 1 of 1 greedy, each prompt); 0 unequal, 0 failed.tf-cuda-test prompt-cuts MODEL long_document.ids.txton this PR: a pass keeping states inside chunks and attheir ends equals the uncut pass, and passes resumed at each keep equal it (PASS, PASS). Its third check fails
the same way on main:
a background pass stepping aside kept { 512 }, not [768]. WithTF_HEAT_HIGH/TF_HEAT_LOWset, the heat gate's wait asks the test's cancel too (
beforeChunk), so its call count runs ahead; not this change.Decode speed before and after, from
tools/bench_openai.py(--tokens 256 --reps 3 --temperatures 0, medians intokens/s, boots in the order main, PR, PR, main; every arm's reply hash is the same):
fibonacci-raw(code)gpu-chat-no-think(prose)Unchanged: the change runs only when segment buffers are made, and a decode round never reads a sibling.
Prompt speed before and after:
tools/bench_cache.py --require-cold --prompt-file long_document.ids.json --expected-prompt-tokens 8186, the first (cold) request'sttft_son a fresh server: main 4.453 s and 4.456 s,this PR 4.468 s and 4.449 s (qualified in all four). Default serve flags run one segment a call, as before.
Tests run, with pass, fail and skip counts:
zig build test --summary all: 84/84 steps, 417 of 424 tests passed, 7 skipped, 0 failed.zig build test-kernel-contract,zig build test-golden(309/319 equal to the frozen answers, 0 unexpecteddifferences),
zig build fuzz-cortheon,zig fmt --check: pass.tools/zig/lean_check.py: 517 problems on the base, 517 here, 0 new (tools/zig/lean_new.py).tf-cuda-test prompt-segments1 pass (1 fail on main with only the test, as above);prompt-cuts2 pass,1 fail, the same on main (above).
Not run, and why:
cuda_state.zig), and there is no Mac here.error.SegmentsNeedOneRank), so a TP=2 server never makes siblings.shared) are read by decode windows only, whichrun on the owner's buffers; not run.
tensorfold segments(the developer bench) and training passes (cuda_train.zig): not run.tf-cuda-test kernel-contract: no kernel changed.Checklist
"draft": false, a resumed prompt equals a fresh one, and concurrent equals solo.SUMMARYline is in the receipt. (No kernel changed.)prompt-segmentsis atf-cuda-testcommand that takes the checkpoint and ids file, asprompt-cutsdoes.)