Skip to content

vllm.models.nemotron_shortcut.nvidia.moe

Nemotron Shortcut's MoE: latent routed experts with a soft-clamped ReLU².

Modules:

  • config –

    The MoE config of Nemotron Shortcut's clamped ReLU² experts.

  • experts –

    Nemotron Shortcut routed experts and their quantization methods.

  • flashinfer –

    FlashInfer experts that implement Nemotron Shortcut's clamped ReLU².

  • kernels –

    Triton expert GEMMs for Nemotron Shortcut's clamped ReLU² experts.

  • layer –

    Nemotron Shortcut's latent MoE.

  • runner –

    A MoE runner whose routing and expert compute are separate graph nodes.

Classes:

NemotronShortcutMoE

Bases: Module

Latent MoE with shared experts, run in caller-placed stages.

begin_staged routes and dispatches, run_staged_experts runs the routed experts once the caller's current_path_output exists, and finish_staged adds the shared experts' output. forward runs the three in a row. A caller that runs a mixer between the first two calls receive_staged before the mixer's attention or GDP op.

Methods:

  • route_logit_space –

    Select topk(logits + bias); weight by the unbiased sigmoid scores.

Source code in vllm/models/nemotron_shortcut/nvidia/moe/layer.py
class NemotronShortcutMoE(nn.Module):
    """Latent MoE with shared experts, run in caller-placed stages.

    `begin_staged` routes and dispatches, `run_staged_experts` runs the routed
    experts once the caller's `current_path_output` exists, and
    `finish_staged` adds the shared experts' output. `forward` runs the three
    in a row. A caller that runs a mixer between the first two calls
    `receive_staged` before the mixer's attention or GDP op.
    """

    def __init__(
        self,
        config: "PreTrainedConfig",
        quant_config: QuantizationConfig | None = None,
        parallel_config: ParallelConfig | None = None,
        prefix: str = "",
    ) -> None:
        super().__init__()
        self.routed_scaling_factor = config.routed_scaling_factor
        self.top_k = config.num_experts_per_tok
        self.n_routed_experts = config.n_routed_experts
        self.gate = GateLinear(
            config.hidden_size,
            config.n_routed_experts,
            out_dtype=torch.float32,
            force_fp32_compute=True,
            prefix=f"{prefix}.gate",
        )
        self.gate.e_score_correction_bias = nn.Parameter(
            torch.empty(config.n_routed_experts, dtype=torch.float32)
        )
        self.fc1_latent_proj = ReplicatedLinear(
            config.hidden_size,
            config.moe_latent_size,
            bias=False,
            quant_config=quant_config,
            prefix=f"{prefix}.fc1_latent_proj",
        )
        self.fc2_norm = (
            RMSNorm(config.moe_latent_size, eps=config.rms_norm_eps)
            if config.moe_use_norm_before_up_proj
            else nn.Identity()
        )
        self.fc2_latent_proj = ReplicatedLinear(
            config.moe_latent_size,
            config.hidden_size,
            bias=False,
            quant_config=quant_config,
            prefix=f"{prefix}.fc2_latent_proj",
        )
        self.shared_experts = (
            NemotronShortcutMLP(
                config,
                config.hidden_size,
                config.moe_shared_expert_intermediate_size,
                quant_config=quant_config,
                # The runner reduces it with the routed output.
                reduce_results=False,
                prefix=f"{prefix}.shared_experts",
            )
            if config.moe_shared_expert_intermediate_size is not None
            else None
        )
        runner = FusedMoEFactory(
            num_experts=config.n_routed_experts,
            top_k=self.top_k,
            hidden_size=config.moe_latent_size,
            intermediate_size=config.moe_intermediate_size,
            quant_config=quant_config,
            prefix=f"{prefix}.experts",
            renormalize=self.top_k > 1,
            activation="relu2_no_mul",
            # Logit-space selection replaces the fused sigmoid top-k router
            # and applies the bias and routed_scaling_factor itself.
            custom_routing_function=(
                self.route_logit_space
                if getattr(config, "moe_router_bias_space", "score") == "logit"
                else None
            ),
            scoring_func="sigmoid",
            e_score_correction_bias=self.gate.e_score_correction_bias,
            routed_scaling_factor=self.routed_scaling_factor,
            routed_input_transform=self.fc1_latent_proj,
            routed_output_transform=NemotronShortcutMoEOutput(
                self.fc2_norm, self.fc2_latent_proj
            ),
            router_logits_dtype=torch.float32,
            ckpt_names=("up_proj", "down_proj", None),
            moe_config_cls=NemotronShortcutMoEConfig,
            routed_experts_cls=NemotronShortcutRoutedExperts,
            routed_experts_args={
                "activation_clamp_value": config.activation_clamp_value
            },
            runner_cls=NemotronShortcutMoERunner,
        )
        assert isinstance(runner, NemotronShortcutMoERunner)
        self.experts = runner

    def route_logit_space(
        self,
        hidden_states: torch.Tensor,
        gating_output: torch.Tensor,
        topk: int,
        renormalize: bool,
    ) -> tuple[torch.Tensor, torch.Tensor]:
        """Select `topk(logits + bias)`; weight by the unbiased sigmoid scores."""
        logits = gating_output.float()
        topk_ids = torch.topk(
            logits + self.gate.e_score_correction_bias,
            k=topk,
            dim=-1,
            sorted=envs.VLLM_BATCH_INVARIANT,
        )[1]
        topk_weights = logits.gather(1, topk_ids).sigmoid()
        if renormalize:
            topk_weights = topk_weights / (
                topk_weights.sum(dim=-1, keepdim=True) + 1e-20
            )
        return topk_weights * self.routed_scaling_factor, topk_ids

    def begin_staged(self, routed_hidden_states: torch.Tensor) -> StagedDispatch:
        logits, _ = self.gate(routed_hidden_states)
        return self.experts.begin_staged(routed_hidden_states, logits)

    def receive_staged(
        self, dispatch: StagedDispatch, projections: Sequence[torch.Tensor]
    ) -> StagedDispatch:
        return self.experts.receive_staged(dispatch, projections)

    def run_staged_experts(
        self, dispatch: StagedDispatch, current_path_output: torch.Tensor
    ) -> torch.Tensor:
        return self.experts.run_staged_experts(dispatch, current_path_output)

    def finish_staged(
        self, combine: torch.Tensor, shared_hidden_states: torch.Tensor
    ) -> torch.Tensor:
        shared = (
            self.shared_experts(shared_hidden_states)
            if self.shared_experts is not None
            else None
        )
        return self.experts.finish_staged(combine, shared_hidden_states, shared)

    def forward(
        self,
        routed_hidden_states: torch.Tensor,
        shared_hidden_states: torch.Tensor,
    ) -> torch.Tensor:
        dispatch = self.begin_staged(routed_hidden_states)
        combine = self.run_staged_experts(dispatch, shared_hidden_states)
        return self.finish_staged(combine, shared_hidden_states)

    def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]) -> set[str]:
        experts = self.experts.routed_experts
        # Checkpoints store each projection fused over the experts:
        # "experts.{up,down}_proj" plus, when quantized, its scales.
        fused_names = {
            f"experts.{projection}{suffix}": (parameter + target, shard)
            for projection, parameter, shard in (
                ("up_proj", "w13", "w1"),
                ("down_proj", "w2", "w2"),
            )
            for suffix, target in (
                ("", "_weight"),
                ("_scale", "_weight_scale"),
                ("_scale_2", "_weight_scale_2"),
                ("_input_scale", "_input_scale"),
            )
        }
        loaded = set()
        other = []
        for name, weight in weights:
            if name not in fused_names:
                other.append((name, weight))
                continue
            param_name, shard_id = fused_names[name]
            param = getattr(experts, param_name)
            for expert_id, expert_weight in enumerate(weight):
                experts.weight_loader(
                    param,
                    expert_weight,
                    param_name,
                    shard_id,
                    expert_id,
                    return_success=False,
                )
            loaded.add(f"experts.routed_experts.{param_name}")
        return loaded | AutoWeightsLoader(self).load_weights(other)

