[ci] CI supports use cached models (#7874)

This commit is contained in:
Hank Han
2025-07-14 19:42:21 +08:00
committed by GitHub
parent c07f647c9f
commit 2117f82def
2 changed files with 75 additions and 0 deletions

View File

@@ -2,6 +2,7 @@
import argparse
import copy
import json
import logging
import os
import random
@@ -102,6 +103,15 @@ def is_in_amd_ci():
return get_bool_env_var("SGLANG_AMD_CI")
def _use_cached_default_models(model_repo: str):
cache_dir = os.getenv("DEFAULT_MODEL_CACHE_DIR")
if cache_dir and model_repo:
model_path = os.path.join(cache_dir, model_repo)
if os.path.isdir(model_path):
return os.path.abspath(model_path)
return ""
if is_in_ci():
DEFAULT_PORT_FOR_SRT_TEST_RUNNER = (
5000 + int(os.environ.get("CUDA_VISIBLE_DEVICES", "0")[0]) * 100
@@ -419,6 +429,31 @@ def get_call_select(args: argparse.Namespace):
return func
def _get_default_models():
import inspect
current_module = inspect.getmodule(_get_default_models)
default_models = set()
for name, value in current_module.__dict__.items():
if (
isinstance(name, str)
and "DEFAULT_" in name
and "MODEL_" in name
and isinstance(value, str)
):
if "," in value:
parts = [part.strip() for part in value.split(",")]
default_models.update(parts)
else:
default_models.add(value.strip())
return json.dumps(list(default_models))
def try_cached_model(model_repo: str):
model_dir = _use_cached_default_models(model_repo)
return model_dir if model_dir else model_repo
def popen_launch_server(
model: str,
base_url: str,