Skip to main content

uor_addr/gguf/shapes/
bounds.rs

1//! GGUF v3 spec-pinned constants.
2//!
3//! ADR-060 removed the fixed-width two-level commitment
4//! (`GGUF_CANON_MAX_BYTES` / `GGUF_CANON_BYTES`) and the
5//! application-policy capacity profile (`GgufHostBounds` /
6//! `GgufAddrBounds`) with its KV-count / tensor-count / string-width /
7//! array-length / tensor-data ceilings. The realization now emits the
8//! **full flat canonical skeleton** (header + per-KV and per-tensor
9//! records, with variable-length leaves replaced by their streamed
10//! SHA-256 digests) as an unbounded `alloc` buffer that flows through the
11//! pipeline as a borrowed carrier. Every count and width is unbounded.
12//!
13//! What remains are GGUF v3 **spec constants** (fixed by the format) plus
14//! one native-stack-overflow guard on the recursive ARRAY-metadata
15//! measurer.
16
17/// `GGUF_MAGIC` — ASCII `"GGUF"` little-endian `u32`. Source: `gguf.md`.
18pub const GGUF_MAGIC: u32 = 0x4655_4747;
19
20/// The only GGUF version this realization admits. Source: `gguf.md`.
21pub const GGUF_VERSION_REQUIRED: u32 = 3;
22
23/// Header byte width: magic(4) + version(4) + tensor_count(8) +
24/// kv_count(8). Source: `gguf.md`.
25pub const GGUF_HEADER_BYTES: usize = 24;
26
27/// Default tensor-data alignment when `general.alignment` is absent.
28/// Overridable via that metadata key (must be a power of two ≥ 8).
29/// Source: `gguf.h` `GGUF_DEFAULT_ALIGNMENT`.
30pub const GGUF_DEFAULT_ALIGNMENT: u64 = 32;
31
32/// Maximum tensor rank (`GGML_MAX_DIMS`). Source: `ggml.h`. A GGUF v3
33/// tensor declares at most this many dimensions; this is a format
34/// constant, not an application cap.
35pub const GGUF_MAX_DIMS: usize = 4;
36
37/// Native-stack-overflow guard on the recursive ARRAY-of-ARRAY metadata
38/// measurer. Guards the call stack against pathologically-nested array
39/// metadata; it is not a ceiling on array length or element count.
40pub const GGUF_METADATA_ARRAY_DEPTH_MAX: usize = 64;