55import sys
66import time
77import traceback
8+ from math import log
89
910import requests
1011
@@ -153,41 +154,19 @@ def monitor_and_release_process(backend_process, frontend_process):
153154def should_auto_configure_deepep () -> bool :
154155 """
155156 Check if DeepEP should be auto-configured.
156- Returns True if current values match defaults (user hasn't manually set them).
157- Returns False if user has manually set any of the DeepEP values to non-default.
158-
159- This function reads values from StaticConfig.moe_config and compares them with
160- default values to determine if user has manually configured.
161-
162- Default values:
163- - USE_DEEPEP_MOE: False
164- - USE_DEEPEP_INTERNODE: False
165- - USE_DEEPEP_LOW_LATENCY: True
157+ Returns True if environment variables are not set (None), meaning user hasn't manually configured.
158+ Returns False if user has manually set any of the DeepEP environment variables.
166159 """
167- # Default values
168- default_use_deepep_moe = False
169- default_use_deepep_internode = False
170- default_use_deepep_low_latency = True
171-
172- # Read current values from StaticConfig.moe_config
173- current_use_deepep_moe = StaticConfig .moe_config .use_deepep_moe
174- current_use_deepep_internode = StaticConfig .moe_config .use_deepep_internode
175- current_use_deepep_low_latency = StaticConfig .moe_config .use_deepep_low_latency
176-
177- # Check if current values match defaults
178- # If all match defaults, user hasn't manually set them, so we should auto-configure
179- # If any value differs from default, user has manually configured, so we shouldn't auto-configure
180- return (
181- current_use_deepep_moe == default_use_deepep_moe
182- and current_use_deepep_internode == default_use_deepep_internode
183- and current_use_deepep_low_latency == default_use_deepep_low_latency
184- )
160+ return StaticConfig .should_auto_configure_deepep ()
185161
186162
187163def auto_configure_deepep (args : argparse .Namespace ):
188164 """
189165 Automatically configure DeepEP settings based on deployment scenario.
190166
167+ Note: USE_ALL_GATHER should be enabled for pure TP scenarios (ep_size == tp_size).
168+ When USE_ALL_GATHER is enabled, DeepEP should not be used.
169+
191170 Configuration rules (for 8-GPU machine):
192171 - Non-PD separation + Inference node + Single GPU (1TP): 0, 0, 0
193172 - Non-PD separation + Inference node + Single-node multi-GPU (>1TP): 1, 0, 0
@@ -199,10 +178,19 @@ def auto_configure_deepep(args: argparse.Namespace):
199178 - PD separation + Prefill node + Multi-node multi-GPU (>=9 GPUs): 1, 0, 1
200179 - PD separation + Decode node + Multi-node multi-GPU (>=9 GPUs): 1, 1, 1
201180 """
202- # If USE_ALL_GATHER is enabled, disable all DeepEP settings
203- use_all_gather = StaticConfig .parallelism_distributed_config .use_all_gather
181+ logging .info ("auto configure deepep work" )
182+ # Get parallelism info for use_all_gather calculation
183+ world_size = g_parallel_info .world_size
184+ tp_size = g_parallel_info .tp_size
185+ ep_size = g_parallel_info .ep_size
186+ logging .info (f"world_size: { world_size } , tp_size: { tp_size } , ep_size: { ep_size } " )
187+ # If USE_ALL_GATHER is enabled (for pure TP scenarios), disable all DeepEP settings
188+ # Calculate use_all_gather: (USE_ALL_GATHER env is True) and (ep_size == tp_size)
189+ use_all_gather_env = StaticConfig .parallelism_distributed_config .use_all_gather
190+ use_all_gather = use_all_gather_env and (ep_size == tp_size )
204191
205192 if use_all_gather :
193+ logging .info ("use all gather in `auto_configure_deepep`" )
206194 os .environ ["USE_DEEPEP_MOE" ] = "0"
207195 os .environ ["USE_DEEPEP_LOW_LATENCY" ] = "0"
208196 os .environ ["USE_DEEPEP_INTERNODE" ] = "0"
@@ -217,8 +205,6 @@ def auto_configure_deepep(args: argparse.Namespace):
217205 role_type = (
218206 role_type_enum .name if hasattr (role_type_enum , "name" ) else str (role_type_enum )
219207 )
220- world_size = g_parallel_info .world_size
221- tp_size = g_parallel_info .tp_size
222208
223209 # Get number of nodes
224210 try :
0 commit comments