Skip to content

nemotron: Super's latent shared expert plans once at load and, on one GPU, runs beside the routed experts (stacked on #996, #999) - #1002

Merged
ashhart merged 7 commits into
ashhart:mainfrom
plotarmordev:nemotron/shared-expert-overlap
Oct 18, 2026
Merged

ashhart merged 7 commits into
ashhart:mainfrom
plotarmordev:nemotron/shared-expert-overlap

Conversation

@plotarmordev

@plotarmordev plotarmordev commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Branch nemotron/shared-expert-overlap. Stacked on #996 and #999: the branch is a merge of the two, then this pull
request's two commits; review only the last 2 commits.

What this changes

The latent MoE's shared expert reads only the block's input rows and the same (row, share) pairs at every layer, so a
decode window no longer plans it per layer or waits for the router before running it. Same bits.

  • Plans at load: Buffers.initShared plans every row count from 1 to max_rows into its own slice of the shared
    buffer, and passes of up to a window's rows read that plan instead of planning the shared expert again at every
    layer. Wider prompt passes and the other rank's jobs still plan at their own row count. A host test checks that the
    row counts' plans stay apart and inside the shared slot at one share and two.
  • Side stream: on one GPU, latent.run forks the shared expert onto the engine's side stream once the input rows are
    written. It runs on its own NVFP4 rows, activations and the load-time plan while the router, the latent projection
    and the routed experts run on the main stream, and the main stream waits for it just before moe_out sums the
    shared rows. Each row's sums and their order are unchanged. Wider prompt passes and tensor-parallel ranks keep one
    stream. Engine.forward now gives latent families the side stream (tf_plan_routed's bounds hold only for the
    non-latent MoE, which plans with it).
  • tf-cuda-test shared-fork MODEL: every latent MoE layer (40 blocks and the MTP head) at 1 to 16 rows, in both
    precisions, forked against the same layer on one stream, byte for byte. Before each forked run it fills the shared
    rows' slot with NaN and holds the side stream back with copies, so a sum that does not wait for the join reads NaN.
  • docs/recipes/nemotron-3.5-super-vl.md says where the plans come from and what runs on the side stream.

Receipt

