sgl-project/sglang · error · ValueError
Invalid quantization method: {quantization}
Error message
Invalid quantization method: {quantization} What it means
get_quantization_config looks up the requested quantization method in QUANTIZATION_METHODS and raises when the name is not registered. This is the standard entry point mapping a quantization string (e.g. from model config or CLI) to its QuantizationConfig class.
Source
Thrown at python/sglang/multimodal_gen/runtime/layers/quantization/__init__.py:94
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]
__all__ = [
"QuantizationMethods",
"QuantizationConfig",
"get_quantization_config",
"QUANTIZATION_METHODS",
]
View on GitHub (pinned to 0132848349)
Solutions
- Print/inspect QUANTIZATION_METHODS and correct the string to a registered name
- If it's a custom method, ensure the module calling register_quantization is imported before lookup
- Upgrade/downgrade to the version that supports the method you need
Example fix
// before
config = get_quantization_config("fpx") # typo
// after
config = get_quantization_config("fp8") Defensive patterns
Strategy: validation
Validate before calling
from ...quantization import QUANTIZATION_METHODS
if quantization not in QUANTIZATION_METHODS:
raise SystemExit(f"Unknown quant method {quantization!r}; valid: {QUANTIZATION_METHODS}") Try / catch
try:
cfg = get_quantization_config(name)
except ValueError as e:
# fall back to a default or exit with a clear message
... Prevention
- Validate the quantization string against QUANTIZATION_METHODS at config parse time
- Catch ValueError and surface valid options to the user
When it happens
Trigger: Calling get_quantization_config("some_method") where the string is not in QUANTIZATION_METHODS — typo'd names, unregistered custom methods, or methods only available in a newer/older version.
Common situations: Typo in a CLI --quantization flag or model config quantization_config.quant_method; using a quant method whose plugin isn't imported; version mismatch where the method was added or removed.
Related errors
- The quantization method `{quantization}` is already exists.
- The quantization config must be a subclass of `QuantizationC
- kitchen_w4a4 is inferred from per-layer checkpoint metadata;
- GGUFConfig must be constructed from a GGUF checkpoint
- f"Cannot parse checkpoint quantization for {component_name!r
AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28).
Data as JSON: /api/errors/59d675646173ec02.
Report an issue: GitHub.