route_logit_space(hidden_states, gating_output, topk, renormalize)

Select topk(logits + bias); weight by the unbiased sigmoid scores.

Source code in vllm/models/nemotron_shortcut/nvidia/moe/layer.py
def route_logit_space(
    self,
    hidden_states: torch.Tensor,
    gating_output: torch.Tensor,
    topk: int,
    renormalize: bool,
) -> tuple[torch.Tensor, torch.Tensor]:
    """Select `topk(logits + bias)`; weight by the unbiased sigmoid scores."""
    logits = gating_output.float()
    topk_ids = torch.topk(
        logits + self.gate.e_score_correction_bias,
        k=topk,
        dim=-1,
        sorted=envs.VLLM_BATCH_INVARIANT,
    )[1]
    topk_weights = logits.gather(1, topk_ids).sigmoid()
    if renormalize:
        topk_weights = topk_weights / (
            topk_weights.sum(dim=-1, keepdim=True) + 1e-20
        )
    return topk_weights * self.routed_scaling_factor, topk_ids

NemotronShortcutMoEConfig dataclass

Bases: FusedMoEConfig

FusedMoEConfig plus the soft clamp of the experts' ReLU².

Source code in vllm/models/nemotron_shortcut/nvidia/moe/config.py
@dataclass
class NemotronShortcutMoEConfig(FusedMoEConfig):
    """`FusedMoEConfig` plus the soft clamp of the experts' ReLU²."""

    # c in relu2(c * tanh(x / c)); None is the plain ReLU².
    activation_clamp_value: float | None = None

