From 19f6a33ce9d53f58c65a8ffdac0a805f4e19281d Mon Sep 17 00:00:00 2001 From: Lianmin Zheng Date: Thu, 13 Nov 2025 15:58:47 -0800 Subject: [PATCH] [Auto Sync] Update pynccl_wrapper.py, environ.py, registry.... (20251111) (#13097) Co-authored-by: github-actions[bot] Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com> --- .../srt/distributed/device_communicators/pynccl_wrapper.py | 6 +++--- python/sglang/srt/environ.py | 6 ++++++ python/sglang/srt/models/registry.py | 6 ++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/python/sglang/srt/distributed/device_communicators/pynccl_wrapper.py b/python/sglang/srt/distributed/device_communicators/pynccl_wrapper.py index 579811777..6b12f2922 100644 --- a/python/sglang/srt/distributed/device_communicators/pynccl_wrapper.py +++ b/python/sglang/srt/distributed/device_communicators/pynccl_wrapper.py @@ -340,10 +340,10 @@ class NCCLLibrary: self.lib = NCCLLibrary.path_to_library_cache[so_file] except Exception as e: logger.error( - "Failed to load NCCL library from %s ." - "It is expected if you are not running on NVIDIA/AMD GPUs." + "Failed to load NCCL library from %s . " + "It is expected if you are not running on NVIDIA/AMD GPUs. " "Otherwise, the nccl library might not exist, be corrupted " - "or it does not support the current platform %s." + "or it does not support the current platform %s. " "If you already have the library, please set the " "environment variable SGLANG_NCCL_SO_PATH" " to point to the correct nccl library path.", diff --git a/python/sglang/srt/environ.py b/python/sglang/srt/environ.py index 3903f0be5..8bec1c3c8 100644 --- a/python/sglang/srt/environ.py +++ b/python/sglang/srt/environ.py @@ -75,6 +75,11 @@ class EnvField: return self.get() +class EnvTuple(EnvField): + def parse(self, value: str) -> tuple[str, ...]: + return tuple(s.strip() for s in value.split(",") if s.strip()) + + class EnvStr(EnvField): def parse(self, value: str) -> str: return value @@ -125,6 +130,7 @@ class Envs: # Model & File Download SGLANG_USE_MODELSCOPE = EnvBool(False) + SGLANG_DISABLED_MODEL_ARCHS = EnvTuple(tuple()) # Logging Options SGLANG_LOG_GC = EnvBool(False) diff --git a/python/sglang/srt/models/registry.py b/python/sglang/srt/models/registry.py index 5e2a3c67e..1745b7d7b 100644 --- a/python/sglang/srt/models/registry.py +++ b/python/sglang/srt/models/registry.py @@ -9,6 +9,8 @@ from typing import AbstractSet, Dict, List, Optional, Tuple, Type, Union import torch.nn as nn +from sglang.srt.environ import envs + logger = logging.getLogger(__name__) @@ -91,6 +93,10 @@ def import_model_classes(package_name: str): package = importlib.import_module(package_name) for _, name, ispkg in pkgutil.iter_modules(package.__path__, package_name + "."): if not ispkg: + if name.split(".")[-1] in envs.SGLANG_DISABLED_MODEL_ARCHS.get(): + logger.debug(f"Skip loading {name} due to SGLANG_DISABLED_MODEL_ARCHS") + continue + try: module = importlib.import_module(name) except Exception as e: