Expand description
2026-09-25: KV paging namespace and wire-key derivation, and the strict parsers for
the METRALE_KV_PAGING* variables.
Owner: storage, KV paging tier. Invariants:
- Every namespace returned is non-zero:
derive_kv_nsfalls back toFNV_OFFSETand an override of 0 is an error. - The namespace is a pure function of its six arguments, encoded as the tagged
records listed on
derive_kv_ns. - The parsers never default: junk input is an error.
The paging peer keys its residency by the u64 the client sends
(snapshot_swap::run_paging_loop_shared), so the namespace folded into that key
is what separates two models, and two clients of one model, on one peer. A KV
GroupKey.block is a client-local disk-block index
(HighSpeedSwap::alloc_disk_block_id), so two clients of one model use the same
block ids for unrelated data. The namespace therefore folds a per-client salt,
random per connect unless METRALE_KV_PAGING_SALT pins it: clients share peer
capacity, not cached blocks.
The model fingerprint does not encode the KV cache dtype or block layout, and
GroupLayout::group_id depends on num_blocks, so the namespace folds the full
layout next to the fingerprint. The fingerprint arrives as a plain u64
(ModelDims::model_fp); this crate does not depend on the model config.
Constants§
- KV_
DOMAIN - 2026-09-25: Domain separator hashed into every KV namespace as the tag-0x02
record, so KV keys differ from SSM keys in the key material as well as by the
peer’s per-
(kind, blob_bytes)arena. ASCII"KV"+"PAGE"+ 1. - KV_
NS_ VERSION - 2026-09-25: Encoding version, hashed as the tag-0x00 record. Changing it changes every KV namespace.
Functions§
- cascade_
conflicts_ with_ paging - 2026-09-25:
truewhenkv_peer_setandflag_rawselects the paging backend; an invalidflag_rawis an error.CascadeBackendevicts through per-headwrite_from_host, whichKvPagingBackendrefuses. - derive_
kv_ ns - 2026-09-25: Derive the KV paging namespace: FNV-1a/64 over fixed-width
[tag][8-byte LE]records. A change to the fields or their order must bumpKV_NS_VERSION: - kv_
paging_ selected - 2026-09-25: Resolve the
METRALE_KV_PAGINGvalue after trimming: unset or0isfalse(the raw one-sidedRdmaKvBackend),1istrue(the paging backend), anything else is an error. - parse_
u64_ strict - 2026-09-25: Parse a u64 in decimal or
0x/0Xhex, after trimming; anything else is an error namingvar. - resolve_
arena_ bytes_ from - 2026-09-25: Resolve
METRALE_KV_PAGING_ARENA_GB, the peer arena size in GiB (fractional accepted), floored to a multiple ofblock_bytes. Unset, non-finite, not above 0, or smaller than one block is an error. The raw backend sizes its arena to hold every group (RdmaKvBackend::connect); the paging arena has no such size to derive, so it must be given. - resolve_
kv_ ns_ from - 2026-09-25: Resolve the
METRALE_KV_PAGING_NSvalue:Nonereturnsderived; a value is parsed strictly and 0 is an error. - resolve_
salt_ from - 2026-09-25: Resolve the
METRALE_KV_PAGING_SALTvalue:NonereturnsOk(None), and the caller draws a random salt; a value is parsed strictly. - wire_
key - 2026-09-25: Wire key for one KV block:
mix64(base_group_id, ns), the fold the SSM tier’sPagingSnapshotStore::wirealso uses. For a fixed namespace it is a bijection, so distinct group ids never share a key. The caller passes the id of the block’s first group,group_id(GroupKey::new(layer, block, 0, K)).