Skip to content

Nemotron 3.5 Super TP=2 on CUDA: one header a decode window, one message a layer - #2839

Merged
ashhart merged 4 commits into
mainfrom
lead/nemotron-tp2-header
Nov 17, 2026
Merged

ashhart merged 4 commits into
mainfrom
lead/nemotron-tp2-header

Conversation

@ashhart

@ashhart ashhart commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Nemotron 3.5 Super at TP=2 on CUDA sends rank 1 a header for every layer job: during decode, a window of more than one row makes two messages a layer, and rank 1 waits on the host to read each header (two stream syncs a read) before it can queue the layer's work.

What changes (cuda_worker.zig, cuda_forward.zig):

  • Under TP=2, routedWindow gives each decode window one pass header carrying the rows, the job count and a layer mask. After it, each layer's job is one exact-size message.
  • Rank 1 reads that header once a window, then queues every layer's receive, partials and reply with no host read in between.
  • parse refuses a short or malformed header; the pass header has its own magic, so a build without passes refuses it instead of misreading it (mismatched builds are already refused at startup by the executable hash).
  • Prompt chunks and the MTP head keep a header a job, with the same bytes and message sizes as main.
  • Rank 1's exit line now counts jobs, messages and header reads, so a device run shows one message a layer.

For a 40-layer window that is about 41 messages and one header read where main makes 80 messages and 40 header reads.

Exactness: each job's rows land at the same device addresses with the same layout on both ranks, and rank 1 runs the same partials in the same order on one stream; no kernel, reduction or ordering changes. TP=1 never reaches this code.

Checks: six host tests in cuda_worker_test.zig (new step test-nemotron-tp-jobs-host, 19/19) run rank 0's real send code into a fake host-memory link and rank 1's real loop out of it; each fails when the part it pins is broken. test-bolt-host, test-nemotron-copies-host (28/28), check-native-cuda-host, compile-cuda-tests -Dtarget=aarch64-linux-gnu, zig fmt --check and the lean count pass. One existing test (test-nemotron-mtp-policy-host) built a forward with no weights; it now gets empty weights and passes 10/10.

Still to run before landing: two GB10s at TP=2, Nemotron 3.5 Super NVFP4, main against this branch with the same binary on both ranks for each side: 1 and 4 streams, undrafted and MTP-drafted, greedy and seeded, token hashes equal to main and the golden set equal to TP=1, with rank 1's message and header-read counts from its exit line.

For #2834.

  • Synthena (Ash's Agent)

@ashhart

ashhart commented Nov 11, 2026

Copy link
Copy Markdown
Owner Author

An independent read found one gap, now closed in a9ca692662: if rank 0 failed partway through an eager window (four-stream verifyShared, or a masked window that runs eagerly) after the window's first job went out, rank 1 had already queued every remaining layer's receive, so the next header would land in a payload-sized receive and either hang or be misread. Each window now counts its jobs out and replies in; a failure while rank 1 is still inside the window logs the error, sends its name on the liveness line and stops, and rank 1 stops too, naming it. A failure before the first job, after the last reply, or during a capture still isn't fatal. Two new host tests pin it (without the fix the first one sees rank 0's end header misread as a payload, SizeMismatch); test-nemotron-tp-jobs-host 21/21. The device run will also cover a cancelled request followed by a fresh one, and the four-stream eager path.

  • Synthena (Ash's Agent)

@ashhart
ashhart force-pushed the lead/nemotron-tp2-header branch from a9ca692 to 910cec5 Compare November 17, 2026 06:04
ashhart added a commit that referenced this pull request Nov 17, 2026
…ward.zig back under 600 (#2839)

On main 3f1290f the TP=2 job headers take zig/src/families/nemotron/cuda_forward.zig to 610 lines. The window
profile's timing types, Class and Marks (tf-cuda-test window-profile's events), move unchanged to
cuda_window_marks.zig; cuda_forward.zig re-exports both names, so every caller is as it was. 597 lines.
…ayer

A window's latent MoE jobs to rank 1 go under one pass header (rows, job count, layer mask) in the
fixed first message; every later job sends only its rows, at the size that header gave. Rank 1 reads
one header a window, then queues each layer's receive, partials and reply with no host read between.
A job's rows land where a job of its size always did, on both ranks, so rank 1 runs the same bytes
from the same places. Prompt chunks and the MTP head keep a header a job. The pass header has its own
magic, so a build without passes refuses it as a bad job. test-nemotron-tp-jobs-host runs rank 0's
real posts against rank 1's real loop over a fake link. #2834.
Once a window's first job is out, rank 1 has queued a receive for every later job of its pass. An
eager window that then failed on rank 0's host (a launch error in verifyShared, a masked window off
its graphs, a dump run) left rank 1 waiting, and rank 0's next message (its end header, or the next
window's) would land in a receive of another size, which NCCL leaves undefined. A window now counts
its jobs out and replies in (Flight); windowSegs hands a failure to windowFailed, and while rank 1
still waits inside the window, rank 0 tells every rank the error's name on its liveness line and
exits, the way completion.drain does. A capture sent nothing and stops no rank, nor does a failure
before the first job or after the last reply. Host tests pin a failure after k of 40 jobs: rank 1
runs exactly those k jobs, then stops with rank 0's error's name. #2834.
…ward.zig back under 600 (#2839)

On main 3f1290f the TP=2 job headers take zig/src/families/nemotron/cuda_forward.zig to 610 lines. The window
profile's timing types, Class and Marks (tf-cuda-test window-profile's events), move unchanged to
cuda_window_marks.zig; cuda_forward.zig re-exports both names, so every caller is as it was. 597 lines.
@ashhart
ashhart force-pushed the lead/nemotron-tp2-header branch from 910cec5 to 48e9b1b Compare November 17, 2026 14:32
@ashhart
ashhart merged commit b7b4722 into main Nov 17, 2026
1 of 10 checks passed
ashhart added a commit that referenced this pull request Nov 17, 2026
…ward.zig back under 600 (#2839)

On main 3f1290f the TP=2 job headers take zig/src/families/nemotron/cuda_forward.zig to 610 lines. The window
profile's timing types, Class and Marks (tf-cuda-test window-profile's events), move unchanged to
cuda_window_marks.zig; cuda_forward.zig re-exports both names, so every caller is as it was. 597 lines.
@ashhart
ashhart deleted the lead/nemotron-tp2-header branch November 17, 2026 14:32
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.

1 participant