[quantization][config] enable override existing quant_config (#28510)

Signed-off-by: Hank <hcc.mayday@gmail.com>
Co-authored-by: Michael Goin <mgoin64@gmail.com>
This commit is contained in:
Hank_
2025-11-14 09:24:10 +08:00
committed by GitHub
parent f2b8e1c551
commit 4d5943bda6
2 changed files with 20 additions and 6 deletions

View File

@@ -7,6 +7,7 @@ See https://github.com/vllm-project/vllm/issues/11926 for more details.
Run `pytest tests/quantization/test_register_quantization_config.py`.
"""
import logging
from typing import Any
import pytest
@@ -100,17 +101,22 @@ class CustomQuantConfig(QuantizationConfig):
return None
def test_register_quantization_config():
def test_register_quantization_config(caplog_vllm):
"""Test register custom quantization config."""
# The quantization method `custom_quant` should be registered.
assert get_quantization_config("custom_quant") == CustomQuantConfig
# The quantization method `custom_quant` is already exists,
# should raise an error.
with pytest.raises(ValueError):
# should raise a warning when re-registering it.
with caplog_vllm.at_level(logging.WARNING):
register_quantization_config("custom_quant")(CustomQuantConfig)
assert any(
"The quantization method 'custom_quant' already exists" in message
for message in caplog_vllm.messages
), "Expected a warning when re-registering custom_quant"
@pytest.mark.parametrize(
argnames="model",