Skip to content

vllm.config.quantization

Classes:

Functions:

QuantSpec

Quantization spec for one layer kind (linear or MoE).

An omitted activation key lets the quantization implementation choose its default. An explicitly configured activation: null requests no activation quantization; methods that do not support that request raise an error.

Methods:

  • __post_init__ –

    Record the explicitly set fields; unset ones become None.

  • __str__ –

    The spec as configured, e.g. mxfp4 or

Attributes:

  • activation (QuantKeyField) –

    Activation quantization key, or a name from QUANT_KEY_NAMES.

  • fields_set (frozenset[str]) –

    Names explicitly provided when constructing this spec.

  • hadamard_size (int | None) –

    Block size (a power of two) of an orthonormal Hadamard rotation applied

  • weight (QuantKeyField) –

    Weight quantization key, or a name from QUANT_KEY_NAMES.

activation = _UNSET class-attribute instance-attribute

Activation quantization key, or a name from QUANT_KEY_NAMES.

fields_set = field(init=False, repr=False, compare=False) class-attribute instance-attribute

Names explicitly provided when constructing this spec.

hadamard_size = None class-attribute instance-attribute

Block size (a power of two) of an orthonormal Hadamard rotation applied along the input dimension of both the weight and the activation before quantization (see InputHadamardLinearMethod). The GEMM result is unchanged up to quantization error, which the rotation shrinks by spreading outliers across each block. Linear layers only; validated with MXFP4.

weight = _UNSET class-attribute instance-attribute

Weight quantization key, or a name from QUANT_KEY_NAMES.

__post_init__()

Record the explicitly set fields; unset ones become None.

__str__()

The spec as configured, e.g. mxfp4 or {"weight":"mxfp4","activation":null}.

QuantizationConfigArgs

User-facing quantization configuration.

See docs/features/quantization/online.md for the schema and shorthand string forms accepted on linear and moe.

Attributes:

  • ignore (list[str]) –

    Layers to skip quantization for. Online quantization also supports

  • linear (QuantSpec | None) –

    Spec applied to LinearBase layers.

  • moe (QuantSpec | None) –

    Spec applied to FusedMoEFactory layers.

  • targets (dict[str, str | QuantSpec] | None) –

    Per-layer online quantization overrides, keyed by exact layer name or

ignore = Field(default_factory=list) class-attribute instance-attribute

Layers to skip quantization for. Online quantization also supports fnmatch-style patterns.

linear = None class-attribute instance-attribute

Spec applied to LinearBase layers.

moe = None class-attribute instance-attribute

Spec applied to FusedMoEFactory layers.

targets = None class-attribute instance-attribute

Per-layer online quantization overrides, keyed by exact layer name or regex patterns with a re:, or fnmatch-style patterns for online quantization. A target can map to an online shorthand name (see _ONLINE_SHORTHANDS) or a quantization spec containing weight and activation keys. A layer that matches no pattern is left unquantized. Mutually exclusive with linear and moe.

layer_target_spec_scope(spec)

Apply a layer's targets spec to user_activation_override.

merge_quantization_config(base, override)

Apply the fields explicitly set in override on top of a shorthand's base config.

quant_key_name(quant_key)

User-facing name of quant_key, falling back to str(quant_key).

resolve_quantization_config(quantization, quantization_config)

Resolve --quantization shorthand and --quantization-config into a QuantizationConfigArgs.

quantization is a CLI shorthand that desugars into a base config via _ONLINE_SHORTHANDS. quantization_config is a dict or pre-built args object. When both are given, fields explicitly set in quantization_config take precedence over the shorthand.

user_activation_override(kind, config)

The user's activation override for the layer being built, and whether it was set (explicit null included): the layer's targets spec if any, else quantization_config.<kind> in config (a VllmConfig or None; kind is linear or moe).