feat: size routed_experts carry dtype from the model's expert count - #3113
Merged
terrykong merged 1 commit intoJul 17, 2026
Merged
Conversation
Contributor
Author
|
/ok to test c4074b7 |
Resolve the narrowest signed dtype that fits expert ids plus the -1 missing-route sentinel (int8 <=128 experts, int16 <=32768, int32 beyond; int16 fallback when undetectable) once per run, and use it at every routed_experts ingestion point instead of hardcoded int32. Shrinks route payloads 2-4x across message logs, transports, replay buffers, and checkpoints. A one-time per-process range check turns a mis-detected expert count into a loud error instead of silent wraparound. The Megatron replay install still converts to int64 at the gather site, so training math is unchanged. Signed-off-by: Zeyu Zhou <zezhou@nvidia.com>
zyzhou5
force-pushed
the
zezhou/r3-routed-experts-int16
branch
from
July 8, 2026 21:36
c4074b7 to
8520240
Compare
Contributor
Author
|
/ok to test 8520240 |
Contributor
|
Thanks a lot. @zyzhou5 LGTM! |
ZhiyuLi-Nvidia
approved these changes
Jul 13, 2026
terrykong
approved these changes
Jul 17, 2026
arnavk-nvidia
pushed a commit
that referenced
this pull request
Jul 17, 2026
…3113) Signed-off-by: Zeyu Zhou <zezhou@nvidia.com> Signed-off-by: Arnav Kundu <arnavk@nvidia.com>
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.
What does this PR do ?
Resolve the narrowest signed dtype that fits expert ids plus the -1 missing-route sentinel (int8 <=128 experts, int16 <=32768, int32 beyond; int16 fallback when undetectable) once per run, and use it at every routed_experts ingestion point instead of hardcoded int32. Shrinks route payloads 2-4x across message logs, transports, replay buffers, and checkpoints. A one-time per-process range check turns a mis-detected expert count into a loud error instead of silent wraparound. The Megatron replay install still converts to int64 at the gather site, so training math is unchanged.
Validation
We observed no regression after the change.
