[XPU] Enable XPU graph support (decode full-graph + prefill tc_piecewise) (#29053)

This commit is contained in:
Cao E
2026-07-02 13:24:35 +08:00
committed by GitHub
parent 4fffc6448b
commit 926140d789
25 changed files with 886 additions and 43 deletions
+1
View File
@@ -38,6 +38,7 @@ class TestDeepSeekOCR(CustomTestCase):
"xpu",
"--attention-backend",
"intel_xpu",
"--disable-decode-cuda-graph",
]
os.environ["SGLANG_USE_SGL_XPU"] = "1"
cls.process = popen_launch_server(
@@ -41,6 +41,7 @@ class TestDeepSeekOCRTriton(TestDeepSeekOCR):
"xpu",
"--attention-backend",
"intel_xpu",
"--disable-decode-cuda-graph",
]
os.environ["SGLANG_USE_SGL_XPU"] = "0"
cls.process = popen_launch_server(
@@ -39,6 +39,7 @@ class TestEncoderAttention(CustomTestCase):
"xpu",
"--mm-attention-backend",
"xpu_attn",
"--disable-decode-cuda-graph",
]
os.environ["SGLANG_USE_SGL_XPU"] = "1"
cls.process = popen_launch_server(
@@ -127,6 +128,7 @@ class TestEncoderAttention_Triton(TestEncoderAttention):
"xpu",
"--mm-attention-backend",
"triton_attn",
"--disable-decode-cuda-graph",
]
os.environ["SGLANG_USE_SGL_XPU"] = "0"
cls.process = popen_launch_server(
+1
View File
@@ -53,6 +53,7 @@ XPU_SERVER_ARGS = [
"intel_xpu",
"--model-impl",
"sglang",
"--disable-decode-cuda-graph",
]
# Standard sglang e2e Q&A prompt (see test_openai_server.py::run_chat_completion).
@@ -34,6 +34,7 @@ def intel_xpu_benchmark(
"1",
"--device",
"xpu",
"--disable-decode-cuda-graph",
]
ci_args = ["--input", "64", "--output", "4"] if is_in_ci() else []
full_args = common_args + ci_args + (extra_args or [])
@@ -31,6 +31,7 @@ def triton_attention_benchmark(extra_args=None, mem_fraction_static="0.84"):
"2050",
"--attention-backend",
"triton",
"--disable-decode-cuda-graph",
]
full_args = common_args + (extra_args or [])
+1
View File
@@ -33,6 +33,7 @@ class TestXPUBasic(CustomTestCase):
"0.6",
"--batch-size",
"1",
"--disable-decode-cuda-graph",
]
if is_in_ci():
args += ["--input", "64", "--output", "4"]
+6 -1
View File
@@ -34,7 +34,12 @@ class TestXPUEmbedding(CustomTestCase):
cls.model,
cls.base_url,
timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
other_args=["--is-embedding", "--device", "xpu"],
other_args=[
"--is-embedding",
"--device",
"xpu",
"--disable-decode-cuda-graph",
],
)
cls.openai_url = cls.base_url + "/v1"
+71
View File
@@ -0,0 +1,71 @@
"""
XPU graph tests: verifies decode full-graph and prefill tc_piecewise graph
on Intel XPU produce valid outputs.
- TestXPUGraph : decode full-graph and prefill tc_piecewise graph enabled
together in a single bench_one_batch invocation.
Usage:
python3 -m unittest test_xpu_graph.TestXPUGraph
"""
import unittest
from sglang.test.ci.ci_register import register_xpu_ci
from sglang.test.test_utils import (
DEFAULT_SMALL_MODEL_NAME_FOR_TEST_QWEN,
CustomTestCase,
is_in_ci,
run_bench_one_batch,
)
register_xpu_ci(est_time=600, suite="stage-b-test-1-gpu-xpu")
_COMMON_ARGS = [
"--device",
"xpu",
"--attention-backend",
"triton",
"--disable-radix-cache",
"--mem-fraction-static",
"0.6",
"--batch-size",
"1",
]
_CI_IO_ARGS = ["--input", "64", "--output", "4"]
_FULL_IO_ARGS = ["--input", "128", "--output", "16"]
class TestXPUGraph(CustomTestCase):
"""Decode full-graph + prefill tc_piecewise together."""
def test_full_graph_runs(self):
args = [
*_COMMON_ARGS,
"--cuda-graph-config",
'{"decode":{"backend":"full"},"prefill":{"backend":"tc_piecewise","tc_compiler":"eager"}}',
"--cuda-graph-bs-prefill",
"64",
"128",
]
if is_in_ci():
args += _CI_IO_ARGS
else:
args += _FULL_IO_ARGS
prefill_latency, decode_throughput, _ = run_bench_one_batch(
DEFAULT_SMALL_MODEL_NAME_FOR_TEST_QWEN, args
)
self.assertGreater(
prefill_latency,
0,
"prefill latency must be > 0 with tc_piecewise XPU graph",
)
self.assertGreater(
decode_throughput, 0, "decode throughput must be > 0 with full XPU graph"
)
if __name__ == "__main__":
unittest.main()
@@ -43,7 +43,7 @@ class TestXPUServingFeatures(CustomTestCase):
cls.model,
cls.base_url,
timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
other_args=["--device", "xpu"],
other_args=["--device", "xpu", "--disable-decode-cuda-graph"],
)
cls.openai_url = cls.base_url + "/v1"