From 4052b53227f6d234862a45d36b3214fa7ca02784 Mon Sep 17 00:00:00 2001 From: Juan Muneton <102537701+jmunetong@users.noreply.github.com> Date: Wed, 18 Mar 2026 21:54:19 -0700 Subject: [PATCH] =?UTF-8?q?fix=20scheduler=20for=20non-cuda=20devices=20an?= =?UTF-8?q?d=20disable=20piecewise=20cuda=20graph=20f=E2=80=A6=20(#19992)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kangyan-Zhou --- .github/workflows/pr-test-xpu.yml | 6 +- python/sglang/srt/server_args.py | 5 +- test/srt/run_suite.py | 2 +- test/srt/xpu/test_internvl.py | 147 ------------------------------ 4 files changed, 6 insertions(+), 154 deletions(-) delete mode 100644 test/srt/xpu/test_internvl.py diff --git a/.github/workflows/pr-test-xpu.yml b/.github/workflows/pr-test-xpu.yml index 38b89762a..e1a4a5766 100644 --- a/.github/workflows/pr-test-xpu.yml +++ b/.github/workflows/pr-test-xpu.yml @@ -114,15 +114,13 @@ jobs: docker exec "$cid" /home/sdp/miniforge3/envs/py3.10/bin/python3 -m pip install pytest expecttest ray huggingface_hub docker exec "$cid" /home/sdp/miniforge3/envs/py3.10/bin/python3 -m pip uninstall -y flashinfer-python docker exec "$cid" /bin/bash -c '/home/sdp/miniforge3/envs/py3.10/bin/hf auth login --token ${HF_TOKEN} ' - docker exec -u root "$cid" /bin/bash -c "ln -sf /home/sdp/miniforge3/envs/py3.10/bin/python3 /usr/bin/python3" + - name: Run E2E Bfloat16 tests timeout-minutes: 20 run: | cid="${{ steps.start_container.outputs.container_id }}" - docker exec -w /home/sdp/sglang/ "$cid" \ - bash -c "LD_LIBRARY_PATH=/home/sdp/miniforge3/envs/py3.10/lib:$LD_LIBRARY_PATH && cd ./test/srt && python3 run_suite.py --suite per-commit-xpu" - + docker exec "$cid" bash -c "source /home/sdp/miniforge3/bin/activate && conda activate py3.10 && cd /home/sdp/sglang/test/srt && python3 run_suite.py --suite per-commit-xpu" - name: Cleanup container if: always() run: | diff --git a/python/sglang/srt/server_args.py b/python/sglang/srt/server_args.py index ed815b16a..589ef1ce2 100644 --- a/python/sglang/srt/server_args.py +++ b/python/sglang/srt/server_args.py @@ -59,6 +59,7 @@ from sglang.srt.utils.common import ( is_sm100_supported, is_sm120_supported, is_triton_kernels_available, + is_xpu, json_list_type, nullable_str, parse_connector_type, @@ -1067,8 +1068,8 @@ class ServerArgs: # 5. Pipeline parallelism if self.pp_size > 1: self.disable_piecewise_cuda_graph = True - # 6. Non-CUDA hardware (AMD, NPU, CPU, MPS, MUSA, etc.) - if is_hip() or is_npu() or is_cpu() or is_mps() or is_musa(): + # 6. Non-CUDA hardware (AMD, NPU, CPU, etc.) + if is_hip() or is_npu() or is_cpu() or is_mps() or is_musa() or is_xpu(): self.disable_piecewise_cuda_graph = True # 7. MoE A2A backend if self.moe_a2a_backend != "none": diff --git a/test/srt/run_suite.py b/test/srt/run_suite.py index 3a505b670..be6877844 100644 --- a/test/srt/run_suite.py +++ b/test/srt/run_suite.py @@ -75,7 +75,7 @@ suite_xeon = { suite_xpu = { "per-commit-xpu": [ TestFile("xpu/test_deepseek_ocr.py"), - TestFile("xpu/test_internvl.py"), + # TestFile("xpu/test_internvl.py"), TestFile("xpu/test_intel_xpu_backend.py"), ], } diff --git a/test/srt/xpu/test_internvl.py b/test/srt/xpu/test_internvl.py deleted file mode 100644 index d2e2c3435..000000000 --- a/test/srt/xpu/test_internvl.py +++ /dev/null @@ -1,147 +0,0 @@ -""" -XPU tests for InternVL models (InternVL2.5-2B, InternVL3.5-2B). - -Uses the same structure as test_vision_openai_server_a.py: OpenAI /v1 chat API -and ImageOpenAITestMixin. An XPU-specific base injects --device xpu and ---attention-backend intel_xpu. - -Usage (pick module path to match your cwd): - - From test/srt/xpu: - python3 -m unittest test_internvl.TestInternVL25Server.test_single_image_chat_completion - python3 -m unittest test_internvl - - From test/srt: - python3 -m unittest xpu.test_internvl.TestInternVL25Server.test_single_image_chat_completion - python3 -m unittest xpu.test_internvl - - From repo root: - python3 -m unittest test.srt.xpu.test_internvl.TestInternVL25Server.test_single_image_chat_completion - python3 -m unittest test.srt.xpu.test_internvl -""" - -import os -import unittest - -from sglang.test.vlm_utils import ( - DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH, - DEFAULT_URL_FOR_TEST, - ImageOpenAITestMixin, - TestOpenAIMLLMServerBase, - kill_process_tree, - popen_launch_server, -) - -# XPU args injected into server launch for all InternVL XPU tests -XPU_ARGS = [ - "--device", - "xpu", - "--attention-backend", - "intel_xpu", -] - - -# Longer launch timeout for InternVL3.5 (can be slow to start on XPU) -INTERNVL35_LAUNCH_TIMEOUT = 900 - - -class InternVLXPUServerBase(TestOpenAIMLLMServerBase): - """Base for InternVL tests on XPU. Injects XPU args and sets SGLANG_USE_SGL_XPU.""" - - use_sgl_xpu = True # subclasses override for Triton backend - launch_timeout = None # subclasses can set to override (seconds) - - @classmethod - def setUpClass(cls): - cls.base_url = DEFAULT_URL_FOR_TEST - cls.api_key = "sk-123456" - - os.environ["SGLANG_USE_SGL_XPU"] = "1" if cls.use_sgl_xpu else "0" - - other_args = list(XPU_ARGS) + list(cls.extra_args) - if cls.trust_remote_code: - other_args.extend(cls.fixed_args) - else: - other_args.extend( - arg for arg in cls.fixed_args if arg != "--trust-remote-code" - ) - - timeout = ( - cls.launch_timeout - if cls.launch_timeout is not None - else DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH - ) - cls.process = popen_launch_server( - cls.model, - cls.base_url, - timeout=timeout, - api_key=cls.api_key, - other_args=other_args, - ) - cls.base_url += "/v1" - - @classmethod - def tearDownClass(cls): - kill_process_tree(cls.process.pid) - - -class TestInternVL25Server(ImageOpenAITestMixin, InternVLXPUServerBase): - """InternVL2.5-2B on XPU with SGL XPU backend.""" - - model = "OpenGVLab/InternVL2_5-2B" - use_sgl_xpu = True - extra_args = [ - "--cuda-graph-max-bs=4", - ] - - def test_video_images_chat_completion(self): - # Video test uses 10 frames and exceeds max_prefill_tokens (23124 > 16384). - pass - - -class TestInternVL25TritonServer(ImageOpenAITestMixin, InternVLXPUServerBase): - """InternVL2.5-2B on XPU with Triton (non-SGL) backend.""" - - model = "OpenGVLab/InternVL2_5-2B" - use_sgl_xpu = False - extra_args = [ - "--cuda-graph-max-bs=4", - ] - - def test_video_images_chat_completion(self): - # Video test exceeds max_prefill_tokens on XPU with default limits. - pass - - -class TestInternVL35_2BServer(ImageOpenAITestMixin, InternVLXPUServerBase): - """InternVL3.5-2B on XPU with SGL XPU backend.""" - - model = "OpenGVLab/InternVL3_5-2B" - use_sgl_xpu = True - launch_timeout = INTERNVL35_LAUNCH_TIMEOUT - extra_args = [ - "--cuda-graph-max-bs=4", - ] - - def test_video_images_chat_completion(self): - # Video test exceeds max_prefill_tokens (23202 > 14588) on InternVL3.5. - pass - - -class TestInternVL35_2BTritonServer(ImageOpenAITestMixin, InternVLXPUServerBase): - """InternVL3.5-2B on XPU with Triton (non-SGL) backend.""" - - model = "OpenGVLab/InternVL3_5-2B" - use_sgl_xpu = False - launch_timeout = INTERNVL35_LAUNCH_TIMEOUT - extra_args = [ - "--cuda-graph-max-bs=4", - ] - - def test_video_images_chat_completion(self): - # Video test exceeds max_prefill_tokens on InternVL3.5. - pass - - -if __name__ == "__main__": - unittest.main()