diff --git a/python/sglang/srt/distributed/device_communicators/custom_all_reduce.py b/python/sglang/srt/distributed/device_communicators/custom_all_reduce.py index b14211e17..8a9d4dd13 100644 --- a/python/sglang/srt/distributed/device_communicators/custom_all_reduce.py +++ b/python/sglang/srt/distributed/device_communicators/custom_all_reduce.py @@ -344,6 +344,8 @@ def dispatch_custom_allreduce(): On CUDA, the JIT-compiled v2 implementation is used by default. Set SGLANG_OPT_USE_CUSTOM_ALL_REDUCE_V2=0 to fall back to the legacy CustomAllreduce. + Note: ``ServerArgs._handle_environment_variables`` forces this env to "0" when + ``nnodes > 1`` since custom AR is intra-node only. """ if _is_cuda and envs.SGLANG_OPT_USE_CUSTOM_ALL_REDUCE_V2.get(): from .custom_all_reduce_v2 import CustomAllReduceV2 diff --git a/python/sglang/srt/server_args.py b/python/sglang/srt/server_args.py index 4a1fe0540..7d1ff0e31 100644 --- a/python/sglang/srt/server_args.py +++ b/python/sglang/srt/server_args.py @@ -4012,6 +4012,16 @@ class ServerArgs: envs.SGLANG_ENABLE_DETERMINISTIC_INFERENCE.set( "1" if self.enable_deterministic_inference else "0" ) + # Custom all-reduce v2 uses IPC handles and is intra-node only. Force-disable + # on multi-node so the dispatch falls back to the legacy CustomAllreduce path. + if self.nnodes > 1 and envs.SGLANG_OPT_USE_CUSTOM_ALL_REDUCE_V2.get(): + if envs.SGLANG_OPT_USE_CUSTOM_ALL_REDUCE_V2.is_set(): + logger.warning( + "Disabling SGLANG_OPT_USE_CUSTOM_ALL_REDUCE_V2 because nnodes=%d " + "(custom all-reduce v2 is intra-node only).", + self.nnodes, + ) + envs.SGLANG_OPT_USE_CUSTOM_ALL_REDUCE_V2.set("0") if self.debug_cuda_graph: if not is_cuda(): logger.warning(