Configuration for MoE.
| 441 | |
| 442 | |
| 443 | class MoeConfig(StrictBaseModel): |
| 444 | """ |
| 445 | Configuration for MoE. |
| 446 | """ |
| 447 | backend: Literal["CUTLASS", "CUTEDSL", "WIDEEP", "TRTLLM", "DEEPGEMM", |
| 448 | "VANILLA", |
| 449 | "TRITON"] = Field(default='CUTLASS', |
| 450 | description="MoE backend to use.") |
| 451 | |
| 452 | max_num_tokens: Optional[int] = Field( |
| 453 | default=None, |
| 454 | description= |
| 455 | "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." |
| 456 | ) |
| 457 | |
| 458 | load_balancer: Optional[Union[object, str]] = Field( |
| 459 | default=None, |
| 460 | description="Configuration for MoE load balancing.", |
| 461 | json_schema_extra={"type": "Union[MoeLoadBalancerConfig, dict, str]"}) |
| 462 | |
| 463 | disable_finalize_fusion: bool = Field( |
| 464 | default=False, |
| 465 | description= |
| 466 | "Disable FC2+finalize kernel fusion in CUTLASS MoE backend. Setting this to True recovers deterministic numerical behavior with top-k > 2." |
| 467 | ) |
| 468 | |
| 469 | use_low_precision_moe_combine: bool = Field( |
| 470 | default=False, |
| 471 | description= |
| 472 | "Use low precision combine in MoE operations (only for NVFP4 quantization). When enabled, uses lower precision for combining expert outputs to improve performance." |
| 473 | ) |
| 474 | |
| 475 | @classmethod |
| 476 | def from_dict(cls, data: dict): |
| 477 | return cls(**data) |
| 478 | |
| 479 | |
| 480 | class Nvfp4GemmConfig(StrictBaseModel): |