Skip to main content

Crate dynamo_kv_hashing

Crate dynamo_kv_hashing 

Source
Expand description

Universal Request → Vec<PositionalLineageHash> contract for KV cache identity.

See README.md for the design rationale (the three-representation problem, why PLH wins, the multimodal gap, and the extension-vs-PLH-alone caveat). This crate is the single contract that the router, consolidator, kvbm, and framework workers should converge on for block hashing.

§Pure-computation contract

This crate is intentionally a library, not a service. It contains no async, no transports, no traits over runtime/scheduler config, and no event types. Those belong in higher layers (kvbm-connector, consolidator, kv-router).

Structs§

PositionalLineageHash
A 128-bit positional lineage hash encoding parental lineage for tree traversal.
Request
Canonical Request used to derive a deterministic sequence of block hashes.
RequestBuilder
Builder for Request.
RequestMmObjectInfo
Multimodal placeholder run as carried on a Request.
TokenBlockMmInfo
Metadata describing a single multimodal placeholder run within a token sequence.
UniversalBlock
Per-block hashing result. PLH is self-contained for chain extension via PositionalLineageHash::extend; no out-of-band tracking required.

Enums§

KvHashingError
Errors raised while constructing a crate::Request or computing block hashes.
MmInfoError
Errors raised while validating TokenBlockMmInfo inputs.

Constants§

MM_SLOT_TAG_PLACEHOLDER
Slot-tag byte for multimodal placeholder slots. See compute_block_bytes_with_mm.
MM_SLOT_TAG_TOKEN
Slot-tag byte distinguishing real-token slots from multimodal placeholder slots in the per-block byte buffer. See compute_block_bytes_with_mm.

Functions§

compute_block_bytes_with_mm
Builds the byte buffer used to compute a block’s BlockHash.
compute_block_hash
Canonical BlockHash construction: XXH3 over the per-block byte buffer (already encoded by compute_block_bytes_with_mm or cast_slice for the no-MM path), seeded by SaltHash.
compute_hash_v2
Computes a hash of the data using the given seed (raw u64).
compute_salt_hash_from_bytes
Canonical SaltHash construction from a pre-canonicalized salt-payload byte buffer. Application-layer callers should use dynamo_kv_hashing::Request::salt_hash which canonicalizes (salt, lora_name) first; this function is the low-level path.
validate_and_sort_mm_info
Validates mm_info against tokens_len and returns a copy sorted by offset.

Type Aliases§

BlockHash
A 64-bit hash computed from the tokens within a single block (with optional MM frames), seeded by the request’s SaltHash.
SaltHash
A 64-bit hash of the salt. Computed once per request and used as the seed for every block-hash computation in that request.
SequenceHash
A 64-bit sequence-aware hash. Equals the BlockHash at position 0 and compute_next_sequence_hash(prev_seq, block_hash) at every subsequent position. Salt propagates through seq_hash[0] since block_hash[0] already encodes it.
Token
A token is represented as a 32-bit unsigned integer.