# Kv Cache Eviction Eval

> Evaluates the quality of learned key-value (KV) cache eviction policies in preserving long-context reasoning and generation capabilities under strict memory constraints. It measures how well different compression strategies retain critical tokens without access to query-specific attention scores during the compression phase. Use when the user wants to benchmark on RULER-4k, OASST2-4k, BoolQ, ARC-Challenge, MMLU, HellaSwag, GovReport, or asks about evaluating this task. Reports accuracy.

- Skill: `qhjqhj00/kv-cache-eviction-eval` (Agent Skill)
- Install (CLI): `npx skillmds add qhjqhj00/kv-cache-eviction-eval`
- Raw SKILL.md: https://api.skillmd.com/api/skills/qhjqhj00/kv-cache-eviction-eval/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Productivity
- Author: qhjqhj00 (https://skillmd.com/u/qhjqhj00)
- Updated: 2026-09-08
- Page: https://skillmd.com/skills/qhjqhj00/kv-cache-eviction-eval

---


# kv-cache-eviction-eval

> Learning to Evict from Key-Value Cache — Moschella et al. (2026) (arXiv:2602.10238, 2026)

## What this evaluates

Evaluates the quality of learned key-value (KV) cache eviction policies in preserving long-context reasoning and generation capabilities under strict memory constraints. It measures how well different compression strategies retain critical tokens without access to query-specific attention scores during the compression phase.

## Datasets

- **RULER-4k** — total ?; splits: test (-1)
- **OASST2-4k** — total ?; splits: test (-1)
- **BoolQ** — total ?; splits: test (-1)
- **ARC-Challenge** — total ?; splits: test (-1)
- **MMLU** — total ?; splits: test (-1)
- **HellaSwag** — total ?; splits: test (-1)
- **GovReport** — total ?; splits: test (-1)

## Metrics

- `accuracy` **(primary)** — range: [0, 1]
  - Exact-match accuracy: the fraction of generated answers that exactly match the ground-truth answer for each benchmark instance.
- `perplexity (PPL)` — range: [0, inf)
  - Perplexity measures next-token prediction capability: PPL = exp(-1/N * sum_{i=1}^N log p(x_i)), where p(x_i) is the model's predicted probability for token i.
- `ROUGE-L` — range: [0, 1]
  - Longest common subsequence-based F1 score between the generated summary and the reference summary, measuring structural overlap.
- `negative per-budget reward (-R^b)` — range: other
  - The negative sum of future importance scores of evicted tokens across all cache budgets, used as an ablation metric to quantify policy learning quality.

## Input / output format

**Input**: Key-value vectors and token positions for each token in the context. For attention-based baselines, attention scores are also provided during the prefill stage.

**Output**: A ranked permutation of tokens indicating eviction priority (for policy evaluation), or generated text answers/summaries for downstream benchmarks.

## Scoring recipe

```python
def compute_metrics(predictions, gold, metric_type):
    if metric_type == 'accuracy':
        return sum(1 for p, g in zip(predictions, gold) if p == g) / len(gold)
    elif metric_type == 'perplexity':
        return math.exp(-sum(math.log(p) for p in predictions) / len(predictions))
    elif metric_type == 'rouge_l':
        return rouge_l_score(predictions, gold)
    elif metric_type == 'reward':
        return -sum(evicted_token_importance for budget in budgets)
    return None
```

## Common pitfalls

- Using relative compression ratios instead of absolute token budgets, which obscures fixed-memory constraints and makes cross-scenario comparison unstable.
- Comparing attention-free methods against baselines that use query-specific attention scores computed during the prefill stage, giving the latter an unfair informational advantage.
- Including the final question in the prefill stage for BoolQ and GovReport, which violates the zero-shot generalization setup where the text is compressed before the question is known.

## Evidence (verbatim from paper)

> We evaluate performance on the RULER benchmark using its official text-based accuracy metric, which requires generating the correct answer for long-context reasoning tasks. We evaluate the efficacy of KV cache compression by its impact on perplexity (PPL), a measure of the model’s next-token prediction capability. We report performance as a function of absolute KV cache size (i.e., the number of tokens retained) rather than a relative compression ratio.

## Citation

```bibtex
@misc{moschella2026learning,
  title={Learning to Evict from Key-Value Cache},
  author={Moschella et al. (2026)},
  year={2026},
  note={arXiv:2602.10238}
}
```

- arXiv: 2602.10238

