diff --git a/python/sglang/srt/layers/quantization/w8a8_int8.py b/python/sglang/srt/layers/quantization/w8a8_int8.py index 7c145e310..7c9ff6385 100644 --- a/python/sglang/srt/layers/quantization/w8a8_int8.py +++ b/python/sglang/srt/layers/quantization/w8a8_int8.py @@ -28,6 +28,7 @@ from sglang.srt.utils import ( set_weight_attrs, use_intel_amx_backend, ) +from sglang.srt.utils.patch_torch import register_fake_if_exists if TYPE_CHECKING: from sglang.srt.layers.moe.token_dispatcher import StandardDispatchOutput @@ -39,6 +40,20 @@ _is_cpu = is_cpu() if _is_cuda: from sgl_kernel import int8_scaled_mm + @register_fake_if_exists("sgl_kernel::int8_scaled_mm") + def _int8_scaled_mm_abstract( + mat_a, + mat_b, + scales_a, + scales_b, + out_dtype, + bias=None, + ): + M = mat_a.shape[-2] + N = mat_b.shape[-1] + return mat_a.new_empty((M, N), dtype=out_dtype) + + logger = logging.getLogger(__name__) diff --git a/test/srt/run_suite.py b/test/srt/run_suite.py index 91c224e89..225c512f4 100644 --- a/test/srt/run_suite.py +++ b/test/srt/run_suite.py @@ -151,7 +151,7 @@ suites = { TestFile("test_local_attn.py", 411), TestFile("test_multi_instance_release_memory_occupation.py", 64), TestFile("test_pp_single_node.py", 500), - TestFile("test_piecewise_cuda_graph.py", 1200), + TestFile("test_piecewise_cuda_graph.py", 1260), TestFile("test_epd_disaggregation.py", 400), ], "per-commit-8-gpu-h200": [ diff --git a/test/srt/test_piecewise_cuda_graph.py b/test/srt/test_piecewise_cuda_graph.py index 4fc5934d6..75d80cf20 100644 --- a/test/srt/test_piecewise_cuda_graph.py +++ b/test/srt/test_piecewise_cuda_graph.py @@ -288,6 +288,43 @@ class TestPiecewiseCudaGraphFP8(CustomTestCase): print(f"MGSM Accuracy: {metrics['score']:.3f}") +class TestPiecewiseCudaGraphW8A8Int8(CustomTestCase): + """Test piecewise CUDA graph with W8A8 INT8 quantized model""" + + @classmethod + def setUpClass(cls): + cls.model = "RedHatAI/Llama-3.2-1B-Instruct-quantized.w8a8" + cls.base_url = DEFAULT_URL_FOR_TEST + cls.process = popen_launch_server( + cls.model, + cls.base_url, + timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH, + other_args=[ + "--enable-piecewise-cuda-graph", + "--quantization", + "w8a8_int8", + ], + ) + + @classmethod + def tearDownClass(cls): + kill_process_tree(cls.process.pid) + + def test_mgsm_accuracy(self): + """Test MGSM accuracy with W8A8 INT8 model""" + num_examples = 1319 + args = SimpleNamespace( + base_url=self.base_url, + model=self.model, + eval_name="mgsm_en", + num_examples=num_examples, + num_threads=min(num_examples, 1024), + ) + metrics = run_eval(args) + print(f"MGSM Accuracy: {metrics['score']:.3f}") + self.assertGreaterEqual(metrics["score"], 0.40) + + class TestPiecewiseCudaGraphQwen25VL(CustomTestCase): """Test piecewise CUDA graph with Qwen2.5-VL-7B-Instruct model"""