Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions python/sglang/srt/utils/hf_transformers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
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

Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions python/sglang/srt/utils/hf_transformers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

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 (
Expand All @@ -32,6 +31,7 @@
_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

Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions python/sglang/srt/utils/hf_transformers/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
attach_additional_stop_token_ids,
download_from_hf,
get_tokenizer_from_processor,
resolve_runai_obj_uri,
)
from .mistral_utils import (
is_mistral_model,
Expand Down Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions python/sglang/srt/utils/hf_transformers/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
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,
Expand Down Expand Up @@ -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.
Expand Down
Loading