Skip to content

Nemotron Super on CUDA: shared windows of several streams run the latent shared expert on the side stream again - #1058

Closed
plotarmordev wants to merge 1 commit into
ashhart:mainfrom
plotarmordev:nemotron-shared-window-overlap
Closed

plotarmordev wants to merge 1 commit into
ashhart:mainfrom
plotarmordev:nemotron-shared-window-overlap

Conversation

@plotarmordev

Copy link
Copy Markdown
Contributor

What this changes

43212bf (in 1.1.0) took the side stream away from shared windows of more than one sequence: Forward.routedWindow
nulls side when segs.len > 1 or f.tp != null, because "the side stream took the latent shared expert in every
window, which put a fork and a join into each layer of a shared round". This pull request drops the segs.len > 1
half. Two ranks keep the main stream as they do now. On one GPU, a shared round's 40 MoE layers again run the shared
expert beside the router, the latent projection and the routed experts, as a lone window does. Same bits.

Why that is safe:

  • A shared window is one forward over all its streams' rows (Engine.verifyShared → windowSegs); only the mixers
    run per segment. Each MoE layer sees the window's total rows (32 at most) and reads the plan built at load for that
    row count. The shared expert's (row, share) pairs do not depend on which stream owns a row.
  • The side stream reads b.y, b.sids and that plan. It writes b.sact, the shared rows of b.ymoe and the
    shared section of the NVFP4 rows. The main stream never touches those while the side stream runs. b is the
    engine's scratch in a lone window and in a shared one, so segments add no buffer the fork could race on.
  • The fork and join are the ones a lone window uses: the side stream waits for the input rows, and the main stream
    waits for the side stream right before moe_out, the first reader of the shared rows. The next layer's writes to
    b.y come after that wait.
  • Shared rounds run eager, so no captured graph changes. The MTP head's batched levels already fork and join over
    several streams' rows in every shared round (networkSpans → latent.run on e.forward(null)).
  • Window costs are timed on lone windows, which already overlap, and shared rounds are priced from that table, so
    draft depths keep the same inputs.

Tests:

  • tf-cuda-test shared-fork MODEL runs every latent MoE layer (40 blocks and the MTP head, both precisions) lone at 1
    to 32 rows, as before, and now also in shared windows of 2, 4 and 8 streams. Each stream count runs at its narrowest
    window (one row a stream) and at 32 rows, laid out as verifyShared lays them. Before each forked run the test fills
    the shared rows with NaN and holds the side stream back with copies, so a sum that does not wait for the join reads
    NaN. A shared window without a side stream fails with SharedWindowWithoutSideStream.
  • The host test that asserted the old schedule (mtp policy: shared latent windows …) now asserts the new one: 1, 2,
    4 and 8 segments keep the side stream on one GPU, and none has it at two ranks.

No documentation change: the recipe already says passes of up to a window's rows run the shared expert on the side
stream on one GPU.

Receipt

Raw receipts: receipts (README.md maps every file to its binary).

  • Environment: this branch at 33d0db58172efe1f05a30e02d7006827547cfa2b on main d46d17a784758b8a8b66badde1f728f36bdc9541.
    main's three commits after v1.1.0 change only app/, docs/ and README.md, so the GPU runs used v1.1.0
    (76aafcf2) as the base. The measured branch build was v1.1.0 plus this commit and a separate commit (its own
    pull request) that copies MTP confidences once per shared round. Without --mtp-confidence, which no run here sets,
    that commit only adds up to 8 small device-to-host copies and an event record after each batched draft. Builds come
    from clean checkouts: zig 0.17.0 and nvcc 13.0 fatbins for sm_121, then zig build native / install with
    -Doptimize=fast -Dstrip=true -Dtarget=aarch64-linux-gnu.2.28 -Dcpu=baseline -Dversion=1.1.0. tensorfold-native
    sha256: base 04167a172c847952737a4b401fb5945b74d598a51312ed19f4e6ddd974015088, measured branch
    ec0ff22f7bdb5354c3faa8d5e1db125fcfbbcbf329df70042f3ca25b02789c69; this tip builds to
    119f25c8ce8eb2564ef48ef4a3021ab4158411c2b362cb313fe7d7d66a6034fc. Two DGX Spark (GB10), driver 580.173.02,
    CUDA 13.0. Checkpoint nvidia/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-NVFP4@82d93699acd3be9e4617c53360fe5b3f5dbeb1b3.
    Every speed hold's server ran as serve <checkpoint> --context 131072 --parallel auto --vision --thinking (8
    streams) in a fresh HOME, so each timed its own window costs, with TF_HEAT_HIGH=85 TF_HEAT_LOW=75.

  • Exactness:

    • tf-cuda-test shared-fork: PASS shared-fork (checkpoint): 1558 (layer, rows) cases, lone and shared, the forked delta byte-equal to the one-stream delta, and the same line for (full) (41 layers × (32 lone widths + 3 stream
      counts × 2 widths)).
    • tensorfold shared-widths <checkpoint> prompts-ids.json --streams N --max-tokens 400: 2 streams 798 of 798 kept
      rows equal serial (43 shared windows), 4 streams 1596 of 1596 (71), 8 streams 3192 of 3192 (132).
    • In every speed hold below, every wave's replies equal their reply alone: 112 of 112 replies a hold on the first
      Spark and 144 of 144 on the second. bench.py streams (1, 2, 4 and 8 streams): every reply equals its prompt
      alone. One stream, bench.py decode: drafted equals "draft": false on every hold. The hashes are the same on
      the base and the branch: count 1b3d78d3b1bfd175…, prose 71494803187745a9…, code 3d4d30129aebb7a2….
  • Decode speed. Identical requests released together run in one of two modes on every build. Either request 2 is
    admitted one prompt pass after request 1 (on time), or a lone round later (late, about 240 ms of lag instead of
    about 90). On count, late waves are about 20 % slower on the base too, so a median over waves mostly reports which
    mode it caught. The table compares the base and the branch within the same mode (scripts/modes.py): the median wave
    tok/s (all replies' output tokens over dispatch to last token, 400 tokens each, greedy, thinking off) of the
    measured waves in each mode, with each mode's wave count in brackets.

    First Spark, holds in the order base, branch, base:

    case base on time / late branch on time / late branch vs base, same mode
    count, 2 streams 112.35 / 90.24 (4/2) — / 91.86 (0/3) — / +1.8 %
    count, 4 streams 202.56 / 164.71 (2/4) 206.31 / 167.16 (1/2) +1.9 % / +1.5 %
    count, 8 streams 290.73 / 241.77 (1/5) — / 245.70 (0/3) — / +1.6 %
    prose, 2 streams 56.30 / 59.92 (1/5) — / 61.60 (0/3) — / +2.8 % (see below)
    prose, 4 streams 103.77 / 103.38 (2/4) 107.33 / 106.44 (1/2) +3.4 % / +3.0 %
    prose, 8 streams 146.76 / 146.57 (1/5) 150.87 / 150.58 (2/1) +2.8 % / +2.7 %

    Second Spark, holds in the order base, branch, base:

    case base on time / late branch on time / late branch vs base, same mode
    count, 4 streams 200.15 / 163.29 (2/4) 202.26 / 165.33 (2/1) +1.1 % / +1.2 %
    count, 8 streams 286.86 / 238.76 (1/5) 291.51 / 241.91 (2/1) +1.6 % / +1.3 %
    prose, 4 streams 102.50 / 96.11 (4/2) 101.30 / — (3/0) −1.2 % / —
    prose, 8 streams 144.44 / 144.67 (1/5) 147.11 / — (3/0) +1.8 % / —
    code, 4 streams 151.49 / 124.11 (2/4) 150.54 / — (3/0) −0.6 % / —
    code, 8 streams 253.06 / 214.15 (1/5) 257.28 / — (3/0) +1.7 % / —

    In the same mode, count gains 1–2 % at 2 to 8 streams on both Sparks, and prose about 3 % on the first. Prose at 2
    streams is a weak comparison: the two base holds drafted differently (179.5 and 221.3 rounds a reply, the branch
    181.5). On the second Spark, the branch's prose 4-stream waves all reached first text later (median 840 ms against
    221 and 272) [not traced]. Their decode rate from first to last text was 105.77 tok/s against 102.81 and 102.15.
    bench.py streams aggregate at 1/2/4/8 streams on the first Spark: base 52.35/46.87/65.52/90.51, branch
    52.75/47.32/66.16/90.70, base 52.73/46.97/64.85/89.42. One stream is unchanged, as expected, since lone windows
    already overlap: count 95.65 / 95.82 / 95.71 tok/s (base, branch, base; second Spark).

  • Prompt speed: n/a. Only verifyShared passes more than one segment to routedWindow, so prompt passes run the same
    launches on the same streams as before.

  • Tests run:

    • At this tip, each step on a fresh cache: zig build test 2413 passed, 9 skipped, 0 failed (base: the same; no
      host test is added, one changes its assertions). zig build test-kernel-contract: 43 of 43.
      zig build test-golden: 306 of 319 equal, 0 unexpected differences (base: the same). zig build fuzz-cortheon:
      8 of 8. zig build test-nemotron-mtp-policy-host: 10 of 10. zig build compile-cuda-tests: builds.
      zig fmt --check zig build.zig: clean. tools/zig/lean_check.py: 503 problems, the same 503 as the base, 0 new.
    • GPU: shared-fork 2 of 2 PASS and shared-widths 3 of 3 PASS (above); cached-plans-tp2 on two ranks (below).
    • Failing receipts:
      • v1.1.0 with only the tests added: FAIL shared-fork: SharedWindowWithoutSideStream.
      • The branch with the join removed (gpu/mutant-no-join.diff) fails at its first case: FAIL shared-fork (checkpoint): layer 0 at 1 rows: first difference at byte 0, 2048 of 2048 words differ (NaN for every word).
      • The host test on this tip with the source line reverted (host/before.diff): 9 pass, 1 fail, at the shared
        windows' side-stream assertion.
  • Two ranks (TP=2, two GB10s over RoCE): ranks keep one stream, unchanged by this pull request. tf-cuda-test cached-plans-tp2 with the measured branch build passes on both ranks: PASS cached shared plans: world 2, rank 0, every width equals an on-demand plan, then prompt-cuts' cut, resumed, background and step-aside passes. Served
    two-rank identity is partial. With NCCL 2.32.3 rank 0 was serving 60 s after start, and bench.py decode gave count
    and prose drafted equal to "draft": false (1b3d78d3b1bfd175…, 71494803187745a9…). These are the same tokens as
    one GPU and as the stock 1.1.0 release at TP=2. The harness's 8-minute limit stopped the server during the code
    requests; the client had paused three times before for the node to cool. (NCCL 2.28.9 hangs two-rank serving on every build we tried, the
    stock releases included; reported separately.)

  • Not run, and why: Metal (no Mac here; the change is CUDA-only). A non-latent Nemotron: its condition is unchanged
    (f.c.latent > 0). tf-cuda-test kernel-contract: no kernel changed (this tip's fatbins equal the measured build's,
    83 of 84; glm_quant.fatbin differs among every build compared, from the same source). The mutant ran only with the
    side stream held back. tools/bench_openai.py / bench_concurrent.py: the decode receipt uses the wave client
    above, whose replies are checked against their reply alone, and the speed holds ran before this branch was cut
    from main. Resumed against fresh prompts: not exercised separately; no prompt-path or cache code changes.

Checklist

  • Every token still goes through the lane rounds. No serial path, and nothing that needs drafts off.
  • Drafted output equals "draft": false, a resumed prompt equals a fresh one, and concurrent equals solo. (Drafted vs "draft": false and concurrent vs alone measured above; resume not exercised separately.)
  • No precision traded for speed. If the bits change, the description says which sums change and why. (No bits change: the same launches in the same order on each stream, byte-compared by shared-fork lone and shared.)
  • A new or changed GPU kernel is registered with the kernel contract (docs/kernel-contract.md); each backend's SUMMARY line is in the receipt. (No kernel changed.)
  • Prompt processing is no slower than the last release. (Prompt passes are untouched; see Prompt speed.)
  • The description says which platforms I ran, Metal M1 to M5 and CUDA, and which I could not.
  • New tests fail before the change, pass after it, and skip cleanly without their dependency. (shared-fork is a tf-cuda-test command that takes the checkpoint.)
  • Comments and docstrings are one line. No measurements or history in the source.
  • No personal data, machine names, internal hosts or local paths. No AI attribution lines.

…red expert on the side stream again

A shared window is one forward over its streams' rows: every MoE layer reads the engine's shared scratch, the cached
plan for the window's total rows and one fork and join, as a lone window and the MTP head's batched levels already do.
Only two ranks keep the shared expert on the main stream. tf-cuda-test shared-fork adds shared windows of 2, 4 and 8
streams at their narrowest and widest, with the shared rows poisoned and the side stream held back.
@plotarmordev

Copy link
Copy Markdown
Contributor Author

TP=2 update: with the overlap build, a served two-rank run (NCCL 2.32.3, see #1060) now completes count, prose and code: drafted output equals "draft": false and the token hashes equal the single-GPU ones (1b3d78d3…, 71494803…, 3d4d3012…). The same check passes on unpatched v1.1.0. The earlier partial run was cut short by our harness (the server's heat gate waiting on a box another job kept above 75 °C), not by the change.

@ashhart

ashhart commented Oct 19, 2026

Copy link
Copy Markdown
Owner

Thanks @plotarmordev. Your race argument holds up on our GB10: shared-fork passes all 1,558 cases at checkpoint and full precision, including the NaN-filled 2-, 4- and 8-stream windows, and every stream's tokens match the line without the change.

Alone, it cost 4-stream prose 2.6%: its cheaper rounds drafted shallower under the depth rule in your #1059. With our shared-round depth probe for #1059 beside it, Super VL NVFP4 (ABBA, 2 servers × 5 waves) measures 4-stream count at +1.5% (122.70 against 120.91 tok/s without either change) and 4-stream prose at +1.3%. 8 streams are within 0.5%, at the 32-row cap. We're carrying both onto the 1.1.2 line under your name.

Posted by Ash's AI Assistant Synthena

ashhart added a commit that referenced this pull request Oct 21, 2026
…dits

The 1.1.2 section had no entries for the contributed pull requests carried into this release, so neither their
changes nor their authors reached the release notes. Add an entry for each, written from its commits: Flash Next's
CUDA prompt tiles and structured output (#1046, #1062), --thinking-reserve, the long-loop guard and the --vision
template diagnostic (#1064, #1075, #1076), GLM's Metal eh_proj tile and CUDA waiting ranks (#1066, #1053), M1's
simdgroup cap (#1055), Nemotron's CUDA image and shared-window fixes (#1057, #1058), Qwen's live-row expert routing
(#1047), the shared CUDA operators and contract fixture (#1056, #1068, #1070, #1071, #1073), the ROCm receipt,
drafter and draft-count work (#1043, #1044, #1045), the ModelOpt recipe numbers (#1042), the Windows host build
(#1034) and the session store's allocation-free rollback (#637). Thank #643's and #1060's reporters as the other
entries thank theirs.
@ashhart

ashhart commented Oct 21, 2026

Copy link
Copy Markdown
Owner

The Nemotron Super CUDA shared-window scheduling change is included in 1.1.2 (https://github.com/ashhart/TensorFold/releases/tag/v1.1.2), with your original authorship retained. Shared windows on one GPU can keep the shared expert on its side stream; tensor-parallel latent windows keep the main-stream schedule. Closing this as carried, and thank you.

It landed as fadbf9a.

- Synthema, Ash's AI Assistant.

@ashhart ashhart closed this Oct 21, 2026
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.

2 participants