Skip to content

Commit e9e85a0

Browse files
pjdurdenclaude
andcommitted
docs: fix VeriCache misattribution, drop false novelty wedge, add cited gap audit
VeriCache (2605.17613) is real but doesn't claim perplexity-insensitivity; re-cite Pitfalls (2510.00231) and frame 'perplexity is blind' as a hypothesis under test. Drop the contradicted 'nobody measures functional correctness' wedge (KVPress et al. already do); narrow to executable-code + tool-schema conformance. Flag StreamingLLM no-re-roping and head-averaged SnapKV as known fidelity limitations. Add docs/RESEARCH.md (full adversarially-verified audit). Docs only; no code changed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 254cfa7 commit e9e85a0

3 files changed

Lines changed: 176 additions & 37 deletions

File tree

README.md

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,25 @@
66

77
**A canary for *silent* KV-cache-compression failures.**
88

9-
Lossy KV-cache compression (quantization, token eviction) is benchmarked almost entirely on
10-
**speed and memory** — and on token-level quality (perplexity). But token-level metrics can stay
11-
flat while **functional** outputs silently break: generated code stops passing its tests, tool
12-
calls stop being valid JSON. kv-canary measures that gap.
13-
14-
> The wedge: everyone measures how *fast* KV compression is. Almost nobody measures whether it
15-
> silently breaks your code and tool calls while perplexity says everything is fine.
16-
17-
This is a measurement harness + methodology, motivated by VeriCache
18-
([arXiv:2605.17613](https://arxiv.org/html/2605.17613)), which showed lossy-KV bias accumulates
19-
linearly and functional tasks fail while token-level metrics look unchanged. kv-canary makes that
20-
effect reproducible and quantifiable across compression methods.
9+
Lossy KV-cache compression (quantization, token eviction) silently breaks **functional** outputs:
10+
generated code stops passing its tests, tool calls stop being valid JSON. VeriCache
11+
([arXiv:2605.17613](https://arxiv.org/abs/2605.17613)) shows these methods are "inherently
12+
lossy … their outputs increasingly diverge from full-KV-cache outputs as more tokens are decoded,
13+
which leads to catastrophic failures in code generation and tool calling." *The Pitfalls of KV Cache
14+
Compression* ([arXiv:2510.00231](https://arxiv.org/abs/2510.00231), ACL 2026) shows aggregate
15+
benchmark metrics hide these per-instruction failures.
16+
17+
> The question kv-canary tests: when KV compression breaks your code and tool calls, does the cheap
18+
> token-level metric (perplexity) **warn you, or stay silent?** This is a *hypothesis under test*
19+
> no paper has shown perplexity is blind to KV-compression damage; kv-canary measures whether it is.
20+
21+
**Scope & prior art (honest).** Functional/downstream degradation under KV compression is *already*
22+
measured by [NVIDIA KVPress](https://github.com/NVIDIA/kvpress), Pitfalls (IFEval), and
23+
[arXiv:2512.12008](https://arxiv.org/abs/2512.12008) (8 reasoning benchmarks). What those don't score
24+
is **executable code (pass@k) and JSON/tool-call schema conformance** specifically — that narrow
25+
target, contrasted against perplexity, is kv-canary's niche. See
26+
[`docs/RESEARCH.md`](docs/RESEARCH.md) for the full cited gap audit, including known implementation
27+
limitations (StreamingLLM re-roping, per-head SnapKV) that a faithful run must address.
2128

2229
---
2330

@@ -100,19 +107,26 @@ configs/*.yaml ─▶ runner ─▶ results/raw/*.jsonl ─▶ aggregate ─▶
100107

101108
## Status & honest caveats
102109

103-
**v1 is the harness.** 16 build steps, ~38 tests, green CI. The real run is documented in
104-
[`docs/RUNBOOK.md`](docs/RUNBOOK.md) and needs a single 24GB GPU.
105-
106-
- **The headline finding is not in this repo yet.** One piece is intentionally deferred to the GPU
107-
run: wiring the eviction selection into HuggingFace's live KV cache (a custom `DynamicCache`
108-
subclass). Until that lands, `HFBackend` records *how much* KV each method would retain but runs
109-
normal generation — so **all methods produce identical output and the divergence is NULL.** This
110-
is called out in the `HFBackend` docstring and the runbook. Any numbers you see in a freshly
111-
generated `report/` from the CPU smoke are pipeline-shape placeholders, **not** a result.
112-
- The gap kv-canary targets rests on a single recent paper (VeriCache); the contribution here is
113-
making it *measurable and reproducible*, not claiming novelty of the phenomenon.
114-
- The wedge is **functional-vs-token-level divergence**, not "reproducible benchmarking" — local
115-
inference benchmarking is fragmented (a coverage gap), but that is a different problem.
110+
**v1 is the harness, wired end-to-end.** Compression is applied into HF's live KV cache
111+
(`CompressedCache`), `score()` measures perplexity under the compressed context, and the divergence
112+
is real (not NULL). The headline GPU run on a real instruct model is documented in
113+
[`docs/RUNBOOK.md`](docs/RUNBOOK.md); run it before trusting any numbers. Full cited audit in
114+
[`docs/RESEARCH.md`](docs/RESEARCH.md). Known limitations a faithful run must weigh:
115+
116+
- **The method implementations are simplified and a faithful reviewer would flag two of them.**
117+
StreamingLLM here evicts from a *post-RoPE* HF cache **without re-roping** kept keys to contiguous
118+
cache positions — the real method caches keys pre-RoPE and re-indexes positions, so eviction here
119+
is degraded partly *for the wrong reason* (see RESEARCH.md Q3). SnapKV here **averages attention
120+
over heads** with no pooling, whereas real SnapKV selects **per-head with a max-pool clustering
121+
step** (Q4). Treat these as "StreamingLLM-/SnapKV-style" eviction, not exact reproductions.
122+
- **"Perplexity is blind" is a hypothesis under test, not a cited result.** VeriCache shows the
123+
functional failures; no paper shows perplexity fails to warn. kv-canary measures whether it does.
124+
- **Prior art exists.** KVPress / Pitfalls / arXiv:2512.12008 already measure functional/downstream
125+
degradation under KV compression; kv-canary's narrow niche is executable-code + tool-schema
126+
conformance specifically. The originality is that corner, not the phenomenon.
127+
- **Design scope.** Compression is applied to the prompt once (no decode-time rolling); VeriCache's
128+
failures accrue over long *decode*, so this design under-exercises that regime (RESEARCH.md §Deeper
129+
problems). Quant is per-tensor absmax and `bits/16` ignores scale/zero-point overhead.
116130

117131
## Layout
118132

docs/RESEARCH.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# kv-canary — foundations & gap audit (deep research, 2026-06-12)
2+
3+
A multi-source, adversarially-verified review of the claims and method implementations behind
4+
kv-canary. 23 sources fetched, 99 claims extracted, 25 verified by 3-vote adversarial checking
5+
(24 confirmed, 1 killed). Load-bearing arXiv IDs were independently re-fetched. Findings that
6+
change the project are recorded here so the repo is honest about what it does and doesn't establish.
7+
8+
## TL;DR verdict
9+
10+
- The **thesis is sound and correctly grounded**: lossy KV-cache compression really does cause
11+
catastrophic functional failures in code generation and tool calling (VeriCache, real).
12+
- The **originality wedge is false**: functional/downstream degradation under KV compression is
13+
already measured by NVIDIA KVPress and multiple 2025–2026 papers. Only a *narrow* corner survives.
14+
- **Two method implementations are wrong**, not merely simplified: StreamingLLM without re-roping,
15+
and head-averaged SnapKV without pooling. A knowledgeable reviewer would dismiss those results.
16+
- The **prompt-only design may be confounded** for the long-decode failure mode it targets.
17+
18+
## Q1 — Citation check
19+
20+
**VeriCache is real.** `arXiv:2605.17613` = *"VeriCache: Turning Lossy KV Cache into Lossless LLM
21+
Inference"* (Yao, Shen, Du, Feng, Seo, Zhang, Huang, Liu, Lu, Jiang; May 17 2026). Abstract:
22+
> "almost all of these methods are inherently lossy—despite minimal accuracy degradation for short
23+
> outputs, their outputs increasingly diverge from full-KV-cache outputs as more tokens are decoded,
24+
> which leads to catastrophic failures in code generation and tool calling."
25+
26+
**But VeriCache does NOT make the "perplexity is blind" argument** (verified, 0-3 — the one killed
27+
claim). It never mentions perplexity; it frames short-output-small vs long-output-large divergence.
28+
Citing VeriCache for "token-level metrics stay flat" is a **misattribution**.
29+
30+
The closest real support for "aggregate/token-level metrics hide functional damage" is
31+
***The Pitfalls of KV Cache Compression*** (`arXiv:2510.00231`, Chen, Geh, Grover, Van den Broeck,
32+
Israel; UCLA; ACL 2026):
33+
> "certain instructions degrade much more rapidly with compression, effectively causing them to be
34+
> completely ignored by the LLM."
35+
36+
It evaluates the exact methods kv-canary models (StreamingLLM, SnapKV, +TOVA/H2O/K-Norm) on
37+
Llama3.1-8B and Qwen2.5-14B — but measures **IFEval instruction-following, not perplexity**. So
38+
"perplexity fails to warn" is kv-canary's **hypothesis to test**, not an established result. Source:
39+
https://arxiv.org/abs/2605.17613 · https://arxiv.org/abs/2510.00231
40+
41+
## Q2 — Is the wedge novel? No (broadly)
42+
43+
"Everyone measures speed/memory, nobody measures functional correctness under KV compression" is
44+
**contradicted**:
45+
- **NVIDIA KVPress** (https://github.com/NVIDIA/kvpress, maintained) — accuracy CLI over RULER,
46+
LongBench/-v2, Loogle, InfiniteBench, Zero-Scrolls, Needle-in-a-Haystack.
47+
- **Pitfalls** (2510.00231) — IFEval instruction-following.
48+
- **Hold Onto That Thought** (`arXiv:2512.12008`, Dec 2025) — 8 reasoning benchmarks (FOLIO, DROP,
49+
GSM8K, MATH-500, ReClor, StrategyQA, CommonSenseQA, OpenBookQA), built on the kvpress library.
50+
51+
**Narrow survivor:** none of these score **executable-code-passing-unit-tests + valid-JSON/tool-call
52+
schema conformance** specifically (they do QA / retrieval / reasoning / instruction-following
53+
accuracy). That narrow corner is kv-canary's only remaining originality. Source:
54+
https://github.com/NVIDIA/kvpress · https://arxiv.org/abs/2512.12008
55+
56+
## Q3 — StreamingLLM re-roping (CONFIRMED BUG, 3-0)
57+
58+
StreamingLLM **requires** caching keys *pre*-RoPE and assigning positions by **cache index**, not
59+
original token position. Paper (`arXiv:2309.17453`, ICLR 2024):
60+
> "When determining the relative distance and adding positional information to tokens, StreamingLLM
61+
> focuses on positions within the cache rather than those in the original text." … "For encoding like
62+
> RoPE, we cache the Keys of tokens prior to introducing the rotary transformation."
63+
64+
Worked example: cache `[0,1,2,3,6,7,8]` decoding token 9 uses positions `[0,1,2,3,4,5,6,7]`.
65+
HF transformers issue #35350 confirms post-RoPE eviction yields "confused position"; KVPress ships a
66+
`KeyRerotationPress` to correct it. **kv-canary evicts from a post-RoPE HuggingFace DynamicCache
67+
without re-roping → degraded-for-the-wrong-reason.** Source: https://arxiv.org/abs/2309.17453 ·
68+
https://github.com/huggingface/transformers/issues/35350 · https://github.com/NVIDIA/kvpress
69+
70+
## Q4 — SnapKV per-head + pooling (CONFIRMED MISREPRESENTATION, 3-0)
71+
72+
SnapKV (`arXiv:2404.14469`, NeurIPS 2024) selects "clustered important KV positions **for each
73+
attention head**", preserving the head dimension throughout, and a **1D max-pooling clustering step
74+
is mandatory** (ablated as essential: "with the pooling … performs significantly better"). Observation
75+
window = last segment of the prompt (~16–64 tokens) used to vote; top-k per head after pooling.
76+
**kv-canary averages attention over all heads into one per-layer keep set with no pooling — that is
77+
not SnapKV.** Source: https://arxiv.org/abs/2404.14469 · https://github.com/FasterDecoding/SnapKV
78+
79+
## Q5 — Perplexity protocol & quant memory (medium confidence)
80+
81+
- A single **0.5 context/continuation split** is legitimate but **non-standard**; the HF/NLP
82+
convention is **sliding-window (strided) perplexity**. A single split underestimates variance and
83+
is cherry-pickable. (https://huggingface.co/docs/transformers/perplexity)
84+
- **`kv_bytes_retained = bits/16`** ignores per-tensor/group **scale + zero-point** overhead, so true
85+
retained memory is higher than reported — compression is modestly **overstated**. Per-tensor absmax
86+
quant is also cruder than the per-token/per-channel group-wise quant used in real KV-quant (KIVI,
87+
KVQuant), so kv-canary's quant results are likely **pessimistic**.
88+
89+
## Deeper problems (matter more than the bugs)
90+
91+
1. **Design vs. failure mode.** VeriCache's functional failures arise during **long decode**;
92+
kv-canary compresses the **prompt once, no decode-time rolling**. `2512.12008` finds decode-time
93+
compression is what governs reasoning correctness. The prompt-only design may be **confounded for
94+
the very code/tool-over-long-decode failures it targets.**
95+
2. **"Why not just use KVPress?"** Fixing Q3+Q4 properly ≈ reimplementing KVPress (worse). NVIDIA
96+
maintains it.
97+
98+
## Recommended direction
99+
100+
Reframe the contribution as **executable / structured-output correctness (code-exec pass@k +
101+
JSON/tool-call schema validity) under *decode-time* KV compression**, ideally **built on top of
102+
NVIDIA KVPress** rather than a solo reimplementation — inheriting KVPress's correct StreamingLLM/
103+
SnapKV (Q3/Q4 gone), targeting the one gap KVPress's accuracy CLI doesn't cover, and landing in a
104+
high-visibility NVIDIA repo. If kept standalone: drop the broad wedge, frame "perplexity warns?" as a
105+
hypothesis, fix re-roping + per-head-SnapKV-with-pooling, and add decode-time compression.
106+
107+
## Open questions
108+
109+
- Is there ANY existing tool scoring executable-code + tool-schema conformance under KV compression?
110+
If not, that narrow wedge is the whole contribution.
111+
- Authoritative magnitudes for Q5 (strided-perplexity doc; KIVI/KVQuant overhead bytes).
112+
- Can a prompt-only design generalize to decode-time functional failures at all?
113+
114+
## Caveats on this audit
115+
116+
Fast-moving subfield (key papers Oct/Dec 2025, May 2026; KVPress v0.3.0 June 2026) — the prior-art
117+
picture can shift in months. Q1–Q4 rest on primary sources with unanimous/near-unanimous votes and
118+
are robust; Q5 is medium confidence (lives inside a synthesizing verifier's note, not a separately
119+
primary-cited claim).

docs/index.html

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,16 @@ <h1>kv-<span class="canary">canary</span></h1>
4141
<a href="https://github.com/pjdurden/kv-canary/blob/main/docs/RUNBOOK.md">Runbook</a>
4242
</p>
4343

44-
<p>Lossy KV-cache compression (quantization, token eviction) is benchmarked almost entirely on
45-
<strong>speed and memory</strong>, and on token-level quality (perplexity). But token-level
46-
metrics can stay flat while <strong>functional</strong> outputs silently break: generated code
47-
stops passing its tests, tool calls stop being valid JSON. kv-canary measures that gap.</p>
44+
<p>Lossy KV-cache compression (quantization, token eviction) silently breaks <strong>functional</strong>
45+
outputs: generated code stops passing its tests, tool calls stop being valid JSON.
46+
<a href="https://arxiv.org/abs/2605.17613">VeriCache</a> shows these methods' outputs "increasingly
47+
diverge from full-KV-cache outputs as more tokens are decoded, [leading] to catastrophic failures in
48+
code generation and tool calling"; <a href="https://arxiv.org/abs/2510.00231">The Pitfalls of KV
49+
Cache Compression</a> shows aggregate metrics hide those per-instruction failures.</p>
4850

49-
<p class="pitch">Everyone measures how <em>fast</em> KV compression is. Almost nobody measures
50-
whether it silently breaks your code and tool calls while perplexity says everything is fine.</p>
51+
<p class="pitch">The question kv-canary tests: when KV compression breaks your code and tool calls,
52+
does the cheap token-level metric (perplexity) warn you, or stay silent? That is a <em>hypothesis
53+
under test</em> — no paper has shown perplexity is blind to KV-compression damage.</p>
5154

5255
<h2>The finding: divergence</h2>
5356
<p>For each compression method, kv-canary plots two lines against <strong>KV memory retained</strong>:
@@ -88,12 +91,15 @@ <h2>How it works</h2>
8891
finished cells — so a killed spot-GPU run restarts cheaply.</p>
8992

9093
<div class="note">
91-
<strong>Status — honest caveat.</strong> This is the measurement harness. The headline finding
92-
is not in the repo yet: one piece is intentionally deferred to the GPU run — wiring the eviction
93-
selection into HuggingFace's live KV cache. Until that lands, all methods produce identical output
94-
and the divergence is NULL. Any numbers in a freshly generated report from the CPU smoke are
95-
pipeline-shape placeholders, not a result. See the
96-
<a href="https://github.com/pjdurden/kv-canary/blob/main/docs/RUNBOOK.md">runbook</a>.
94+
<strong>Status &amp; honest caveats.</strong> The harness is wired end-to-end — compression is
95+
applied into HF's live KV cache and perplexity is measured under it, so the divergence is real
96+
(run the GPU matrix on a real instruct model before trusting numbers). Two method implementations
97+
are simplified and a faithful reviewer would flag them: StreamingLLM evicts from a post-RoPE cache
98+
<em>without re-roping</em>, and SnapKV is head-averaged without pooling — so treat these as
99+
"-style" eviction, not exact reproductions. Functional-degradation-under-KV-compression is also
100+
already measured by NVIDIA KVPress and others; the narrow niche here is executable-code +
101+
tool-schema conformance vs. perplexity. Full cited audit:
102+
<a href="https://github.com/pjdurden/kv-canary/blob/main/docs/RESEARCH.md">RESEARCH.md</a>.
97103
</div>
98104

99105
<footer>

0 commit comments

Comments
 (0)