From bce40fa217bbb293fb36fa827eedd9af4e472721 Mon Sep 17 00:00:00 2001 From: alisonshao <54658187+alisonshao@users.noreply.github.com> Date: Thu, 27 Nov 2025 15:24:27 -0800 Subject: [PATCH] Fix utils import issue for nightly tests (#13944) --- test/{srt/lora/utils.py => lora_utils.py} | 14 -------------- test/manual/lora/test_lora_cuda_graph.py | 2 +- test/manual/lora/test_lora_qwen3_vl.py | 2 +- test/manual/lora/test_lora_spec_decoding.py | 2 +- test/nightly/test_lora_qwen3.py | 12 +++++++++++- test/nightly/test_lora_radix_cache.py | 9 ++++++++- test/run_suite_nightly.py | 5 +++++ test/srt/lora/test_lora.py | 8 +++++++- test/srt/lora/test_lora_backend.py | 8 +++++++- test/srt/lora/test_lora_tp.py | 8 +++++++- test/srt/lora/test_multi_lora_backend.py | 8 +++++++- 11 files changed, 55 insertions(+), 23 deletions(-) rename test/{srt/lora/utils.py => lora_utils.py} (96%) diff --git a/test/srt/lora/utils.py b/test/lora_utils.py similarity index 96% rename from test/srt/lora/utils.py rename to test/lora_utils.py index 12046c299..1ff0f87b5 100644 --- a/test/srt/lora/utils.py +++ b/test/lora_utils.py @@ -1,17 +1,3 @@ -# Copyright 2023-2024 SGLang Team -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ============================================================================== - import dataclasses import random from typing import List diff --git a/test/manual/lora/test_lora_cuda_graph.py b/test/manual/lora/test_lora_cuda_graph.py index d14e3c76e..221f2b660 100644 --- a/test/manual/lora/test_lora_cuda_graph.py +++ b/test/manual/lora/test_lora_cuda_graph.py @@ -17,7 +17,7 @@ import os import unittest from typing import List -from utils import ( +from lora_utils import ( ALL_OTHER_LORA_MODELS, CI_LORA_MODELS, DEFAULT_PROMPTS, diff --git a/test/manual/lora/test_lora_qwen3_vl.py b/test/manual/lora/test_lora_qwen3_vl.py index 063873640..93afc2913 100644 --- a/test/manual/lora/test_lora_qwen3_vl.py +++ b/test/manual/lora/test_lora_qwen3_vl.py @@ -2,7 +2,7 @@ import random import unittest from typing import Sequence -from utils import TORCH_DTYPES, LoRAAdaptor, LoRAModelCase, ensure_reproducibility +from lora_utils import TORCH_DTYPES, LoRAAdaptor, LoRAModelCase, ensure_reproducibility from sglang.srt.models.qwen3_vl import Qwen3VLForConditionalGeneration from sglang.srt.models.qwen3_vl_moe import Qwen3VLMoeForConditionalGeneration diff --git a/test/manual/lora/test_lora_spec_decoding.py b/test/manual/lora/test_lora_spec_decoding.py index 8e8ddee2c..f1970c727 100644 --- a/test/manual/lora/test_lora_spec_decoding.py +++ b/test/manual/lora/test_lora_spec_decoding.py @@ -15,7 +15,7 @@ import multiprocessing as mp import unittest -from utils import ( +from lora_utils import ( CI_MULTI_LORA_MODELS, LoRAAdaptor, LoRAModelCase, diff --git a/test/nightly/test_lora_qwen3.py b/test/nightly/test_lora_qwen3.py index e292df27a..39d5a755e 100644 --- a/test/nightly/test_lora_qwen3.py +++ b/test/nightly/test_lora_qwen3.py @@ -13,9 +13,19 @@ # ============================================================================== import multiprocessing as mp +import sys import unittest +from pathlib import Path -from utils import LoRAAdaptor, LoRAModelCase, run_lora_multiple_batch_on_model_cases +# Add test directory to path for lora_utils import +# TODO: can be removed after migration +sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) + +from lora_utils import ( + LoRAAdaptor, + LoRAModelCase, + run_lora_multiple_batch_on_model_cases, +) from sglang.test.ci.ci_register import register_cuda_ci diff --git a/test/nightly/test_lora_radix_cache.py b/test/nightly/test_lora_radix_cache.py index d50e0a43e..fee9bfce1 100644 --- a/test/nightly/test_lora_radix_cache.py +++ b/test/nightly/test_lora_radix_cache.py @@ -13,10 +13,17 @@ # ============================================================================== import multiprocessing as mp +import sys import unittest +from pathlib import Path import torch -from utils import CI_MULTI_LORA_MODELS, run_lora_test_one_by_one + +# Add test directory to path for lora_utils import +# TODO: can be removed after migration +sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) + +from lora_utils import CI_MULTI_LORA_MODELS, run_lora_test_one_by_one from sglang.test.ci.ci_register import register_cuda_ci diff --git a/test/run_suite_nightly.py b/test/run_suite_nightly.py index 24f9ac0c0..370ec082d 100644 --- a/test/run_suite_nightly.py +++ b/test/run_suite_nightly.py @@ -74,6 +74,11 @@ def main(): nightly_dir = Path(__file__).parent / "nightly" os.chdir(nightly_dir) + # Add test/ to PYTHONPATH so tests can import shared utils + test_dir = str(Path(__file__).parent) + pythonpath = os.environ.get("PYTHONPATH", "") + os.environ["PYTHONPATH"] = f"{test_dir}:{pythonpath}" if pythonpath else test_dir + print(f"Running {len(files)} tests from suite: {args.suite}") print(f"Test files: {[f.name for f in files]}") diff --git a/test/srt/lora/test_lora.py b/test/srt/lora/test_lora.py index d918febb2..3dc08d2f1 100644 --- a/test/srt/lora/test_lora.py +++ b/test/srt/lora/test_lora.py @@ -14,9 +14,15 @@ import multiprocessing as mp import os +import sys import unittest +from pathlib import Path -from utils import ( +# Add test directory to path for lora_utils import +# TODO: can be removed after migration +sys.path.insert(0, str(Path(__file__).resolve().parent.parent.parent)) + +from lora_utils import ( ALL_OTHER_MULTI_LORA_MODELS, CI_MULTI_LORA_MODELS, run_lora_multiple_batch_on_model_cases, diff --git a/test/srt/lora/test_lora_backend.py b/test/srt/lora/test_lora_backend.py index 2217e8dd6..bf9d5b75c 100644 --- a/test/srt/lora/test_lora_backend.py +++ b/test/srt/lora/test_lora_backend.py @@ -14,10 +14,16 @@ import multiprocessing as mp import os +import sys import unittest +from pathlib import Path from typing import List -from utils import ( +# Add test directory to path for lora_utils import +# TODO: can be removed after migration +sys.path.insert(0, str(Path(__file__).resolve().parent.parent.parent)) + +from lora_utils import ( ALL_OTHER_LORA_MODELS, BACKENDS, CI_LORA_MODELS, diff --git a/test/srt/lora/test_lora_tp.py b/test/srt/lora/test_lora_tp.py index e459532a5..8e7b23f62 100644 --- a/test/srt/lora/test_lora_tp.py +++ b/test/srt/lora/test_lora_tp.py @@ -14,10 +14,16 @@ import multiprocessing as mp import os +import sys import unittest +from pathlib import Path from typing import List -from utils import ( +# Add test directory to path for lora_utils import +# TODO: can be removed after migration +sys.path.insert(0, str(Path(__file__).resolve().parent.parent.parent)) + +from lora_utils import ( ALL_OTHER_LORA_MODELS, CI_LORA_MODELS, DEFAULT_PROMPTS, diff --git a/test/srt/lora/test_multi_lora_backend.py b/test/srt/lora/test_multi_lora_backend.py index de5961abf..84def4813 100644 --- a/test/srt/lora/test_multi_lora_backend.py +++ b/test/srt/lora/test_multi_lora_backend.py @@ -14,9 +14,15 @@ import multiprocessing as mp import os +import sys import unittest +from pathlib import Path -from utils import ( +# Add test directory to path for lora_utils import +# TODO: can be removed after migration +sys.path.insert(0, str(Path(__file__).resolve().parent.parent.parent)) + +from lora_utils import ( ALL_OTHER_MULTI_LORA_MODELS, CI_MULTI_LORA_MODELS, run_lora_multiple_batch_on_model_cases,