Repository navigation
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
MultiLatentAttention: low-rank q/kv latents (RMSNorm fused into LayerNormLinear up-projections), decoupled RoPE/NoPE head split with a shared key rope head, DotProductAttention with kv_channels=(qk, v) for the cuDNN fused backend. DeepSeekV3MoE: fused sigmoid router with aux-loss-free expert bias and grouped top-k, routed experts as te.ops GroupedLinear+ScaledSwiGLU+ GroupedLinear (CuTe fused grouped MLP on supported HW), probs applied per-token in the activation, local permute/unpermute or NCCL expert parallelism via ep_dispatch/ep_combine, optional shared expert. DeepSeekV3Layer: pre-RMSNorm + MLA and dense LayerNormMLP (RMSNorm, swiglu) or MoE with residual connections. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
run_deepseek_ep.py checks the EP path against the all-experts-local path numerically (forward, input/gate grads, all-reduced expert wgrads) and smoke-tests the full layer with EP. Also size the default EP recv capacity for per-expert alignment padding and the fused grouped MLP's row-count requirement. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
The per-expert wgrad check called all_reduce on different tensors per rank (rank-local experts), corrupting the reference grads; reduce every expert's grad on every rank instead. Also pass zero-filled recv/grad buffers to ep_dispatch/ep_combine so alignment-padding rows inside the grouped-GEMM m_splits can never poison expert wgrads. Verified on lyris (4x GB300, arm64): run_test_deepseek_ep.sh passes on all ranks (EP forward/dgrad/gate-grad/expert-wgrad match the all-local reference; full-layer EP smoke passes). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Move the Triton MLA RoPE kernels (Megatron-LM fused_mla_yarn_rope_apply port) from tests/pytorch/attention/ mla_rope_utils.py into models/deepseek_v3/mla_rope.py and use them in MultiLatentAttention: the q kernel rotates the rope slice in place and the kv kernel assembles key/value in a single pass, removing the torch.cat/expand/contiguous copies (~10% of layer GPU time). PyTorch fallback (same convention) covers missing Triton and bshd. Fix a latent bug from the test util: the q backward kernel assumed a contiguous incoming gradient, but cuDNN attention backward can hand over a strided one (allocator-state dependent IMA). The old test file stays as a compat shim. Add a Triton-vs-PyTorch parity test. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Maps HF DeepseekV3DecoderLayer weights into DeepSeekV3Layer (GLU interleave for routed experts, fused latent norms) and checks forward and input grads match within bf16 tolerance. Expose layernorm_epsilon on MultiLatentAttention (HF latent RMSNorms use 1e-6). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
docs/api/pytorch_models.rst: usage (local and EP), fused-path notes, HF checkpoint weight mapping, and the class API; linked from the PyTorch API page via a toctree entry. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Keep the verified weight-mapping table in the docs; the comparison itself stays as an out-of-tree script. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
…scripts Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
…eek_v3.mla_rope directly Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
…rical comparison Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
…hell launcher Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
… grouped GEMM in local MoE path Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
…; expose MLA softmax_scale; clean docstrings Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
…ters Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
… routed experts Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
…ad of syncing bincount Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
…p standard layers, autocast and other utilities Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
| drop_on_overflow = get_ep_drop_on_overflow() | ||
| if drop_on_overflow is None: | ||
| raise RuntimeError("EP requires ep_bootstrap before constructing DeepSeekV3MoE.") |
There was a problem hiding this comment.
Model construction requires bootstrap
If a caller builds a DeepSeekV3MoE with ep_group before calling ep_bootstrap(), this new check raises during construction. Previously, bootstrap was required when creating the EP buffer for forward, so callers could build the model first and bootstrap before execution. That workflow can no longer instantiate the layer.
Remove caller-supplied receive and gradient tensors from the DeepSeek Sequential path. Keep per-call EpBuffer routing state for overlapping forward/backward calls. Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Use supported MLA and expert dimensions in DeepSeek sanity tests and check finite outputs and gradients. Restrict NVFP4 MoE coverage to the BF16 dtype supported by grouped Hadamard transforms. Align Float8BlockScaling expert rows to 128 for grouped quantization, enforce its split-accumulator requirement in legacy grouped GEMM, and abort invalid grouped block-scaling row layouts even when device assertions are disabled. Add numerical MoE/GEMM coverage and isolated invalid-layout regressions. Validated on B100 and H100 with targeted normal/debug PyTorch tests. Rebuilt the common library in Release on H100: 44 grouped-quantization PyTorch cases and 144 existing C++ cases pass. Python L0 lint, formatting and pre-commit checks pass. Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Restore grouped FP8 block-scaling device error handling and remove the associated invalid-row subprocess regression to keep this PR focused on the DeepSeek layer. Retain the MoE padding, grouped GEMM accumulation and sanity coverage fixes. Both restored files match their pre-b14c09ff versions exactly. Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
| @@ -0,0 +1,281 @@ | |||
| # Copyright (c) 2022-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved. | |||
There was a problem hiding this comment.
@ksivaman, you proposed offline that we should add MoE layer and MLA to general layers and have DeepSeekV3TransformerLayer one in models section. I agreed with this approach by then, but now I am a bit skeptical.
We have TransformerLayer and MultiHeadAttention in TE which become really big over the time, and I am afraid that MoELayer may have similar problem in the future. Also I think the future trend will be rather using small building blocks by agents and this layers should be more like examples.
What do you think?
cc: @ptrendx
| PyTorch | ||
| ======= | ||
|
|
||
| .. autoapiclass:: transformer_engine.pytorch.autocast(enabled=True, calibrating=False, recipe=None, amax_reduction_group=None) |
There was a problem hiding this comment.
Why move the autocast API here?
| These functions apply the decoupled RoPE used by multi-latent attention (MLA). | ||
| The rotary input channels contain interleaved pairs; rotated outputs use | ||
| NeoX half-split order. ``sbhd`` denotes sequence, batch, head and channel axes; | ||
| ``bshd`` exchanges the first two axes. Build the cosine/sine tables on the | ||
| same device as the tensors, with one row per sequence position. |
There was a problem hiding this comment.
Could you make that more human-readable? If there is a formula we could write here that is being computed that would be good. We don't need to explain here what sbhd or bshd is.
| A forward + backward benchmark of one `DeepSeekV3Layer`: RMSNorm, multi-latent attention, | ||
| and MoE with a shared expert. Routed experts are sharded across GPUs using NCCL EP. | ||
|
|
||
| ## Results |
There was a problem hiding this comment.
I'm not super sure whether we should include those results here since they will relatively quickly become stale. If we want to do that, we should at least say which TE version was used to gather them. We should probably then also include other implementations, like MoK, rather than just pure pytorch.
| The following NCCL EP requirements apply to `--impl te`. The naive variants use | ||
| ordinary NCCL collectives and can also run on older GPUs without NVLink. | ||
|
|
||
| - SM90 or newer GPUs connected with NVLink (NCCL EP falls back to the network transport and |
There was a problem hiding this comment.
If it deadlocks on the PCI only nodes then that is a bug we should raise and have a fix in NCCL EP. I don't think we need to share the exact failure mode of unsupported configurations - feels like Claude trying to be too helpful.
| - NCCL >= 2.30.4, PyTorch >= 2.11 (symmetric memory), Transformer Engine built with the | ||
| `3rdparty/nccl-extensions` submodule. |
There was a problem hiding this comment.
We should say which env variable needs to be enabled/how to check the support is there in the precompiled version rather than saying which submodule is involved.
| ### C. Benchmark configuration | ||
|
|
||
| | Setting | Value | | ||
| |---|---| | ||
| | hardware | GB200 (SM100), one node; GB300 (SM103), one or two nodes; 4 GPUs per node, both GB300 nodes in one NVLink domain (MNNVL) | | ||
| | software | CUDA 13.3, NCCL 2.30.7, PyTorch 2.13.0a0+9186a08b2c.nv26.07, cuDNN 9.26, cuDNN Frontend 1.29.0, CUTLASS DSL 4.6.2 | | ||
| | NVIDIA driver | GB200: 580.173.02; GB300: 580.173.10 | | ||
| | `--dsv3` dims | hidden 7168, 128 heads, MLA q_lora 1536 / kv_lora 512 / nope 128 / rope 64 / v 128, expert ffn 2048, shared expert ffn 2048 | | ||
| | MoE | 8 local experts per rank (32 on 4 GPUs, 64 on 8), top-k 8, 4096 tokens per rank | | ||
| | precision | bf16 params and activations; `--recipe mxfp8` = MXFP8 block scaling for the expert GEMMs and dense projections | | ||
| | timing | fwd + bwd, 5 warmup, 10 timed iterations per run, median of 3 runs; wall-clock timing with CUDA synchronization, no CUDA graphs or profiler | | ||
| | environment | `OMP_NUM_THREADS=8`, `NVTE_GROUPED_LINEAR_SINGLE_PARAM=0`, `NVTE_ALLOW_NONDETERMINISTIC_ALGO=1`, `NVTE_FLASH_ATTN_V2=1`, `NVTE_FLASH_ATTN_V3=0`, `NVTE_FLASH_ATTN_V4=0`; EP buffer reused | | ||
|
|
||
| Each run reuses a normally distributed random input and backpropagates an all-ones | ||
| output gradient. Parameter and input gradients are cleared before each iteration. |
There was a problem hiding this comment.
This should be part of those "Results" section. Also, that results section should be later, not right away.
| ### D. Profiling with nsys | ||
|
|
||
| The timed iterations run inside a `torch.cuda.profiler.start()` / `stop()` window, so | ||
| `-c cudaProfilerApi` records only them, one NVTX range per iteration: | ||
|
|
||
| ```bash | ||
| NSYS=1 NVTE_CUTEDSL_FUSED_GROUPED_MLP=1 bash run_deepseek_v3_layer_ep.sh --dsv3 --recipe mxfp8 | ||
| # -> results/deepseek_v3_layer_ep_<hostname>.nsys-rep | ||
| nsys stats --report cuda_gpu_kern_sum results/deepseek_v3_layer_ep_<hostname>.nsys-rep | ||
| ``` | ||
|
|
||
| The launcher wraps `torchrun`, so all local ranks land in one report. For multi-node runs put | ||
| the same `nsys profile ... -o <path>_%q{SLURM_NODEID}` in front of `torchrun` on each node. | ||
|
|
||
| Running under `nsys` adds about 1.5 ms per iteration to these numbers. |
| ### E. TE kernel breakdown | ||
|
|
||
| The profiles in sections E and F predate the September 30 measurements and were not | ||
| regenerated for the results above. | ||
|
|
||
| 8 GPUs, `--dsv3`, MXFP8 fused. Per GPU and iteration, from `nsys stats --report cuda_gpu_kern_sum` | ||
| on one node (kernel time 10.8 ms; the iteration takes 10.5 ms without the profiler). Profiling adds | ||
| skew between nodes, so the wait row is taken from the node that was not slowed down by nsys. | ||
|
|
||
| | Group | ms | Kernels | | ||
| |---|---:|---| | ||
| | NCCL EP all-to-all | 2.3 | `nccl_ep_jit_ht_dispatch_kernel` (1.05), `nccl_ep_jit_ht_combine_kernel` (1.29), each twice per iteration (fwd + bwd) | | ||
| | NCCL EP local permute | 0.6 | `local_permute_dup/reduce`: staging buffer to expert-major layout, zero-filled padding | | ||
| | rank skew wait | 0.5 | `ncclDevKernel_AllGather_RING_LL` (routing-map all-gather in prepare, ~0.06 ms of transfer); the first collective of the layer absorbs load imbalance between ranks | | ||
| | fused grouped MLP (cuDNN, MXFP8) | 2.4 | fc1+SwiGLU fwd (0.53), fc2 fwd (0.82), dGLU bwd (0.31), wgrad (0.78) | | ||
| | MXFP8 quantization | 1.1 | `group_quantize_mxfp8` on the recv buffer (0.4), `quantize_mxfp8_kernel_cast_only` for dense GEMM inputs (0.7) | | ||
| | dense MXFP8 GEMMs (MLA projections, shared expert) | 1.4 | `nvjet_sm103_qqtst_*` | | ||
| | attention (cuDNN SDPA) | 0.9 | flash fprop (0.18) + bprop (0.51) + dq / dO helpers | | ||
| | RMSNorm, RoPE, adds | 0.8 | `rmsnorm_fwd/bwd` (0.39), `rotary_*_kv` (0.18), residual adds (0.2) | | ||
|
|
||
| Both nodes sit in one NVLink domain, so dispatch and combine move roughly 470 MB per GPU per | ||
| call over NVLink at close to link bandwidth; on an InfiniBand-connected pair of nodes the | ||
| all-to-all share would be much larger. | ||
|
|
||
| ### F. Naive kernel profiles | ||
|
|
||
| Per GPU and iteration, the `naive` MoE spends (8 GPUs, kernel time 24.0 ms of a 27.5 ms | ||
| iteration; the rest is host syncs and launch gaps): | ||
|
|
||
| | Group | ms | Details | | ||
| |---|---:|---| | ||
| | expert and dense GEMMs (`nvjet_*`) | 6.5 | 8 separate GEMM pairs per rank instead of one grouped GEMM, plus the MLA projections | | ||
| | elementwise adds | 3.6 | `index_add` and its backward, residuals | | ||
| | `ncclDevKernel_SendRecv` | 3.4 | 8 all_to_all launches per iteration (tokens and probs fwd/bwd, results fwd/bwd, counts, indices) | | ||
| | indexing kernels | 3.3 | `x[tok]`, `nonzero` masks, `index_copy`, `index_fill`, `indexing_backward`, sorts | | ||
| | `FillFunctor` (zeros) | 2.5 | `zeros_like` for the per-expert output buffer and `index_add` targets | | ||
| | device-to-device copies | 2.3 | `index_copy` and gathers materialising per-expert slices | | ||
| | attention, norms | 1.1 | same as in the TE variant | | ||
|
|
||
| #### Historical `naive_grouped` profile | ||
|
|
||
| 8 GPUs, kernel time 17.1 ms of a 17.2 ms iteration. This profile predates the | ||
| router-gradient fix and omits probability-gradient communication. It is retained for | ||
| reference, not for direct comparison with the other profiles or headline timings. | ||
|
|
||
| | Group | ms | Details | | ||
| |---|---:|---| | ||
| | `ncclDevKernel_SendRecv` | 3.8 | 7 all_to_all launches in this historical run; the current implementation has 8 | | ||
| | grouped GEMMs (`nvjet_*_ptrGroup_*`) | 4.1 | fc1 / fc2 forward, dgrad, wgrad as grouped GEMMs, same as in `te` | | ||
| | sorting rows by expert and back | 2.6 | `argsort`, gathers (`x[tok]`, `x_recv[by_expert]`), `index_copy`, `indexing_backward` | | ||
| | dense GEMMs (MLA projections, shared expert) | 2.4 | same as in `te` | | ||
| | elementwise adds | 0.7 | `index_add`, residuals | | ||
| | attention, norms | 1.1 | same as in `te` | | ||
|
|
||
| #### Interpreting the current results | ||
|
|
||
| In the headline GB300 BF16 timings, `naive` -> `naive_grouped` reduces iteration time by | ||
| 10.5 ms on 4 GPUs and 10.6 ms on 8 GPUs. `naive_grouped` -> `te` saves another | ||
| 4.4 ms and 3.0 ms, respectively. These are end-to-end differences between | ||
| implementations, not isolated measurements of Python-loop or communication overhead. | ||
|
|
||
| NCCL EP dispatch and combine write directly into the expert-major layout and zero-fill | ||
| the padding. Both naive variants synchronise with the host to obtain the all_to_all | ||
| split sizes; TE avoids those synchronizations. MXFP8 is only supported by `te`: the naive | ||
| variants would need per-expert row counts padded to the MXFP8 block size. | ||
|
|
There was a problem hiding this comment.
I don't believe those sections are useful.
| ### G. EP implementation notes | ||
|
|
||
| - `ep_bootstrap` must be given the same recv capacity the layer uses: | ||
| `DeepSeekV3MoE.ep_recv_capacity(ep_size, tokens_per_rank, topk, num_local_experts)`. | ||
| - Per-expert zones in the recv buffer are aligned to 256 rows; the fused grouped MLP requires | ||
| that alignment. | ||
| - The recv and grad buffers are allocated uninitialized: NCCL EP zero-fills the alignment | ||
| padding between experts itself. |
There was a problem hiding this comment.
Are those decisions you used for running the benchmark? If so, that should be included in the benchmark setup section (via something like "env variable X was set to Y"). Especially the last point reads like an implementation detail of the example implementation and is not needed.
| if any(isinstance(tensor, Float8BlockwiseQTensorStorage) for tensor in (*A, *B)): | ||
| use_split_accumulator = True |
There was a problem hiding this comment.
There was a talk about removing the split accumulator entirely. @vthumbe1503
Restore autocast to its original docs section, describe MLA RoPE with a formula, and shorten the example README: drop profiling and kernel breakdown sections, merge the benchmark configuration into Results and point to NVTE_WITH_NCCL_EP instead of the NCCL EP submodule. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
…e standalone example Signed-off-by: Pawel Gadzinski <pgadzinski@nvidia.com>
| y.sum().backward() | ||
| optimizer.step() | ||
| optimizer.zero_grad() | ||
| dist.all_reduce(layer.mlp._last_tokens_per_expert, group=ep_group) |
There was a problem hiding this comment.
Ranks train different shared weights
The EP training example builds and updates the router, shared expert, attention, and norms independently on each rank. EP exchanges work for routed experts, but does not keep these shared weights in sync. Reducing _last_tokens_per_expert only synchronizes routing counts, not gradients. The ranks therefore train different shared parts of the model.
Broadcast the replicated parameters at startup and reduce their gradients before optimizer.step(). Keep the sharded expert weights separate.
| for step in range(num_steps): | ||
| with te.autocast(recipe=MXFP8BlockScaling()): | ||
| y = layer(x, ep_buffer=ep_buffer) | ||
| y.sum().backward() | ||
| optimizer.step() | ||
| optimizer.zero_grad() |
There was a problem hiding this comment.
Usage examples use undefined names
Both usage examples call optimizer.step() without defining optimizer. The EP example also uses an undefined num_steps. Users copying either snippet hit a NameError before completing a training step. Since the runnable example was removed, define these values in the replacement snippets.
Description
Adds
transformer_engine.pytorch.models, a namespace for model-specific layers built from TE modules, with a DeepSeek-V3 transformer layer analogous toTransformerLayer.MultiLatentAttention: low-rank q/kv latents with RMSNorm fused into the up-projections, decoupled RoPE/NoPE heads,DotProductAttentionwith asymmetric head dims (cuDNN fused attention), fused Triton MLA RoPE kernels, optional YaRN scaling, TP.DeepSeekV3MoE: fused sigmoid router with aux-loss-free bias and grouped top-k, experts aste.ops.Sequential(GroupedLinear, ScaledSwiGLU, GroupedLinear)(auto-fuses into the CuTe grouped MLP where available), local routing or expert parallelism over NCCL EP, optional shared expert.DeepSeekV3Layer: pre-RMSNorm + MLA, then denseLayerNormMLPorDeepSeekV3MoE, residual connections.Type of change
Changes
transformer_engine/pytorch/models/deepseek_v3/:MultiLatentAttention,DeepSeekV3MoE,DeepSeekV3Layer, MLA RoPE kernels; exported viatransformer_engine.pytorch.modelsModel-specific layerssection indocs/api/pytorch.rsttests/pytorch/test_models.py(RoPE, YaRN, MoE vs dense reference),test_sanity.py::test_sanity_deepseek_v3_layer(all recipes),tests/pytorch/distributed/test_models.py(EP vs all-experts-local, L1)examples/pytorch/deepseek_v3/: runnable EP example with a plain-PyTorch MoE baseline and a README with measurementsPerformance
DeepSeekV3Layerwith DeepSeek-V3 dims, 8 experts per rank, top-k 8, 4096 tokens per rank, fwd+bwd, bf16 unless noted. GB300, 4 GPUs per node, one NVLink domain.naive= torchall_to_all_single+ Python loop of per-expert MLPs,naive_grouped= same all_to_all with a TE grouped GEMM,te=DeepSeekV3MoE. Attention and norms identical in all three.naivenaive_groupedtete, MXFP8te, MXFP8 fused grouped MLPWhere the time goes in the optimized variant (
te, MXFP8 fused, 8 GPUs), per GPU and iteration, fromnsys stats --report cuda_gpu_kern_sum(kernel time 10.8 ms, iteration 10.5 ms without the profiler; no memsets or copies left):nccl_ep_jit_ht_dispatch_kernel(1.05),nccl_ep_jit_ht_combine_kernel(1.29), each twice per iteration (fwd + bwd)local_permute_dup/reduce: staging buffer to expert-major layout, zero-filled paddingncclDevKernel_AllGather_RING_LL(routing-map all-gather in prepare, ~0.06 ms of transfer); the first collective of the layer absorbs load imbalance between ranksgroup_quantize_mxfp8on the recv buffer (0.4),quantize_mxfp8_kernel_cast_onlyfor dense GEMM inputs (0.7)nvjet_sm103_qqtst_*rmsnorm_fwd/bwd(0.39),rotary_*_kv(0.18), residual adds (0.2)For comparison the
naivevariant spends 3.4 ms in all_to_all, 6.5 ms in 8 separate GEMM pairs, and ~12 ms in indexing, zero-fills, copies and adds;naive_groupedremoves the loop (about 10.5 ms) and NCCL EP the remaining all_to_all plus sort / gather / scatter overhead (2.9 ms on 8 GPUs). Full breakdowns inexamples/pytorch/deepseek_v3/README.md.Checklist:
🤖 Generated with Claude Code