Fix RunAI object-storage checkpoint index filtering (#38988)

This commit is contained in:
Aurick Qiao
2026-09-12 12:25:57 +08:00
committed by GitHub
parent a984c78330
commit c389dd0863
4 changed files with 191 additions and 25 deletions
+9 -1
View File
@@ -4118,7 +4118,11 @@ class RunaiModelStreamerLoader(BaseModelLoader):
"""Prepare weights for the model.
If the model is not local, it will be downloaded."""
from sglang.srt.utils.runai_utils import is_runai_obj_uri, list_safetensors
from sglang.srt.utils.runai_utils import (
ObjectStorageModel,
is_runai_obj_uri,
list_safetensors,
)
is_object_storage_path = is_runai_obj_uri(model_name_or_path)
if self._is_distributed is None:
@@ -4160,6 +4164,10 @@ class RunaiModelStreamerLoader(BaseModelLoader):
self.load_config.download_dir,
revision,
)
if is_object_storage_path:
index_file = os.path.abspath(
os.path.join(ObjectStorageModel.get_path(hf_folder), index_file)
)
hf_weights_files = filter_duplicate_safetensors_files(
hf_weights_files, hf_folder, index_file
)
+14 -2
View File
@@ -830,7 +830,10 @@ def filter_duplicate_safetensors_files(
if any(fnmatch.fnmatch(rel_path, pattern) for pattern in allow_patterns):
files_to_validate.add(f)
missing_files = sorted(f for f in files_to_validate if not os.path.isfile(f))
if "://" in hf_folder:
missing_files = sorted(files_to_validate.difference(hf_weights_files))
else:
missing_files = sorted(f for f in files_to_validate if not os.path.isfile(f))
if missing_files:
raise RuntimeError(
f"{index_file} references {len(missing_files)} shard file(s) missing "
@@ -876,7 +879,16 @@ def maybe_add_mtp_safetensors(
# Check if mtp.safetensors exists and is not already in the file list
mtp_path = os.path.join(hf_folder, "mtp.safetensors")
if not os.path.isfile(mtp_path) or mtp_path in hf_weights_files:
if mtp_path in hf_weights_files:
return hf_weights_files
from sglang.srt.utils.runai_utils import is_runai_obj_uri, list_safetensors
if is_runai_obj_uri(hf_folder):
mtp_exists = mtp_path in list_safetensors(hf_folder)
else:
mtp_exists = os.path.isfile(mtp_path)
if not mtp_exists:
return hf_weights_files
# mtp.safetensors exists but not in index - this is a bug