Skip to main content

Module gguf

Module gguf 

Source
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§

GgufLayout
Fully-parsed GGUF checkpoint layout.
GgufLayoutMmap
GGUF layout backed by a read-only file mapping instead of an owned Vec<u8>.
GgufMetadata
Parsed GGUF metadata key-value store.
PageAlignedTensorBytes
Page-aligned view covering a tensor payload inside a mapping.
ParseLimits
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_4 layout (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_FLOAT32
GGUF value type: 32-bit IEEE 754 float.
GGUF_VALUE_TYPE_FLOAT64
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_type u32 code to a short human-readable label.
load_gguf
Load a .gguf checkpoint from disk and parse its header, KV metadata, and tensor directory.
load_gguf_mmap
Memory-map a .gguf file and parse its header, KV metadata, and tensor directory without copying the file into a Vec<u8>.
load_gguf_mmap_with_limits
Memory-map a .gguf file with an explicit ParseLimits policy.
load_gguf_with_limits
Load a .gguf checkpoint with an explicit ParseLimits policy.
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 ParseLimits policy.