Module gguf

Module gguf 

Source
Expand description

GGUF Export (spec §7.2)

Pure Rust writer for GGUF format (llama.cpp compatible). WASM compatible - no C/C++ dependencies.

§Format Structure

┌─────────────────────────────────────────┐
│ Magic: "GGUF" (4 bytes)                 │
│ Version: u32 (currently 3)              │
│ Tensor count: u64                       │
│ Metadata KV count: u64                  │
├─────────────────────────────────────────┤
│ Metadata KV pairs                       │
├─────────────────────────────────────────┤
│ Tensor info array                       │
├─────────────────────────────────────────┤
│ Tensor data (aligned)                   │
└─────────────────────────────────────────┘

Reference: [GGUF2023] Gerganov, G. (2023). GGUF Format.

Structs§

GgufHeader
GGUF file header
GgufTensor
A tensor to be exported to GGUF format
GgufTensorInfo
GGUF tensor info

Enums§

GgmlType
GGUF tensor types (from ggml)
GgufValue
GGUF metadata value
GgufValueType
GGUF value types (from ggml)

Constants§

GGUF_DEFAULT_ALIGNMENT
Default alignment for tensor data
GGUF_MAGIC
GGUF magic number: “GGUF” in little-endian
GGUF_VERSION
GGUF format version (v3 is current)

Functions§

export_tensors_to_gguf
Export tensors to GGUF format
padding_for_alignment
Calculate padding bytes needed for alignment
write_metadata_kv
Write a metadata key-value pair