[diffusion] fix: reject unsupported modelopt checkpoint algorithms (#35182)
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
|
||||
import unittest
|
||||
|
||||
from sglang.srt.layers.modelopt_utils import canonicalize_modelopt_quant_algo
|
||||
from sglang.srt.layers.quantization.base_config import QuantizationConfig
|
||||
from sglang.srt.model_loader.checkpoint_quantization import (
|
||||
CheckpointQuantSpec,
|
||||
resolve_checkpoint_quant_spec,
|
||||
@@ -26,6 +28,34 @@ class _QuantConfigObject:
|
||||
|
||||
|
||||
class TestResolveCheckpointQuantSpec(CustomTestCase):
|
||||
def test_modelopt_quant_algo_canonicalization(self):
|
||||
cases = {
|
||||
"FP8": "modelopt_fp8",
|
||||
"mxfp8": "mxfp8",
|
||||
"NVFP4": "modelopt_fp4",
|
||||
"NVFP4_AWQ": "modelopt_fp4",
|
||||
"W4A16_NVFP4": "modelopt_fp4",
|
||||
"FP8_FAKE": None,
|
||||
"MIXED_PRECISION": None,
|
||||
None: None,
|
||||
}
|
||||
for quant_algo, expected in cases.items():
|
||||
with self.subTest(quant_algo=quant_algo):
|
||||
self.assertEqual(canonicalize_modelopt_quant_algo(quant_algo), expected)
|
||||
|
||||
def test_srt_modelopt_override_uses_the_exact_algorithm_allowlist(self):
|
||||
self.assertEqual(
|
||||
QuantizationConfig._modelopt_override_quantization_method(
|
||||
{"quant_algo": "NVFP4"}, "modelopt"
|
||||
),
|
||||
"modelopt_fp4",
|
||||
)
|
||||
self.assertIsNone(
|
||||
QuantizationConfig._modelopt_override_quantization_method(
|
||||
{"quant_algo": "NVFP4_FAKE"}, "modelopt"
|
||||
)
|
||||
)
|
||||
|
||||
def test_top_level_quantization_config(self):
|
||||
config = {
|
||||
"quantization_config": {
|
||||
|
||||
Reference in New Issue
Block a user