# HubKV Method Overview Source

This Mermaid diagram is the text source for the method-overview figure. The compiled paper uses `method_overview.pdf`, while this file keeps the pipeline easy to inspect and revise.

```mermaid
flowchart LR
    accTitle: HubKV Method Overview
    accDescr: HubKV refines raw KV-cache importance scores through local hub detection, soft neighbor discounting, head-wise calibration, and compression-ratio gating before using the standard budgeted pruning interface.

    prefill([Prefill full KV cache]) --> scorer[Base scorer produces raw score tensor s]
    scorer --> hubs[Local hub detection by 1D max pooling]
    hubs --> smd[Submodular marginal discounting]
    smd --> calibrate[Head-wise selectivity calibration]
    calibrate --> gate[Compression-ratio gate]
    gate --> prune[Budgeted Top-B pruning]
    prune --> compressed([Compressed KV cache])

    protected[Protected sink and recent tokens] -. set z=1 .-> gate
    objective[Submodular local coverage objective] -. guides .-> smd
    compressed --> decode[Standard decoding interface]

    classDef input fill:#f3f4f6,stroke:#6b7280,stroke-width:2px,color:#1f2937
    classDef process fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#1e3a5f
    classDef correction fill:#ede9fe,stroke:#7c3aed,stroke-width:2px,color:#3b0764
    classDef guard fill:#fef9c3,stroke:#ca8a04,stroke-width:2px,color:#713f12
    classDef output fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d

    class prefill,scorer input
    class hubs,smd,calibrate,gate correction
    class protected,objective guard
    class prune,compressed,decode output
```
