You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c5bc7e5
Browse filesBrowse the repository at this point in the historyBrowse files
authored
perf(deepseek-v41): opt-in torch.compile cores for mHC and fp32 RMSNorm (NVIDIA-NeMo#4079)
* perf(deepseek-v41): opt-in torch.compile cores for mHC and fp32 RMSNorm
The single-pass mHC math and the fp32 RMSNorm run as 4-5 full fp32 passes each in eager mode, and
HyperConnection.expand materializes a [batch, sequence, streams, streams, hidden] fp32 temporary before its
stream sum (1.3 GB per call at 4096 tokens). On the 16-node GB200 benchmark these elementwise kernels are 44 %
of the step. The arithmetic now lives in module-level cores that torch.compile can fuse:
- DeepseekV41TextConfig.hc_impl = "compile" (default "torch") wraps the projection, collapse and expand cores
once per process; the Sinkhorn normalization keeps its TileKernels/torch backend (compiling the 20-iteration
torch loop is slower than the fused kernel);
- BackendConfig.compile_norm (the existing generic knob, Kimi K3 pattern) wraps the fp32 RMSNorm core.
Modules call the dispatchers, so instances built before the hook still pick up the compiled core. Static shapes
only (dynamic=False): with dynamic shapes inductor keeps the broadcast temporary and expand runs at eager speed.
Compiled numerics are allclose to eager (bf16 streams within one ulp, fp32 coefficient gradients within 5e-4),
not bitwise-identical; both knobs default off.
1-GPU micro-benchmark (GB200, 4096 / 8192 tokens, fwd+bwd per call): expand 5.98 -> 0.75 ms / 11.86 -> 1.43,
collapse 1.24 -> 0.49 / 2.46 -> 0.42, projection 1.50 -> 1.06 / 2.73 -> 1.07, RMSNorm 0.82 -> 0.44 / 1.57 -> 0.44;
transient peak of expand 2.97 -> 0.51 GiB.
Signed-off-by: Yisong Li <yisongbetter@gmail.com>
* Apply batched suggestions from code review
Co-authored-by: jgerh <163925524+jgerh@users.noreply.github.com>
Signed-off-by: Alexandros Koumparoulis <153118171+akoumpa@users.noreply.github.com>
* test(deepseek-v41): runtime budget for the compiled-cores parity test
The test compiles the three mHC cores and the fp32 RMSNorm core for one
dtype and takes about 10 s on the CI runners, over the 5 s default budget
that main now applies to changed tests. Declare the exact budget with its
reason as the conftest asks.
Signed-off-by: Yisong Li <yisongbetter@gmail.com>
* refactor(deepseek-v41): compile_hc moves to BackendConfig
Review follow-up: the knob moves from DeepseekV41TextConfig.hc_impl (a model
config field, saved into config.json) to BackendConfig.compile_hc, next to
compile_norm and compile_situ, which select kernels the same way. Same hooks,
same compiled cores; recipes set model.backend.compile_hc: true instead of
model.config.text_config.hc_impl: compile. Tests and the model-coverage page
follow.
Signed-off-by: Yisong Li <yisongbetter@gmail.com>
* fix(deepseek-v41): compiled mHC cores run eager past the recompile limit
With fullgraph=True a run with more than recompile_limit distinct sequence
lengths raised FailOnRecompileLimitHit once a core passed the limit. The
cores have no graph breaks (asserted in the parity test), so fullgraph adds
nothing at runtime; without it dynamo skips the frame and the core runs
eager. New test lowers the limit to one and checks the second shape runs
eager with eager numerics.
Signed-off-by: Yisong Li <yisongbetter@gmail.com>
---------
Signed-off-by: Yisong Li <yisongbetter@gmail.com>
Signed-off-by: Alexandros Koumparoulis <153118171+akoumpa@users.noreply.github.com>
Co-authored-by: Alexandros Koumparoulis <153118171+akoumpa@users.noreply.github.com>
Co-authored-by: jgerh <163925524+jgerh@users.noreply.github.com>
Co-authored-by: Huiying <willwin.lee@gmail.com>
0 commit comments