derive_kv_ns

Function derive_kv_ns 

Source
pub fn derive_kv_ns(
    model_fp: u64,
    layout: &GroupLayout,
    elem_bytes: u32,
    block_size: u32,
    head_dim: u32,
    client_salt: u64,
) -> NonZeroU64
Expand 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:

tagfieldtagfieldtagfield
0x00KV_NS_VERSION0x04block_size0x08num_kv_heads
0x01model_fp0x05head_dim0x09fs_block_size
0x02KV_DOMAIN0x06num_layers0x0agroup_stride
0x03elem_bytes0x07num_blocks0x0bclient_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.