Raw receipts: receipts/nemotron/shared-expert-overlap (README.md maps every file to its binary).

  • Environment: this branch at 14c78e735cc9effb2dfb2c2dc53c54b93d06f481 against its base
    ed44eefbaefdfc6b52c0740ac9aeda3bbc5a36ba (the merge of nemotron: a prompt segment's buffers read the owner's shared-expert plans and pair ids #996 and nemotron: decode forms of Super's latent top-k and NVFP4 experts on CUDA, same bits #999). Both built from clean checkouts with
    zig build fatbins -Dsm=121 -Dnvcc=…, zig build install and zig build native (-Doptimize=fast -Dstrip=true -Dtarget=aarch64-linux-gnu.2.28 -Dcpu=baseline -Dversion=1.0.12, zig 0.17.0; builds.txt). tensorfold-native
    sha256: base f24658bd2f308a05495928e18f9d9e8240323bc11f4573feaef35deaefbdb93f, branch
    33d9dcf6e0064903ce08f723fd6b3559f8b3f03828e71200c9c02e5a314e8d6f; tf-cuda-test: base
    cc76592e24263fb8e3e5ca531a6339011aa2245f0f942fabc9f50b1900e7d4ef, branch
    07ad762d349ff5028dea72e24327fff73d5c7475a6b0b11919f3ee7431e6710e. A DGX Spark (GB10), CUDA 13.0 (nvcc
    13.0.r13.0), driver 580.173.02; the tf-cuda-test runs on a second DGX Spark.
    nvidia/NVIDIA-Nemotron-3.5-Super-VL-120B-A12B-NVFP4@82d93699acd3be9e4617c53360fe5b3f5dbeb1b3, served as
    tensorfold-native serve <checkpoint> --name super --no-update-check --prompt-cache-gib 0 on loopback with
    TF_HEAT_HIGH=85 TF_HEAT_LOW=75, everything else default (checkpoint math and MTP drafts on). Four holds on one
    node, each a fresh server, in the order base, branch, branch, base. Every receipt JSON carries source_commit and
    binary_sha256.

  • Exactness: in every hold bench_concurrent.py --levels 1,4 --tokens 256 --reps 3 --temperatures 0 --alone --serial
    gives 30 of 30 concurrent replies equal to their request alone and 4 of 4 alone runs equal to "draft": false. Both
    bench_openai prompts' drafted token_sha256 equals "draft": false, and the hashes are the same on the base and
    the branch: code 51e4c630298a14a1…, chat 161034fd0a090a34…. The cold prefills' 16-token replies hash the same
    too (58b069bf157f…). tf-cuda-test shared-fork:
    PASS shared-fork (checkpoint): 656 (layer, rows) cases, the forked delta byte-equal to the one-stream delta, and the
    same line for (full).

  • Decode window cost, tf-cuda-test window-profile MODEL 1,4,16 IDS at position 8,170 (medians of 5), base → branch:
    graph 48.859 → 47.474 ms at 1 row, 80.384 → 79.111 ms at 4 rows, 145.390 → 144.511 ms at 16 rows. On the branch at
    1 row, eager with marks, the 40 layers' experts_down span is 17.626 ms forked (plus 2.102 ms shared_wait) against
    20.427 ms on one stream.

  • Decode speed, bench_openai.py --tokens 256 --reps 3 --temperatures 0 (medians of 3; all runs in the receipt):

    run code (fibonacci-raw) tok/s prose (gpu-chat-no-think) tok/s
    base 1 46.72 36.06
    branch 1 47.85 36.78
    branch 2 47.93 36.82
    base 2 46.69 36.06
    median of 6 runs, base → branch 46.71 → 47.90 (+2.5%) 36.06 → 36.80 (+2.1%)

    bench_concurrent aggregate tok/s, base 1 / branch 1 / branch 2 / base 2: code x1 46.7 / 47.8 / 47.9 / 46.7, code x4
    135.8 / 138.2 / 138.3 / 135.8, chat x1 36.1 / 36.8 / 36.8 / 36.1, chat x4 108.3 / 100.4 / 100.4 / 108.2. The chat x4
    cell is lower on this tip's own window-cost table, not because of its launches: on the same table the tip is faster in
    every cell, chat x4 included (+1.5% and +1.6%, followup/). With its own, cheaper table the depth rule drafts less for
    four chat streams (139-140 rounds against 109-110), which lowers chat x4 on either build; that cost-rule interaction is
    not this pull request's to change.

  • Prompt speed: bench_cache.py --require-cold --tokens 16 --repeats 2 --streams 1 on an 8,186-token chat prompt
    (token ids in the receipt), cold first request ttft_s: base 4.454, 4.461, 4.456, 4.459; branch 4.452, 4.466, 4.458,
    4.458 (the last four from holds that ran only this request, in the order branch, base, base, branch). This
    prompt's chunks are wider than a window and run the same launches on one stream as before.

  • Tests run:

    • zig build test: 1377 passed, 7 skipped, 0 failed (base: 1376 and 7; the new one is the shared-plan layout
      test). zig build test-kernel-contract: 18 of 18. zig build test-golden: 309 of 319 equal, 0 unexpected
      differences (base: the same). zig build fuzz-cortheon: 7 of 7. zig fmt --check zig build.zig: clean.
      tools/zig/lean_check.py: 517 problems, the same 517 as the base, 0 new.
    • GPU: tf-cuda-test shared-fork 2 of 2 PASS (above). window-profile on the base and the branch (above).
    • Failing receipts: the base with only the test added fails, FAIL shared-fork: NoSideStream (a latent MoE gets no
      side stream there). 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.
  • Not run, and why: Metal (no Mac here; the change is CUDA-only). TP=2 across two GB10s: ranks keep one stream, but
    rank 0's own shares at window widths now read the load-time plan, and that path was not run. A non-latent Nemotron
    (Nano): Engine.forward keeps its side-stream condition, not run. tf-cuda-test kernel-contract: no kernel changed.
    Resumed against fresh prompts: not exercised separately; no prompt-path or cache code changes. The test's mutant was
    run only with the side stream held back, not without the hold.

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. (Resumed vs fresh: followup/resume.)
  • 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.)
  • 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. (Cold ttft_s above.)
  • 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, as prompt-segments does.)
  • 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.

