Fix external_models import path and migrate model loading tests (#16458)

This commit is contained in:
Alison Shao
2026-01-08 23:43:49 -08:00
committed by GitHub
parent 9d4d57dbfa
commit e46f79431b
8 changed files with 24 additions and 21 deletions
@@ -2,13 +2,17 @@ import unittest
import sglang as sgl
from sglang.srt.environ import envs
from sglang.test.ci.ci_register import register_amd_ci, register_cuda_ci
from sglang.test.test_utils import CustomTestCase
register_cuda_ci(est_time=30, suite="stage-b-test-small-1-gpu")
register_amd_ci(est_time=45, suite="stage-b-test-small-1-gpu")
class TestExternalModels(CustomTestCase):
def test_external_model(self):
envs.SGLANG_EXTERNAL_MODEL_PACKAGE.set("external_models")
envs.SGLANG_EXTERNAL_MM_PROCESSOR_PACKAGE.set("external_models")
envs.SGLANG_EXTERNAL_MODEL_PACKAGE.set("sglang.test.external_models")
envs.SGLANG_EXTERNAL_MM_PROCESSOR_PACKAGE.set("sglang.test.external_models")
prompt = "Today is a sunny day and I like"
model_path = "Qwen/Qwen2-VL-2B-Instruct"
@@ -17,6 +17,9 @@ from sglang.srt.configs.device_config import DeviceConfig
from sglang.srt.configs.load_config import LoadConfig
from sglang.srt.configs.model_config import ModelConfig
from sglang.srt.model_loader.loader import ModelOptModelLoader
from sglang.test.ci.ci_register import register_cuda_ci
register_cuda_ci(est_time=9, suite="stage-b-test-small-1-gpu")
# Note: PYTHONPATH=python should be set when running tests
@@ -10,6 +10,14 @@ from unittest.mock import MagicMock, patch
import torch.nn as nn
from sglang.srt.configs.device_config import DeviceConfig
from sglang.srt.configs.load_config import LoadConfig
from sglang.srt.configs.model_config import ModelConfig
from sglang.srt.layers.modelopt_utils import QUANT_CFG_CHOICES
from sglang.srt.model_loader.loader import ModelOptModelLoader
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.test_utils import CustomTestCase
# Note: PYTHONPATH=python should be set when running tests
# Constants for calibration parameters to avoid hard-coded values
@@ -17,17 +25,7 @@ CALIBRATION_BATCH_SIZE = 36
CALIBRATION_NUM_SAMPLES = 512
DEFAULT_DEVICE = "cuda:0"
# Constants for calibration parameters to avoid hard-coded values
CALIBRATION_BATCH_SIZE = 36
CALIBRATION_NUM_SAMPLES = 512
DEFAULT_DEVICE = "cuda:0"
from sglang.srt.configs.device_config import DeviceConfig
from sglang.srt.configs.load_config import LoadConfig
from sglang.srt.configs.model_config import ModelConfig
from sglang.srt.layers.modelopt_utils import QUANT_CFG_CHOICES
from sglang.srt.model_loader.loader import ModelOptModelLoader
from sglang.test.test_utils import CustomTestCase
register_cuda_ci(est_time=11, suite="stage-b-test-small-1-gpu")
class TestModelOptModelLoader(CustomTestCase):
@@ -9,8 +9,11 @@ from transformers import AutoModelForCausalLM
from sglang.srt.entrypoints.engine import Engine
from sglang.srt.weight_sync.utils import update_weights
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.test_utils import DEFAULT_SMALL_MODEL_NAME_FOR_TEST
register_cuda_ci(est_time=29, suite="stage-b-test-small-1-gpu")
class AsyncEngine(Engine):
def __init__(self, **kwargs):
@@ -1,21 +0,0 @@
from sglang.srt.models.qwen2_vl import (
Qwen2VLForConditionalGeneration as OriginalQwen2VLForConditionalGeneration,
)
from sglang.srt.multimodal.processors.qwen_vl import QwenVLImageProcessor
class Qwen2VLForConditionalGeneration(OriginalQwen2VLForConditionalGeneration):
def __init__(self, config, quant_config, prefix: str = "") -> None:
super().__init__(config, quant_config, prefix)
print("init custom model:", self.__class__.__name__)
class CustomProcessor(QwenVLImageProcessor):
models = [Qwen2VLForConditionalGeneration]
def __init__(self, hf_config, server_args, _processor, *args, **kwargs):
super().__init__(hf_config, server_args, _processor, *args, **kwargs)
print("init custom processor:", self.__class__.__name__)
EntryClass = Qwen2VLForConditionalGeneration
-5
View File
@@ -10,11 +10,7 @@ from sglang.test.ci.ci_utils import TestFile, run_unittest_files
suites = {
"per-commit-1-gpu": [
TestFile("test_evs.py", 20),
TestFile("test_external_models.py", 30),
TestFile("test_modelopt_loader.py", 11),
TestFile("test_utils_update_weights.py", 29),
TestFile("test_video_utils.py", 5),
TestFile("test_modelopt_export.py", 9),
],
"per-commit-4-gpu": [
TestFile("models/test_qwen3_next_models.py", 650),
@@ -92,7 +88,6 @@ suite_amd = {
# TestFile("lora/test_lora_cuda_graph.py", 250), # Disabled temporarily, see https://github.com/sgl-project/sglang/issues/13107
# TestFile("lora/test_lora_qwen3.py", 97), # Disabled temporarily, see https://github.com/sgl-project/sglang/issues/13107
TestFile("test_bench_typebaseddispatcher.py", 10),
TestFile("test_external_models.py", 45),
TestFile("test_rope_rocm.py", 3),
# TestFile("test_torch_compile_moe.py", 210), # Disabled temporarily, see https://github.com/sgl-project/sglang/issues/13107
TestFile("test_type_based_dispatcher.py", 10),