MoeConfig#

class tensorrt_llm.llmapi.MoeConfig(
*,
backend: Literal['AUTO', 'CUTLASS', 'CUTEDSL', 'CUTEDSL_FC12', 'TRTLLM', 'DEEPGEMM', 'DENSEGEMM', 'VANILLA', 'TRITON', 'MARLIN', 'MEGAMOE_DEEPGEMM', 'MEGAMOE_CUTEDSL'] = 'AUTO',
tactic: str | None = None,
max_num_tokens: int | None = None,
load_balancer: Annotated[MoeLoadBalancerConfig | MoePerLayerDynamicLoadBalancerConfig, FieldInfo(annotation=NoneType, required=True, discriminator='mode')] | str | None = None,
disable_finalize_fusion: bool = False,
megamoe_fuse_shared_expert: bool = False,
use_low_precision_moe_combine: bool = False,
)[source]#

Bases: StrictBaseModel

Configuration for MoE.

field backend: Literal['AUTO', 'CUTLASS', 'CUTEDSL', 'CUTEDSL_FC12', 'TRTLLM', 'DEEPGEMM', 'DENSEGEMM', 'VANILLA', 'TRITON', 'MARLIN', 'MEGAMOE_DEEPGEMM', 'MEGAMOE_CUTEDSL'] = 'AUTO'#

MoE backend to use. Choosing a backend other than AUTO is planned for deprecation where tactic can replace it; which tactic does depends on the checkpoint’s format (see tactic). AUTO selects default backend based on model. It currently doesn’t always give the best choice for all scenarios. The capabilities of auto selection will be improved in future releases.

field disable_finalize_fusion: bool = False#

Disable FC2+finalize kernel fusion in CUTLASS MoE backend. Setting this to True recovers deterministic numerical behavior with top-k > 2.

field load_balancer: Annotated[MoeLoadBalancerConfig | MoePerLayerDynamicLoadBalancerConfig, FieldInfo(annotation=NoneType, required=True, discriminator='mode')] | str | None = None#

Configuration for standard or per-layer dynamic EPLB.

field max_num_tokens: int | None = None#

If set, at most max_num_tokens tokens will be sent to torch.ops.trtllm.fused_moe at the same time. If the number of tokens exceeds max_num_tokens, the input tensors will be split into chunks and a for loop will be used.

field megamoe_fuse_shared_expert: bool = False#

Run a DeepSeek-V4 or DeepSeek-V4.1 model’s single FP8 block-scale shared expert inside the fused MoE kernel. Used only with the MEGAMOE_CUTEDSL backend on SM100/SM103, under attention DP with moe_tensor_parallel_size 1, for a model with one shared expert; ignored otherwise.

field tactic: str | None = None#

MoE implementation to run for the target model; unrelated to the autotuner’s kernel tactics. The recommended interface for choosing it. Takes an id ‘provider.technique.kernel_name.quant’ (e.g. ‘trtllm.cutlass.grouped_gemm.nvfp4’) or any dotted subset of its segments (e.g. ‘cutlass’, ‘mega_moe’); case-insensitive. The first match in catalog order that can serve a layer of the checkpoint’s expert format runs, with no fallback; the matches must belong to one backend family. Requires backend AUTO. A backend family can span several techniques, so the tactic that replaces a backend depends on the format (CUTLASS also covers the hopper_grouped_gemm and triton FP8 block-scale implementations); VANILLA has none. Drafts and MTP layers are selected by speculative_config.moe_tactic; with both draft fields unset, a target tactic makes a draft resolve AUTO for its own weights instead of inheriting the target’s backend. The ids, the shortest tactic naming each, and the segment values are listed in the MoE implementation catalog of the MoE performance guide (https://nvidia.github.io/TensorRT-LLM/developer-guide/moe-perf-guide.html, docs/source/developer-guide/moe-perf-guide.md in the source tree); a run logs the id of each MoE implementation it builds.

field use_low_precision_moe_combine: bool = False#

Use low precision combine in MoE operations (only for NVFP4 quantization). When enabled, uses lower precision for combining expert outputs to improve performance.

__init__(**data: Any) → None#

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

validator resolve_load_balancer_compatibility  »  all fields[source]#

Resolve the backend required by per-layer dynamic EPLB.

validator resolve_load_balancer_config  »  load_balancer[source]#
validator validate_tactic_excludes_backend  »  all fields[source]#
validator validate_tactic_syntax  »  tactic[source]#

Check that tactic names an implementation; lowercase it.