…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.
…d of its own, tf_super_topk's bits

tf_super_topk takes a row's picks one argmax at a time on one warp. tf_super_topk_few, which calls of up to
launch.few_rows rows now take, ranks each expert on a thread of its own by how many others beat it (higher score,
then lower id): pick k is the expert k others beat, and once the finite scores run out every later pick is expert 0,
as tf_super_topk's repeated argmax over -inf gives. Scores, sums and weights are the same operations in the same
order. Prompt chunks keep tf_super_topk.

glue_ref.superTopk is the host twin; the glue test runs both forms against it at 512 experts, 22 picks, 2 shares,
rows 1/16/300, equal scores, fewer finite scores than picks, and the norm on and off. The glue tests' Rig moves to
glue_rig.zig, which keeps glue_tests.zig under 600 lines.
…mns a warp, four steps in flight, same bits

ck_experts.cu's grouped kernel is a template over a warp's n8 tiles and the steps of codes, scales and weights it
keeps in registers ahead of the mma. Prompt chunks keep 8 tiles and one step; calls of up to launch.few_rows token
rows take the _few pair, 4 tiles and 4 steps. Each column still takes its 64-input steps in order through the same
mma_fp4, and the epilogue is unchanged. Ck.down takes the call's token rows to choose. The modelopt test checks up
and down at 1 and 16 token rows byte-equal to the same pairs inside a 40-row call.
…-equal to the kernels they replace

tf_super_topk_few replaces tf_super_topk at decode-sized calls: gate 1 holds it to tf_super_topk's bytes and to
glue_ref.superTopk's picks on NaN and infinite logits and fewer finite scores than picks, gate 3 to tf_super_topk's
bytes at 512 experts and at 22, 31, 32 and 33.

tf_ck4_up_relu2_few and tf_ck4_down_f32_few replace tf_ck4_up_relu2 and tf_ck4_down_f32 at up to launch.few_rows
token rows: gates 1 and 3 compare their bytes with the prompt kernels' on the same plan (NaN and infinite alphas, a
NaN block scale; Super's routed and shared widths, and K at one to five steps), gate 4 runs mirrored FP4 sums exact
in fp32. Ck.run and Ck.warp_columns are public for the test to launch either form. The usage records are
kernel-contract-limits' over sm_80, sm_86, sm_89, sm_120 and sm_121 fatbins.
…, at buffer load, one per row count

The latent shared expert's pairs are the same (row, share) list at every layer, so initShared now plans each row count
up to max_rows into its own slice of the shared buffer and the expert pass reads that plan instead of planning the
shared expert again at every layer. Prompt passes wider than a window and the other ranks' jobs still plan at their
row count. A host test checks that the row counts' plans stay apart and inside the shared slot at one share and two.
…he side stream beside the routed experts

The latent shared expert reads only the block's input rows, so on one GPU a pass of up to max_rows rows forks it onto
the engine's side stream once the input is written. It runs on its own NVFP4 rows, activations and the plan built at
load while the router, the latent projection and the routed experts run on the main stream, which waits for it just
before the shared rows are summed. Every row's sums and their order are unchanged. Prompt passes wider than a window
and tensor-parallel ranks keep one stream. Engine.forward gives latent families the side stream: tf_plan_routed's
bounds hold only for the non-latent MoE, which plans with it.

`tf-cuda-test shared-fork MODEL` runs every latent MoE layer at 1 to 16 rows in both precisions with the side stream
held back by copies before the fork, against the same layer on one stream: the deltas must be byte-equal.

@cwschroeder cwschroeder left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Source/CPU review of the last two commits only, c6004831 and 14c78e73 above ed44eefb: I found no material source defect in the shared-plan slices, separate scratch/output regions or fork/join ordering. TP stays on one stream, and the main stream waits for the shared result before the final sum.

The actual host plan-layout test passes (2/2 including the imported config test), whole-tree Zig 0.17.0 formatting passes, and the safe aarch64 Linux driver/CLI cross-build completes 12/12 steps. No GPU binaries were executed here. All four current-head CI checks are green.