NemotronShortcutMoEOutput

Bases: Module

The routed output transform: RMSNorm, then the latent up-projection.

Source code in vllm/models/nemotron_shortcut/nvidia/moe/layer.py
class NemotronShortcutMoEOutput(nn.Module):
    """The routed output transform: RMSNorm, then the latent up-projection."""

    def __init__(self, norm: nn.Module, projection: ReplicatedLinear) -> None:
        super().__init__()
        self.norm = norm
        self.projection = projection
        # Not the projection's weight dtype: a quantized (e.g. MXFP8)
        # projection's weight dtype is not an activation dtype.
        self.activation_dtype = torch.get_default_dtype()

    def forward(self, hidden_states: torch.Tensor) -> torch.Tensor:
        # The runner reduces the FP32 latent partials before this nonlinear
        # transform; round them once, here.
        hidden_states = hidden_states.to(self.activation_dtype)
        # Inside the opaque staged-MoE op inductor can't fuse the native norm.
        with ir.ops.rms_norm.set_priority(["vllm_c", "native"]):
            hidden_states = self.norm(hidden_states)
        return self.projection(hidden_states)[0]

NemotronShortcutMoERunner

Bases: MoERunner

MoERunner with the forward split into three caller-placed stages.

Shared experts are not part of the runner: the caller runs them on its own input and passes their (unreduced) output to finish_staged.

Methods:

  • begin_staged –

    Route and dispatch hidden_states; returns the later stages' input.

  • finish_staged –

    Reduce, transform and add the shared output.

  • receive_staged –

    Wait for the dispatch if a piecewise CUDA graph piece is captured.

  • run_staged_experts –

    Run the routed experts after current_path_output is computed.

Attributes:

