Skip to main content

hash_seq_chunks

Function hash_seq_chunks 

Source
pub fn hash_seq_chunks(model: &str, tokens: &[u32]) -> Vec<[u8; 32]>
Expand description

Walk a full token sequence and yield one sequence-chained digest per chunk. Chunk N’s digest depends on chunks 0..=N, so the digest at position N uniquely identifies the prefix tokens[0..(N+1)*TOKENS_PER_CHUNK].

This is the correct hash for KV-cache prefix matching: a node that reports holding the chain [d_0, d_1, ..., d_K] can skip prefilling up to chunk K of a request that shares those exact digests in order.