Expand description
Output convention: vllm-project/compressed-tensors
layered on plain .safetensors, so quantized checkpoints stay loadable by existing HF/vLLM
tooling for INT8/FP8. For a quantized weight tensor named foo.weight:
foo.weightitself becomes the quantized values (I8, packedU8for INT4, orF8_E4M3/F8_E5M2).foo.weight_scaleholds oneF32scale per group (flattened to 1-D, length = number of groups – seecrate::quant::compute_groupsfor how elements map to groups).foo.weight_zero_pointholds oneI32zero-point per group, only for asymmetric schemes (symmetric schemes have an implicit zero-point of0and omit this tensor).- A
quantization_configJSON blob in the file’s__metadata__header describes the scheme (config_groups), which tensors were left unquantized (ignore), and – since this crate’s INT4 packing (seecrate::quant::pack4) doesn’t match compressed-tensors’ own int32-basedpack-quantizedlayout – ateenygrad_packed_int4extension recording each packed tensor’s true logical shape.
Tensors are only quantized if they’re rank >= 2 (see should_quantize) – 1-D tensors
(biases, norm weights) are passed through unchanged and listed in ignore, matching common
PTQ tooling’s default of leaving those alone.
Structs§
- Config
Group - One compressed-tensors config group: a scheme plus the module types it applies to.
- Packed
Tensor Info - Logical shape of a nibble-packed INT4 tensor, since the packed
U8tensor’s own shape ([ceil(n / 2)]) doesn’t reflect it. Seecrate::quant::pack4. - Quantization
Config - The full
quantization_configmetadata blob embedded in the output.safetensorsheader. - Weights
Config - The compressed-tensors
weightsblock for one scheme.
Constants§
- QUANTIZATION_
CONFIG_ KEY - The metadata key
quantization_configis stored under in the.safetensorsheader.
Functions§
- build_
config - Assembles the full
QuantizationConfigfor a checkpoint quantized uniformly withscheme/granularity. - config_
from_ metadata - Parses a
quantization_configblob previously produced byconfig_to_metadata. - config_
to_ metadata - Serializes
configinto the.safetensorsstring-metadata map underQUANTIZATION_CONFIG_KEY. - dequantize_
tensor - Dequantizes a tensor previously written by
quantize_tensor, given its already-decoded scale (and, for asymmetric schemes, zero-point) values. Used bycrate::validate. - quantize_
tensor - Quantizes one tensor per
scheme/granularity, returning the output tensors to insert (quantized weight,_scale, and – for asymmetric schemes –_zero_point), keyed by their final names.nameis the original (unsuffixed) tensor name. - scale_
tensor_ name foo.weight->foo.weight_scale.- should_
quantize - Whether a tensor should be quantized: rank >= 2 (so biases/norm weights are left alone) and a
dtype
crate::read::read_f32can upcast from. - zero_
point_ tensor_ name foo.weight->foo.weight_zero_point.