[Bugfix] Skip routed-experts hot path when disabled (#42148)

This commit is contained in:
aoshen02
2026-05-09 18:01:04 -07:00
committed by GitHub
parent ea0e501bb1
commit 006af4b956
+6
View File
@@ -6154,6 +6154,7 @@ class GPUModelRunner(
"Skipping CUDA graph capture. To turn on CUDA graph capture, " "Skipping CUDA graph capture. To turn on CUDA graph capture, "
"ensure `cudagraph_mode` was not manually set to `NONE`" "ensure `cudagraph_mode` was not manually set to `NONE`"
) )
if self.model_config.enable_return_routed_experts:
self.init_routed_experts_capturer() self.init_routed_experts_capturer()
return 0 return 0
@@ -6193,6 +6194,7 @@ class GPUModelRunner(
# address is baked into the graph. Do NOT call this inside # address is baked into the graph. Do NOT call this inside
# _capture_cudagraphs() -- creating the capturer twice replaces # _capture_cudagraphs() -- creating the capturer twice replaces
# the device buffer, causing graphs to write to a dead buffer. # the device buffer, causing graphs to write to a dead buffer.
if self.model_config.enable_return_routed_experts:
self.init_routed_experts_capturer() self.init_routed_experts_capturer()
# Trigger CUDA graph capture for specific shapes. # Trigger CUDA graph capture for specific shapes.
@@ -6989,6 +6991,10 @@ class GPUModelRunner(
"Initializing routed experts capturer, enable_return_routed_experts: %s", "Initializing routed experts capturer, enable_return_routed_experts: %s",
self.model_config.enable_return_routed_experts, self.model_config.enable_return_routed_experts,
) )
if not self.model_config.enable_return_routed_experts:
self.routed_experts_initialized = False
return
from vllm.distributed import get_tp_group from vllm.distributed import get_tp_group
if hasattr(self.model_config.hf_text_config, "n_shared_experts"): if hasattr(self.model_config.hf_text_config, "n_shared_experts"):