Skip to content

PTQ-Level Efficiency, QAT-Level Accuracy | 训练后量化的效率,量化感知训练的精度

Adapt the latest sglang integration test Engine kwargs. (#1964)

Wang, Chang49244549a052
diff --git a/test/test_cuda/integrations/test_sglang.py b/test/test_cuda/integrations/test_sglang.py
index 44aaf3af5..34465a74e 100644
--- a/test/test_cuda/integrations/test_sglang.py
+++ b/test/test_cuda/integrations/test_sglang.py
@@ -1,3 +1,4 @@
+import dataclasses
import gc
import json
import multiprocessing.resource_tracker
@@ -64,9 +65,27 @@ class TestAutoRound:
)
except Exception:
pass
- llm = sgl.Engine(
- model_path=str(model_path), mem_fraction_static=0.5, disable_piecewise_cuda_graph=True, cuda_graph_bs=[1]
- )
+
+ def _server_arg_fields():
+ try:
+ from sglang.srt.server_args import ServerArgs
+
+ return {f.name for f in dataclasses.fields(ServerArgs)}
+ except Exception:
+ return set()
+
+ engine_kwargs = {"model_path": str(model_path), "mem_fraction_static": 0.5}
+ fields = _server_arg_fields()
+ if "disable_piecewise_cuda_graph" in fields:
+ engine_kwargs["disable_piecewise_cuda_graph"] = True
+ if "cuda_graph_bs" in fields:
+ engine_kwargs["cuda_graph_bs"] = [1]
+ elif "disable_cuda_graph" in fields:
+ engine_kwargs["disable_cuda_graph"] = True
+ if "cuda_graph_bs_decode" in fields:
+ engine_kwargs["cuda_graph_bs_decode"] = [1]
+
+ llm = sgl.Engine(**engine_kwargs)
try:
prompts = ["Hello, my name is"]
sampling_params = {"temperature": 0.6, "top_p": 0.95}