Source code in vllm/models/nemotron_shortcut/nvidia/moe/runner.py
class NemotronShortcutMoERunner(MoERunner):
    """`MoERunner` with the forward split into three caller-placed stages.

    Shared experts are not part of the runner: the caller runs them on its
    own input and passes their (unreduced) output to `finish_staged`.
    """

    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs)
        if self.shared_experts is not None:
            raise ValueError("pass the shared experts output to finish_staged")
        if self.moe_config.is_sequence_parallel:
            raise NotImplementedError("staged MoE does not support sequence parallel")
        slots = 2 if self.enable_dbo else 1
        self._routed: list[_Routed | None] = [None] * slots
        self._combined: list[_Combined | None] = [None] * slots

    def _op_layer_name(self) -> _LayerNameType:
        # Always the real name: the shared "from_forward_context" counter
        # counts one call per MoE layer.
        return LayerName(self.layer_name) if _USE_LAYERNAME else self.layer_name

    @property
    def _slot(self) -> int:
        return dbo_current_ubatch_id() if self.enable_dbo else 0

    # The side stream's events, reused across forwards: the compute stream
    # waits for each before the next forward records it again.
    @cached_property
    def _dispatch_done(self) -> torch.cuda.Event:
        return torch.cuda.Event()

    @cached_property
    def _combine_done(self) -> torch.cuda.Event:
        return torch.cuda.Event()

    @property
    def overlaps_transport(self) -> bool:
        """Whether the dispatch and the combine run on the side stream.

        Only the all-gather/reduce-scatter transport, the one these experts
        use with DP. DBO overlaps it with the other microbatch instead, and
        PCP adds collectives outside the kernel.
        """
        kernel = self._quant_method.moe_kernel
        return (
            current_platform.is_cuda()
            and not self.enable_dbo
            and self.moe_config.pcp_size == 1
            and kernel is not None
            and isinstance(
                kernel.prepare_finalize, MoEPrepareAndFinalizeNaiveDPEPModular
            )
        )

    def begin_staged(
        self, hidden_states: torch.Tensor, router_logits: torch.Tensor
    ) -> StagedDispatch:
        """Route and dispatch `hidden_states`; returns the later stages' input."""
        dependency = torch.ops.vllm.nemotron_shortcut_moe_begin(
            hidden_states, router_logits, self._op_layer_name()
        )
        return StagedDispatch(dependency, hidden_states, router_logits)

    def receive_staged(
        self, dispatch: StagedDispatch, projections: Sequence[torch.Tensor]
    ) -> StagedDispatch:
        """Wait for the dispatch if a piecewise CUDA graph piece is captured.

        Callers place this after `projections` and before the op that ends the
        piece (an attention or GDP op), so the dispatch still overlaps the
        projections. Otherwise the experts stage waits, after the whole mixer.
        """
        dependency = torch.ops.vllm.nemotron_shortcut_moe_receive(
            dispatch.dependency, list(projections), self._op_layer_name()
        )
        return StagedDispatch(
            dependency, dispatch.hidden_states, dispatch.router_logits
        )

    def run_staged_experts(
        self, dispatch: StagedDispatch, current_path_output: torch.Tensor
    ) -> torch.Tensor:
        """Run the routed experts after `current_path_output` is computed."""
        return torch.ops.vllm.nemotron_shortcut_moe_experts(
            dispatch.dependency,
            current_path_output,
            dispatch.hidden_states,
            dispatch.router_logits,
            self._op_layer_name(),
        )

    def finish_staged(
        self,
        dependency: torch.Tensor,
        output_template: torch.Tensor,
        shared_output: torch.Tensor | None = None,
    ) -> torch.Tensor:
        """Reduce, transform and add the shared output.

        `output_template` gives the result's shape and dtype.
        """
        return torch.ops.vllm.nemotron_shortcut_moe_finish(
            dependency, output_template, shared_output, self._op_layer_name()
        )

    def _begin_impl(
        self, hidden_states: torch.Tensor, router_logits: torch.Tensor
    ) -> torch.Tensor:
        slot = self._slot
        if self._routed[slot] is not None or self._combined[slot] is not None:
            raise RuntimeError(f"{self.layer_name}: a staged forward is pending")
        if self.overlaps_transport:
            logger.info_once(
                "Nemotron Shortcut MoE: all-gather and reduce-scatter run on a "
                "side stream, overlapped with the mixer and the shared experts"
            )
            # The mixer reads neither the routing nor the dispatch.
            routed = _launch_on_side_stream(
                hidden_states.device,
                self._dispatch_done,
                lambda: self._route(hidden_states, router_logits, dispatch=True),
            )
            routed.dispatch_pending = True
        else:
            routed = self._route(hidden_states, router_logits, dispatch=False)
        self._routed[slot] = routed
        return hidden_states.new_empty(0)

    def _route(
        self, hidden_states: torch.Tensor, router_logits: torch.Tensor, dispatch: bool
    ) -> _Routed:
        block_input = hidden_states
        hidden_states, _ = self.apply_routed_input_transform(hidden_states)
        # The block input sizes the final output: the transform returns to it.
        hidden_states, pre_trunc, post_trunc = self._maybe_pad_hidden_states(
            block_input, hidden_states
        )
        self.routed_experts._ensure_moe_quant_config_init()
        with self._sequence_parallel_context():
            hidden_states, router_logits, hidden_states_scale = self._maybe_dispatch(
                hidden_states, router_logits
            )
            # Only the PCP gather pre-quantizes, and only for monolithic kernels.
            assert hidden_states_scale is None
            topk_weights, topk_ids = self.router.select_experts(
                hidden_states=hidden_states,
                router_logits=router_logits,
                topk_indices_dtype=self._quant_method.topk_indices_dtype,
            )
            tokens = None
            if dispatch:
                kernel = self._quant_method.moe_kernel
                assert kernel is not None
                tokens = dispatch_tokens(
                    kernel, self.routed_experts, hidden_states, topk_weights, topk_ids
                )
        return _Routed(
            hidden_states, topk_weights, topk_ids, pre_trunc, post_trunc, tokens
        )

    def _receive_impl(self) -> None:
        routed = self._routed[self._slot]
        if routed is None:
            raise RuntimeError(f"{self.layer_name}: begin_staged was not called")
        if routed.dispatch_pending and _capturing_graph_piece():
            current_stream().wait_event(self._dispatch_done)
            routed.dispatch_pending = False

    def _experts_impl(self, dependency: torch.Tensor) -> torch.Tensor:
        slot = self._slot
        routed = self._routed[slot]
        if routed is None:
            raise RuntimeError(f"{self.layer_name}: begin_staged was not called")
        self._routed[slot] = None
        with self._sequence_parallel_context():
            if routed.tokens is None:
                combined = self._run_experts(routed)
            else:
                combined = self._run_dispatched_experts(routed, routed.tokens)
        self._combined[slot] = combined
        return torch.empty_like(dependency)

    def _run_experts(self, routed: _Routed) -> _Combined:
        output = self.routed_experts.forward_modular(
            x=routed.hidden_states,
            topk_weights=routed.topk_weights,
            topk_ids=routed.topk_ids,
        )
        if isinstance(output, UnfinalizedMoEOutput):
            raise NotImplementedError("staged MoE needs a finalized output")
        output = self._maybe_combine(None, output)
        assert isinstance(output, torch.Tensor)
        return _Combined(
            output, routed.pre_transform_trunc_size, routed.post_transform_trunc_size
        )

    def _run_dispatched_experts(
        self, routed: _Routed, tokens: DispatchedTokens
    ) -> _Combined:
        if routed.dispatch_pending:
            current_stream().wait_event(self._dispatch_done)
        kernel = self._quant_method.moe_kernel
        assert kernel is not None
        fused_output = run_experts(
            kernel, self.routed_experts, tokens, self.routed_experts.activation
        )
        output = fused_output.new_empty(tokens.output_shape)
        # The caller's shared experts overlap the reduce-scatter.
        _launch_on_side_stream(
            output.device,
            self._combine_done,
            lambda: combine_tokens(kernel, tokens, fused_output, output),
        )
        return _Combined(
            output,
            routed.pre_transform_trunc_size,
            routed.post_transform_trunc_size,
            fused_output,
        )

    def _finish_impl(self, shared_output: torch.Tensor | None) -> torch.Tensor:
        slot = self._slot
        combined = self._combined[slot]
        if combined is None:
            raise RuntimeError(f"{self.layer_name}: run_staged_experts was not called")
        self._combined[slot] = None
        if combined.fused_output is not None:
            current_stream().wait_event(self._combine_done)
        # The same steps as MoERunner.forward after its custom op.
        output = combined.output
        if combined.pre_transform_trunc_size is not None:
            output = output[..., : combined.pre_transform_trunc_size]
        output, reduced = self._maybe_reduce_routed_output_before_transform(
            output, self._fused_output_is_reduced
        )
        shared_output = self._maybe_reduce_shared_expert_output(shared_output, reduced)
        shared_output, output = self._maybe_apply_routed_scale_to_output(
            shared_output, output
        )
        output = self.apply_routed_output_transform(output)
        if shared_output is not None:
            output = shared_output + output
        return self._maybe_reduce_final_output(
            output, combined.post_transform_trunc_size, reduced
        )