I verified all 122 receipt files against the pinned Git blobs at 7371337c and reproduced summary.md byte for byte. The audit, negative control and local build receipts check the reported full hashes and source/binary labels. Changing only a full hash's suffix makes the audit fail. This checks receipt consistency, not the underlying token IDs or binary provenance independently.

Two qualifications need to stay explicit:

  • The clean A/B/B/A holds show chat x4 at 108.3 / 100.4 / 100.4 / 108.2 aggregate tok/s, a 7.25% lower median on this tip. Earlier builds showing both levels do not establish that this change is uninvolved. Please qualify “the chat x4 cell is not this change's” as unresolved; startup calibration is a hypothesis until a trace or controlled comparison separates it.
  • The exactness checklist includes resumed vs fresh, but the receipt explicitly says that was not exercised. Please leave that combined item unchecked or supply its receipt. TP2's newly cached shared-plan path also remains untested, as disclosed.

The supplied GPU pass and mutant logs are useful evidence, but I did not rerun them. This is a scoped source/CPU review, not approval of the full stack or GPU/performance qualification.

Update: the description now keeps the 7.25% chat-x4 decrease unresolved, names calibration as a hypothesis, and leaves the combined exactness checklist unchecked. Both wording requests are addressed; the unrun TP2/resume paths and unresolved performance cause remain evidence limits.

@plotarmordev

Copy link
Copy Markdown
Contributor Author

Thanks for the audit. Both points, with new receipts under receipts/nemotron/shared-expert-overlap/followup/ (same
clean-checkout binaries: tip 33d9dcf6e0064903ce08f723fd6b3559f8b3f03828e71200c9c02e5a314e8d6f, base
f24658bd2f308a05495928e18f9d9e8240323bc11f4573feaef35deaefbdb93f; no code change; every JSON carries
source_commit and binary_sha256).

chat x4. The gap follows the window-cost table, not the build. Each build times its decode windows at its first
start and keeps the table under a key hashed from its own executable (core/lanes/cost_cache.zig), so in the published
holds every base server read the base's table and every tip server the tip's (keys 249d4493… and c620f43f…, found
by starting each build once with an empty HOME; followup/calibration/, followup/tables/). I then put one table
under both keys and ran eight fresh servers, base, tip, tip, base on the base's table, then tip, base, base, tip on the
tip's (followup/table-swap/summary.md), bench_concurrent --levels 1,4 --tokens 256 --reps 3 --temperatures 0 --alone --serial:

table read chat x4 base chat x4 tip code x4 base code x4 tip
base's 108.2, 108.4 110.0, 109.9 136.1, 136.1 137.9, 139.5
tip's 98.6, 98.5 100.3, 100.0 136.3, 135.9 137.9, 137.8

On the same table the tip is ahead in every cell (chat x4 +1.5% on the base's table and +1.6% on the tip's; every code x4 and x1 cell too), and either build
drops about 9% at chat x4 when it reads the tip's table. The server logs show how: on the tip's table all 12 concurrent
chat requests take 139–140 rounds (fewer, more often accepted drafts), against 109–110 rounds on the base's table, so
the depth rule drafts less for four chat streams.

So the drop is not this change's launches. It is the cost rule's response to the table the tip measures. That table
is the change's: it has cheaper windows, 45.87 against 46.96 ms at 1 row and 116.51 against 117.76 ms at 16. A second,
fresh calibration of each build came out close to its published table (45.39 / 116.48 ms tip, 46.89 / 117.67 ms base),
so I expect a tip server to land on the lower chat x4 level by default [inference: the recalibrated tables were not
served]. Tokens are unchanged: 30 of 30 concurrent equal to alone and 4 of 4 alone equal to "draft": false in all
eight holds. The PR body now says this: on the same table the tip is faster everywhere; with its own table chat x4 is
lower through the depth rule's choices, a cost-rule interaction this PR does not address.

Resumed vs fresh. Tip, default prompt cache (followup/resume/). A second chat turn (8,467 tokens) resumed from
the first turn's kept state (8,180 tokens cached) gave token_sha256 81b5f8e576552b1c…, as did the same turn
resumed again with "draft": false (8,461 cached), and the same turn on a fresh server (0 cached). The first turn
fresh and resumed (8,180 cached) both gave 857f11a3163c107f…. Resumed equals fresh, so the combined exactness item
can be ticked. TP=2 stays untested, as disclosed.

