sgl-project/sglang · error · ValueError
The quantization config must be a subclass of `QuantizationC
Error message
The quantization config must be a subclass of `QuantizationConfig`.
What it means
The register_quantization decorator requires the decorated class to be a subclass of QuantizationConfig. Passing an arbitrary class fails this isinstance check because the framework needs the QuantizationConfig interface (get_config_filenames, from_config, etc.) to serve the method.
Source
Thrown at python/sglang/multimodal_gen/runtime/layers/quantization/__init__.py:82
def register_quantization_config(quantization: str):
"""Register a customized vllm quantization config.
When a quantization method is not supported by vllm, you can register a customized
quantization config to support it.
Args:
quantization (str): The quantization method name.
""" # noqa: E501
def _wrapper(quant_config_cls):
if quantization in QUANTIZATION_METHODS:
raise ValueError(
f"The quantization method `{quantization}` is already exists."
)
if not issubclass(quant_config_cls, QuantizationConfig):
raise ValueError(
"The quantization config must be a subclass of " "`QuantizationConfig`."
)
_CUSTOMIZED_METHOD_TO_QUANT_CONFIG[quantization] = quant_config_cls
QUANTIZATION_METHODS.append(quantization)
return quant_config_cls
return _wrapper
def get_quantization_config(quantization: str) -> type[QuantizationConfig]:
if quantization not in QUANTIZATION_METHODS:
raise ValueError(f"Invalid quantization method: {quantization}")
method_to_config: dict[str, type[QuantizationConfig]] = {}
# Update the `method_to_config` with customized quantization methods.
method_to_config.update(_CUSTOMIZED_METHOD_TO_QUANT_CONFIG)
return method_to_config[quantization]View on GitHub (pinned to 0132848349)
Solutions
- Make your class inherit from QuantizationConfig (directly or via an existing subclass)
- Implement the required abstract methods such as from_config and get_config_filenames
- If you meant to register an existing config type, decorate the actual QuantizationConfig subclass
Example fix
// before
@register_quantization("my_quant")
class MyConfig: # not a QuantizationConfig
...
// after
from sglang...quantization import QuantizationConfig
@register_quantization("my_quant")
class MyConfig(QuantizationConfig):
... Defensive patterns
Strategy: type-guard
Type guard
def is_quant_config(cls: type) -> bool:
import inspect
from ...quantization import QuantizationConfig
return inspect.isclass(cls) and issubclass(cls, QuantizationConfig) Prevention
- Always subclass QuantizationConfig
- Run issubclass check in tests for custom quant configs
When it happens
Trigger: Decorating a class that does not inherit from QuantizationConfig with @register_quantization(...), e.g. a plain dataclass or a subclass of a different config base.
Common situations: Writing a custom quant backend without reading the base-class contract; refactoring a config class so it accidentally loses its QuantizationConfig parent; multiple inheritance ordering issues.
Related errors
- rollout_noise_level must be a number, got {noise!r}
- The quantization method `{quantization}` is already exists.
- Invalid quantization method: {quantization}
- kitchen_w4a4 is inferred from per-layer checkpoint metadata;
- GGUFConfig must be constructed from a GGUF checkpoint
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/4ce45188a4740c3c.
Report an issue: GitHub.