veloxquant_mlx.cache.chunkkv_coordinator module¶
ChunkKV cross-layer coordinator — layer-wise kept-index reuse (Algorithm 2).
The paper observes (Table 2) that ChunkKV’s kept-chunk indices are far more
similar between adjacent layers than token-level methods’ (44-58% Jaccard
similarity vs 15-28% for H2O/SnapKV on the models tested). Layer-wise index reuse
exploits this: layers are grouped into consecutive blocks of Nreuse; only the
first (“leader”) layer in each block runs full eviction, and the remaining
(“follower”) layers reuse the leader’s exact kept-token positions instead of
scoring and evicting on their own. The paper reports up to 20.7% latency
reduction and 26.5% throughput improvement from this, at <0.6% LongBench /
neutral-to-positive GSM8K performance cost.
Unlike SqueezeCoordinator (a one-shot prefill-boundary re-budget), this
coordinator exchanges the leader’s kept-index list every step — prefill and
decode alike — since eviction (and therefore the reusable index set) can change
at any step once the cache is over budget. Single-threaded by construction
(mlx_lm.generate is sequential), so plain dicts need no locking.
- class veloxquant_mlx.cache.chunkkv_coordinator.ChunkKVIndexReuseCoordinator(n_layers, reuse_layers)[source]¶
Bases:
objectShared per-model layer-wise index-reuse state for one generation.
- Parameters:
- publish(layer_id, head_idx, kept_positions)[source]¶
Leader layer publishes one head’s this-step per-token kept-index lists.
- fetch(layer_id, head_idx)[source]¶
Follower layer fetches its leader’s most recently published indices.
- Return type:
- Returns:
The leader’s kept-index lists for
head_idx, orNoneif the leader hasn’t published for this step yet (should not happen under the standardfor_modelbuild, where layers are updated leader-first within a block by construction order).- Parameters: