pub fn derive_kv_ns(
model_fp: u64,
layout: &GroupLayout,
elem_bytes: u32,
block_size: u32,
head_dim: u32,
client_salt: u64,
) -> NonZeroU64Expand description
Derive the KV paging namespace. FROZEN tagged encoding (injective:
fixed-width [tag][8-byte LE] records) — any field or order change is a
deliberate fleet cache flush and must bump KV_NS_VERSION:
| tag | field | tag | field | tag | field |
|---|---|---|---|---|---|
| 0x00 | KV_NS_VERSION | 0x04 | block_size | 0x08 | num_kv_heads |
| 0x01 | model_fp | 0x05 | head_dim | 0x09 | fs_block_size |
| 0x02 | KV_DOMAIN | 0x06 | num_layers | 0x0a | group_stride |
| 0x03 | elem_bytes | 0x07 | num_blocks | 0x0b | client_salt |
model_fp carries the quant identity + model_type + ATLAS_MODEL_ID
salt (ModelFingerprint::derive_kv in spark-model); the geometry fields
make the layout identity explicit because group_id numbering is
layout-relative. Zero-avoidance falls back to FNV_OFFSET (p = 2^-64),
keeping the result total — ns = 0 stays unrepresentable end-to-end.