[bugfix] fix quant method validation bug (#4831)
### What this PR does / why we need it? When `hf_quant_cfg` is not None and `hf_quant_cfg.quant_method == ""`, func `override_quantization_method` will return None and raise ValidationError. ### Does this PR introduce _any_ user-facing change? ### How was this patch tested? - vLLM version: v0.12.0 - vLLM main: https://github.com/vllm-project/vllm/commit/ad32e3e19ccf0526cb6744a5fed09a138a5fb2f9 Signed-off-by: zzzzwwjj <1183291235@qq.com>
This commit is contained in:
1 parent
863a5a5a17
commit
f404c9af7f
2 files changed
+9
-1
No files matched your search
@@ -66,11 +66,19 @@ class TestAscendQuantConfig(TestBase):
|
||||
mock_is_available.return_value = True
|
||||
result = AscendQuantConfig.override_quantization_method(None, None)
|
||||
self.assertIsNone(result)
|
||||
hf_quant_cfg = {"quant_method": ""}
|
||||
result = AscendQuantConfig.override_quantization_method(
|
||||
hf_quant_cfg, None)
|
||||
self.assertEqual(result, "ascend")
|
||||
|
||||
# Test when NPU is not available
|
||||
mock_is_available.return_value = False
|
||||
result = AscendQuantConfig.override_quantization_method(None, None)
|
||||
self.assertIsNone(result)
|
||||
hf_quant_cfg = {"quant_method": ""}
|
||||
result = AscendQuantConfig.override_quantization_method(
|
||||
hf_quant_cfg, None)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_get_quant_method_for_linear(self):
|
||||
mock_config = MagicMock()
|
||||
|
||||
@@ -96,7 +96,7 @@ class AscendQuantConfig(QuantizationConfig):
|
||||
user_quant) -> Optional[str]:
|
||||
if hf_quant_cfg is not None:
|
||||
quant_method = hf_quant_cfg.get("quant_method", None)
|
||||
if quant_method is None and torch.npu.is_available():
|
||||
if not quant_method and torch.npu.is_available():
|
||||
return ASCEND_QUANTIZATION_METHOD
|
||||
return None
|
||||
|
||||
|
||||
Reference in new issue
Block a user