Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add j4flmao/agent-skills --skill kv-cachegit clone --depth 1 https://github.com/j4flmao/agent-skillsWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/j4flmao/agent-skills/kv-cache)<a href="https://agentmods.dev/skills/j4flmao/agent-skills/kv-cache"><img src="https://agentmods.dev/badge/skills/j4flmao/agent-skills/kv-cache/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/j4flmao/agent-skills/kv-cache"><img src="https://agentmods.dev/badge/skills/j4flmao/agent-skills/kv-cache.svg" alt="Reviewed on agentmods" width="80" height="20"></a>- NVIDIA SkillSpector pass
What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00150 | $0.02044 |
| Opus 5.5 | $0.00060 | $0.00818 |
| Sonnet 5.5 | $0.00030 | $0.00409 |
| Haiku 4.5 | $0.00015 | $0.00204 |
Grade A, and why
llm-kv-cache-paged-attention scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 139 lines — stays where its author put it; the contents beside it link to each section on GitHub.
KV Cache & PagedAttention
Purpose
During decoding each new token attends to the keys and values of all previous tokens. Caching K and V avoids recomputing them, but the cache grows linearly with sequence length and batch size and usually becomes the binding constraint on concurrency. This skill gives the sizing math and the serving-engine levers (paging, prefix sharing, KV quantization, scheduling) to maximize throughput without OOM.
Agent Protocol
Trigger
"KV cache", "PagedAttention", "vLLM OOM", "gpu_memory_utilization", "max_num_seqs", "prefix caching", "long context memory", "KV cache quantization".
Input Context
- Model architecture: layers, KV heads, head dim (from
config.json), dtype. - GPU count/VRAM, target context length, expected concurrent requests.
- Prompt shape: shared system prompts or few-shot prefixes?
Output Artifact
KV budget calculation and serving configuration (vLLM flags or equivalent) with expected max concurrency.
Response Format
Model: {name} L={layers} kv_heads={h} head_dim={d} dtype={bytes}
KV per token: 2*L*h*d*bytes = {KiB}
KV budget: {GiB} -> tokens in cache ≈ {n}
Max concurrency at {ctx} tokens ≈ {n}
Config: --max-model-len {..} --gpu-memory-utilization {..} --kv-cache-dtype {..} --max-num-seqs {..}
Completion Criteria
- KV bytes/token computed from the real config (KV heads, not attention heads).
- Budget accounts for weights and activation/workspace memory.
- Concurrency estimate validated with a load test.
- Prefix caching considered for shared prompts.
Sizing Math
KV bytes per token = 2 (K and V) × num_layers × num_kv_heads × head_dim × bytes_per_element
| Model (config) | Per-token KV (bf16) | 8k-token sequence |
|---|---|---|
| Llama-3-8B: 32 layers, 8 KV heads, head_dim 128 | 2·32·8·128·2 = 128 KiB | 1 GiB |
| Same model with fp8 KV cache | 64 KiB | 0.5 GiB |
| Hypothetical MHA (32 KV heads) | 512 KiB | 4 GiB |
Grouped-query attention (GQA) shares each KV head across several query heads, cutting the cache by the group factor; multi-query attention (MQA) uses one KV head; multi-head latent attention (MLA, DeepSeek-V2/V3) stores a compressed latent instead of full K/V.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- yesterday Changed · +83 lines · +150 tokens per session d57e36dd142b
- 1mo ago First seen · 56 lines · 0 tokens per session scan A efd4223325fa
llm-kv-cache-paged-attention is a skill published in the GitHub repository j4flmao/agent-skills (35 stars, last pushed yesterday), licensed MIT. It adds 150 tokens to every session and 2,044 once invoked, about $0.0006 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
vllm
Use when self-hosting an OpenAI-compatible LLM endpoint with vLLM 0.32 — vllm serve, offline LLM.generate / llm.chat, PagedAttention with continuous batching and prefix caching, --tensor-parallel-size / --pipeline-parallel-size, AWQ/GPTQ/FP8 quantization, or wiring LangChain/LlamaIndex clients at…
Inference
Guides model-serving and runtime-inference decisions across local, remote, and packaged deployment paths.
sglang-diffusion-performance
Use when choosing the fastest SGLang Diffusion flags for a model, GPU, and VRAM budget.
sglang-diffusion-add-model
Use when adding a new diffusion model or Diffusers pipeline to SGLang.
sglang-diffusion-cache-dit
Workflow for upgrading/integrating cache-dit in SGLang diffusion (multimodalgen): DBCache, DMD calibrator, TaylorSeer, SVDQuant DQ; porting upstream PRs and resolving conflicts against the per-request knob system; adding new cache knobs; building the sglang generate CLI test matrix; precision validation (PSNR / log…
sglang-diffusion-modelopt-quant
Use when quantizing a diffusion DiT with NVIDIA ModelOpt and making the resulting FP8 or NVFP4 checkpoint loadable, verifiable, and benchmarkable in SGLang Diffusion.