vllm.config.quantization
¶
Classes:
-
QuantSpec–Quantization spec for one layer kind (linear or MoE).
-
QuantizationConfigArgs–User-facing quantization configuration.
Functions:
-
layer_target_spec_scope–Apply a layer's
targetsspec touser_activation_override. -
merge_quantization_config–Apply the fields explicitly set in
overrideon top of a shorthand's -
quant_key_name–User-facing name of
quant_key, falling back tostr(quant_key). -
resolve_quantization_config–Resolve
--quantizationshorthand and--quantization-configinto a -
user_activation_override–The user's activation override for the layer being built, and whether it
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.
mxfp4or
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.
Source code in vllm/config/quantization.py
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.
Source code in vllm/config/quantization.py
__str__()
¶
The spec as configured, e.g. mxfp4 or
{"weight":"mxfp4","activation":null}.
Source code in vllm/config/quantization.py
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
LinearBaselayers. -
moe(QuantSpec | None) –Spec applied to
FusedMoEFactorylayers. -
targets(dict[str, str | QuantSpec] | None) –Per-layer online quantization overrides, keyed by exact layer name or
Source code in vllm/config/quantization.py
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
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.
Source code in vllm/config/quantization.py
merge_quantization_config(base, override)
¶
Apply the fields explicitly set in override on top of a shorthand's
base config.
Source code in vllm/config/quantization.py
quant_key_name(quant_key)
¶
User-facing name of quant_key, falling back to str(quant_key).
Source code in vllm/config/quantization.py
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.
Source code in vllm/config/quantization.py
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).