Repository navigation
Conversation
…ernels An NCCL kernel that waits for its peers holds its SMs, so a GEMM launched over every SM runs a second wave next to it. model.gemm_sm_carveout makes cuBLAS and CUTLASS GEMMs (torch._grouped_mm included) leave that many SMs free, via torch._C._set_sm_carveout_experimental, in the RL and SFT trainers. Off by default.
Collaborator
|
It looks like we only used this with PP in experiments? Don't think it had much other purpose for being. So let's table it until we have more advanced support for PP in prime-rl, wdyt? |
MarioSieg
marked this pull request as ready for review
December 3, 2026 19:44
This branch has not been deployed
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
model.gemm_sm_carveout(default unset, so off). When it is set, the RL trainer (rl/train.py) and the SFT/pretrain trainer (train.py) calltorch._C._set_sm_carveout_experimental(n)before model setup, so cuBLAS and CUTLASS GEMMs,torch._grouped_mmincluded, leavenSMs free.torch._grouped_mmwas 1.9x slower and dense GEMMs 1.11x slower. With a carve-out of 4 they ran at 1.00-1.12x their normal speed. When no kernel waits, the carve-out costs about 1%.NCCL_MAX_CTAS). A carve-out may change cuBLAS's kernel choice, so check losses rather than expecting bit-equality.docs/scaling.md.Test plan
torch._C._set_sm_carveout_experimental/_get_sm_carveout_experimentalexist and round-trip in torch 2.14.0, the pinned version (CPU build).ModelConfig(gemm_sm_carveout=4)parses, the default isNone, and0is rejected.uvx ruff check/uvx ruff format --checkon the changed files.Note
Low Risk
Opt-in performance tuning with a safe default of
None; only affects GEMM SM scheduling on GPU when explicitly set.Overview
Adds optional
trainer.model.gemm_sm_carveoutso cuBLAS/CUTLASS GEMMs (includingtorch._grouped_mm) reserve SMs instead of occupying the full GPU when NCCL collectives overlap.When set, both the RL trainer and the SFT/pretrain trainer call
torch._C._set_sm_carveout_experimentalduring startup, immediately after matmul precision is configured and before EP/parallel mesh setup. Default is unset (None), so behavior is unchanged unless configured.The FSDP scaling docs now document the knob, including guidance to size it at least to overlapping NCCL CTAs (
NCCL_MAX_CTAS) and expected tradeoffs (~1% GEMM cost when nothing is waiting vs. large slowdowns when a waiting NCCL kernel shares the device).Reviewed by Cursor Bugbot for commit bdb1d11. Bugbot is set up for automated code reviews on this repo. Configure here.