Expand description
The GGUF weight formats, and their dequantization to f32.
Each format is a run of fixed-size blocks; a block holds a fixed count of weights and the scales that turn its
packed integers back into numbers. The dequantizers here follow ggml’s own reference definitions
(ggml/src/ggml-quants.c, dequantize_row_*) operation for operation, in the order those definitions write
them, so their output is the reference’s to the bit (model_quant_lock compiles the reference and compares).
Structs§
- Scale
Grid - The scale of a scaled-float tensor (an FP8 checkpoint’s
weight_scale_inv) broadcast over the weight’s elements, as the Hugging Face converter’sdequant_simplebroadcasts it beforeweight.float() * scale: with a block size, each of the scale’s trailing axes repeated a block’s length and cropped to the weight’s; then axes of length 1 appended until the scale has the weight’s rank, every axis either 1 (broadcast) or the weight’s length.
Enums§
- Ggml
Type - A ggml tensor type this crate reads, by its GGUF type id.
Constants§
- KVALUES_
IQ4NL - The non-linear levels an IQ4 nibble indexes (ggml’s
kvalues_iq4nl).
Functions§
- bf16_
to_ f32 - bfloat16 → binary32: the high half of the word.
- e4m3fn_
to_ f32 - An
e4m3fnfloat’s value astorchwidens it: bias 7, no infinities,S.1111.111a NaN keeping its sign and mantissa bits. - e5m2_
to_ f32 - An
e5m2float’s value: the high byte of a binary16. - f16_
to_ f32 - IEEE-754 binary16 → binary32, exactly (subnormals included).
- f32_
to_ bf16 xrounded to bfloat16, to nearest with ties to even; a NaN stays a quiet NaN.- f32_
to_ f16 xrounded to binary16, to nearest with ties to even: subnormals kept, past the largest finite value infinite, a NaN quiet.