[Bug Fix] Fix RunAI streamer: corrupted weights, missing quant init, and broken URIs for multimodal models (#22715)
Co-authored-by: Alex Nails <alex.nails@radixark.ai>
This commit is contained in:
@@ -52,6 +52,7 @@ from sglang.srt.configs import (
|
|||||||
from sglang.srt.configs.deepseek_ocr import DeepseekVLV2Config
|
from sglang.srt.configs.deepseek_ocr import DeepseekVLV2Config
|
||||||
from sglang.srt.configs.internvl import InternVLChatConfig
|
from sglang.srt.configs.internvl import InternVLChatConfig
|
||||||
from sglang.srt.utils import get_bool_env_var, logger, lru_cache_frozenset
|
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
|
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)
|
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):
|
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)."""
|
"""Resolve a file from a local directory or HF hub cache (no network)."""
|
||||||
local_path = Path(model_name_or_path) / filename
|
local_path = Path(model_name_or_path) / filename
|
||||||
|
|||||||
@@ -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.connector import create_remote_connector
|
||||||
from sglang.srt.utils import is_remote_url, lru_cache_frozenset
|
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 ..hf_transformers_patches import _ensure_gguf_version
|
||||||
from .common import (
|
from .common import (
|
||||||
@@ -32,6 +31,7 @@ from .common import (
|
|||||||
_override_v_head_dim_if_zero,
|
_override_v_head_dim_if_zero,
|
||||||
check_gguf_file,
|
check_gguf_file,
|
||||||
get_hf_text_config,
|
get_hf_text_config,
|
||||||
|
resolve_runai_obj_uri,
|
||||||
)
|
)
|
||||||
from .mistral_utils import is_mistral_model, load_mistral_config
|
from .mistral_utils import is_mistral_model, load_mistral_config
|
||||||
|
|
||||||
@@ -60,8 +60,7 @@ def get_config(
|
|||||||
kwargs["gguf_file"] = model
|
kwargs["gguf_file"] = model
|
||||||
model = Path(model).parent
|
model = Path(model).parent
|
||||||
|
|
||||||
if is_runai_obj_uri(model):
|
model = resolve_runai_obj_uri(model)
|
||||||
model = ObjectStorageModel.get_path(model)
|
|
||||||
|
|
||||||
if is_remote_url(model):
|
if is_remote_url(model):
|
||||||
client = create_remote_connector(model)
|
client = create_remote_connector(model)
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ from .common import (
|
|||||||
attach_additional_stop_token_ids,
|
attach_additional_stop_token_ids,
|
||||||
download_from_hf,
|
download_from_hf,
|
||||||
get_tokenizer_from_processor,
|
get_tokenizer_from_processor,
|
||||||
|
resolve_runai_obj_uri,
|
||||||
)
|
)
|
||||||
from .mistral_utils import (
|
from .mistral_utils import (
|
||||||
is_mistral_model,
|
is_mistral_model,
|
||||||
@@ -150,6 +151,8 @@ def get_processor(
|
|||||||
_ensure_fastokens_patched()
|
_ensure_fastokens_patched()
|
||||||
|
|
||||||
revision = kwargs.pop("revision", tokenizer_revision)
|
revision = kwargs.pop("revision", tokenizer_revision)
|
||||||
|
tokenizer_name = resolve_runai_obj_uri(tokenizer_name)
|
||||||
|
|
||||||
if is_mistral_model(tokenizer_name):
|
if is_mistral_model(tokenizer_name):
|
||||||
config = load_mistral_config(
|
config = load_mistral_config(
|
||||||
tokenizer_name,
|
tokenizer_name,
|
||||||
|
|||||||
@@ -28,13 +28,13 @@ from transformers import (
|
|||||||
from sglang.srt.connector import create_remote_connector
|
from sglang.srt.connector import create_remote_connector
|
||||||
from sglang.srt.utils import is_remote_url, logger
|
from sglang.srt.utils import is_remote_url, logger
|
||||||
from sglang.srt.utils.patch_tokenizer import patch_tokenizer
|
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 ..hf_transformers_patches import _ensure_gguf_version
|
||||||
from .common import (
|
from .common import (
|
||||||
_resolve_local_or_cached_file,
|
_resolve_local_or_cached_file,
|
||||||
attach_additional_stop_token_ids,
|
attach_additional_stop_token_ids,
|
||||||
check_gguf_file,
|
check_gguf_file,
|
||||||
|
resolve_runai_obj_uri,
|
||||||
)
|
)
|
||||||
from .mistral_utils import (
|
from .mistral_utils import (
|
||||||
_MISTRAL_TOKENIZER_REDIRECTS,
|
_MISTRAL_TOKENIZER_REDIRECTS,
|
||||||
@@ -146,8 +146,7 @@ def _resolve_tokenizer_name(tokenizer_name, kwargs):
|
|||||||
kwargs["gguf_file"] = tokenizer_name
|
kwargs["gguf_file"] = tokenizer_name
|
||||||
tokenizer_name = Path(tokenizer_name).parent
|
tokenizer_name = Path(tokenizer_name).parent
|
||||||
|
|
||||||
if is_runai_obj_uri(tokenizer_name):
|
tokenizer_name = resolve_runai_obj_uri(tokenizer_name)
|
||||||
tokenizer_name = ObjectStorageModel.get_path(tokenizer_name)
|
|
||||||
|
|
||||||
if is_remote_url(tokenizer_name):
|
if is_remote_url(tokenizer_name):
|
||||||
# BaseConnector implements __del__() to clean up the local dir.
|
# BaseConnector implements __del__() to clean up the local dir.
|
||||||
|
|||||||
Reference in New Issue
Block a user