@ashhart

ashhart commented Oct 17, 2026

Copy link
Copy Markdown
Owner

Thanks @plotarmordev for the table swap and resumed/fresh hashes. They separate the same-table gain from the depth rule's response to each build's own costs. The fresh-calibration default outcome remains an inference because those recalibrated tables were not served.

That is stronger evidence than our earlier scheduling inference. We have prepared a conservative shared/TP schedule follow-up, but have not measured it fixing chat x4. Keep the default-table regression visible and compare the integrated policy in matched runs with drafts and caching on. The new resume receipt covers its pinned build; the changed TP2 cached-plan path and final merged performance are still owed.

Posted by Ash's AI Assistant Synthena

@plotarmordev

Copy link
Copy Markdown
Contributor Author

Thanks. Understood on keeping the default-table chat x4 result visible; the description states it as measured.

I can run the owed checks on two DGX Sparks (GB10, TP=2 over their direct link) once the integrated source is up: the TP2 cached shared-plan path (TP=2 tokens against TP=1 and against main), and matched runs of the integrated policy against main with drafts and the prompt cache on, including chat/code x1/x4 on fresh calibrations. Point me at the branch or commit and I'll post the receipts here in the same format.

@ashhart
ashhart merged commit 29aad5b into ashhart:main Oct 18, 2026
4 checks passed
ashhart added a commit that referenced this pull request Oct 18, 2026
…d 128-pair NVFP4 expert tiles, router tiles past 32 rows

The branch builds on #999's and #1002's heads, which this line already holds. Ten files took both sides. The router
keeps this line's slice widening for Bolt's rows and its wide top-k, with #1008's tile path in a logits call that the
latent router shares. The latent forward keeps the per-checkpoint window, both projection partial pointers and its
schedule, and adds #1008's share-sum combine and add. The scratch table keeps the router slices and lane partials and
takes #1008's activation rows. ck.zig keeps the 32-row decode bound beside the 128-row prompt bound. The contract and
runner keep every case they had and add #1008's. The eight new launches' records go to nemotron_prompt_records.zig,
which keeps registry.zig under 600 lines.
ashhart added a commit that referenced this pull request Oct 18, 2026
@ashhart

ashhart commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Thank you, @plotarmordev, for cached shared-expert plans and for reporting the chat-x4 regression alongside the lone-stream gains.

We merged the work for 1.1.0 in 29aad5b. Plans are built for each decode row count. Lone captured windows retain side-stream overlap; shared multisequence and two-rank windows keep the earlier schedule and continue batching through the common lanes.

Actual schedule controls stay with the change.

GB10 Super VL passed 17/17, concurrent 2/4 and chat 12/12; a standalone shared-plan throughput comparison remains unrecorded.

Posted by Ash's AI Assistant Synthena

BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…t once at load, and on one GPU the shared expert beside the routed ones

The branch builds on ashhart#999's earlier commits, which come in with it. Six files took both sides, keeping ashhart#999's
1,024-expert, 32-pick reference, the 32-row tests, Bolt's own layout, lanePartBytes and both projection partials, KV
pages, copy ownership, sibling plan borrowing and the shared cap and confidence policy. Latent cached plans cover the
checkpoint's window, Bolt keeps its fixed affine plans, and the side stream's join stays before its shared result is
read.
BlivionIaG pushed a commit to BlivionIaG/TensorFold that referenced this pull request Oct 20, 2026
…iles and 128-pair NVFP4 expert tiles, router tiles past 32 rows

The branch builds on ashhart#999's and ashhart#1002's heads, which this line already holds. Ten files took both sides. The router
keeps this line's slice widening for Bolt's rows and its wide top-k, with ashhart#1008's tile path in a logits call that the
latent router shares. The latent forward keeps the per-checkpoint window, both projection partial pointers and its
schedule, and adds ashhart#1008's share-sum combine and add. The scratch table keeps the router slices and lane partials and
takes ashhart#1008's activation rows. ck.zig keeps the 32-row decode bound beside the 128-row prompt bound. The contract and
runner keep every case they had and add ashhart#1008's. The eight new launches' records go to nemotron_prompt_records.zig,
which keeps registry.zig under 600 lines.
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.

3 participants