vllm.model_executor.layers.quantization
¶
Modules:
-
auto_awq– -
auto_gptq– -
base_config– -
compressed_tensors– -
dequant_linear–Linear layers that a checkpoint stores in FP8 and the model runs in BF16.
-
experts_int8– -
fbgemm_fp8– -
fp8– -
humming– -
inc– -
input_hadamard–Block Hadamard rotation of linear-layer inputs, independent of the weight
-
input_quant_fp8– -
kv_cache– -
modelopt– -
modelopt_block_quant–ModelOpt safetensors block codecs with BF16 activations.
-
moe_wna16– -
mxfp4– -
online– -
quark– -
torchao– -
turboquant–TurboQuant: KV-cache quantization for vLLM.
-
utils– -
w4afp8–w4afp8checkpoints: INT4 group-128 routed experts with FP8 activations,
Classes:
-
QuantizationConfig–Base class for quantization configs.
Functions:
-
register_quantization_config–Register a customized vllm quantization config.
-
resolve_quant_method–Return the checkpoint method with configured online quantization.
QuantizationConfig
¶
Bases: ABC
Base class for quantization configs.
Methods:
-
apply_vllm_mapper–Interface for models to update module names referenced in
-
from_config–Create a config class from the model's quantization config.
-
get_cache_scale_mapper–Mapping from checkpoint KV-cache scale names to vLLM scale names.
-
get_checkpoint_weight_mapper–Discard activation-order metadata unused by supported kernels.
-
get_config_filenames–List of filenames to search for in the model directory.
-
get_from_keys–Get a value from the model's quantization config.
-
get_from_keys_or–Get an optional value from the model's quantization config.
-
get_kv_cache_dtype–Return a checkpoint-selected KV-cache dtype for one layer.
-
get_min_capability–Minimum GPU capability to support the quantization method.
-
get_name–Name of the quantization method.
-
get_quant_method–Get the quantize method to use for the quantized layer, from the
-
get_supported_act_dtypes–List of supported activation dtypes.
-
maybe_update_config–Interface to update values after config initialization.
-
override_quantization_method–Detects if this quantization method can support a given checkpoint
_ignore_unexpected_suffixes = ('.q_scale', '.k_scale', '.v_scale', '.q_zero_point', '.k_zero_point', '.v_zero_point')
class-attribute
instance-attribute
¶
Suffixes of quantization parameters that may be present in the checkpoint but not in the model, and should be ignored if unexpected during loading. These are used after remapping, so should be in vLLM format (e.g. .q_scale, not .q.scale).
apply_vllm_mapper(hf_to_vllm_mapper)
¶
Interface for models to update module names referenced in quantization configs in order to reflect the vllm model structure
Parameters:
-
(hf_to_vllm_mapper¶WeightsMapper) –maps from hf model structure (the assumed structure of the qconfig) to vllm model structure
from_config(config)
abstractmethod
classmethod
¶
Create a config class from the model's quantization config.
get_cache_scale_mapper()
staticmethod
¶
Mapping from checkpoint KV-cache scale names to vLLM scale names.
Returning a mapper here causes AutoWeightsLoader to apply it to the
weight stream automatically; individual model load_weights methods
do not need to know about KV-cache scales.
get_checkpoint_weight_mapper()
staticmethod
¶
Discard activation-order metadata unused by supported kernels.
get_config_filenames()
abstractmethod
staticmethod
¶
List of filenames to search for in the model directory.
get_from_keys(config, keys)
staticmethod
¶
Get a value from the model's quantization config.
get_from_keys_or(config, keys, default)
staticmethod
¶
Get an optional value from the model's quantization config.
get_kv_cache_dtype(prefix)
¶
Return a checkpoint-selected KV-cache dtype for one layer.
get_min_capability()
abstractmethod
classmethod
¶
Minimum GPU capability to support the quantization method.
E.g., 70 for Volta, 75 for Turing, 80 for Ampere. This requirement is due to the custom CUDA kernels used by the quantization method.
get_name()
abstractmethod
¶
Name of the quantization method.
get_quant_method(layer, prefix)
abstractmethod
¶
Get the quantize method to use for the quantized layer, from the pre-quantized checkpoint quant_method.
Parameters:
-
(layer¶Module) –The layer for the quant method.
-
(prefix¶str) –The full name of the layer in the state dict
Returns: The quantize method. None if the given layer doesn't support quant method.
get_supported_act_dtypes()
abstractmethod
¶
List of supported activation dtypes.
maybe_update_config(model_name, hf_config=None, revision=None)
¶
override_quantization_method(hf_quant_cfg, user_quant, hf_config=None)
classmethod
¶
Detects if this quantization method can support a given checkpoint format by overriding the user specified quantization method -- this method should only be overwritten by subclasses in exceptional circumstances.
Parameters:
register_quantization_config(quantization)
¶
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.
Parameters:
Examples:
>>> from vllm.model_executor.layers.quantization import (
... register_quantization_config,
... )
>>> from vllm.model_executor.layers.quantization import get_quantization_config
>>> from vllm.model_executor.layers.quantization.base_config import (
... QuantizationConfig,
... )
>>>
>>> @register_quantization_config("my_quant")
... class MyQuantConfig(QuantizationConfig):
... pass
>>>
>>> get_quantization_config("my_quant")
<class 'MyQuantConfig'>
resolve_quant_method(quant_config, layer, prefix)
¶
Return the checkpoint method with configured online quantization.