diff --git a/python/sglang/srt/utils/hf_transformers/common.py b/python/sglang/srt/utils/hf_transformers/common.py index 280fcfec6..ecd024f4c 100644 --- a/python/sglang/srt/utils/hf_transformers/common.py +++ b/python/sglang/srt/utils/hf_transformers/common.py @@ -52,6 +52,7 @@ from sglang.srt.configs import ( from sglang.srt.configs.deepseek_ocr import DeepseekVLV2Config from sglang.srt.configs.internvl import InternVLChatConfig from sglang.srt.utils import get_bool_env_var, logger, lru_cache_frozenset +from sglang.srt.utils.runai_utils import ObjectStorageModel, is_runai_obj_uri from ..hf_transformers_patches import normalize_rope_scaling_compat @@ -140,6 +141,12 @@ def download_from_hf( return snapshot_download(model_path, allow_patterns=allow_patterns) +def resolve_runai_obj_uri(model_name_or_path: str) -> str: + if is_runai_obj_uri(model_name_or_path): + return ObjectStorageModel.get_path(model_name_or_path) + return model_name_or_path + + def _resolve_local_or_cached_file(model_name_or_path, filename, revision=None): """Resolve a file from a local directory or HF hub cache (no network).""" local_path = Path(model_name_or_path) / filename diff --git a/python/sglang/srt/utils/hf_transformers/config.py b/python/sglang/srt/utils/hf_transformers/config.py index 479199669..3069cb09e 100644 --- a/python/sglang/srt/utils/hf_transformers/config.py +++ b/python/sglang/srt/utils/hf_transformers/config.py @@ -20,7 +20,6 @@ from transformers.models.auto.modeling_auto import MODEL_FOR_CAUSAL_LM_MAPPING_N from sglang.srt.connector import create_remote_connector from sglang.srt.utils import is_remote_url, lru_cache_frozenset -from sglang.srt.utils.runai_utils import ObjectStorageModel, is_runai_obj_uri from ..hf_transformers_patches import _ensure_gguf_version from .common import ( @@ -32,6 +31,7 @@ from .common import ( _override_v_head_dim_if_zero, check_gguf_file, get_hf_text_config, + resolve_runai_obj_uri, ) from .mistral_utils import is_mistral_model, load_mistral_config @@ -60,8 +60,7 @@ def get_config( kwargs["gguf_file"] = model model = Path(model).parent - if is_runai_obj_uri(model): - model = ObjectStorageModel.get_path(model) + model = resolve_runai_obj_uri(model) if is_remote_url(model): client = create_remote_connector(model) diff --git a/python/sglang/srt/utils/hf_transformers/processor.py b/python/sglang/srt/utils/hf_transformers/processor.py index e19227a3e..a57e4b4c1 100644 --- a/python/sglang/srt/utils/hf_transformers/processor.py +++ b/python/sglang/srt/utils/hf_transformers/processor.py @@ -35,6 +35,7 @@ from .common import ( attach_additional_stop_token_ids, download_from_hf, get_tokenizer_from_processor, + resolve_runai_obj_uri, ) from .mistral_utils import ( is_mistral_model, @@ -150,6 +151,8 @@ def get_processor( _ensure_fastokens_patched() revision = kwargs.pop("revision", tokenizer_revision) + tokenizer_name = resolve_runai_obj_uri(tokenizer_name) + if is_mistral_model(tokenizer_name): config = load_mistral_config( tokenizer_name, diff --git a/python/sglang/srt/utils/hf_transformers/tokenizer.py b/python/sglang/srt/utils/hf_transformers/tokenizer.py index 41df30610..9a0fafb0f 100644 --- a/python/sglang/srt/utils/hf_transformers/tokenizer.py +++ b/python/sglang/srt/utils/hf_transformers/tokenizer.py @@ -28,13 +28,13 @@ from transformers import ( from sglang.srt.connector import create_remote_connector from sglang.srt.utils import is_remote_url, logger from sglang.srt.utils.patch_tokenizer import patch_tokenizer -from sglang.srt.utils.runai_utils import ObjectStorageModel, is_runai_obj_uri from ..hf_transformers_patches import _ensure_gguf_version from .common import ( _resolve_local_or_cached_file, attach_additional_stop_token_ids, check_gguf_file, + resolve_runai_obj_uri, ) from .mistral_utils import ( _MISTRAL_TOKENIZER_REDIRECTS, @@ -146,8 +146,7 @@ def _resolve_tokenizer_name(tokenizer_name, kwargs): kwargs["gguf_file"] = tokenizer_name tokenizer_name = Path(tokenizer_name).parent - if is_runai_obj_uri(tokenizer_name): - tokenizer_name = ObjectStorageModel.get_path(tokenizer_name) + tokenizer_name = resolve_runai_obj_uri(tokenizer_name) if is_remote_url(tokenizer_name): # BaseConnector implements __del__() to clean up the local dir.