[Piecewise CUDA Graph] Support INT8 (#14918)
This commit is contained in:
@@ -28,6 +28,7 @@ from sglang.srt.utils import (
|
|||||||
set_weight_attrs,
|
set_weight_attrs,
|
||||||
use_intel_amx_backend,
|
use_intel_amx_backend,
|
||||||
)
|
)
|
||||||
|
from sglang.srt.utils.patch_torch import register_fake_if_exists
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from sglang.srt.layers.moe.token_dispatcher import StandardDispatchOutput
|
from sglang.srt.layers.moe.token_dispatcher import StandardDispatchOutput
|
||||||
@@ -39,6 +40,20 @@ _is_cpu = is_cpu()
|
|||||||
if _is_cuda:
|
if _is_cuda:
|
||||||
from sgl_kernel import int8_scaled_mm
|
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__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ suites = {
|
|||||||
TestFile("test_local_attn.py", 411),
|
TestFile("test_local_attn.py", 411),
|
||||||
TestFile("test_multi_instance_release_memory_occupation.py", 64),
|
TestFile("test_multi_instance_release_memory_occupation.py", 64),
|
||||||
TestFile("test_pp_single_node.py", 500),
|
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),
|
TestFile("test_epd_disaggregation.py", 400),
|
||||||
],
|
],
|
||||||
"per-commit-8-gpu-h200": [
|
"per-commit-8-gpu-h200": [
|
||||||
|
|||||||
@@ -288,6 +288,43 @@ class TestPiecewiseCudaGraphFP8(CustomTestCase):
|
|||||||
print(f"MGSM Accuracy: {metrics['score']:.3f}")
|
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):
|
class TestPiecewiseCudaGraphQwen25VL(CustomTestCase):
|
||||||
"""Test piecewise CUDA graph with Qwen2.5-VL-7B-Instruct model"""
|
"""Test piecewise CUDA graph with Qwen2.5-VL-7B-Instruct model"""
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user