vllm.models.nemotron_shortcut.nvidia.moe.experts
¶
Nemotron Shortcut routed experts and their quantization methods.
The experts are non-gated: relu2(c * tanh(x / c)) between the two
projections, with c the checkpoint's activation_clamp_value. The MoE
plumbing sees the plain RELU2_NO_MUL activation; the clamp is carried on
NemotronShortcutMoEConfig and only the experts classes in this package read it.
NemotronShortcutRoutedExperts therefore selects every experts implementation
itself and never goes through the generic MoE oracles, which would pick a
backend that drops the clamp.
Classes:
-
DispatchedTokens–The tokens this rank's experts run, as the dispatch returns them.
-
NemotronShortcutMoEMethod–Unquantized experts.
-
NemotronShortcutModelOptMxfp8MoEMethod–ModelOpt MXFP8 experts.
-
NemotronShortcutModelOptNvFp4MoEMethod–ModelOpt NVFP4 experts on FlashInfer's CuTe-DSL fused MoE.
-
NemotronShortcutMxfp8TritonExperts–The reference experts on MXFP8 weights (Triton
dot_scaled). -
NemotronShortcutRoutedExperts–Routed experts that select one of the clamp-aware implementations.
-
NemotronShortcutTritonExperts–The reference experts:
kernels.routed_expertson BF16 weights.
Functions:
-
apply_moe_kernel–Run a modular MoE kernel, keeping the experts' accumulation dtype.
-
combine_tokens–kernel's finalize: reducefused_outintooutputon this rank. -
dispatch_tokens–kernel's prepare: quantizexif the experts want it, then dispatch. -
run_experts–The experts' output for the dispatched tokens, before the combine.
-
select_mxfp8_experts–CuTe-DSL MXFP8 experts where supported, else the Triton reference.
DispatchedTokens
dataclass
¶
The tokens this rank's experts run, as the dispatch returns them.
Source code in vllm/models/nemotron_shortcut/nvidia/moe/experts.py
NemotronShortcutMoEMethod
¶
Bases: FusedMoEMethodBase
Unquantized experts.
FlashInfer's CUTLASS fused MoE where it implements the clamp, else the
Triton reference experts; --moe-backend triton forces the latter.
Source code in vllm/models/nemotron_shortcut/nvidia/moe/experts.py
NemotronShortcutModelOptMxfp8MoEMethod
¶
Bases: FusedMoEMethodBase
ModelOpt MXFP8 experts.
RoutedExperts.weight_loader picks the ModelOpt loading rules by the quant method's class name, so the name must contain "ModelOpt".
Source code in vllm/models/nemotron_shortcut/nvidia/moe/experts.py
NemotronShortcutModelOptNvFp4MoEMethod
¶
Bases: ModelOptNvFp4FusedMoE
ModelOpt NVFP4 experts on FlashInfer's CuTe-DSL fused MoE.
The routing weight is applied before the down projection, as in training. RoutedExperts.weight_loader picks the ModelOpt loading rules by the quant method's class name, so the name must contain "ModelOpt".
Source code in vllm/models/nemotron_shortcut/nvidia/moe/experts.py
NemotronShortcutMxfp8TritonExperts
¶
Bases: NemotronShortcutTritonExperts
The reference experts on MXFP8 weights (Triton dot_scaled).
Activations are quantized in-kernel at the input of each projection; weights are E4M3 with E8M0 block-32 scales, as in the checkpoint.
Source code in vllm/models/nemotron_shortcut/nvidia/moe/experts.py
NemotronShortcutRoutedExperts
¶
Bases: RoutedExperts
Routed experts that select one of the clamp-aware implementations.
Source code in vllm/models/nemotron_shortcut/nvidia/moe/experts.py
NemotronShortcutTritonExperts
¶
Bases: FusedMoEExpertsModular
The reference experts: kernels.routed_experts on BF16 weights.
Each EP rank runs its contiguous expert interval on every token, so the tokens must be replicated across EP ranks (no dispatcher, or the all-gather / reduce-scatter one).
Source code in vllm/models/nemotron_shortcut/nvidia/moe/experts.py
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 | |
_resolve_mixed_precision(quant_config, prefix)
¶
The single per-layer config of a fused expert group.
Source code in vllm/models/nemotron_shortcut/nvidia/moe/experts.py
apply_moe_kernel(kernel, layer, x, topk_weights, topk_ids, activation, shared_experts=None, shared_experts_input=None)
¶
Run a modular MoE kernel, keeping the experts' accumulation dtype.
FusedMoEKernel.apply returns the finalized output in the activation
dtype. Experts whose workspace dtype is wider (the FP32 top-k sum of the
Triton experts) keep it here, so the runner reduces EP and TP partial sums
before anything rounds them.
Source code in vllm/models/nemotron_shortcut/nvidia/moe/experts.py
combine_tokens(kernel, tokens, fused_out, output)
¶
kernel's finalize: reduce fused_out into output on this rank.
Source code in vllm/models/nemotron_shortcut/nvidia/moe/experts.py
dispatch_tokens(kernel, layer, x, topk_weights, topk_ids)
¶
kernel's prepare: quantize x if the experts want it, then dispatch.
Source code in vllm/models/nemotron_shortcut/nvidia/moe/experts.py
run_experts(kernel, layer, tokens, activation)
¶
The experts' output for the dispatched tokens, before the combine.
Source code in vllm/models/nemotron_shortcut/nvidia/moe/experts.py
select_mxfp8_experts(moe)
¶
CuTe-DSL MXFP8 experts where supported, else the Triton reference.
Only these two implement the clamp, so any other --moe-backend errors
instead of silently running a plain ReLU².