                       CateKV: On Sequential Consistency for Long-Context LLM Inference Acceleration

Table 4: Efficiency comparison between CateKV and Full Attention on a single A100 GPU. In the single-sample inference
task, we utilized texts of lengths 500K, 180K, and 650K as inputs for the following three models. For the batch-sample
inference task, the sample length was set at 40K, and the maximum feasible batch size was used for each method evaluated.
                                          Accuracy (Avg)                  Single-sample inference         Batch-sample inference
    Model                           RULER-128K       Longbench           Memory           Latency       Batchsize          Throughput
    Llama-3-8B-1M (8 KV heads)       84.10 (0.00)    31.27 (0.00)   77.72 (1.00×)      54.28 (1.00×)   12 (1.00×)         229.37 (1.00×)
    CateKV (r = 0.4, η = 1.0)       84.61 (+0.51)   31.48 (+0.21)   41.02 (1.89×)      32.75 (1.66×)   28 (2.33×)         511.46 (2.23×)
    CateKV (r = 0.3, η = 0.7)       83.85 (-0.25)   31.21 (-0.06)   28.59 (2.72×)      24.86 (2.18×)   52 (4.33×)         909.69 (3.96×)
    Phi-3-Mini-128K (32 KV heads)   72.06 (0.00)    34.00 (0.00)    75.11 (1.00×)      55.51 (1.00×)    4 (1.00×)         78.53 (1.00×)
    CateKV (r = 0.4, η = 1.0)       71.69 (-0.37)   33.73 (-0.27)   35.58 (2.11×)      31.06 (1.79×)   10 (2.50×)         167.11 (2.13×)
    CateKV (r = 0.3, η = 1.0)       71.48 (-0.58)   33.66 (-0.33)   29.02 (2.59×)      27.81 (2.00×)   14 (3.50×)         221.29 (2.82×)
    Yi-9B-200K (4 KV heads)          64.52 (0.00)   33.02 (0.00)    77.65 (1.00×)      56.30 (1.00×)   16 (1.00×)         292.55 (1.00×)
    CateKV (r = 0.4, η = 1.0)       65.76 (+1.24)   32.83 (-0.19)   41.62 (1.87×)      36.05 (1.56×)   38 (2.38×)         659.02 (2.25×)
    CateKV (r = 0.3, η = 0.8)       65.75 (+1.23)   32.78 (-0.24)   31.58 (2.46×)      29.96 (1.88×)   60 (3.75×)         980.86 (3.35×)




                        (a)                                             (b)                                         (c)
Figure 8: (a) The effect of adaptive head ratio on memory and decoding latency is approximately linear. (b) Impact of
retention ratio on accuracy in RULER-128K and decoding latency for 500K length input. (c) Minimal effect of sparse
budget in consistent heads on accuracy.

not exhibit a perfect inverse correlation. Rather, the per-              tings of r = 0.4 and η = 1.0, even when the sparse budget
formance remains relatively stable with decreasing r until               in the consistent head is reduced to approximately 0.78%
reaching a critical threshold (≈0.2), beyond which signifi-              (1024), CateKV still maintains comparable performance to
cant degradation occurs due to excessive reliance on critical            full attention in terms of average accuracy. This indicates
tokens during the prefilling stage. In terms of efficiency,              that, during inference, the consistent head only requires a
as shown in Figure 8(a), both memory usage and decoding                  minimal portion of the cache to perform its function, while
latency decrease almost linearly with decreasing r.                      the acquisition of global information relies primarily on
                                                                         adaptive heads, which retain the majority of KV pairs dur-
4.4.2. R ETENTION R ATIO IN A DAPTIVE H EAD                              ing the decoding stage. Since the sparse budget for the
                                                                         consistent head is a small fraction of the total cache, its im-
In adaptive heads, there is still a subset of tokens that are
                                                                         pact on memory usage and inference latency is negligible.
always not important. This enables a reduction in the pro-
portion of the KV cache retained within adaptive heads.
Figure 8(b) illustrates the impact of changes in the retention           5. Conclusion
ratio η on accuracy and latency. When η exceeds a certain
                                                                         We propose CateKV, a novel hybrid KV cache method that
threshold (≈0.6), the model maintains or even surpasses
                                                                         leverages sequential consistency to improve LLM inference
the performance achieved with the full KV cache. How-
                                                                         efficiency in long-context tasks. By using a coefficient-of-
ever, dropping below this threshold results in a significant
                                                                         variation-based algorithm, CateKV classifies attention heads
performance decline, indicating that adaptive heads heavily
                                                                         into consistent and adaptive types. It selectively retains crit-
depend on the majority of the KV cache. Additionally, a de-
                                                                         ical KV pairs in consistent heads and most pairs in adaptive
crease in η leads to a linear reduction in latency. In practical
                                                                         heads, reducing memory usage and decoding latency while
applications, it is essential to adjust both r and η to balance
                                                                         maintaining performance. Additionally, it can be easily
accuracy and memory consumption.
                                                                         integrated with other acceleration methods for further en-
                                                                         hancement. Extensive evaluations demonstrate that CateKV
4.4.3. S PARSE B UDGET IN C ONSISTENT H EAD
                                                                         achieves significant efficiency gains, including up to 2.72×
As illustrated in Figure 8(c), CateKV demonstrates strong                reduction in memory usage, 2.18× acceleration in decoding,
robustness across different sparse budgets. Under the set-               and a 3.96× throughput increase in batch scenarios.


                                                                    9
