Skip to content

feat: size routed_experts carry dtype from the model's expert count - #3113

Merged
terrykong merged 1 commit into
NVIDIA-NeMo:mainfrom
zyzhou5:zezhou/r3-routed-experts-int16
Jul 17, 2026
Merged

feat: size routed_experts carry dtype from the model's expert count#3113
terrykong merged 1 commit into
NVIDIA-NeMo:mainfrom
zyzhou5:zezhou/r3-routed-experts-int16

Conversation

@zyzhou5

@zyzhou5 zyzhou5 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

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.
Screenshot 2026-07-08 at 1 48 07 PM

@zyzhou5
zyzhou5 requested review from a team as code owners July 8, 2026 03:59
@copy-pr-bot

copy-pr-bot Bot commented Jul 8, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@zyzhou5 zyzhou5 added the CI:L1 Run doctests, unit tests, and functional tests label Jul 8, 2026
@zyzhou5

zyzhou5 commented Jul 8, 2026

Copy link
Copy Markdown
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
zyzhou5 force-pushed the zezhou/r3-routed-experts-int16 branch from c4074b7 to 8520240 Compare July 8, 2026 21:36
@zyzhou5

zyzhou5 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 8520240

Comment thread nemo_rl/environments/nemo_gym.py
Comment thread nemo_rl/models/generation/interfaces.py
@ZhiyuLi-Nvidia

Copy link
Copy Markdown
Contributor

Thanks a lot. @zyzhou5 LGTM!

@terrykong
terrykong merged commit f2705e0 into NVIDIA-NeMo:main Jul 17, 2026
94 checks passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:L1 Run doctests, unit tests, and functional tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants