Explore the research collection
4 entries · Follow this search
- Other
Shard: getting to 10x KV cache compression
Engineering writeup of Shard, a drop-in HuggingFace Cache. Reimplementing TurboQuant stalled around 4-6x; authors split K and V: undo RoPE then PCA+int4 on K (rank 192/1024, DP bit allocation with a 4x drop penalty) and Hadamard + 4-d vector quantization on V. Attention scores run on int4 PCA coeffs via a relative-Delta RoPE identity; V Hadamard is applied after the weighted sum. 4 FP16 sink tokens + 64-token recency window. Decode stream uses data-oblivious Hadamard+Lloyd-Max (8-bit path 750/750 FP16 match at 150 tokens). Llama-3.1-8B: 10x at 8K / 11.2x at 32K, NIAH recall 1.000 across 4K-32K, LongBench-E avg 16.19 vs FP16 16.24, WikiText-2 PPL +0.26%. Decode throughput 0.39-0.49x FP16, so a memory win not a latency win. Code krish1905/shard.
- Code
n8loom
Python library (mlx_lm + Transformers) that stores per-node KV-cache fragments and concatenates the ancestor path when generating, so many ToT branches can share prefix cache without duplicating the full prompt cache at each node. Core types are Heddle (a reasoning node) and Loom (chat-root Heddle); ramify/crown helpers batch- or stream-expand children. Llama-architecture only. pip install n8loom; optional FastAPI example server. CC0.
- Paper
Introspection Fine-Tuning (IFT): Training Small LLMs to Introspect
Shows binary yes/no injection detection is confounded in small models (r=0.999 with a factual-no control on Llama-3.1-8B). Replaces it with sentence localization (N=10, chance 10%) and strength comparison (chance 50%). Across Llama-3.2 1B/3B/8B and Gemma-4 2B/4B/26B-A4B, introspection emerges at 2–3B and generally rises with scale; Llama-1B is at or below chance. IFT (LoRA r=16 on the model’s own steered forward passes) lifts Llama-1B average localization 9.6%→60.6% (semantic, random layer) and strength comparison 30.2%→52.2% zero-shot; Llama-3B loc 14.4%→34.7%; Llama-8B 16.8%→28.3%. MMLU/Winogrande mostly preserved (Llama-1B MMLU 49.1→46.7 under Random·Semantic).
- Paper
Cross-Model KV Cache Transfer in LLM Families: A Closed-Form Linear Mapping for Prefill Reuse
Shows within-family matched-KV pairs (shared KV head count and head dim) have substantial linear structure: on Qwen3 14B->32B one source layer explains 56%/32% of target key/value variance, 79%/65% with multiple layers. A closed-form per-head ridge mapper with top-k cross-layer source selection and RoPE-stripped content-space keys retains 73-98% of standalone-prefill accuracy on four of six pairs (Qwen3, Llama 3.1, Ministral 3) and is 2.7-25x faster than re-prefill; two Ministral pairs collapse and a nonlinear MLP recovers up to +37 pp HellaSwag. Attention-output cosine predicts retention better than reconstruction R^2.