overlaps_transport property

Whether the dispatch and the combine run on the side stream.

Only the all-gather/reduce-scatter transport, the one these experts use with DP. DBO overlaps it with the other microbatch instead, and PCP adds collectives outside the kernel.

begin_staged(hidden_states, router_logits)

Route and dispatch hidden_states; returns the later stages' input.

Source code in vllm/models/nemotron_shortcut/nvidia/moe/runner.py
def begin_staged(
    self, hidden_states: torch.Tensor, router_logits: torch.Tensor
) -> StagedDispatch:
    """Route and dispatch `hidden_states`; returns the later stages' input."""
    dependency = torch.ops.vllm.nemotron_shortcut_moe_begin(
        hidden_states, router_logits, self._op_layer_name()
    )
    return StagedDispatch(dependency, hidden_states, router_logits)

finish_staged(dependency, output_template, shared_output=None)

Reduce, transform and add the shared output.

output_template gives the result's shape and dtype.

Source code in vllm/models/nemotron_shortcut/nvidia/moe/runner.py
def finish_staged(
    self,
    dependency: torch.Tensor,
    output_template: torch.Tensor,
    shared_output: torch.Tensor | None = None,
) -> torch.Tensor:
    """Reduce, transform and add the shared output.

    `output_template` gives the result's shape and dtype.
    """
    return torch.ops.vllm.nemotron_shortcut_moe_finish(
        dependency, output_template, shared_output, self._op_layer_name()
    )

