KV Cache is 1 Bit Per Channel: Efficient Large Language Model Inference with Coupled Quantization

Efficient deployment of Large Language Models (LLMs) requires batching multiple requests together to improve throughput. As the batch size, context length, or model size increases, the size of the key and value (KV) cache can quickly become the main contributor to GPU memory usage and the bottleneck of inference latency. Quantization has emerged as an effective technique for KV cache compression, but existing methods still fail at very low bit widths. We observe that distinct channels of a key/value activation embedding are highly inter-dependent, and the joint entropy of multiple channels grows at a slower rate than the sum of their marginal entropies. Based on this insight, we propose Coupled Quantization (CQ), which couples multiple key/value channels together to exploit their inter-dependency and encode the activations in a more information-efficient manner. Extensive experiments reveal that CQ outperforms or is competitive with existing baselines in preserving model quality. Furthermore, we demonstrate that CQ can preserve model quality with KV cache quantized down to 1-bit.

Paper

Similar papers

Peer review

Reviewer rmbd6/10 · confidence 5/52024-07-11

Summary

This paper presents a novel approach to KV Cache compression in Large Language Models (LLMs) called Coupled Quantization (CQ). The authors analyze the correlation between different channels in the KV Cache from an information entropy perspective, revealing significant interdependencies. Leveraging this insight, they propose a multi-channel joint non-uniform quantization method that achieves superior compression performance compared to previous per-channel quantization approaches. Experimental results demonstrate that by combining CQ with a sliding window approach, the KV Cache can potentially be compressed to 1 bit while maintaining model quality.

Strengths

1. Thorough Analysis and Clear Motivation: The paper provides a detailed and intuitive explanation of the inter-channel correlation using information entropy, solidly justifying the design of Coupled Quantization. The motivation and effectiveness of the proposed method are well-articulated and supported by comprehensive experimental results. 2. Good Performance at Low Bit-widths: CQ demonstratesadvantages over previous per-channel quantization methods without introducing additional overhead. 3. Practical Efficiency Gains: The authors demonstrate substantial improvements in inference throughput and batch size compared to the FP16 baseline, highlighting the practical benefits of their approach.

Weaknesses

1. Limited Evaluation Tasks: The main experiments focus on datasets (WinoGrande, PIQA, and ARC-C) that primarily consist of short-context QA or multiple-choice questions. Testing KV Cache quantization on these tasks may not fully demonstrate its benefits, as KV Cache compression is most relevant in long-text scenarios. 2. Incomplete Explanation of Channel Correlation: While the visualizations in Figure 2 and the appendix show some layers have significant channel correlation, this is mainly evident in the first few layers. The paper doesn't fully explain the existence and variability of channel correlation across different layers, which may raise questions about the method's general applicability.

Questions

1. Quantization Setting: Is the KV Cache quantized during the prefill stage, or only during the decoding stage (after full-precision prefill computation), similar to the KIVI approach? 2. Channel Grouping Strategy: The paper chooses to group adjacent continuous channel groups together. Would coupling non-adjacent channels with high mutual information potentially bring more benefits? 3. CUDA Kernel Implementation Questions: The compute pattern described for kernel fusion maybe potentially inefficient. Given the relatively small size of centroids for each channel group (e.g., 256 bytes for 4-bit quantization), is shared memory size truly a limiting factor? Could the efficiency be improved by adjusting the thread block assignments and reduction strategies for operations like $QK^T$ and $SV$?

Rating

6

Confidence

5

Soundness

3

Presentation

3

Contribution

3

Limitations

Based on my review of the paper, I believe the authors have partially addressed limitations and potential negative societal impacts.

Reviewer dwgV7/10 · confidence 4/52024-07-12

Summary

This paper identifies a significant interdependency among distinct channels of key/value activation tensors in Transformer models. By quantizing multiple key/value channels together using joint entropy, the authors achieve high inference throughput while maintaining model quality. In extreme cases, the KV cache can be quantized down to 1 bit.

Strengths

* The observation regarding the interdependency of KV channels is actually interesting and insightful. * The proposed joint entropy-based quantization is intuitive and effective. * The presentation is easy to follow and supported by comprehensive experiments.

Weaknesses

* The improvement in inference throughput over the fp16 version is primarily observed with large batch sizes due to the high (de)quantization overhead.

Questions

