sgl-project/sglang · error · ValueError

The quantization method `{quantization}` is already exists.

Error message

The quantization method `{quantization}` is already exists.

What it means

Raised by the register_quantization decorator's _wrapper when attempting to register a quantization method name that already exists in QUANTIZATION_METHODS. The library maintains a registry of quantization method names to prevent duplicate registrations that would silently override configs.

Source

Thrown at python/sglang/multimodal_gen/runtime/layers/quantization/__init__.py:78

    "kitchen_int8": KitchenInt8Config,
}


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]] = {}

View on GitHub (pinned to 0132848349)

Solutions

  1. Choose a unique name for your custom quantization method and register it again
  2. If re-registration is expected (e.g. module reload), guard with `if quantization not in QUANTIZATION_METHODS:` before registering
  3. Check QUANTIZATION_METHODS to see the existing names before picking yours

Example fix

// before
@register_quantization("fp8")
class MyConfig(QuantizationConfig): ...

// after
@register_quantization("my_custom_fp8")
class MyConfig(QuantizationConfig): ...
Defensive patterns

Strategy: validation

Validate before calling

from ...quantization import QUANTIZATION_METHODS
assert "my_quant" not in QUANTIZATION_METHODS, "name already registered"

Prevention

When it happens

Trigger: Calling register_quantization with a name (e.g. "my_quant") that is already in QUANTIZATION_METHODS, e.g. registering a custom method whose name collides with a built-in like "fp8" or registering the same custom method twice.

Common situations: Re-running a notebook/cell that registers a custom quant method; copy-pasting a plugin module that gets imported twice; picking a custom method name that clashes with a built-in method.

Related errors


AI-assisted analysis of sgl-project/sglang@0132848349 (2026-08-28). Data as JSON: /api/errors/5a437260e007c6ab. Report an issue: GitHub.