From e46f79431b809aca979f105cb6034684f9ff9b53 Mon Sep 17 00:00:00 2001 From: Alison Shao <54658187+alisonshao@users.noreply.github.com> Date: Thu, 8 Jan 2026 23:43:49 -0800 Subject: [PATCH] Fix external_models import path and migrate model loading tests (#16458) --- .github/workflows/pr-test.yml | 4 ++-- .../srt/layers/moe/moe_runner/deep_gemm.py | 2 +- .../test}/external_models/custom_qwen2_vl.py | 0 .../model_loading}/test_external_models.py | 8 ++++++-- .../model_loading}/test_modelopt_export.py | 3 +++ .../model_loading}/test_modelopt_loader.py | 20 +++++++++---------- .../test_utils_update_weights.py | 3 +++ test/srt/run_suite.py | 5 ----- 8 files changed, 24 insertions(+), 21 deletions(-) rename {test/srt => python/sglang/test}/external_models/custom_qwen2_vl.py (100%) rename test/{srt => registered/model_loading}/test_external_models.py (63%) rename test/{srt => registered/model_loading}/test_modelopt_export.py (99%) rename test/{srt => registered/model_loading}/test_modelopt_loader.py (99%) rename test/{srt => registered/model_loading}/test_utils_update_weights.py (97%) diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml index 1b9ad0ea9..7b870277d 100644 --- a/.github/workflows/pr-test.yml +++ b/.github/workflows/pr-test.yml @@ -594,7 +594,7 @@ jobs: strategy: fail-fast: false matrix: - partition: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] + partition: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] steps: - name: Checkout code uses: actions/checkout@v4 @@ -622,7 +622,7 @@ jobs: if [[ "${{ needs.check-changes.outputs.continue_on_error }}" == "true" ]]; then CONTINUE_ON_ERROR_FLAG="--continue-on-error" fi - python3 run_suite.py --hw cuda --suite stage-b-test-small-1-gpu --auto-partition-id ${{ matrix.partition }} --auto-partition-size 11 $CONTINUE_ON_ERROR_FLAG + python3 run_suite.py --hw cuda --suite stage-b-test-small-1-gpu --auto-partition-id ${{ matrix.partition }} --auto-partition-size 14 $CONTINUE_ON_ERROR_FLAG stage-b-test-large-1-gpu: needs: [check-changes, call-gate, stage-a-test-1, sgl-kernel-build-wheels] diff --git a/python/sglang/srt/layers/moe/moe_runner/deep_gemm.py b/python/sglang/srt/layers/moe/moe_runner/deep_gemm.py index f60a428ef..7fa8193fb 100644 --- a/python/sglang/srt/layers/moe/moe_runner/deep_gemm.py +++ b/python/sglang/srt/layers/moe/moe_runner/deep_gemm.py @@ -45,7 +45,7 @@ _DEEPGEMM_ON_H20 = get_bool_env_var("SGLANG_DEEPGEMM_ON_H20") # TODO(kaixih@nvidia): ideally we should merge this logic into # `fill_gateup_input_triton_kernel` to directly generate e8m0 scale. -@torch.compile +@torch.compile(disable=_is_hip or _is_npu) def _cast_to_e8m0_with_rounding_up(x: torch.Tensor) -> torch.Tensor: temp = x.to(torch.float32).view(torch.int32) exp = torch.bitwise_right_shift(temp, 23) diff --git a/test/srt/external_models/custom_qwen2_vl.py b/python/sglang/test/external_models/custom_qwen2_vl.py similarity index 100% rename from test/srt/external_models/custom_qwen2_vl.py rename to python/sglang/test/external_models/custom_qwen2_vl.py diff --git a/test/srt/test_external_models.py b/test/registered/model_loading/test_external_models.py similarity index 63% rename from test/srt/test_external_models.py rename to test/registered/model_loading/test_external_models.py index 49fd00391..3dbfcecf8 100644 --- a/test/srt/test_external_models.py +++ b/test/registered/model_loading/test_external_models.py @@ -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" diff --git a/test/srt/test_modelopt_export.py b/test/registered/model_loading/test_modelopt_export.py similarity index 99% rename from test/srt/test_modelopt_export.py rename to test/registered/model_loading/test_modelopt_export.py index aa477ff67..322cd9bc1 100644 --- a/test/srt/test_modelopt_export.py +++ b/test/registered/model_loading/test_modelopt_export.py @@ -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 diff --git a/test/srt/test_modelopt_loader.py b/test/registered/model_loading/test_modelopt_loader.py similarity index 99% rename from test/srt/test_modelopt_loader.py rename to test/registered/model_loading/test_modelopt_loader.py index a2bad70b5..96aaffa95 100644 --- a/test/srt/test_modelopt_loader.py +++ b/test/registered/model_loading/test_modelopt_loader.py @@ -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): diff --git a/test/srt/test_utils_update_weights.py b/test/registered/model_loading/test_utils_update_weights.py similarity index 97% rename from test/srt/test_utils_update_weights.py rename to test/registered/model_loading/test_utils_update_weights.py index 8c138f0ab..b670b2b46 100644 --- a/test/srt/test_utils_update_weights.py +++ b/test/registered/model_loading/test_utils_update_weights.py @@ -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): diff --git a/test/srt/run_suite.py b/test/srt/run_suite.py index edd33cd18..add18b8ff 100644 --- a/test/srt/run_suite.py +++ b/test/srt/run_suite.py @@ -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),