Repository navigation
cuda: the expert plan as a shared module (cuda/grouped.zig); Nemotron routes through it - #558
Merged
Merged
Conversation
The plan that groups routed pairs by expert (experts.route on experts.cu's plan kernels) lived inside families/nemotron. It moves to cuda/grouped.zig (maxItems, Plan, Router.route) with the same kernels, grids and arguments; Nemotron keeps its names as aliases and Ops.plan delegates, so no caller changes. tf-cuda-test grouped-plan compares members, items and counts with experts.route for one-block and wide plans at tiles 16 and 64.
jschmied
marked this pull request as ready for review
October 9, 2026 19:52
This was referenced Oct 10, 2026
Closed
Owner
|
Thank you, @jschmied. This is merged into main (4c1e4cf), with your commit as it was, and it ships in the next We checked it on a GB10. With the plan in one module, the MoE ports you listed (#481, #472, #509) can share it instead of carrying copies. |
otarkhan
pushed a commit
to otarkhan/TensorFold
that referenced
this pull request
Oct 10, 2026
This was referenced Oct 10, 2026
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
…ig); Nemotron routes through it
BlivionIaG
pushed a commit
to BlivionIaG/TensorFold
that referenced
this pull request
Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Draft for #548's second step, as a concrete example of the shape it proposes: the expert plan that groups routed pairs by expert (
experts.routeonexperts.cu's plan kernels) moves out offamilies/nemotronintozig/src/cuda/grouped.zig, and Nemotron routes through it. Behaviour doesn't change: same kernels, same grids, same arguments.cuda/grouped.zig:maxItems,Plan(the scratch the plan writes) andRouter(resolvefrom the loaded experts module,route= the one-block plan up to 1,024 pairs, else rank, offsets and scatter).families/nemotron/cuda_kernels.zig:PlanandmaxItemsbecome aliases,Kernelsholds aRouterinstead of four plan functions, andOps.plandelegates. No caller changes. The family is 42 lines shorter.tf-cuda-test grouped-plan <dir>withoracle/grouped_plan.py: members, items and counts againstexperts.route(python-0.6) for one-block and wide plans at tiles 16 and 64 (1 to 2,048 rows, 7 and 9 slots, 33 and 385 experts).Every MoE port needs this plan: Kolibri's FP8 experts (#481), Flash Next's NVFP4 experts (#472) and GLM's EXL3 experts (#509). With it here, the per-format expert kernels can share one plan instead of each carrying its own.
Receipts so far:
zig build testpasses on GB10 (Linux aarch64), the CUDA kernels build for sm_121, andlean_checkis clean for the touched files.Receipts on GB10 (DGX Spark, sm_121, CUDA 13.0):
tf-cuda-test grouped-plan: members, items and counts equalexperts.route's bytes in all 5 cases: one-block plans at 1 and 3 rows, wide plans at 300 rows (tile 64), 512 rows over 385 experts (tile 16) and 2,048 x 9 pairs over 385 experts (tile 64).Nemotron 3.5 Lightning (
TensorFold/NVIDIA-Nemotron-3.5-Lightning-30B-A3B-MLX-4bit@d9d758fb, the 1.0.2 release'ssm121kernel set),tensorfold run,main(78ee0f4) against this branch built the same way. Three prompts (11, 20 and 1,090 tokens; the long one's prefill takes the wide plan), greedy and sampled (temperature 0.8, top_k 20, top_p 0.95, seed 7). All six reply hashes are equal:5923b40d570bbothe8332a360154bothc5c4b6cb25f0bothb8d9ce6085d8both95bce61a71a7botha6961a8c7589bothOne sampled run took 60 rounds on this branch and 61 on
main, with the same reply. MTP's draft length follows measured round costs, so the round count can differ between runs; the reply can't.If you'd rather keep the plan inside the families, say so and I'll close this.