receive_staged(dispatch, projections)

Wait for the dispatch if a piecewise CUDA graph piece is captured.

Callers place this after projections and before the op that ends the piece (an attention or GDP op), so the dispatch still overlaps the projections. Otherwise the experts stage waits, after the whole mixer.

Source code in vllm/models/nemotron_shortcut/nvidia/moe/runner.py
def receive_staged(
    self, dispatch: StagedDispatch, projections: Sequence[torch.Tensor]
) -> StagedDispatch:
    """Wait for the dispatch if a piecewise CUDA graph piece is captured.

    Callers place this after `projections` and before the op that ends the
    piece (an attention or GDP op), so the dispatch still overlaps the
    projections. Otherwise the experts stage waits, after the whole mixer.
    """
    dependency = torch.ops.vllm.nemotron_shortcut_moe_receive(
        dispatch.dependency, list(projections), self._op_layer_name()
    )
    return StagedDispatch(
        dependency, dispatch.hidden_states, dispatch.router_logits
    )

run_staged_experts(dispatch, current_path_output)

Run the routed experts after current_path_output is computed.

Source code in vllm/models/nemotron_shortcut/nvidia/moe/runner.py
def run_staged_experts(
    self, dispatch: StagedDispatch, current_path_output: torch.Tensor
) -> torch.Tensor:
    """Run the routed experts after `current_path_output` is computed."""
    return torch.ops.vllm.nemotron_shortcut_moe_experts(
        dispatch.dependency,
        current_path_output,
        dispatch.hidden_states,
        dispatch.router_logits,
        self._op_layer_name(),
    )

NemotronShortcutRoutedExperts

Bases: RoutedExperts

Routed experts that select one of the clamp-aware implementations.

Source code in vllm/models/nemotron_shortcut/nvidia/moe/experts.py
class NemotronShortcutRoutedExperts(RoutedExperts):
    """Routed experts that select one of the clamp-aware implementations."""

    def __init__(
        self,
        layer_name: str,
        params_dtype: torch.dtype,
        moe_config: FusedMoEConfig,
        quant_config: QuantizationConfig | None,
        *,
        activation_clamp_value: float | None,
        **kwargs,
    ) -> None:
        if not isinstance(moe_config, NemotronShortcutMoEConfig):
            raise TypeError(
                "pass moe_config_cls=NemotronShortcutMoEConfig to the factory"
            )
        if activation_clamp_value is not None and not (
            math.isfinite(activation_clamp_value) and activation_clamp_value > 0
        ):
            raise ValueError(
                "activation_clamp_value must be positive and finite, got "
                f"{activation_clamp_value}"
            )
        # Set before RoutedExperts.__init__ selects the quantization method.
        moe_config.activation_clamp_value = activation_clamp_value
        super().__init__(layer_name, params_dtype, moe_config, quant_config, **kwargs)

    def _get_quant_method(
        self,
        prefix: str,
        quant_config: QuantizationConfig | None,
        moe_config: FusedMoEConfig,
    ) -> FusedMoEMethodBase:
        if isinstance(quant_config, ModelOptMixedPrecisionConfig):
            quant_config = _resolve_mixed_precision(quant_config, prefix)
        elif isinstance(
            quant_config, (ModelOptMxFp8Config, ModelOptNvFp4Config)
        ) and quant_config.is_layer_excluded(prefix):
            quant_config = None
        nvfp4 = isinstance(quant_config, ModelOptNvFp4Config)
        mxfp8 = isinstance(quant_config, ModelOptMxFp8Config)
        if quant_config is not None and not (nvfp4 or mxfp8):
            raise NotImplementedError(
                "Nemotron Shortcut quantized experts require ModelOpt MXFP8 or NVFP4"
            )
        if (nvfp4 or mxfp8) and not (
            current_platform.is_cuda() and current_platform.has_device_capability(100)
        ):
            raise NotImplementedError(
                "Nemotron Shortcut quantized experts require SM100 or newer"
            )
        parallel = moe_config.moe_parallel_config
        if parallel.use_ep and (
            parallel.pcp_size > 1
            or parallel.is_sequence_parallel
            or parallel.enable_eplb
            or self.expert_placement_strategy != "linear"
            or parallel.all2all_backend != "allgather_reducescatter"
        ):
            raise NotImplementedError(
                "Nemotron Shortcut expert parallelism needs linear placement, the "
                "allgather_reducescatter backend, and no PCP, SP or EPLB: "
                "every EP rank sees every token"
            )
        if nvfp4:
            return NemotronShortcutModelOptNvFp4MoEMethod(
                cast(ModelOptNvFp4Config, quant_config), moe_config
            )
        if mxfp8:
            return NemotronShortcutModelOptMxfp8MoEMethod(moe_config)
        return NemotronShortcutMoEMethod(moe_config)