Skip to content

vllm.model_executor.layers.quantization.kv_cache

Classes:

BaseKVCacheMethod

Bases: QuantizeMethodBase

Quant method that adds _k_scale and _v_scale attributes to the Attention layer to support loading those scaling factors from checkpoints. The k/v_scale will be used to: - quantize k/v_cache entries before saving them to the cache - dequantize k/v_cache entries before fetching them from the cache

Parameters:

Methods:

  • create_weights –

    Create "weight" (aka q_scale, k_scale and v_scale)

create_weights(layer)

Create "weight" (aka q_scale, k_scale and v_scale) for an attention layer.

KVCacheScaleParameter

Bases: Parameter

Scalar parameter for KV-cache scales.

Initialized to -1.0 (an invalid sentinel) so call sites just write KVCacheScaleParameter(). The weight_loader accepts shape () or (1,) and rejects anything else — per-head scales go through a separate path (compressed-tensors' _tp_aware_loader), not this one. Per-instance overrides still work because instance attribute assignment shadows this class-level loader.