A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 13, 07:00 UTC
[quantization][config] enable override existing quant_config (#28510)
Signed-off-by: Hank <hcc.mayday@gmail.com> Co-authored-by: Michael Goin <mgoin64@gmail.com>
Hank_ committed
Nov 14, 2025 at 09:24 UTC
4d5943bda63c306275afc1a10edee26da45cd4ef
2 files changed
+20
-6
tests/quantization/test_register_quantization_config.py
+9
-3
@@ -7,6 +7,7 @@ See https://github.com/vllm-project/vllm/issues/11926 for more details.
7
Run `pytest tests/quantization/test_register_quantization_config.py`.
8
"""
9
10
+import logging
11
from typing import Any
12
13
import pytest
@@ -100,17 +101,22 @@ class CustomQuantConfig(QuantizationConfig):
101
return None
102
103
103
-def test_register_quantization_config():
104
+def test_register_quantization_config(caplog_vllm):
105
"""Test register custom quantization config."""
106
107
# The quantization method `custom_quant` should be registered.
108
assert get_quantization_config("custom_quant") == CustomQuantConfig
109
110
# The quantization method `custom_quant` is already exists,
110
- # should raise an error.
111
- with pytest.raises(ValueError):
111
+ # should raise a warning when re-registering it.
112
+ with caplog_vllm.at_level(logging.WARNING):
113
register_quantization_config("custom_quant")(CustomQuantConfig)
114
115
+ assert any(
116
+ "The quantization method 'custom_quant' already exists" in message
117
+ for message in caplog_vllm.messages
118
+ ), "Expected a warning when re-registering custom_quant"
119
+
120
121
@pytest.mark.parametrize(
122
argnames="model",
vllm/model_executor/layers/quantization/__init__.py
+11
-3
@@ -3,8 +3,11 @@
3
4
from typing import Literal, get_args
5
6
+from vllm.logger import init_logger
7
from vllm.model_executor.layers.quantization.base_config import QuantizationConfig
8
9
+logger = init_logger(__name__)
10
+
11
QuantizationMethods = Literal[
12
"awq",
13
"deepspeedfp",
@@ -70,15 +73,20 @@ def register_quantization_config(quantization: str):
73
74
def _wrapper(quant_config_cls):
75
if quantization in QUANTIZATION_METHODS:
73
- raise ValueError(
74
- f"The quantization method `{quantization}` is already exists."
76
+ logger.warning(
77
+ "The quantization method '%s' already exists and will be "
78
+ "overwritten by the quantization config %s.",
79
+ quantization,
80
+ quant_config_cls,
81
)
82
+ else:
83
+ QUANTIZATION_METHODS.append(quantization)
84
+
85
if not issubclass(quant_config_cls, QuantizationConfig):
86
raise ValueError(
87
"The quantization config must be a subclass of `QuantizationConfig`."
88
)
89
_CUSTOMIZED_METHOD_TO_QUANT_CONFIG[quantization] = quant_config_cls
81
- QUANTIZATION_METHODS.append(quantization)
90
return quant_config_cls
91
92
return _wrapper