Expand description
GGUF file format: header + metadata + tensor directory.
Entry point: load_gguf reads a .gguf file into a GgufLayout
containing parsed metadata, a tensor directory, and the underlying
byte buffer. Packed K-quant dequant helpers are re-exported from this module.
Optional mmap-backed loading is behind the mmap feature.
Structs§
- Gguf
Layout - Fully-parsed GGUF checkpoint layout.
- Gguf
Layout Mmap - GGUF layout backed by a read-only file mapping instead of an owned
Vec<u8>. - Gguf
Metadata - Parsed GGUF metadata key-value store.
- Page
Aligned Tensor Bytes - Page-aligned view covering a tensor payload inside a mapping.
- Parse
Limits - Resource budgets applied before allocation or loops proportional to attacker-declared GGUF values.
- Tensor
- A single tensor’s directory entry: name, shape, dtype, and offsets.
Enums§
- DType
- GGML tensor dtype codes encountered in GGUF checkpoints.
Constants§
- GGML_
TYPE_ BF16 GGML_TYPE_BF16— Google Brain bfloat16.- GGML_
TYPE_ F16 GGML_TYPE_F16— 16-bit IEEE-754 half float.- GGML_
TYPE_ F32 GGML_TYPE_F32— 32-bit IEEE-754 float.- GGML_
TYPE_ F64 GGML_TYPE_F64— 64-bit IEEE-754 double float.- GGML_
TYPE_ I8 GGML_TYPE_I8— 8-bit signed integer.- GGML_
TYPE_ I16 GGML_TYPE_I16— 16-bit signed integer.- GGML_
TYPE_ I32 GGML_TYPE_I32— 32-bit signed integer.- GGML_
TYPE_ I64 GGML_TYPE_I64— 64-bit signed integer.- GGML_
TYPE_ IQ1_ M GGML_TYPE_IQ1_M— i-quant 1-bit medium.- GGML_
TYPE_ IQ1_ S GGML_TYPE_IQ1_S— i-quant 1-bit small.- GGML_
TYPE_ IQ2_ S GGML_TYPE_IQ2_S— i-quant 2-bit small.- GGML_
TYPE_ IQ2_ XS GGML_TYPE_IQ2_XS— i-quant 2-bit extra-small.- GGML_
TYPE_ IQ2_ XXS GGML_TYPE_IQ2_XXS— i-quant 2-bit extra-extra-small.- GGML_
TYPE_ IQ3_ M_ BLOCK - Internal id for the 111-byte IQ3_M block layout decoder only.
- GGML_
TYPE_ IQ3_ S GGML_TYPE_IQ3_S— i-quant 3-bit small (3.44 bpw).- GGML_
TYPE_ IQ3_ XXS GGML_TYPE_IQ3_XXS— i-quant 3-bit extra-extra-small.- GGML_
TYPE_ IQ4_ NL GGML_TYPE_IQ4_NL— i-quant 4-bit non-linear.- GGML_
TYPE_ IQ4_ XS GGML_TYPE_IQ4_XS— i-quant 4-bit extra-small.- GGML_
TYPE_ Q2_ K GGML_TYPE_Q2_K— k-quant 2-bit.- GGML_
TYPE_ Q3_ K GGML_TYPE_Q3_K— k-quant 3-bit.- GGML_
TYPE_ Q4_ 0 GGML_TYPE_Q4_0— 4-bit quantization (symmetric, block size 32).- GGML_
TYPE_ Q4_ 0_ 4_ 4 - GGUF wire type 31: historical
Q4_0_4_4layout (removed from current ggml). - GGML_
TYPE_ Q4_ 1 GGML_TYPE_Q4_1— 4-bit quantization (with min, block size 32).- GGML_
TYPE_ Q4_ K GGML_TYPE_Q4_K— k-quant 4-bit.- GGML_
TYPE_ Q5_ 0 GGML_TYPE_Q5_0— 5-bit quantization (symmetric, block size 32).- GGML_
TYPE_ Q5_ 1 GGML_TYPE_Q5_1— 5-bit quantization (with min, block size 32).- GGML_
TYPE_ Q5_ K GGML_TYPE_Q5_K— k-quant 5-bit.- GGML_
TYPE_ Q6_ K GGML_TYPE_Q6_K— k-quant 6-bit.- GGML_
TYPE_ Q8_ 0 GGML_TYPE_Q8_0— 8-bit quantization (symmetric, block size 32).- GGML_
TYPE_ Q8_ 1 GGML_TYPE_Q8_1— 8-bit quantization (with min, block size 32).- GGML_
TYPE_ Q8_ K GGML_TYPE_Q8_K— k-quant 8-bit.- GGUF_
VALUE_ TYPE_ ARRAY - GGUF value type: length-prefixed array of nested values.
- GGUF_
VALUE_ TYPE_ BOOL - GGUF value type: boolean (1 byte, 0 or 1).
- GGUF_
VALUE_ TYPE_ FLOA T32 - GGUF value type: 32-bit IEEE 754 float.
- GGUF_
VALUE_ TYPE_ FLOA T64 - GGUF value type: 64-bit IEEE 754 float.
- GGUF_
VALUE_ TYPE_ INT8 - GGUF value type: 8-bit signed integer.
- GGUF_
VALUE_ TYPE_ INT16 - GGUF value type: 16-bit signed integer.
- GGUF_
VALUE_ TYPE_ INT32 - GGUF value type: 32-bit signed integer.
- GGUF_
VALUE_ TYPE_ INT64 - GGUF value type: 64-bit signed integer.
- GGUF_
VALUE_ TYPE_ STRING - GGUF value type: length-prefixed UTF-8 string.
- GGUF_
VALUE_ TYPE_ UINT8 - GGUF value type: 8-bit unsigned integer.
- GGUF_
VALUE_ TYPE_ UINT16 - GGUF value type: 16-bit unsigned integer.
- GGUF_
VALUE_ TYPE_ UINT32 - GGUF value type: 32-bit unsigned integer.
- GGUF_
VALUE_ TYPE_ UINT64 - GGUF value type: 64-bit unsigned integer.
Functions§
- dequantize_
iq3_ m - Dequantize packed IQ3_M block-layout bytes (111 bytes / 256 values) to
f32. - dequantize_
packed - Dispatch packed dequant for the dtypes this crate implements.
- dequantize_
q5_ k - Dequantize packed Q5_K bytes (block size 256) to
f32. - dequantize_
q6_ k - Dequantize packed Q6_K bytes (block size 256) to
f32. - dequantize_
q8_ 0 - Dequantize packed Q8_0 bytes (block size 32) to
f32. - f16_
bits_ to_ f32 - Convert a 16-bit IEEE-754 half-precision float (as raw bits) into a 32-bit float. Pure bit manipulation — no external math library.
- ggml_
type_ label - Map a raw GGML
ggml_typeu32code to a short human-readable label. - load_
gguf - Load a
.ggufcheckpoint from disk and parse its header, KV metadata, and tensor directory. - load_
gguf_ mmap - Memory-map a
.gguffile and parse its header, KV metadata, and tensor directory without copying the file into aVec<u8>. - load_
gguf_ mmap_ with_ limits - Memory-map a
.gguffile with an explicitParseLimitspolicy. - load_
gguf_ with_ limits - Load a
.ggufcheckpoint with an explicitParseLimitspolicy. - os_
page_ size - OS page size used for
GgufLayoutMmap::tensor_page_aligned_bytes. - packed_
row_ size - Packed byte length of one row for a blocked quant dtype.
- parse_
bytes - Parse an already-loaded byte buffer as a GGUF checkpoint. Useful for
unit tests and in-memory round-trips. Uses
ParseLimits::default. - parse_
bytes_ with_ limits - Parse an already-loaded byte buffer with an explicit
ParseLimitspolicy.