This paper is an enjoyable read, and I believe grouping K/V channels is an effective way to reduce memory storage burden and improves inference performance. Nevertheless, I have some questions listed below: 1. This work primarily focuses on quantizing the KV cache. Can it be combined with other quantization methods such as weight/activation quantization like SmoothQuant and AWQ? The authors mention that these methods are orthogonal to this work; could you elaborate on how they might be incorporated together? 2. "We employ the 'binning' trick [17] to estimate entropy. We first observe an empirical distribution of key and value channels by saving the KV cache on a dataset". Does this mean that the estimation needs to be done for each dataset and cannot be reused? Which dataset was used for the centroid learning in Table 8? 3. Section 3.3 seems to be a standard practice for fusing (de)quantization operations with other operations. The lookup table also does not seem efficient. Is it possible to conduct an ablation study or profiling to understand the overhead of centroid loading? Can these centroids be reused instead of being frequently loaded from global memory? 4. The experiment in Section 4.4 with large batch sizes is more relevant for online serving scenarios. It would be beneficial to integrate your method with [vllm](https://blog.vllm.ai/2023/06/20/vllm.html) or other serving frameworks and use real traces to evaluate performance. From Figure 4, it seems all CQ methods perform worse than the fp16 version with small batch sizes. Can you explain why? Is it due to the overhead of (de)quantization? 5. "This sliding window of full-precision cache only introduces a small constant memory overhead for each sequence." What about the latency overhead? How does the sliding window affect inference latency? 6. Based on Figure 1, it seems that only by combining the sliding window and CQ can a similar perplexity to the fp16 version be achieved. How do you determine the best sliding window size to achieve the optimal tradeoff? Also, what happens if the number of coupled channels exceeds 8?

Rating

7

Confidence

4

Soundness

4

Presentation

4

Contribution

3

Limitations

Refer to the Weaknesses and Questions sections. Additionally, here are some minor issues: * It would be useful to include latency experiments in Section 4.4 in addition to throughput, which can help readers better understand the benefits of the proposed method. * It would be more helpful to show the actual memory usage in GB instead of the parameter count in Table 8.

Reviewer qfND6/10 · confidence 4/52024-07-12

Summary

The paper explores the idea of compressing the KV cache in Transformer models through quantization; specifically, the authors propose Coupled Quantization, which quantizes multiple KV channels together in order to exploit their interdependency. The gains are guaranteed by the fact that the joint entropy is smaller than or equal to the sum of marginal entropies of the channels. The channels are coupled in continuous groups. The experimental results show that CQ maintains the model quality and improves the inference throughput, even with high compression rates.

Strengths

The paper uses known information theoretic techniques and applies them to KV cache quantization. The method is well founded in information theory. The experimental evaluation is comprehensive, showing significant improvements in inference throughput. The method is relevant for a real bottleneck in deploying LLMs, which is the GPU memory usage due to KV caching.

Weaknesses

While the experiments are extensive, they are focused on the Llama family of models. The novelty of the paper is limited.

Questions

Does CQ affect the training process or is it purely an inference-time optimization? Do you envision a way of using non-contiguous channels in the coupling, perhaps with some limited search of finding groups of channels with higher interdependency? Can you clarify the meaning of bold and underline in Tables?

Rating

6

Confidence

4

Soundness

3

Presentation

3

Contribution

2

Limitations

Yes.

Reviewer KwWk6/10 · confidence 3/52024-07-13

Summary

The authors have addressed the KV-cache compression problem by providing a finer quantization level. The KV-cache can pose a significant barrier to the inference of most autoregressive language models, a challenge that has been well studied in recent publications at ICML and NeurIPS. This paper introduces a novel approach by coupling multiple key/value channels together for quantization, exploiting their interdependence to encode the activations in a more information-efficient manner.

Strengths

- The method is novel and demonstrates comparable accuracy to KVQuant, one of the pivotal approaches in this field. - It includes a substantial number of experiments to validate accuracy. - The quantization method introduced here is novel compared to other approaches. Additionally, the implementation in PyTorch represents a significant contribution.

Weaknesses

- The code is not available. For research on KV cache, it is important to have the code available. - The section describing the random variables and entropy, specifically line 120, does not explicitly describe the random variables in mathematical notation. This should be revised for clarity. I would like to see this section more polished. - I believe the LLAMA3 model was available before the NeurIPS submission. Since that time, the authors may have extended their findings to these models. I would like to see the performance of your model in that setting. - I want to see how the runtime of your method compares to other methods. Recent works, like **QJL**, include good plots for token-wise generation time or end-to-end timing. Since you compare with KVQuant, it is also good to compare with **KIVI**, as it is one of the best methods. I recommend comparing with QJL and **KIVI**, and plotting the runtime alongside these methods. - I highly recommend the authors run their code on longer context datasets. LongBench could be a great example to evaluate its performance compared to other methods. I would suggest that perplexity is not the best metric for comparison. Relevant papers: [KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache], [QJL: 1-Bit Quantized JL Transform for KV Cache Quantization with Zero Overhead] **If you address the concerns regarding the experiments and provide a broader comparison to the other methods, I would increase my score.**

Questions

- There is additional overhead regarding storing the centroid for each coupled key/value pair, making it difficult to track. I would like you to mention this overhead and explain how you set those values.

Rating

6

Confidence

3

Soundness

2

Presentation

1

Contribution

2

Limitations

- There is additional overhead regarding storing the centroid for each coupled key/value pair, which can complicate tracking and management. It would be beneficial to address this overhead and provide details on how these values are set.

Authorsrebuttal2024-08-12

QJL Experiment Results & Follow-up

We thank the reviewer again for carefully reviewing our paper and providing constructive feedback. We have conducted additional experiments using the official QJL codebase (https://github.com/amirzandieh/QJL) with an A100 40GB GPU. We evaluate QJL and CQ with Llama-2-7b on LongBench. For QJL, we used a sliding window of size 32 and a group size of 32 (`buffer_size=32,group_size=32`), and set other hyper-parameters following the codebase (`key_quantization_bits=256,key_quantization_bits_initial_layers=512,initial_layers_count=15,outlier_count_general=8,outlier_count_initial_layers=8,value_quantization_bits=2`). For CQ, we use the 4c8b (2-bit) configuration and a sliding window of size 32. The results are presented in the table below. | | Bit Width | Qasper | TREC | SAMSum | TriviaQA | |---|---|---|---|---|---| | FP16 | 16 | 9.52 | 66.00 | 41.69 | 87.72 | | QJL | 3.00 | 5.98 | 15.00 | 14.84 | Error | | CQ-4c8b | 2.00 | **9.58** | **66.00** | **41.13** | **87.72** | We also encountered some challenges when attempting to conduct additional experiments. 1. For QJL on TriviaQA, we ran into the following error: `File ".../QJL/models/llama2_utils_qjl.py", line 143, in _update_outliers self.outlier_indices = torch.cat([self.outlier_indices, outlier_indices], dim=2).contiguous() TypeError: expected Tensor as element 0 in argument 0, but got NoneType`. 2. We tried to directly compare CQ with QJL by following the experimental settings (longchat-7b-v1.5-32k on LongBench) in Table 1 of the QJL paper. However, we ran into out-of-memory issues with CQ-4c8b due to GPU memory constraints (Nvidia A100 40G). Given the time constraint of the discussion period, we have made our best effort to provide a fair comparison between CQ and QJL. We are open to further investigation and would welcome specific suggestions from the reviewer on how to resolve the issues above. We are also happy to provide additional clarification on any follow-up questions. We respectfully request that the reviewer reconsider our paper in light of these responses.

Authorsrebuttal2024-08-14

Thank you to Reviewer

Dear Reviewer KwWk, We would like to express our sincere gratitude for your time and effort in reviewing our paper. Your feedback has been invaluable to us. As the discussion period is drawing to a close, we kindly request that you review our previous responses to your review. If you have any additional questions or concerns, we would be happy to address them promptly. Thank you again for your valuable contributions.

Reviewer KwWk2024-08-14

Score Increased to 6

I'm glad the answer has addressed my questions. Extending the experiments and comparing them to the baselines, including LongBench and LLaMA3, is great! I'll be more than happy to increase my score to 6. I recommend adding all of these results to the main paper.

Authorsrebuttal2024-08-14

Thank You to Reviewer

We sincerely thank the reviewer for their thoughtful comments and suggestions!

Reviewer p3Eo5/10 · confidence 4/52024-07-30

Summary

LLM inference typically involves Key-Value (KV) caching to avoid recomputation. However, the KV cache size grows with batch and context length, imposing bottlenecks in memory footprint and inference speed. Quantization can be employed to reduce the size of the KV cache. Instead of channel-wise independent quantization, this work proposes Coupled Quantization to quantize the KV cache by grouping the channels and performing vector quantization by learning a joint codebook with a calibration corpus. This enables additional compression as the entropy of each channel is distributed over the code bits.

Strengths

- With the proposed method, more aggressive compression of the KV cache is enabled. - System support is provided.

Weaknesses

- Table 2 shows that CQ only outperforms the baselines in the 1bit regime, which already suffers great accuracy loss. For relatively “safer” bitwidths, it is on-par or sub-par to baselines. - As far as I know, the common sense reasoning tasks utilized in the experiments(Windogrande, PIQA, ARC, etc.) are usually multiple choice and do not require long generation (also, they are relatively easy tasks). It could be hard to verify the effectiveness of the proposed method for long generation setting(for instance, experiments on benchmarks such as GSM8k with chain-of-thought, which is a relatively hard task), where the incoming KVs are also quantized. - Baselines are absent in Table 3. - Testing the proposed method on long context benchmarks or multi-hop retrieval tasks, such as the RULER[1] dataset will improve the quality of the paper. - The proposed method involves offline learning of centroids using a calibration dataset. The quality of the centroids may not hold under distribution shifts. Reference: [1] Hsieh et al, “RULER: What's the Real Context Size of Your Long-Context Language Models?”, arXiv 2024.

Questions

- How are shared memory bank conflicts handled during centroid lookup?

Rating

5

Confidence

4

Soundness

3

Presentation

3

Contribution

2

Limitations

The authors have included a separate Limitations & Broader Impacts section in the manuscript.

Authorsrebuttal2024-08-13

Additional Experiments & Follow-up

We appreciate the reviewer for carefully reviewing our paper and offering thoughtful feedback. We have conducted additional experiments on passkey retrieval, following the setup in [1], with Llama-2-7b at its maximum context length of 4096. The passkey retrieval task is similar to the needle retrieval task in RULER. We still have trouble running RULER due to compatibility issues with Docker, and we will continue to work on it. As shown in the table below, CQ consistently outperforms KVQuant at various bit widths on passkey retrieval. We are also happy to provide additional clarification on any follow-up questions. We respectfully request that the reviewer reconsider our paper in light of these responses. | | Bit Width | Retrieval Success Rate | |---|---|---| | KVQuant-4b+1% sparse | 4.32 | **100%** | | KVQuant-4b | 4 | **100%** | | CQ-2c8b | 4 | **100%** | | KVQuant-2b+1% sparse | 2.32 | 94% | | CQ-4c9b | 2.26 | **98%** | | KVQuant-2b | 2 | 0% | | CQ-4c8b | 2 | **96%** | | KVQuant-1b+1% sparse | 1.32 | 2% | | CQ-8c10b | 1.27 | **78%** | | KVQuant-1b | 1 | 0% | | CQ-8c8b | 1 | **12%** | **References** [1] Zhu, Dawei, et al. "Pose: Efficient context window extension of llms via positional skip-wise training." arXiv preprint arXiv:2309.10400 (2023).

Reviewer p3Eo2024-08-13

Thank you for your response. Looking at the discourse of other reviewers, I have questions regarding the latency: I am confused as to why the latency is measured with batch size 1, while the manuscript presents a throughput increase with increasing batch sizes. For latency comparison, shouldn't token throughput or batched decoding latency comparison between CQ KIVI be measured in similar settings?

Authorsrebuttal2024-08-13

We sincerely thank the reviewer for the response, and address your concerns as follows. - We presented the latency measurement with batch size 1, since Reviewer dwgV has specifically asked us for latency experiments in small batch sizes. We quote >From Figure 4, it seems all CQ methods perform worse than the fp16 version with small batch sizes. Can you explain why? Is it due to the overhead of (de)quantization? - Measurements with batch size 1 highlight the efficiency and latency aspects of our CUDA kernels. - We note that the latency comparison we presented between CQ and KIVI is a fair comparison with the same experimental settings: batch size of 1, equal token counts for prefill and decoding, and an identical sliding window size. - We agree with the reviewer that latency and throughput at different batch sizes are important for understanding the efficiency of our approach. Hence we will include additional latency and throughput measurements at different batch sizes and context lengths in the camera-ready version.

Reviewer p3Eo2024-08-14

Thank you for the response, but if measured for batch size 1, isn't the latency dominated by FFN?

Reviewer rmbd2024-08-10

Thank you to the author for the detailed reply, which addressed most of my concerns. I am generally satisfied with the response. I appreciate your detailed explanation of the CUDA kernel implementation. Previously, I had some misunderstandings regarding centroid storage, which have now been clarified. However, inefficiency remains an issue. From the latency measurements of CQ compared to KIVI in your rebuttal, it appears that the latency actually increased when reducing from 2 bits to 1 bit. This suggests that the overhead of lookup table might outweigh the benefits of reducing memory transfers.. Taking everything into consideration, I have decided to maintain my score of 6 points.

Reviewer dwgV2024-08-10

Thank you for your detailed response. Most of my concerns have been addressed. Based on the latency results, there remains a large gap between CQ and the fp16 version (especially for the prefill stage). If compared with the quantized fp8 or int8 implementation, I think the performance gap will be larger, so I hope the authors can further enhance efficiency to make this quantization technique more practical. For now, I will maintain my current score.

Reviewer p3Eo2024-08-14

The accuracy of the proposed method is better compared to KVQuant on benchmark tasks. Although I think (saturated) latency comparisons with KVQuant or KIVI should be provided, Due to the discussion phase ending soon, I preemptively raise my score.

Program Chairsdecision2024-09-25

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC