Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -264,13 +264,8 @@ common-files: &common_files |
tensorrt_llm/_torch/modules/fused_moe/fused_moe_triton.py |
tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py |
tensorrt_llm/_torch/modules/fused_moe/fused_moe_vanilla.py |
tensorrt_llm/_torch/modules/fused_moe/fused_moe_wide_ep.py |
tensorrt_llm/_torch/modules/fused_moe/interface.py |
tensorrt_llm/_torch/modules/fused_moe/moe_load_balancer.py |
tensorrt_llm/_torch/modules/fused_moe/ops/__init__.py |
tensorrt_llm/_torch/modules/fused_moe/ops/moe_op.py |
tensorrt_llm/_torch/modules/fused_moe/ops/moe_op_cutlass.py |
tensorrt_llm/_torch/modules/fused_moe/ops/moe_op_deepgemm.py |
tensorrt_llm/_torch/modules/fused_moe/quantization.py |
tensorrt_llm/_torch/modules/fused_moe/routing.py |
tensorrt_llm/_torch/modules/gated_mlp.py |
Expand Down Expand Up @@ -1038,13 +1033,8 @@ legacy-files: &legacy_files |
tensorrt_llm/_torch/modules/fused_moe/fused_moe_triton.py |
tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py |
tensorrt_llm/_torch/modules/fused_moe/fused_moe_vanilla.py |
tensorrt_llm/_torch/modules/fused_moe/fused_moe_wide_ep.py |
tensorrt_llm/_torch/modules/fused_moe/interface.py |
tensorrt_llm/_torch/modules/fused_moe/moe_load_balancer.py |
tensorrt_llm/_torch/modules/fused_moe/ops/__init__.py |
tensorrt_llm/_torch/modules/fused_moe/ops/moe_op.py |
tensorrt_llm/_torch/modules/fused_moe/ops/moe_op_cutlass.py |
tensorrt_llm/_torch/modules/fused_moe/ops/moe_op_deepgemm.py |
tensorrt_llm/_torch/modules/fused_moe/quantization.py |
tensorrt_llm/_torch/modules/fused_moe/routing.py |
tensorrt_llm/_torch/modules/gated_mlp.py |
Expand Down
2 changes: 1 addition & 1 deletion examples/layer_wise_benchmarks/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def comma_separated_floats(s):
ctx_attn_workspace = torch.empty((0,), device="cuda", dtype=torch.int8)
with mock.patch.dict(
os.environ,
{"TRTLLM_FORCE_ALLTOALL_METHOD": "NotEnabled", "TRTLLM_FORCE_COMM_METHOD": "ALLGATHER"},
{"TRTLLM_FORCE_COMM_METHOD": "ALLGATHER"},
clear=False,
):
ctx_runner = Runner(
Expand Down
5 changes: 0 additions & 5 deletions legacy-files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,8 @@ tensorrt_llm/_torch/modules/fused_moe/fused_moe_deepgemm.py
tensorrt_llm/_torch/modules/fused_moe/fused_moe_triton.py
tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py
tensorrt_llm/_torch/modules/fused_moe/fused_moe_vanilla.py
tensorrt_llm/_torch/modules/fused_moe/fused_moe_wide_ep.py
tensorrt_llm/_torch/modules/fused_moe/interface.py
tensorrt_llm/_torch/modules/fused_moe/moe_load_balancer.py
tensorrt_llm/_torch/modules/fused_moe/ops/__init__.py
tensorrt_llm/_torch/modules/fused_moe/ops/moe_op.py
tensorrt_llm/_torch/modules/fused_moe/ops/moe_op_cutlass.py
tensorrt_llm/_torch/modules/fused_moe/ops/moe_op_deepgemm.py
tensorrt_llm/_torch/modules/fused_moe/quantization.py
tensorrt_llm/_torch/modules/fused_moe/routing.py
tensorrt_llm/_torch/modules/gated_mlp.py
Expand Down
5 changes: 0 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,8 @@ exclude = [
"tensorrt_llm/_torch/modules/fused_moe/fused_moe_triton.py",
"tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py",
"tensorrt_llm/_torch/modules/fused_moe/fused_moe_vanilla.py",
"tensorrt_llm/_torch/modules/fused_moe/fused_moe_wide_ep.py",
"tensorrt_llm/_torch/modules/fused_moe/interface.py",
"tensorrt_llm/_torch/modules/fused_moe/moe_load_balancer.py",
"tensorrt_llm/_torch/modules/fused_moe/ops/__init__.py",
"tensorrt_llm/_torch/modules/fused_moe/ops/moe_op.py",
"tensorrt_llm/_torch/modules/fused_moe/ops/moe_op_cutlass.py",
"tensorrt_llm/_torch/modules/fused_moe/ops/moe_op_deepgemm.py",
"tensorrt_llm/_torch/modules/fused_moe/quantization.py",
"tensorrt_llm/_torch/modules/fused_moe/routing.py",
"tensorrt_llm/_torch/modules/gated_mlp.py",
Expand Down
5 changes: 0 additions & 5 deletions ruff-legacy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,8 @@ include = [
"tensorrt_llm/_torch/modules/fused_moe/fused_moe_triton.py",
"tensorrt_llm/_torch/modules/fused_moe/fused_moe_trtllm_gen.py",
"tensorrt_llm/_torch/modules/fused_moe/fused_moe_vanilla.py",
"tensorrt_llm/_torch/modules/fused_moe/fused_moe_wide_ep.py",
"tensorrt_llm/_torch/modules/fused_moe/interface.py",
"tensorrt_llm/_torch/modules/fused_moe/moe_load_balancer.py",
"tensorrt_llm/_torch/modules/fused_moe/ops/__init__.py",
"tensorrt_llm/_torch/modules/fused_moe/ops/moe_op.py",
"tensorrt_llm/_torch/modules/fused_moe/ops/moe_op_cutlass.py",
"tensorrt_llm/_torch/modules/fused_moe/ops/moe_op_deepgemm.py",
"tensorrt_llm/_torch/modules/fused_moe/quantization.py",
"tensorrt_llm/_torch/modules/fused_moe/routing.py",
"tensorrt_llm/_torch/modules/gated_mlp.py",
Expand Down
4 changes: 0 additions & 4 deletions tensorrt_llm/_torch/models/modeling_deepseekv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
from ..modules.fused_moe import (DeepSeekV3MoeRoutingMethod,
MoEWeightLoadingMode, create_moe,
is_moe_weight_owner)
from ..modules.fused_moe.fused_moe_wide_ep import WideEPMoE
from ..modules.mla import MLA

# isort: off
Expand Down Expand Up @@ -1151,9 +1150,6 @@ def compute_routed_output(self, hidden_states, hidden_states_fp4,
output_dtype=hidden_states.dtype,
all_rank_num_tokens=all_rank_num_tokens,
use_dp_padding=use_dp_padding,
**({
"alltoall_result_do_sum": False
} if isinstance(self.experts, WideEPMoE) else {}),
)

return routed_output
Expand Down
2 changes: 0 additions & 2 deletions tensorrt_llm/_torch/models/modeling_deepseekv4.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
resolve_moe_cls,
)
from ..modules.fused_moe.fused_moe_deepgemm import DeepGemmFusedMoE
from ..modules.fused_moe.fused_moe_wide_ep import WideEPMoE
from ..modules.gated_mlp import GatedMLP
from ..modules.linear import Linear, TensorParallelMode, WeightsLoadingConfig
from ..modules.mhc.hyper_connection import HCHead, HCState, mHC
Expand Down Expand Up @@ -1697,7 +1696,6 @@ def compute_routed_output(
output_dtype=hidden_states.dtype,
all_rank_num_tokens=all_rank_num_tokens,
use_dp_padding=use_dp_padding,
**({"alltoall_result_do_sum": False} if isinstance(self.experts, WideEPMoE) else {}),
)

return routed_output
Expand Down
45 changes: 20 additions & 25 deletions tensorrt_llm/_torch/modules/fused_moe/MOE_DEVELOPER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,16 @@ The codebase is transitioning between two architectures:
| Entry | `XXFusedMoE` (e.g., `CutlassFusedMoE`) | `ConfigurableMoE` + `XXBackend` + `MoEScheduler` |
| Communication | Embedded inside each backend | Separated into `communication/` (or fused into kernel for `FUSED_COMM`) |
| Forward execution | Inline in backend | `MoEScheduler` (`moe_scheduler.py`) |
| EPLB | Only in WideEPMoE | Available to all backends |
| EPLB | Not supported | Available on EPLB-capable backends |
| Status | Being replaced | Active development |

ConfigurableMoE currently supports these backends (`create_moe.py`):
- `CutlassFusedMoE`, `TRTLLMGenFusedMoE`, `DeepGemmFusedMoE`, `CuteDslFusedMoE`, `DenseGEMMFusedMoE`, `MegaMoEDeepGemm`, `MegaMoECuteDsl`
- `CutlassFusedMoE`, `TRTLLMGenFusedMoE`, `DeepGemmFusedMoE`, `CuteDslFusedMoE`,
`CuteDslB12xFusedMoE`, `DenseGEMMFusedMoE`, `MegaMoEDeepGemm`,
`MegaMoECuteDsl`, `MarlinFusedMoE`

Still on old path (standalone, with embedded communication):
- `TritonFusedMoE`, `VanillaMoE`
- `WideEPMoE` — deprecated, the `WIDEEP` backend can no longer be selected

**Rule: All new features should target ConfigurableMoE + Backend + Scheduler architecture.**

Expand All @@ -137,7 +138,7 @@ Still on old path (standalone, with embedded communication):
| `impl_contract.py` | Selection vocabulary — `MoEProblem`, `MoEDeployment`, `MoEEnvironment`, `MoEEligibility`, `MoERejectReason`, `MoEResolutionReport` |
| `impl_environment.py` | The only place that probes the machine (SM, optional wheels, env flags) and freezes the result |
| `impl_identity.py` | `MoEImplId` / `MoEImplDescriptor` / registry — the stable one-id-per-leaf-class mechanism used after an implementation migrates |
| `interface.py` | Base class `MoE` and enums (`MoEWeightLoadingMode`, `MoESchedulerKind`, `AlltoallMethodType`) |
| `interface.py` | Base class `MoE` and enums (`MoEWeightLoadingMode`, `MoESchedulerKind`) |
| `quantization.py` | Quantization method implementations (`FusedMoEMethod` subclasses: weight creation, loading, quant/dequant ops per quant mode) |
| `routing.py` | Routing methods (`TopKRouting`, etc.) |
| `moe_load_balancer.py` | EPLB implementation |
Expand All @@ -157,7 +158,6 @@ Still on old path (standalone, with embedded communication):
| `mega_moe/mega_moe_cute_dsl.py` | `MegaMoECuteDsl` | SM100/SM103 | NVFP4 via ported CuteDSL `Sm100MegaMoEKernel` fused dispatch+FC1+act+FC2+combine kernel; requires CUDA 13 Cutlass DSL runtime (PR #14354) and NVSHMEM provider (hard gate); threads per-expert `fc31_alpha`/`fc2_alpha`/`fc1_norm_const` through the kernel ABI and supports SwiGLU clamp via `swiglu_limit`; default deepgemm graph (topk score folded before fc1-out quant, host `combine_output.sum(dim=1)`) | `FUSED_COMM` |
| `fused_moe_marlin.py` | `MarlinFusedMoE` | SM89-SM99 | W4A16 NVFP4 on Ada/Hopper (BF16 activations + FP4 weights, fused single-launch `marlin_nvfp4_moe_gemm` kernel); supports attention-DP + EP via external comm (scheduler precomputes routing; dispatch payload is plain BF16, no activation scales); non-NVFP4 layers (e.g. unquantized MTP draft layers) degrade to Cutlass in `resolve_moe_impl`, recorded in the layer's `MoEResolutionReport`; no dynamic EPLB | `EXTERNAL_COMM` |
| `fused_moe_triton.py` | `TritonFusedMoE` | SM90 only | GPT-OSS on Hopper (requires `swiglu_gptoss_style=True`) | (legacy path) |
| `fused_moe_wide_ep.py` | `WideEPMoE` | All GPUs | Deprecated — `moe_resolution.py` raises on the `WIDEEP` backend literal. Wide EP and EPLB are available on the other backends: use `DEEPGEMM` for FP8 block-scale checkpoints, or `TRTLLM` / `CUTEDSL` / `CUTLASS` otherwise. Class kept for reference only | (legacy path) |
| `fused_moe_vanilla.py` | `VanillaMoE` | All devices | Reference / debugging only | (legacy path) |

### Communication (`fused_moe/communication/`)
Expand Down Expand Up @@ -310,26 +310,21 @@ unconditionally, not here.

Each backend's `can_implement(p, d)` classmethod declares what it supports. Source of truth: the `can_implement` classmethod in each backend file.

| Quantization | Cutlass | TRTLLMGen | DeepGemm | DenseGEMM | CuteDSL | MegaMoE-DG | MegaMoE-CuteDSL | Triton | Marlin | WideEP (retired)† | Vanilla |
|---|---|---|---|---|---|---|---|---|---|---|---|
| Unquantized (BF16/FP16) | Y (SM80+) | Y (SM100/103, BF16, needs FlashInfer `trtllm_bf16_moe`)§ | N | N | N | N | N | Y (SM90, BF16) | N | Y | Y |
| FP8 QDQ | Y (SM89+) | N | N | N | N | N | N | Y (SM90) | N | Y | Y |
| FP8 Block Scales | Y (SM90, SM120) | Y (SM100/103) | Y (SM100/103) | N | N‡ | N | N | N | N | Y | Y |
| NVFP4 | Y (SM100/103/120/121) | Y (SM100/103) | N | Y (SM100/103) | Y (SM100/103/120/121) | N | Y (SM100/103, cu13 cutlass-dsl + NVSHMEM provider; per-expert alpha/norm_const + SwiGLU clamp) | N | Y (SM89-SM99) | Y | Y |
| W4A16 NVFP4 | Y (SM80+, dequant-on-the-fly) | N | N | N | Y (SM120/121 via `CuteDslB12xFusedMoE`, needs flashinfer) | N | N | N | Y (SM89-SM99, BF16) | N | Y |
| W4A8 NVFP4 FP8 | N | Y (SM100/103) | N | N | N | N | N | N | N | N | N |
| W4A16 MXFP4 | Y (SM90) | Y (SM100/103) | N | N | N | N | N | Y (SM90) | N | N | N |
| W4A8 MXFP4 FP8 | Y (SM100/103) | Y (SM100/103) | N | N | N | N | N | Y (SM90) | N | N | N |
| W4A8 MXFP4 MXFP8 | Y (SM100/103) | Y (SM100/103) | N | N | N | Y (SM100/103, requires `hidden_size % 512 == 0`) | N | N | N | N | N |
| W8A8 MXFP8 MXFP8 | Y (SM100/103) | N | N | N | N | N | N | N | N | N | N |
| W4A8 AWQ | Y (SM89/90) | N | N | N | N | N | N | N | N | N | N |
| W8A16 | Y (SM80+) | N | N | N | N | N | N | N | N | N | N |
| INT4 WoQ (W4AFP8) | N | N | N | N | N | N | N | N | N | Y | N |

† The `WideEP` column is history, not an option. `resolve_moe_impl` raises on the
`WIDEEP` literal, so nothing in that column can be selected — read a `Y` there as
"the retired class implemented this", never as "you may request this". For
`INT4 WoQ (W4AFP8)` that leaves the row without a selectable backend.
| Quantization | Cutlass | TRTLLMGen | DeepGemm | DenseGEMM | CuteDSL | MegaMoE-DG | MegaMoE-CuteDSL | Triton | Marlin | Vanilla |
|---|---|---|---|---|---|---|---|---|---|---|
| Unquantized (BF16/FP16) | Y (SM80+) | Y (SM100/103, BF16, needs FlashInfer `trtllm_bf16_moe`)§ | N | N | N | N | N | Y (SM90, BF16) | N | Y |
| FP8 QDQ | Y (SM89+) | N | N | N | N | N | N | Y (SM90) | N | Y |
| FP8 Block Scales | Y (SM90, SM120) | Y (SM100/103) | Y (SM100/103) | N | N‡ | N | N | N | N | Y |
| NVFP4 | Y (SM100/103/120/121) | Y (SM100/103) | N | Y (SM100/103) | Y (SM100/103/120/121) | N | Y (SM100/103, cu13 cutlass-dsl + NVSHMEM provider; per-expert alpha/norm_const + SwiGLU clamp) | N | Y (SM89-SM99) | Y |
| W4A16 NVFP4 | Y (SM80+, dequant-on-the-fly) | N | N | N | Y (SM120/121 via `CuteDslB12xFusedMoE`, needs flashinfer) | N | N | N | Y (SM89-SM99, BF16) | Y |
| W4A8 NVFP4 FP8 | N | Y (SM100/103) | N | N | N | N | N | N | N | N |
| W4A16 MXFP4 | Y (SM90) | Y (SM100/103) | N | N | N | N | N | Y (SM90) | N | N |
| W4A8 MXFP4 FP8 | Y (SM100/103) | Y (SM100/103) | N | N | N | N | N | Y (SM90) | N | N |
| W4A8 MXFP4 MXFP8 | Y (SM100/103) | Y (SM100/103) | N | N | N | Y (SM100/103, requires `hidden_size % 512 == 0`) | N | N | N | N |
| W8A8 MXFP8 MXFP8 | Y (SM100/103) | N | N | N | N | N | N | N | N | N |
| W4A8 AWQ | Y (SM89/90) | N | N | N | N | N | N | N | N | N |
| W8A16 | Y (SM80+) | N | N | N | N | N | N | N | N | N |
| INT4 WoQ (W4AFP8) | N | N | N | N | N | N | N | N | N | N |

§ The unquantized `TRTLLMGenFusedMoE` path is not a TRTLLM-Gen kernel at all: it
calls FlashInfer's `trtllm_bf16_moe` / `trtllm_bf16_routed_moe`, which is why it
Expand Down
2 changes: 0 additions & 2 deletions tensorrt_llm/_torch/modules/fused_moe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from .fused_moe_triton import TritonFusedMoE
from .fused_moe_trtllm_gen import TRTLLMGenFusedMoE
from .fused_moe_vanilla import VanillaMoE
from .fused_moe_wide_ep import WideEPMoE
from .impl_base import MoEImplBase
from .interface import MoE, MoEWeightLoadingMode
from .moe_load_balancer import (MoeLoadBalancer,
Expand Down Expand Up @@ -61,5 +60,4 @@
"TritonFusedMoE",
"TRTLLMGenFusedMoE",
"VanillaMoE",
"WideEPMoE",
]
6 changes: 1 addition & 5 deletions tensorrt_llm/_torch/modules/fused_moe/create_moe.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from .fused_moe_triton import TritonFusedMoE
from .fused_moe_trtllm_gen import TRTLLMGenFusedMoE
from .fused_moe_vanilla import VanillaMoE
from .fused_moe_wide_ep import WideEPMoE
from .interface import MoE, MoEWeightLoadingMode
from .mega_moe import MegaMoECuteDsl, MegaMoEDeepGemm
from .moe_load_balancer import get_moe_load_balancer
Expand Down Expand Up @@ -98,9 +97,6 @@ def create_moe_backend(
Returns:
MoE: MoE backend instance
"""
if moe_cls is WideEPMoE:
raise ValueError(WIDEEP_DEPRECATION_MESSAGE)

shapes = derive_moe_layer_shapes(
model_config,
num_experts=num_experts,
Expand Down Expand Up @@ -499,7 +495,7 @@ def create_moe(
communication_method=communication_method,
)

# WideEPMoE, TritonFusedMoE and VanillaMoE are not wrapped by ConfigurableMoE
# TritonFusedMoE and VanillaMoE are not wrapped by ConfigurableMoE
# and own their communication and forward paths.
if communication_method is not None:
raise ValueError("communication_method requires ConfigurableMoE.")
Expand Down
Loading
Loading