Expand description
GH-279: Kernel-Level Contracts for the Sovereign AI Stack
Defines invariants that MUST hold for ANY data entering trueno compute kernels. Consumers (realizar, aprender) validate data against these contracts BEFORE calling any kernel. Violating a contract is a hard error, not a silent default.
§Contract Hierarchy
aprender (import) ──► enforce_architecture_completeness() [tensor names]
│
realizar (load) ──► contract_gate::validate_model_load() [architecture]
│
trueno (kernel) ──► contracts::validate_weight_buffer() [bytes & layout]This module is the bottom layer — raw buffer and layout validation. If these fail, the kernel WILL produce garbage or crash.
Structs§
- Quant
Format - Quantization format descriptor with block geometry.
- Weight
Buffer Error - Error returned when a weight buffer fails contract validation.
Enums§
- Tensor
Layout - Tensor layout used by all trueno kernels.
Constants§
- ALL_
FORMATS - All supported quantization formats, ordered by GGML type ID.
- Q4_0
- Q4_0 block format: 32 elements, 18 bytes
- Q4_1
- Q4_1 block format: 32 elements, 20 bytes
- Q4_K
- Q4_K super-block format: 256 elements, 144 bytes (4.5 bits/weight)
- Q4_
K_ BLOCK_ BYTES Q4_Ksuper-block byte size- Q4_
K_ BLOCK_ SIZE Q4_Ksuper-block size (elements per block)- Q5_0
- Q5_0 block format: 32 elements, 22 bytes
- Q5_K
- Q5_K super-block format: 256 elements, 176 bytes (5.5 bits/weight)
- Q5_
K_ BLOCK_ BYTES Q5_Ksuper-block byte size- Q5_
K_ BLOCK_ SIZE Q5_Ksuper-block size (elements per block)- Q6_K
- Q6_K super-block format: 256 elements, 210 bytes (6.5 bits/weight)
- Q6_
K_ BLOCK_ BYTES Q6_Ksuper-block byte size- Q6_
K_ BLOCK_ SIZE Q6_Ksuper-block size (elements per block)- Q8_0
- Q8_0 block format: 32 elements, 34 bytes
- STACK_
LAYOUT - The stack-wide tensor layout. All kernels assume this.
Functions§
- format_
by_ ggml_ type - Lookup a quantization format by GGML type ID.
- validate_
f32_ buffer - Validate that an F32 weight buffer has correct element count.
- validate_
gemv_ shapes - Validate GEMV shape invariants for row-major layout.
- validate_
weight_ buffer - Validate a weight buffer against a known GGML type ID.