Repository navigation
[trainer throughput] Fuse Nemotron's squared-ReLU expert activation - #320
Closed
Micah Yong (micahtyong) wants to merge 1 commit into
Closed
Micah Yong (micahtyong) wants to merge 1 commit into
Micah Yong (micahtyong) wants to merge 1 commit into
Conversation
Micah Yong (micahtyong)
force-pushed
the
micah/nemotron-perf/gap-2-fused-squared-relu
branch
from
November 17, 2026 02:22
ab2ebc6 to
f52fcfd
Compare
Micah Yong (micahtyong)
changed the base branch from
micah/nemotron-perf/gap-1-expert-grouped-gemm
to
main
November 17, 2026 02:46
Micah Yong (micahtyong)
force-pushed
the
micah/nemotron-perf/gap-2-fused-squared-relu
branch
2 times, most recently
from
November 17, 2026 03:07
0a4960d to
5676d17
Compare
Each Nemotron expert activation ran as separate kernels: the squared ReLU, a multiply by the router probability that promoted the activation to fp32, and a cast back to bf16, with the same pattern in backward. Megatron has one fused kernel for this behind use_fused_weighted_squared_relu, but Miles does not pass that setting through, so Spindle sets it on the model provider when a recipe asks with FUSED_WEIGHTED_SQUARED_RELU=1. The Nemotron 3.5 Lightning 64K recipe does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Micah Yong (micahtyong)
force-pushed
the
micah/nemotron-perf/gap-2-fused-squared-relu
branch
from
November 17, 2026 03:32
5676d17 to
022960f
Compare
Micah Yong (micahtyong)
marked this pull request as ready for review
November 17, 2026 03:37
Micah Yong (micahtyong)
requested a review
from Kailash Ranganathan (kailash109)
as a code owner
November 17, 2026 03:37
Collaborator
Author
|
Closing. This turns on Megatron's fused squared-ReLU expert activation by patching the Miles model provider, which upstream Miles doesn't do; the measured gain was about 5% of step time on short rows and not clearly positive on long rows. If it's worth having, the cleaner route is a small upstream Miles change that passes |
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.
Summary
Nemotron-3.5-Lightning's experts use a squared-ReLU activation, multiplied by the router's probability for each token. Megatron runs this as several separate elementwise kernels, with a round trip through fp32, and takes 0.86 s of a training step on short rows. Megatron already has a fused kernel for exactly this,
use_fused_weighted_squared_relu, but Miles does not pass the setting through.This PR turns it on from Spindle when
FUSED_WEIGHTED_SQUARED_RELU=1, which the 64k Lightning recipe sets. The 256k recipe sets it off because it hasn't been measured there.E2E results
Setup: nemotron35-lightning-30b-a3b-lora-64k with the earlier PRs in this stack, 2x H200, stock Tinker SDK, LoRA rank 32. Times are the trainer's
forward_backwardmedian. Per-token log probabilities are within run-to-run noise.The activation itself goes from 0.86 to 0.03 s per step.