Skip to content

feat(issue5): KV Cache store-vs-recompute bandwidth critical value model - #19

Open
xyaohubery wants to merge 1 commit into
Tencent:mainfrom
xyaohubery:feat/issue5-kv-cache-bandwidth-model
Open

feat(issue5): KV Cache store-vs-recompute bandwidth critical value model#19
xyaohubery wants to merge 1 commit into
Tencent:mainfrom
xyaohubery:feat/issue5-kv-cache-bandwidth-model

Conversation

@xyaohubery

Copy link
Copy Markdown

Summary

Analytical model for the KV Cache bandwidth critical value problem, addressing Issue #5.

Key Finding

For a 128K context with 30% hit rate:

  • Critical bandwidth: 804.85 GB/s (well above current TCP 2.5 GB/s)
  • TCP: store-and-load is WORSE than full recompute (5278ms vs 178ms)
  • RDMA at 50 GB/s: still below critical, but 14x faster than TCP
  • QPM gain with RDMA: +956%

The Model

B_crit = KV_size * GPU_TFLOPS / (hit_rate * recompute_flops)

When actual bandwidth > B_crit, store-and-load wins. Otherwise recompute.

Usage

python kv_cache_bandwidth_model.py --hit-rate 0.3 --ctx-len 128K
python kv_cache_bandwidth_model.py --rdma-analysis --sweep --output results.json

🤖 Generated with Claude Code

Analytical model for determining when loading KV Cache from remote
storage beats recomputing from scratch in LLM inference prefill.

Includes:
- Bandwidth critical value (B_crit) derivation from break-even analysis
- TCP vs RDMA comparison with QPM estimates
- Parameter sweep across hit rates (10%-90%) and context lengths (8K-256K)
- Decision matrix for store-vs-recompute across configurations

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant