From 9f3169960a37f230f9fe9629b6bc8e1bbf5969eb Mon Sep 17 00:00:00 2001 From: Thien Tran Date: Thu, 6 Aug 2026 09:17:53 +0800 Subject: [PATCH] [MoE] Align TRTLLM MXFP4 autotune buckets (#50942) Signed-off-by: Thien Tran Co-authored-by: OpenAI Codex --- .../layers/fused_moe/experts/trtllm_mxfp4_moe.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/vllm/model_executor/layers/fused_moe/experts/trtllm_mxfp4_moe.py b/vllm/model_executor/layers/fused_moe/experts/trtllm_mxfp4_moe.py index 315ec9f9c0..7154fce0b2 100644 --- a/vllm/model_executor/layers/fused_moe/experts/trtllm_mxfp4_moe.py +++ b/vllm/model_executor/layers/fused_moe/experts/trtllm_mxfp4_moe.py @@ -14,7 +14,10 @@ from vllm.model_executor.layers.fused_moe.config import ( from vllm.model_executor.layers.fused_moe.topk_weight_and_reduce import ( TopKWeightAndReduceNoOP, ) -from vllm.model_executor.layers.fused_moe.utils import trtllm_moe_pack_topk_ids_weights +from vllm.model_executor.layers.fused_moe.utils import ( + fi_moe_largest_bucket, + trtllm_moe_pack_topk_ids_weights, +) from vllm.model_executor.layers.quantization.utils.flashinfer_utils import ( activation_to_flashinfer_int, has_flashinfer_situ_activation, @@ -113,8 +116,6 @@ class TrtLlmMxfp4ExpertsBase: ) self.gemm1_clamp_limit = None - self.max_capture_size = moe_config.max_capture_size - @staticmethod def _supports_current_device() -> bool: p = current_platform @@ -263,7 +264,7 @@ class TrtLlmMxfp4ExpertsMonolithic( routing_method_type=self.routing_method_type, do_finalize=True, activation_type=self._flashinfer_activation_type(activation), - tune_max_num_tokens=max(self.max_capture_size, 1), + tune_max_num_tokens=fi_moe_largest_bucket(self.moe_config), output=output, routing_replay_out=routing_replay_out, ) @@ -382,7 +383,7 @@ class TrtLlmMxfp4ExpertsModular(TrtLlmMxfp4ExpertsBase, mk.FusedMoEExpertsModula enable_pdl=True, activation_type=self._flashinfer_activation_type(activation), output=output, - tune_max_num_tokens=max(self.max_capture_size, 1), + tune_max_num_tokens=fi_moe_largest_bucket(self.moe_config), ) def apply(