Chelsea707 commited on
Commit
6ca9df8
·
verified ·
1 Parent(s): 9d7b89b

Add Batch e7c9b61b-0c92-47d8-8eda-8f23327dd041 data

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +64 -0
  2. 2024/Junk DNA Hypothesis_ Pruning Small Pre-Trained Weights $_textitIrreversibly$ and $_textitMonotonically$ Impairs “Difficult_ Downstream Tasks in LLMs/8bea9d8d-bba3-4dd6-92fe-6429192b736c_content_list.json +0 -0
  3. 2024/Junk DNA Hypothesis_ Pruning Small Pre-Trained Weights $_textitIrreversibly$ and $_textitMonotonically$ Impairs “Difficult_ Downstream Tasks in LLMs/8bea9d8d-bba3-4dd6-92fe-6429192b736c_model.json +0 -0
  4. 2024/Junk DNA Hypothesis_ Pruning Small Pre-Trained Weights $_textitIrreversibly$ and $_textitMonotonically$ Impairs “Difficult_ Downstream Tasks in LLMs/8bea9d8d-bba3-4dd6-92fe-6429192b736c_origin.pdf +3 -0
  5. 2024/Junk DNA Hypothesis_ Pruning Small Pre-Trained Weights $_textitIrreversibly$ and $_textitMonotonically$ Impairs “Difficult_ Downstream Tasks in LLMs/full.md +404 -0
  6. 2024/Junk DNA Hypothesis_ Pruning Small Pre-Trained Weights $_textitIrreversibly$ and $_textitMonotonically$ Impairs “Difficult_ Downstream Tasks in LLMs/images.zip +3 -0
  7. 2024/Junk DNA Hypothesis_ Pruning Small Pre-Trained Weights $_textitIrreversibly$ and $_textitMonotonically$ Impairs “Difficult_ Downstream Tasks in LLMs/layout.json +0 -0
  8. 2024/Just Cluster It_ An Approach for Exploration in High-Dimensions using Clustering and Pre-Trained Representations/7b2f16fe-5bc7-4629-941e-77e88683d4e9_content_list.json +0 -0
  9. 2024/Just Cluster It_ An Approach for Exploration in High-Dimensions using Clustering and Pre-Trained Representations/7b2f16fe-5bc7-4629-941e-77e88683d4e9_model.json +0 -0
  10. 2024/Just Cluster It_ An Approach for Exploration in High-Dimensions using Clustering and Pre-Trained Representations/7b2f16fe-5bc7-4629-941e-77e88683d4e9_origin.pdf +3 -0
  11. 2024/Just Cluster It_ An Approach for Exploration in High-Dimensions using Clustering and Pre-Trained Representations/full.md +549 -0
  12. 2024/Just Cluster It_ An Approach for Exploration in High-Dimensions using Clustering and Pre-Trained Representations/images.zip +3 -0
  13. 2024/Just Cluster It_ An Approach for Exploration in High-Dimensions using Clustering and Pre-Trained Representations/layout.json +0 -0
  14. 2024/KISA_ A Unified Keyframe Identifier and Skill Annotator for Long-Horizon Robotics Demonstrations/19643242-51ec-4da6-992b-7ebd922e8eaa_content_list.json +0 -0
  15. 2024/KISA_ A Unified Keyframe Identifier and Skill Annotator for Long-Horizon Robotics Demonstrations/19643242-51ec-4da6-992b-7ebd922e8eaa_model.json +0 -0
  16. 2024/KISA_ A Unified Keyframe Identifier and Skill Annotator for Long-Horizon Robotics Demonstrations/19643242-51ec-4da6-992b-7ebd922e8eaa_origin.pdf +3 -0
  17. 2024/KISA_ A Unified Keyframe Identifier and Skill Annotator for Long-Horizon Robotics Demonstrations/full.md +0 -0
  18. 2024/KISA_ A Unified Keyframe Identifier and Skill Annotator for Long-Horizon Robotics Demonstrations/images.zip +3 -0
  19. 2024/KISA_ A Unified Keyframe Identifier and Skill Annotator for Long-Horizon Robotics Demonstrations/layout.json +0 -0
  20. 2024/KIVI_ A Tuning-Free Asymmetric 2bit Quantization for KV Cache/b0cf2b04-a9b0-4077-9961-397b48206580_content_list.json +1940 -0
  21. 2024/KIVI_ A Tuning-Free Asymmetric 2bit Quantization for KV Cache/b0cf2b04-a9b0-4077-9961-397b48206580_model.json +0 -0
  22. 2024/KIVI_ A Tuning-Free Asymmetric 2bit Quantization for KV Cache/b0cf2b04-a9b0-4077-9961-397b48206580_origin.pdf +3 -0
  23. 2024/KIVI_ A Tuning-Free Asymmetric 2bit Quantization for KV Cache/full.md +371 -0
  24. 2024/KIVI_ A Tuning-Free Asymmetric 2bit Quantization for KV Cache/images.zip +3 -0
  25. 2024/KIVI_ A Tuning-Free Asymmetric 2bit Quantization for KV Cache/layout.json +0 -0
  26. 2024/KV-Runahead_ Scalable Causal LLM Inference by Parallel Key-Value Cache Generation/7aa03393-2876-47f2-bf79-bac44a783b1a_content_list.json +2211 -0
  27. 2024/KV-Runahead_ Scalable Causal LLM Inference by Parallel Key-Value Cache Generation/7aa03393-2876-47f2-bf79-bac44a783b1a_model.json +0 -0
  28. 2024/KV-Runahead_ Scalable Causal LLM Inference by Parallel Key-Value Cache Generation/7aa03393-2876-47f2-bf79-bac44a783b1a_origin.pdf +3 -0
  29. 2024/KV-Runahead_ Scalable Causal LLM Inference by Parallel Key-Value Cache Generation/full.md +406 -0
  30. 2024/KV-Runahead_ Scalable Causal LLM Inference by Parallel Key-Value Cache Generation/images.zip +3 -0
  31. 2024/KV-Runahead_ Scalable Causal LLM Inference by Parallel Key-Value Cache Generation/layout.json +0 -0
  32. 2024/Keep the Momentum_ Conservation Laws beyond Euclidean Gradient Flows/0f5417c5-1d82-4164-a466-68fd918679dd_content_list.json +0 -0
  33. 2024/Keep the Momentum_ Conservation Laws beyond Euclidean Gradient Flows/0f5417c5-1d82-4164-a466-68fd918679dd_model.json +0 -0
  34. 2024/Keep the Momentum_ Conservation Laws beyond Euclidean Gradient Flows/0f5417c5-1d82-4164-a466-68fd918679dd_origin.pdf +3 -0
  35. 2024/Keep the Momentum_ Conservation Laws beyond Euclidean Gradient Flows/full.md +0 -0
  36. 2024/Keep the Momentum_ Conservation Laws beyond Euclidean Gradient Flows/images.zip +3 -0
  37. 2024/Keep the Momentum_ Conservation Laws beyond Euclidean Gradient Flows/layout.json +0 -0
  38. 2024/Kepler codebook/ff7aa711-f0cd-4fe1-9c46-7fb24d4e745b_content_list.json +0 -0
  39. 2024/Kepler codebook/ff7aa711-f0cd-4fe1-9c46-7fb24d4e745b_model.json +0 -0
  40. 2024/Kepler codebook/ff7aa711-f0cd-4fe1-9c46-7fb24d4e745b_origin.pdf +3 -0
  41. 2024/Kepler codebook/full.md +544 -0
  42. 2024/Kepler codebook/images.zip +3 -0
  43. 2024/Kepler codebook/layout.json +0 -0
  44. 2024/Kernel Debiased Plug-in Estimation_ Simultaneous, Automated Debiasing without Influence Functions for Many Target Parameters/92d586ff-e6c9-4103-b016-e4da7e2f5a98_content_list.json +0 -0
  45. 2024/Kernel Debiased Plug-in Estimation_ Simultaneous, Automated Debiasing without Influence Functions for Many Target Parameters/92d586ff-e6c9-4103-b016-e4da7e2f5a98_model.json +0 -0
  46. 2024/Kernel Debiased Plug-in Estimation_ Simultaneous, Automated Debiasing without Influence Functions for Many Target Parameters/92d586ff-e6c9-4103-b016-e4da7e2f5a98_origin.pdf +3 -0
  47. 2024/Kernel Debiased Plug-in Estimation_ Simultaneous, Automated Debiasing without Influence Functions for Many Target Parameters/full.md +0 -0
  48. 2024/Kernel Debiased Plug-in Estimation_ Simultaneous, Automated Debiasing without Influence Functions for Many Target Parameters/images.zip +3 -0
  49. 2024/Kernel Debiased Plug-in Estimation_ Simultaneous, Automated Debiasing without Influence Functions for Many Target Parameters/layout.json +0 -0
  50. 2024/Kernel Semi-Implicit Variational Inference/ee6ad02a-42ab-40fd-a7d8-00cf05e58390_content_list.json +0 -0
.gitattributes CHANGED
@@ -4587,3 +4587,67 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
4587
  2024/Jacobian[[:space:]]Regularizer-based[[:space:]]Neural[[:space:]]Granger[[:space:]]Causality/93464bab-cc41-4c12-aeeb-262382503b44_origin.pdf filter=lfs diff=lfs merge=lfs -text
4588
  2024/Jetfire_[[:space:]]Efficient[[:space:]]and[[:space:]]Accurate[[:space:]]Transformer[[:space:]]Pretraining[[:space:]]with[[:space:]]INT8[[:space:]]Data[[:space:]]Flow[[:space:]]and[[:space:]]Per-Block[[:space:]]Quantization/6f1fc1cf-e9e8-44a0-8a38-49b3ae84765c_origin.pdf filter=lfs diff=lfs merge=lfs -text
4589
  2024/Joint[[:space:]]Composite[[:space:]]Latent[[:space:]]Space[[:space:]]Bayesian[[:space:]]Optimization/89bf0743-1d93-45ea-af7b-10a34b8495c2_origin.pdf filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4587
  2024/Jacobian[[:space:]]Regularizer-based[[:space:]]Neural[[:space:]]Granger[[:space:]]Causality/93464bab-cc41-4c12-aeeb-262382503b44_origin.pdf filter=lfs diff=lfs merge=lfs -text
4588
  2024/Jetfire_[[:space:]]Efficient[[:space:]]and[[:space:]]Accurate[[:space:]]Transformer[[:space:]]Pretraining[[:space:]]with[[:space:]]INT8[[:space:]]Data[[:space:]]Flow[[:space:]]and[[:space:]]Per-Block[[:space:]]Quantization/6f1fc1cf-e9e8-44a0-8a38-49b3ae84765c_origin.pdf filter=lfs diff=lfs merge=lfs -text
4589
  2024/Joint[[:space:]]Composite[[:space:]]Latent[[:space:]]Space[[:space:]]Bayesian[[:space:]]Optimization/89bf0743-1d93-45ea-af7b-10a34b8495c2_origin.pdf filter=lfs diff=lfs merge=lfs -text
4590
+ 2024/Junk[[:space:]]DNA[[:space:]]Hypothesis_[[:space:]]Pruning[[:space:]]Small[[:space:]]Pre-Trained[[:space:]]Weights[[:space:]]$_textitIrreversibly$[[:space:]]and[[:space:]]$_textitMonotonically$[[:space:]]Impairs[[:space:]]“Difficult_[[:space:]]Downstream[[:space:]]Tasks[[:space:]]in[[:space:]]LLMs/8bea9d8d-bba3-4dd6-92fe-6429192b736c_origin.pdf filter=lfs diff=lfs merge=lfs -text
4591
+ 2024/Just[[:space:]]Cluster[[:space:]]It_[[:space:]]An[[:space:]]Approach[[:space:]]for[[:space:]]Exploration[[:space:]]in[[:space:]]High-Dimensions[[:space:]]using[[:space:]]Clustering[[:space:]]and[[:space:]]Pre-Trained[[:space:]]Representations/7b2f16fe-5bc7-4629-941e-77e88683d4e9_origin.pdf filter=lfs diff=lfs merge=lfs -text
4592
+ 2024/KISA_[[:space:]]A[[:space:]]Unified[[:space:]]Keyframe[[:space:]]Identifier[[:space:]]and[[:space:]]Skill[[:space:]]Annotator[[:space:]]for[[:space:]]Long-Horizon[[:space:]]Robotics[[:space:]]Demonstrations/19643242-51ec-4da6-992b-7ebd922e8eaa_origin.pdf filter=lfs diff=lfs merge=lfs -text
4593
+ 2024/KIVI_[[:space:]]A[[:space:]]Tuning-Free[[:space:]]Asymmetric[[:space:]]2bit[[:space:]]Quantization[[:space:]]for[[:space:]]KV[[:space:]]Cache/b0cf2b04-a9b0-4077-9961-397b48206580_origin.pdf filter=lfs diff=lfs merge=lfs -text
4594
+ 2024/KV-Runahead_[[:space:]]Scalable[[:space:]]Causal[[:space:]]LLM[[:space:]]Inference[[:space:]]by[[:space:]]Parallel[[:space:]]Key-Value[[:space:]]Cache[[:space:]]Generation/7aa03393-2876-47f2-bf79-bac44a783b1a_origin.pdf filter=lfs diff=lfs merge=lfs -text
4595
+ 2024/Keep[[:space:]]the[[:space:]]Momentum_[[:space:]]Conservation[[:space:]]Laws[[:space:]]beyond[[:space:]]Euclidean[[:space:]]Gradient[[:space:]]Flows/0f5417c5-1d82-4164-a466-68fd918679dd_origin.pdf filter=lfs diff=lfs merge=lfs -text
4596
+ 2024/Kepler[[:space:]]codebook/ff7aa711-f0cd-4fe1-9c46-7fb24d4e745b_origin.pdf filter=lfs diff=lfs merge=lfs -text
4597
+ 2024/Kernel[[:space:]]Debiased[[:space:]]Plug-in[[:space:]]Estimation_[[:space:]]Simultaneous,[[:space:]]Automated[[:space:]]Debiasing[[:space:]]without[[:space:]]Influence[[:space:]]Functions[[:space:]]for[[:space:]]Many[[:space:]]Target[[:space:]]Parameters/92d586ff-e6c9-4103-b016-e4da7e2f5a98_origin.pdf filter=lfs diff=lfs merge=lfs -text
4598
+ 2024/Kernel[[:space:]]Semi-Implicit[[:space:]]Variational[[:space:]]Inference/ee6ad02a-42ab-40fd-a7d8-00cf05e58390_origin.pdf filter=lfs diff=lfs merge=lfs -text
4599
+ 2024/Kernel-Based[[:space:]]Evaluation[[:space:]]of[[:space:]]Conditional[[:space:]]Biological[[:space:]]Sequence[[:space:]]Models/2131708f-d80f-41cb-9759-aebf597baf23_origin.pdf filter=lfs diff=lfs merge=lfs -text
4600
+ 2024/KernelSHAP-IQ_[[:space:]]Weighted[[:space:]]Least[[:space:]]Square[[:space:]]Optimization[[:space:]]for[[:space:]]Shapley[[:space:]]Interactions/2a0155b9-d169-4da6-a8b6-8f89184ad6ef_origin.pdf filter=lfs diff=lfs merge=lfs -text
4601
+ 2024/KernelWarehouse_[[:space:]]Rethinking[[:space:]]the[[:space:]]Design[[:space:]]of[[:space:]]Dynamic[[:space:]]Convolution/da71c718-daae-4b97-83e7-bcb11c8e31e4_origin.pdf filter=lfs diff=lfs merge=lfs -text
4602
+ 2024/Keypoint-based[[:space:]]Progressive[[:space:]]Chain-of-Thought[[:space:]]Distillation[[:space:]]for[[:space:]]LLMs/fef4c433-b140-4f83-a60f-669e16c0c0da_origin.pdf filter=lfs diff=lfs merge=lfs -text
4603
+ 2024/KnowFormer_[[:space:]]Revisiting[[:space:]]Transformers[[:space:]]for[[:space:]]Knowledge[[:space:]]Graph[[:space:]]Reasoning/55883fca-bed0-437f-8d18-3ba907163034_origin.pdf filter=lfs diff=lfs merge=lfs -text
4604
+ 2024/Knowledge[[:space:]]Distillation[[:space:]]with[[:space:]]Auxiliary[[:space:]]Variable/62764955-4511-4409-821f-95b8fdb21bba_origin.pdf filter=lfs diff=lfs merge=lfs -text
4605
+ 2024/Knowledge[[:space:]]Graphs[[:space:]]Can[[:space:]]be[[:space:]]Learned[[:space:]]with[[:space:]]Just[[:space:]]Intersection[[:space:]]Features/0a1bcfc8-bebd-427e-b775-ce0ce91411ce_origin.pdf filter=lfs diff=lfs merge=lfs -text
4606
+ 2024/Knowledge[[:space:]]Transfer[[:space:]]from[[:space:]]Vision[[:space:]]Foundation[[:space:]]Models[[:space:]]for[[:space:]]Efficient[[:space:]]Training[[:space:]]of[[:space:]]Small[[:space:]]Task-specific[[:space:]]Models/5848fb34-a21d-460a-85fa-b6da23402383_origin.pdf filter=lfs diff=lfs merge=lfs -text
4607
+ 2024/Knowledge-aware[[:space:]]Reinforced[[:space:]]Language[[:space:]]Models[[:space:]]for[[:space:]]Protein[[:space:]]Directed[[:space:]]Evolution/17113079-7a96-4167-8fc4-e9626bc4cda7_origin.pdf filter=lfs diff=lfs merge=lfs -text
4608
+ 2024/LAGMA_[[:space:]]LAtent[[:space:]]Goal-guided[[:space:]]Multi-Agent[[:space:]]Reinforcement[[:space:]]Learning/61b77f19-3864-4d70-8632-8a4967b28ec3_origin.pdf filter=lfs diff=lfs merge=lfs -text
4609
+ 2024/LASER_[[:space:]]Linear[[:space:]]Compression[[:space:]]in[[:space:]]Wireless[[:space:]]Distributed[[:space:]]Optimization/8c022bae-2e06-48d5-9a53-021af6c0bf31_origin.pdf filter=lfs diff=lfs merge=lfs -text
4610
+ 2024/LCA-on-the-Line_[[:space:]]Benchmarking[[:space:]]Out[[:space:]]of[[:space:]]Distribution[[:space:]]Generalization[[:space:]]with[[:space:]]Class[[:space:]]Taxonomies/bb928a16-e819-41ba-8a52-a202780f24a0_origin.pdf filter=lfs diff=lfs merge=lfs -text
4611
+ 2024/LESS_[[:space:]]Selecting[[:space:]]Influential[[:space:]]Data[[:space:]]for[[:space:]]Targeted[[:space:]]Instruction[[:space:]]Tuning/336452a8-f430-49cd-bd63-f0b5e80ea1cb_origin.pdf filter=lfs diff=lfs merge=lfs -text
4612
+ 2024/LEVI_[[:space:]]Generalizable[[:space:]]Fine-tuning[[:space:]]via[[:space:]]Layer-wise[[:space:]]Ensemble[[:space:]]of[[:space:]]Different[[:space:]]Views/32bc82de-57cd-4286-9fe4-cf6f9e1a1c1a_origin.pdf filter=lfs diff=lfs merge=lfs -text
4613
+ 2024/LIDAO_[[:space:]]Towards[[:space:]]Limited[[:space:]]Interventions[[:space:]]for[[:space:]]Debiasing[[:space:]](Large)[[:space:]]Language[[:space:]]Models/b5fc767d-46e3-470f-b333-7631df2825ce_origin.pdf filter=lfs diff=lfs merge=lfs -text
4614
+ 2024/LLM[[:space:]]Maybe[[:space:]]LongLM_[[:space:]]SelfExtend[[:space:]]LLM[[:space:]]Context[[:space:]]Window[[:space:]]Without[[:space:]]Tuning/3a519324-9c44-4b11-b72a-b5ba8c3ced66_origin.pdf filter=lfs diff=lfs merge=lfs -text
4615
+ 2024/LLM[[:space:]]and[[:space:]]Simulation[[:space:]]as[[:space:]]Bilevel[[:space:]]Optimizers_[[:space:]]A[[:space:]]New[[:space:]]Paradigm[[:space:]]to[[:space:]]Advance[[:space:]]Physical[[:space:]]Scientific[[:space:]]Discovery/781c0349-619b-43a8-8941-2870a180cd19_origin.pdf filter=lfs diff=lfs merge=lfs -text
4616
+ 2024/LLM-Empowered[[:space:]]State[[:space:]]Representation[[:space:]]for[[:space:]]Reinforcement[[:space:]]Learning/7ace0e7a-272c-48be-ba7f-7a8afaaf87c8_origin.pdf filter=lfs diff=lfs merge=lfs -text
4617
+ 2024/LLaGA_[[:space:]]Large[[:space:]]Language[[:space:]]and[[:space:]]Graph[[:space:]]Assistant/77b81a70-2d2c-43ca-81f6-711d3950d787_origin.pdf filter=lfs diff=lfs merge=lfs -text
4618
+ 2024/LLark_[[:space:]]A[[:space:]]Multimodal[[:space:]]Instruction-Following[[:space:]]Language[[:space:]]Model[[:space:]]for[[:space:]]Music/3990fb42-9530-445c-bc2c-7f0e0a8fd132_origin.pdf filter=lfs diff=lfs merge=lfs -text
4619
+ 2024/LPGD_[[:space:]]A[[:space:]]General[[:space:]]Framework[[:space:]]for[[:space:]]Backpropagation[[:space:]]through[[:space:]]Embedded[[:space:]]Optimization[[:space:]]Layers/b95fb38d-aeda-4f8c-9bb3-1afc068f7abd_origin.pdf filter=lfs diff=lfs merge=lfs -text
4620
+ 2024/LQER_[[:space:]]Low-Rank[[:space:]]Quantization[[:space:]]Error[[:space:]]Reconstruction[[:space:]]for[[:space:]]LLMs/e88b37fa-abe8-4ac2-b815-049a25ce6802_origin.pdf filter=lfs diff=lfs merge=lfs -text
4621
+ 2024/LSEnet_[[:space:]]Lorentz[[:space:]]Structural[[:space:]]Entropy[[:space:]]Neural[[:space:]]Network[[:space:]]for[[:space:]]Deep[[:space:]]Graph[[:space:]]Clustering/d9de81a1-d716-4a4a-baf7-0cfd91180fe6_origin.pdf filter=lfs diff=lfs merge=lfs -text
4622
+ 2024/LaMAGIC_[[:space:]]Language-Model-based[[:space:]]Topology[[:space:]]Generation[[:space:]]for[[:space:]]Analog[[:space:]]Integrated[[:space:]]Circuits/f900398b-ad1f-49ba-9fa0-0a0e71c4a713_origin.pdf filter=lfs diff=lfs merge=lfs -text
4623
+ 2024/LangCell_[[:space:]]Language-Cell[[:space:]]Pre-training[[:space:]]for[[:space:]]Cell[[:space:]]Identity[[:space:]]Understanding/80df907b-98a6-4962-8fcc-6553dd48a291_origin.pdf filter=lfs diff=lfs merge=lfs -text
4624
+ 2024/Langevin[[:space:]]Policy[[:space:]]for[[:space:]]Safe[[:space:]]Reinforcement[[:space:]]Learning/7c422495-2f7e-4961-baea-afcf889c608b_origin.pdf filter=lfs diff=lfs merge=lfs -text
4625
+ 2024/Language[[:space:]]Agent[[:space:]]Tree[[:space:]]Search[[:space:]]Unifies[[:space:]]Reasoning,[[:space:]]Acting,[[:space:]]and[[:space:]]Planning[[:space:]]in[[:space:]]Language[[:space:]]Models/0c264c2f-baa1-49ae-ab9e-957223ff491e_origin.pdf filter=lfs diff=lfs merge=lfs -text
4626
+ 2024/Language[[:space:]]Agents[[:space:]]with[[:space:]]Reinforcement[[:space:]]Learning[[:space:]]for[[:space:]]Strategic[[:space:]]Play[[:space:]]in[[:space:]]the[[:space:]]Werewolf[[:space:]]Game/d5246d38-aec1-4666-b874-ed3d128fc44f_origin.pdf filter=lfs diff=lfs merge=lfs -text
4627
+ 2024/Language[[:space:]]Generation[[:space:]]with[[:space:]]Strictly[[:space:]]Proper[[:space:]]Scoring[[:space:]]Rules/889ed941-0985-49be-8961-7c07397ac93c_origin.pdf filter=lfs diff=lfs merge=lfs -text
4628
+ 2024/Language[[:space:]]Models[[:space:]]Represent[[:space:]]Beliefs[[:space:]]of[[:space:]]Self[[:space:]]and[[:space:]]Others/c53c0c30-7ca1-49cc-9fc6-39027f8e569c_origin.pdf filter=lfs diff=lfs merge=lfs -text
4629
+ 2024/Language[[:space:]]Models[[:space:]]are[[:space:]]Super[[:space:]]Mario_[[:space:]]Absorbing[[:space:]]Abilities[[:space:]]from[[:space:]]Homologous[[:space:]]Models[[:space:]]as[[:space:]]a[[:space:]]Free[[:space:]]Lunch/615d10ae-f39f-4978-a965-211bc460c4a4_origin.pdf filter=lfs diff=lfs merge=lfs -text
4630
+ 2024/Language[[:space:]]Models[[:space:]]as[[:space:]]Science[[:space:]]Tutors/b3711485-c9c8-4fa1-a43f-7af1c8a4372e_origin.pdf filter=lfs diff=lfs merge=lfs -text
4631
+ 2024/Language[[:space:]]Models[[:space:]]as[[:space:]]Semantic[[:space:]]Indexers/85273f34-ba3f-4b5f-bee2-d867b24cfc94_origin.pdf filter=lfs diff=lfs merge=lfs -text
4632
+ 2024/Language[[:space:]]Models[[:space:]]with[[:space:]]Conformal[[:space:]]Factuality[[:space:]]Guarantees/6f15a75d-7ee8-473f-9123-74941b6a7b48_origin.pdf filter=lfs diff=lfs merge=lfs -text
4633
+ 2024/Language-Driven[[:space:]]Cross-Modal[[:space:]]Classifier[[:space:]]for[[:space:]]Zero-Shot[[:space:]]Multi-Label[[:space:]]Image[[:space:]]Recognition/8a50a0f2-664e-4d43-8a5e-a39c577201e9_origin.pdf filter=lfs diff=lfs merge=lfs -text
4634
+ 2024/Language-guided[[:space:]]Skill[[:space:]]Learning[[:space:]]with[[:space:]]Temporal[[:space:]]Variational[[:space:]]Inference/165d360b-a1f9-458a-92a2-6c804da11416_origin.pdf filter=lfs diff=lfs merge=lfs -text
4635
+ 2024/Large[[:space:]]Language[[:space:]]Models[[:space:]]Can[[:space:]]Automatically[[:space:]]Engineer[[:space:]]Features[[:space:]]for[[:space:]]Few-Shot[[:space:]]Tabular[[:space:]]Learning/5cbaeff3-dd3f-49fe-b3bc-c063078bd5c2_origin.pdf filter=lfs diff=lfs merge=lfs -text
4636
+ 2024/Large[[:space:]]Language[[:space:]]Models[[:space:]]are[[:space:]]Geographically[[:space:]]Biased/a5a9edce-4216-46a5-bb5d-a5ecdf901aff_origin.pdf filter=lfs diff=lfs merge=lfs -text
4637
+ 2024/Large[[:space:]]Scale[[:space:]]Dataset[[:space:]]Distillation[[:space:]]with[[:space:]]Domain[[:space:]]Shift/65da9d39-5a95-4556-a6c8-68128981cf65_origin.pdf filter=lfs diff=lfs merge=lfs -text
4638
+ 2024/Larimar_[[:space:]]Large[[:space:]]Language[[:space:]]Models[[:space:]]with[[:space:]]Episodic[[:space:]]Memory[[:space:]]Control/b9448dee-0bf4-4a62-b7ce-1bf586d4c423_origin.pdf filter=lfs diff=lfs merge=lfs -text
4639
+ 2024/Latent[[:space:]]Logic[[:space:]]Tree[[:space:]]Extraction[[:space:]]for[[:space:]]Event[[:space:]]Sequence[[:space:]]Explanation[[:space:]]from[[:space:]]LLMs/46779663-4cb7-422d-b179-d77efa864f74_origin.pdf filter=lfs diff=lfs merge=lfs -text
4640
+ 2024/Latent[[:space:]]Noise[[:space:]]Segmentation_[[:space:]]How[[:space:]]Neural[[:space:]]Noise[[:space:]]Leads[[:space:]]to[[:space:]]the[[:space:]]Emergence[[:space:]]of[[:space:]]Segmentation[[:space:]]and[[:space:]]Grouping/fae2ba22-ff4f-4c12-a0ee-4172a2322671_origin.pdf filter=lfs diff=lfs merge=lfs -text
4641
+ 2024/Latent[[:space:]]Optimal[[:space:]]Paths[[:space:]]by[[:space:]]Gumbel[[:space:]]Propagation[[:space:]]for[[:space:]]Variational[[:space:]]Bayesian[[:space:]]Dynamic[[:space:]]Programming/1ce94729-8562-4639-993c-d5b7c98a47f3_origin.pdf filter=lfs diff=lfs merge=lfs -text
4642
+ 2024/Latent[[:space:]]Space[[:space:]]Symmetry[[:space:]]Discovery/a8c1cb48-f36e-463e-8d15-75767fb61903_origin.pdf filter=lfs diff=lfs merge=lfs -text
4643
+ 2024/Latent[[:space:]]variable[[:space:]]model[[:space:]]for[[:space:]]high-dimensional[[:space:]]point[[:space:]]process[[:space:]]with[[:space:]]structured[[:space:]]missingness/b9ffaaf4-78f9-4299-a591-4cdc7deb492e_origin.pdf filter=lfs diff=lfs merge=lfs -text
4644
+ 2024/Layer-Aware[[:space:]]Analysis[[:space:]]of[[:space:]]Catastrophic[[:space:]]Overfitting_[[:space:]]Revealing[[:space:]]the[[:space:]]Pseudo-Robust[[:space:]]Shortcut[[:space:]]Dependency/de558612-debf-40a2-bc30-9375ffffd40f_origin.pdf filter=lfs diff=lfs merge=lfs -text
4645
+ 2024/LayerMerge_[[:space:]]Neural[[:space:]]Network[[:space:]]Depth[[:space:]]Compression[[:space:]]through[[:space:]]Layer[[:space:]]Pruning[[:space:]]and[[:space:]]Merging/6c82b842-e4e6-451d-8281-ddc6a09cd3a2_origin.pdf filter=lfs diff=lfs merge=lfs -text
4646
+ 2024/Layerwise[[:space:]]Change[[:space:]]of[[:space:]]Knowledge[[:space:]]in[[:space:]]Neural[[:space:]]Networks/5ba49ff7-80a8-4eb3-8761-9580562a1fc1_origin.pdf filter=lfs diff=lfs merge=lfs -text
4647
+ 2024/Layerwise[[:space:]]Proximal[[:space:]]Replay_[[:space:]]A[[:space:]]Proximal[[:space:]]Point[[:space:]]Method[[:space:]]for[[:space:]]Online[[:space:]]Continual[[:space:]]Learning/a83a4440-de5f-4774-a15d-9eb6d6488f44_origin.pdf filter=lfs diff=lfs merge=lfs -text
4648
+ 2024/LeaPformer_[[:space:]]Enabling[[:space:]]Linear[[:space:]]Transformers[[:space:]]for[[:space:]]Autoregressive[[:space:]]and[[:space:]]Simultaneous[[:space:]]Tasks[[:space:]]via[[:space:]]Learned[[:space:]]Proportions/6d9c0202-28f9-4b48-80ac-9d062002dcf2_origin.pdf filter=lfs diff=lfs merge=lfs -text
4649
+ 2024/Learning[[:space:]]1-Bit[[:space:]]Tiny[[:space:]]Object[[:space:]]Detector[[:space:]]with[[:space:]]Discriminative[[:space:]]Feature[[:space:]]Refinement/809ccd5f-110d-4a06-9f4c-5f66866af673_origin.pdf filter=lfs diff=lfs merge=lfs -text
4650
+ 2024/Learning[[:space:]]Adaptive[[:space:]]and[[:space:]]View-Invariant[[:space:]]Vision[[:space:]]Transformer[[:space:]]for[[:space:]]Real-Time[[:space:]]UAV[[:space:]]Tracking/8d3e1e7b-cc1f-4356-a625-ae0bade73d72_origin.pdf filter=lfs diff=lfs merge=lfs -text
4651
+ 2024/Learning[[:space:]]Associative[[:space:]]Memories[[:space:]]with[[:space:]]Gradient[[:space:]]Descent/9223168e-b10d-4b1c-9ead-f215773204fc_origin.pdf filter=lfs diff=lfs merge=lfs -text
4652
+ 2024/Learning[[:space:]]Causal[[:space:]]Domain-Invariant[[:space:]]Temporal[[:space:]]Dynamics[[:space:]]for[[:space:]]Few-Shot[[:space:]]Action[[:space:]]Recognition/80924b22-ef6f-4da7-8b6f-aa830082bb3c_origin.pdf filter=lfs diff=lfs merge=lfs -text
4653
+ 2024/Learning[[:space:]]Causal[[:space:]]Dynamics[[:space:]]Models[[:space:]]in[[:space:]]Object-Oriented[[:space:]]Environments/4628991b-6654-4671-8e05-ab8ac2c83ef8_origin.pdf filter=lfs diff=lfs merge=lfs -text
2024/Junk DNA Hypothesis_ Pruning Small Pre-Trained Weights $_textitIrreversibly$ and $_textitMonotonically$ Impairs “Difficult_ Downstream Tasks in LLMs/8bea9d8d-bba3-4dd6-92fe-6429192b736c_content_list.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/Junk DNA Hypothesis_ Pruning Small Pre-Trained Weights $_textitIrreversibly$ and $_textitMonotonically$ Impairs “Difficult_ Downstream Tasks in LLMs/8bea9d8d-bba3-4dd6-92fe-6429192b736c_model.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/Junk DNA Hypothesis_ Pruning Small Pre-Trained Weights $_textitIrreversibly$ and $_textitMonotonically$ Impairs “Difficult_ Downstream Tasks in LLMs/8bea9d8d-bba3-4dd6-92fe-6429192b736c_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c521d90a77ec132fed61f066d32833d80213c27c55c6c4dcc35401d32b17e5e
3
+ size 733765
2024/Junk DNA Hypothesis_ Pruning Small Pre-Trained Weights $_textitIrreversibly$ and $_textitMonotonically$ Impairs “Difficult_ Downstream Tasks in LLMs/full.md ADDED
@@ -0,0 +1,404 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Junk DNA Hypothesis: Pruning Small Pre-Trained Weights Irreversibly and Monotonically Impairs "Difficult" Downstream Tasks in LLMs
2
+
3
+ Lu Yin *12 Ajay Jaiswal *3 Shiwai Liu 14 Souvik Kundu 5 Zhangyang Wang 3
4
+
5
+ # Abstract
6
+
7
+ We present Junk DNA Hypothesis by adopting a novel task-centric angle for the pre-trained weights of large language models (LLMs). It has been believed that weights in LLMs contain significant redundancy, leading to the conception that a considerable chunk of the parameters can be removed by pruning without compromising performance. Contrary to this belief, this paper presents a counter-argument: small-magnitude weights of pre-trained model weights encode vital knowledge essential for tackling difficult downstream tasks - manifested as the monotonic relationship between the performance drop of downstream tasks across the difficulty spectrum, as we prune more pre-trained weights by magnitude. Moreover, we reveal that these seemingly inconsequential weights can result in irreparable loss of knowledge and performance degradation in difficult tasks, even when downstream continual training is allowed. Interestingly, our evaluations show that the other popular compression, namely quantization fail to exhibit similar "monotonic" effect and does not as convincingly disentangle this task-difficulty information. To study formally, we introduce several quantifiable metrics to gauge the downstream task difficulty: ① within the same task category, and ② across different task categories. Our extensive experiments substantiate the Junk DNA Hypothesis across a diverse range of model sizes, tasks, datasets, and even pruning methods. Codes are available at https://github.com/VITA-Group/Junk_DNA_Hypothesis.git.
8
+
9
+ *Equal contribution 1Eindhoven University of Technology 2University of Surrey 3University of Texas at Austin 4University of Oxford 5Intel Labs. Correspondence to: Zhangyang Wang <atlaswang@utexas.edu>.
10
+
11
+ Proceedings of the $41^{st}$ International Conference on Machine Learning, Vienna, Austria. PMLR 235, 2024. Copyright 2024 by the author(s).
12
+
13
+ # 1. Introduction
14
+
15
+ A prevailing belief suggests that neural networks contain significant and non-significant components across their parameters that record necessary or unnecessary expertise respectively to handle a task, which forms the inherent basis of numerous model compression techniques (Han et al., 2016). Moreover, as model sizes continue to expand, the volume of redundant parameters is poised to escalate (Liu et al., 2022; Kim et al., 2021). This principle extends its effectiveness even to billion-level Large Language Models (LLMs) (Jaiswal et al., 2023b; Frantar & Alistarh, 2023; Hu et al., 2021; Lin et al., 2023b). With the negligible loss in performance stemming from the absence of non-significant components, a widely held belief has taken root: these non-significant components are essentially superfluous components that make a scant contribution to the model's functionality. Yet we pause and pose a question: Could there be crucial facets overlooked in the context of whether these non-significant components are truly inconsequential artifacts for large-scale models?
16
+
17
+ This paper addresses the aforementioned query by employing two popular weight compression methods namely, pruning, and quantization, to concretely discern "what non-significant components are in pre-trained LLM weights, what they do, and what is the best way to disentangle them". At this point, it is important to clarify that this paper neither aims to be an LLM compression exposition nor to re-justify the commonsense that large pre-trained models are compressible - but rather, to use existing popular compression techniques as quantitative and easily controllable tool to probe and comprehend the existence and the functional role of non-significant weight components. The crux of our research lies in adopting a novel task-centric viewpoint towards pre-trained weights. In other words, we investigate how the non-significant weights fraction and their embodied information correlate with model's ability to successfully perform downstream tasks of different complexity levels.
18
+
19
+ Our extensive experiment-based study disrupts conventional assumptions by providing three key observations: ① the assumed non-significant weight components play a pivotal role in handling challenging tasks, ② element-wise pruning simply by pre-trained weight magnitudes, despite being a
20
+
21
+ naive criterion, is a reliable indicator to capture the demarcation of task difficulty encoded within significant and nonsignificant components - experimentally shown as "monotonically impairing" downstream task performance from difficult to simple, as more are pruned by magnitude. ⑧ Meanwhile, quantization fail to display such monotonic effect and do not as convincingly disentangle this task-difficulty information. Drawing a parallel with biological insights<sup>1</sup>, we nickname our discoveries as the Junk DNA Hypothesis:
22
+
23
+ - Contrary to common beliefs, small-magnitude weights of a pre-trained model encode vital knowledge essential for tackling difficult downstream tasks - manifested as monotonic relationships between the amount of pruned weights and the difficulty level of tasks that start to be impaired (Section 3.1 & 3.2). Interestingly though, the same monotonicity observation fail to hold for quantization, another popular compression method.
24
+ - Removing these ostensibly inconsequential weights can cause irreparable loss of knowledge and thus performance degradation on difficult tasks. This can be observed even if downstream continual training is allowed (Section 5).
25
+
26
+ The primary challenge in formalizing and experimentally validating this conjecture lies in providing a precise and "continuously controllable" definition of "task difficulty", for which we explore an extensive range of options:
27
+
28
+ - Within the Same Task Category: To define task difficulty within the same task, we formulate the following four settings: ① vary the adequacy of target domain data (Liu et al., 2019) (e.g., from few-shot to full-shot); ② availability of option counts in multiple-choice question answering (QA) setting; ③ influence of external information availability with varying context length for retrieval-augmented QA (Ram et al., 2023); ④ varying k-shot in-context demonstration examples to assist multiple-choice QA (Mosbach et al., 2023).
29
+ - Across Diverse Task Categories: To define task difficulty across different tasks, we formulate the following two settings: ① we utilize the gap between the best human performance, and the target LLM model's per
30
+
31
+ formance on a specific task (normalized by human performance), as an indicator of complexity "sensed" by LLM for that specific task; 2 we dive in comparing between two QA tasks: factoid-based QA which involve generating precise facts about entities, versus multiple-choice QA setting where models have to choose from a set of provided answer options.
32
+
33
+ Our extensive experiments substantiate the Junk DNA Hypothesis across a diverse range of model sizes, tasks, and datasets. While the overarching notion that...more challenging downstream tasks permit less room for pruning" may not come as a surprise, our study unveils several more subtle, often unexpected findings:
34
+
35
+ - Moving beyond the nebulous distinction between simple and complex tasks, the various conceptions of task difficulty uniquely defined above by us, both within and across tasks, appear to align closely with the behavior of pruning fragility. This suggests a practical desire to estimate the task-dependent achievable degree of LLM sparsity. In certain tasks, even a modest reduction in low-magnitude pre-trained weights (e.g., $10 - 20\%$ ) results in a significant drop in accuracy, underscoring their pivotal role in handling intricate tasks.
36
+ - Unlike pruning, we found that quantization fail to effectively capture the same "monotonically" impairing effect of gradual compression when task complexity varied from difficult to simple.
37
+ - Moreover, we confirm that for difficult tasks, the essential knowledge resides within the pre-trained weight values and uninformed pruning can do "irreversible" damage for challenging tasks, i.e., the "damage" caused by overly pruning pre-trained weights cannot be un-done by continual downstream fine-tuning.
38
+ - Junk DNA Hypothesis holds true when transitioning from unstructured to structured N:M pruning, and even extends to other weight importance-based LLMs pruning techniques (SparseGPT, Wanda). Interestingly, we found the aforementioned methods tend to benefit simple tasks more compared to challenging tasks.
39
+
40
+ # 2. Experimental Settings
41
+
42
+ In this section, we provide a summary of our experimental settings used to validate Junk DNA hypothesis. Table 1 provides details on dataset, model configuration, learning setting, pruning techniques, and difficulty spectrum for various task settings used to quantitatively control task difficulty with and across tasks. We first experiment with popular pruning methods (allow multiple data points to validate our argument): One-shot Magnitude, SparseGPT, and Wanda to comprehensively validate the monotonic impairment
43
+
44
+ Title Suppressed Due to Excessive Size
45
+
46
+ <table><tr><td>Task Setting</td><td>Dataset</td><td>Model</td><td>Learning</td><td>Pruning</td><td>Difficulty Variation</td><td>Across Task</td></tr><tr><td>Setting 1: Data Adequacy</td><td>GLUE benchmark</td><td>RoBERTa-Base</td><td>Fine-tuning</td><td>Magnitude, N:M</td><td>6</td><td>No</td></tr><tr><td>Setting 2: MCQ Option Count</td><td>MMLU</td><td>Vicuna-7B</td><td>None</td><td>Magnitude, SparseGPT, Wanda, N:M</td><td>3</td><td>No</td></tr><tr><td>Setting 3: Context Length</td><td>TriviaQA</td><td>Vicuna-7B</td><td>None</td><td>Magnitude, SparseGPT, Wanda, N:M</td><td>5</td><td>No</td></tr><tr><td>Setting 4: k-shot examples</td><td>MMLU</td><td>Vicuna-7B</td><td>Few-shot</td><td>Magnitude, SparseGPT, Wanda, N:M</td><td>4</td><td>No</td></tr><tr><td>Setting 5: Human-Centric</td><td>PIQA, HellaSwag, OpenBookQA</td><td>Vicuna-13B</td><td>None</td><td>Magnitude, SparseGPT, Wanda, N:M</td><td>3</td><td>Yes</td></tr><tr><td>Setting 6: Factoid v.s. MCQ</td><td>FreebaseQA, MMLU</td><td>Vicuna-7B</td><td>None</td><td>Magnitude, SparseGPT, Wanda</td><td>2</td><td>Yes</td></tr></table>
47
+
48
+ Table 1. Our experimental task settings to quantitatively control task difficulty within tasks and across tasks.
49
+
50
+ claim on our curated difficulty spectrum across various task settings. Next, in Section 4, we will draw parallel between pruning and quantization to illustrate how the later fails to capture this monotonic trend, thus unable to facilitate demarcation across task difficulty.
51
+
52
+ Sparsity: We consider two types of sparsities: (1) Unstructured Sparsity: individual weights in the model are zeroed out independently, leading to irregular zero patterns (LeCun et al., 1990; Han et al., 2016); (2) Structured $N$ : $M$ Sparsity: a fine-grained sparsity pattern in which only $N$ weights are non-zero for every continuous $M$ weights (Nvidia, 2020; Zhou et al., 2021). We report the results of $M = 8$ ( $N$ ranges from 7 to 1). Note that we intentionally focus on one-shot magnitude pruning, to isolate the effect of small-magnitude weights as the sole "delta" between the two models, and due to its recently observed promise to retain LLM performance (Jaiswal et al., 2023b). We additionally include two more SoTA LLM pruning methods: SparseGPT (Frantar & Alistarh, 2023), and Wanda (Sun et al., 2023) to confirm whether the validity of our hypothesis can generalize to other weight importance criteria as well.
53
+
54
+ Dataset: We explore a wide variety of datasets while defining task difficulty to convincingly establish the validity of Junk DNA Hypothesis. For our experiments, we use GLUE benchmark (Wang et al., 2018), MMLU benchmark covering $50+$ subjects (Hendrycks et al., 2020), TriviaQA (Joshi et al., 2017), PIQA (Bisk et al., 2020), HellaSwag (Zellers et al., 2019), OpenBookQA (Mihaylov et al., 2018), and FreebaseQA (Jiang et al., 2019). More information about the aforementioned datasets is available in Appendix D.
55
+
56
+ Normalized Performance Drop: Model performance depends on task category and difficulty level. To fairly illustrate the impact of compression across task category, task difficulty, and pruning techniques, our experiments present normalized performance drop to facilitate ease in perceiving conclusion. Let $f_{d}^{t}$ and $f_{p}^{t}$ be dense and pruned model performance on task $t$ , normalized performance drop is calculated as $(f_{p}^{t} - f_{d}^{t}) / f_{d}^{t}$ .
57
+
58
+ To quantitatively capture the monotonic impairment and trend across the task difficulty spectrum, we make use of two popular statistical measures:
59
+
60
+ 1. Spearman's rank correlation: It assesses how well the ranking relationship between two variables (X & Y) can be described using a monotonic function. A Spearman
61
+
62
+ correlation of zero indicates that there is no tendency for Y to either increase or decrease when X increases.
63
+
64
+ 2. Theil-Sen estimator: It is a robust estimation of linear slopes (treated as a surrogate of "how fast Y changes with X") from many (potentially noisy) sample points (X & Y). It works by choosing the median of the slopes of all possible lines that go through any pair of points. Higher slopes by Theil-Sen estimator indicate faster changes of Y w.r.t. X.
65
+
66
+ # 3. How Pruning Illicit Monotonic Impairment Across Difficulty Spectrum?
67
+
68
+ # 3.1. Case study of difficulty spectrum within same task
69
+
70
+ # 3.1.1. TASK DIFFICULTY SETTING 1: Varying the Adequacy of Target Domain Data
71
+
72
+ Rationale: The difficulty of learning a task is commonly thought to be influenced by the number of available training examples: fewer data points typically imply more challenges to learn well. To quantitatively control task difficulty within a single task, we manually manipulate the volume of data used for fine-tuning by randomly sampling certain ratios of data from the target domain dataset. This allows us to disentangle task difficulty from the task type.
73
+
74
+ Method: To examine the influence of small-magnitude weights, we conduct a comparative analysis between two models: one starting from the pre-trained model with small-magnitude weights, and the other without. The former is commonly referred to as task-specific fine-tuning on downstream tasks, denoted as Dense Transfer in this paper. The latter model, named Sparse Transfer, differs from dense transfer in the way that we first perform magnitude pruning on the pre-trained model, creating a sparse model. We then fine-tune on downstream tasks while keeping the sparse mask fixed. Figure 1 summarizes our results for this setting across unstructured and structured sparsity patterns.
75
+
76
+ # 3.1.2. TASK DIFFICULTY SETTING 2: Varying the Option Count in Multiple-choice QA Setting
77
+
78
+ Rationale: This setting proposed in our work, extends the idea that given a task of multiple-choice question answering with a fixed dataset, the difficulty of the task is proportional to the number of available options to select the correct answer. To quantitatively control task difficulty, we manually
79
+
80
+ ![](images/063d25b2e0bf7b92109175ebb5b41c11077b8414ca3afc7c85716f774af488a6.jpg)
81
+
82
+ ![](images/71bd87459d7e832c85829a2738f58ff935a1f274e3f699799bfba00fc3be11eb.jpg)
83
+
84
+ ![](images/a552f78aca347e91e038ce25cec89739d7fb77763e9a3f6d76a3c19901b8b2ba.jpg)
85
+
86
+ ![](images/476135efa5baadec04d9f8e03eada69b24a2a412b4ca4ab368c92903c9907cfb.jpg)
87
+
88
+ ![](images/77208766aa8caac9ad3e80fe51dcd2e784f324c240838106d188ca398171fa88.jpg)
89
+ Figure 1. Task Difficulty Setting 1: Varying target domain data adequacy: Dense Transfer vs. Sparse Transfer using RoBERTa-Base on various downstream tasks. Task difficulty is measured by the training data volume.
90
+
91
+ ![](images/1c338ad71b314c600e625d5ecd382b7864be3856660e6a7e9aa1d34ee2e23f40.jpg)
92
+
93
+ manipulate the option count for each question from $[2 - 4]$ which provide a random guess success rate from $50\%$ (2 options) to $25\%$ (4 options). This setting uniquely allows us to control the task difficult for a given task.
94
+
95
+ Method: To understand the influence of small-magnitude weights, in this setting, we exploit in-context learning setting with a natural prompting approach to present the question and answer options to the LLMs jointly, and have it output the symbol (e.g., "A") associated with its chosen answer option. We fixed 5 in-context question-answer example pairs while . Here, we attempt to understand how the pruned model can effectively reason and successfully associate the correct answer among the given answer options with symbols that represent them, using knowledge remaining within them with increasing difficulty by varying option counts. Figure 2 summarizes our results for this setting across unstructured and structured sparsity patterns.
96
+
97
+ # 3.1.3. TASK DIFFICULTY SETTING 3: Varying context length for Retrieval-Augmented QA
98
+
99
+ Rationale: In this task setting, we exploit a highly industry-relevant task of Retrieval-Augmented QA in which given a context, LLMs are prompted to answer questions based on the context. To define a quantitative measure of difficulty
100
+
101
+ ![](images/91336aa8db75e6433f19b5fa6ca94037a18bc2905852b26f572059ef55ceaf33.jpg)
102
+
103
+ ![](images/9da52056db552777c25865908474c89ec905ad8343efb5a3113e51918d9b1ce6.jpg)
104
+
105
+ ![](images/026b280420d873cfc123e0f906d7d78b4c13e351e312c9346f29539b3e26e475.jpg)
106
+
107
+ ![](images/8aea56473bc7ce09791d48691f4d9be291236d67ae6e514ae9d09fd503f00dc7.jpg)
108
+
109
+ ![](images/c9aa3e92028bce07b33c7e0fa944486c350e21f0da7bc4fe97230830e4e089b4.jpg)
110
+ Figure 2. Task Difficulty Setting 2: Varying option count in multiple-choice QA. Dense v.s. Sparse subnetwork performance of Vicuna-7B using MMLU. Task difficulty is measured by the number of available choices in a multiple-choice QA setting.
111
+
112
+ ![](images/5c444970e29aca0587f0ee947b76531f385fb0f851e607968ce54f67073fddf3.jpg)
113
+
114
+ ![](images/55e09a88925dbdc1622602b502e73ce9752de205b02545b3289b9324583ff218.jpg)
115
+ Figure 3. Task Difficulty Setting 3: Varying context length in Retrieval-Augmented QA. Dense v.s. Sparse subnetwork performance of Vicuna-7B pruned using TrivaQA Benchmark. Task difficulty is measured by the number of tokens provided in context.
116
+
117
+ ![](images/1015c19880ae0836b0523f554cece79c88758cfe4be036f4f5bc1106f2e2e886.jpg)
118
+
119
+ ![](images/d6a126a9ddf676196d991d57fe07f063cc1dd7c38a1503cc0d012bfc3e4517f5.jpg)
120
+
121
+ for this task, we propose to vary the context length ensuring that the correct answer still resides within the provided context. Retrieval-augmented QA requires LLMs to possess sufficient ability to synthesize long in-context knowledge provided within input prompts, and locate and retrieve correct answers within it. Our novel strategy to control token counts within context helps us to define a smooth relation with the task difficulty.
122
+
123
+ Method: Our evaluation system using TriviaQA includes two high-level components: ① document selection, selecting the set of documents upon which to condition; and ② document reading, determining how to incorporate the selected documents into the LLM answer generation process, which requires extracting correct answer phrases from con
124
+
125
+ ![](images/90297f5bd597d8c15ab591b91358738f7dc22a34b6397c06ba8716b28544d31b.jpg)
126
+ Figure 4. Task Difficulty Setting 4: Few-shot In-context Learning. Dense v.s. Sparse subnetwork performance of Vicuna-7B pruned using MMLU Benchmark. Task difficulty is measured by the number of $K$ shot in-context demonstration examples provided to assist multiple-choice QA.
127
+
128
+ ditioned documents. Given the ground truth, we select $\mathrm{x}\%$ of tokens around it in the context document from the document selection step, to ensure that the context is complete (e.g., no split sentences). We evaluate the performance of pruned LLMs to investigate their ability to generate answers using the provided $\mathrm{x}\%$ tokens. We additionally added a closed-book (Ram et al., 2023) setting at the end of the difficult spectrum (highest) because in this setting, LLMs are not provided with any external information and need to rely on their own internal knowledge ingested during pretraining (Jaiswal et al., 2023a).
129
+
130
+ # 3.1.4. TASK DIFFICULTY SETTING 4: Varying number of $k$ -shot examples for in-context learning
131
+
132
+ Rationale: Modern-day LLMs have shown a unique ability for out-of-domain generalization using in-context learning (ICL). ICL adapts a model to a task by conditioning it with few-shot demonstrations specified purely via text interaction with the model and it has been observed to significantly improve performance on the downstream application (Brown et al., 2020; Mosbach et al., 2023). In this task setting, we propose to control the amount of example demonstrations to quantitatively measure the difficulty of the task. Based on our experimental finding that providing more demonstrations leads to better performance of the dense model, this setting defines the difficulty spectrum directly on the number of example demonstrations provided to the pruned model during the conversation using natural language prompts.
133
+
134
+ Method: Similar to task setting 2, we use in-context learning to present $k$ example demonstration to the compressed model. For our evaluation, we use MMLU benchmark, and use $k \in \{0,1,3,5\}$ examples from the validation set to control the task difficulty where 0 indicates no example was shown to the model (hardest) while 5 indicate the model generated answer observing 5 examples (easiest). Figure 4 summarizes our results for this setting.
135
+
136
+ # 3.1.5. MAIN RESULTS: VALIDATING THE JUNK DNA
137
+
138
+ 1 Removal of small-magnitude weights is viable to some extent for easier tasks in comparison to difficult tasks: In all four task setting's results (Figure 1, 2, 3, and 4), we find that it is feasible to discard around $10 - 15\%$ of small-
139
+
140
+ magnitude at once without significantly compromising the performance in unstructured sparsity. This indicates that for simple tasks, the knowledge encoded in high-magnitude weights is sufficient to handle the task. For instance, in task setting 4 (Figure 4a), we found that for the easiest task (with 5 ICL demonstration), we can remove small weights up to $14\%$ without any drop in performance in comparison with dense counterpart, which is not true for the hardest task (with 0 ICL demonstration).
141
+
142
+ $\Theta$ Eliminating small weight presents a monotonic impairment relationship with increasing task difficulty: Across all our experiments, we found a smooth monotonic impairment relationship between removing small weights and the difficulty of the task. As we gradually move to the hard end of the difficulty spectrum, the impact of pruning small weights keeps increasing which shows that the "useless" small weights are imperative to encode crucial knowledge necessary to solve more challenging downstream tasks. The monotonically increasing theil-sen estimator slope w.r.t. task difficulty provides a quantitative estimate to measure "monotonically impairing" caused by pruning low-magnitude weights.
143
+
144
+ Junk DNA persists in both N:M sparsity and unstructured sparsity, and beyond the magnitude criteria Both N:M sparsity and unstructured sparsity yield similar observations, indicating the presence of Junk DNA in both settings. We further experiment with two other popular LLM-pruning methods: SparseGPT and Wanda which consider weight importance as a criterion for pruning. Our observations can be summarized as: (1) both these methods (including their N:M setting) corroborate with JunkDNA Hypothesis, (2) JunkDNA can be viewed as a benchmark to develop better pruning algorithms which can minimize the performance gap between easy and hard task, (3) interesting, we observe that these new sophisticated weight importance based pruning methods tend to benefit simple task more in comparison to challenging tasks, indicating a need to carefully evaluate true merits of modern compression methods.
145
+
146
+ # 3.2. Case study of difficulty spectrum across tasks
147
+
148
+ # 3.2.1. TASK DIFFICULTY SETTING 5: Estimating LLM-facing Task Difficulty by Normalized Human-LLM Performance Gap
149
+
150
+ Rationale and Method: We propose a method to gauge complexity by juxtaposing the performance of deep learning models with that of human counterparts. Specifically, we define task difficulty as the disparity in performance between humans and models, normalized by human performance. A more pronounced positive performance gap (for instance, where humans outperform the machine to a greater extent) would signify a higher level of difficulty for the model in handling the given task. Conversely, in cases where the ma
151
+
152
+ chine outperforms humans, a larger gap indicates an easier task. The resulting assessment of across-task difficulty is outlined in Table 3. Specifically, we choose a range of downstream tasks, including PIQA, HellaSwag, OpenBookQA and our experiments are conducted using Vicuna-13B.
153
+
154
+ ![](images/d6ac547764976afc8be3a26316108c4217280c40bd331ea1b468497174ce14fb.jpg)
155
+
156
+ ![](images/4718f6be69080f8f074e64f191efa5ccdf0801ca074a4b5522406d0a101d31c9.jpg)
157
+
158
+ ![](images/5bfc7004527b584e9f1489970ab20fe977554434c1403529e35bb51f6b7eb2cb.jpg)
159
+
160
+ ![](images/bfa0a256bbafdc84c6bd926e2f9fbb6e00985787bb8b2f3133743c5f67a654ab.jpg)
161
+
162
+ ![](images/da8014edef5d0c2a44dde7534246c24d9d77f522de890142c18c2dc3621fc1dc.jpg)
163
+ Figure 5. Across-Task Difficulty via Normalized Human-LLM Performance Gap: Dense v.s. Sparse subnetwork performance of Vicuna-13B. Task difficulty is measured by Human-LLM Performance gap normalized by the dense performance.
164
+
165
+ ![](images/b4a3300ce7cfe2191376006678738707133c45413b19f5acc51ab0d1fc54261c.jpg)
166
+
167
+ # 3.2.2. TASK DIFFICULTY SETTING 6: Factoid-based v.s. Multiple-choice QA
168
+
169
+ Rationale and Method: In this setting, we compare two popular QA settings: Factoid-based QA and Multiple-Choice QA. A typical Factoid-QA task aims to answer natural language questions using facts, i.e., entities or attributes of knowledge ingested within them during pre-training. On the other hand, multiple-choice QA setting present the question and answer options to the LLMs jointly, and have it output the symbol (e.g., "A") associated with its chosen answer option. Unlike multiple-choice QA, factoid-based QA requires LLMs' ability to answer natural language questions using facts using its own knowledge and possess the ability to generate full answers unlike output a symbol, which makes it inherently a more challenging task.
170
+
171
+ # 3.2.3. MAIN RESULTS: VALIDATING THE JUNK DNA HYPOTHESIS
172
+
173
+ The findings depicted in Figure 5, 6 echo the conclusions drawn in Section 3.1, once more providing robust support
174
+
175
+ ![](images/30b7707c85b303b4ba6cf920f397514009c09916b0bc41290c07ff2ae1aa7666.jpg)
176
+ Figure 6. Across-Task Difficulty for Factoid-based QA and Multiple-Choice QA: Dense v.s. Sparse subnetwork performance of Vicuna-7B. Task difficulty is measured by Human-LLM Performance gap normalized by the dense performance.
177
+
178
+ ![](images/fa6a1a1bc5c46f4dffeafc8d4b93c08cda59113806c6912290031b6b602249c3.jpg)
179
+
180
+ ![](images/255a557b3f6f7edd1281a1bbf421d266a847f56695589ff08378ae5a913918da.jpg)
181
+
182
+ for the validity of the Junk DNA hypothesis across a broad spectrum of task categories. While it may be feasible to remove small-magnitude weights without significant repercussions in simpler tasks, these pre-trained small weights contain vital downstream knowledge essential for tackling challenging tasks and thus are no longer dispensable suggesting their importance -manifested as monotonic relationships between the amount of pruned weights and the difficult level of tasks that start to be impaired.
183
+
184
+ # 4. Does Quantization Also Yield Monotonic Impairment Across Difficulty Spectrum?
185
+
186
+ Pruning and quantization are two popularly used remedies to reduce the overheads of billions of parameters in current LLMs. Pruning techniques primarily shrink network sizes by removing specific weights from the model - essentially setting them to zero. Quantization methods aim to quantize parameters into low bit-precision to reduce compute and memory budget. Across recently developed quantization methods for LLMs (Lin et al., 2023a; Frantar et al., 2022a; Dettmers et al., 2023), we adopted GPTQ for the quantization of all linear layers (exactly similar to our pruning settings) to study the monotonic impairment induced across the task difficulty spectrum. In this section, we firstly ask: How does the ratio of compression using quantization reflect on the performance of the downstream tasks? Does quantization strength dictate any performance pattern across the difficulty spectrum of the underlying task?
187
+
188
+ To this end, Figure 7 presents our head-to-head comparison for one-shot low-magnitude pruning and GPTQ quantization (Frantar et al., 2022b) various compression strengths. We adopted retrieval-augmented QA (task setting 3) in which task difficulty is controlled by varying the context length (token counts) accommodating the correct answer phrase, and variable option count in multiple-choice QA (task setting 2) for our experiments.
189
+
190
+ Based on our experimental results, we summarize: 1 while pruning shows a monotonic performance degradation with increasing compression ratio, quantization does not exhibit the smooth impairing impact of compression; 2 removal of low magnitude weights using pruning tends to have a monotonically increasing impairing impact if we move along the
191
+
192
+ ![](images/61fa591b8e714bff46866bbc0d44e616c3f28b295053f356a8d9726d167158eb.jpg)
193
+ Figure 7. How is pruning special? Performance comparison of pruning and quantization with varying compression ratios on our task difficulty spectrum. We can observe the monotonic impairment of pruning across task difficulty and pruning ratio. On the contrary, quantization fail to capture this monotonic behavior across task difficulty and compression ratio.
194
+
195
+ extreme end of our task difficulty spectrum, which is again not convincingly demarcated either by quantization. It is interesting to observe that quantization to a certain degree tends to benefit the overall performance but again without any clear pattern across the difficulty spectrum.
196
+
197
+ How Is Pruning Special? It is interesting to see the unique ability of pruning to identify a critical subset of weights that can independently complete specific set of tasks the same way as the dense model - but not quantization. This naturally reminds us the Lottery Ticket Hypothesis (LTH) (Frankle et al., 2019; Chen et al., 2020), stating that there exists a pruned subnetwork that can match the performance of its dense counterpart; meanwhile no similar conclusion has been drawn for quantized networks at scale. Such discrepancy seems to echo the two methods' different impairment behaviors (monotonic or not across task difficulty levels). We additionally experimented with low-rank compression (Yu et al., 2017) (not the low-rank weight updates used in parameter-efficient tuning (Hu et al., 2021)) and found its behavior closer to pruning than quantization (Appendix E).
198
+
199
+ The classical LTH (with iterative pruning and re-training) has not yet been studied for modern-scale LLMs due to its prohibitive computational costs. Previous work in smaller models did find reusable sparse substructures that contain sufficient information to handle a few similar tasks altogether (Chen et al., 2020; Yu et al., 2020). Recent attempt (Jaiswal et al., 2023b) demonstrated a similar property on LLMs for a range of tasks, using cheap one-shot pruning without re-training; but the authors also recognized the "sweetpoint sparsity" was correlated to the difficulty of
200
+
201
+ <table><tr><td>Task Setting</td><td>Difficulty (↓)</td><td>Pruning</td><td>Quantization</td></tr><tr><td rowspan="4">Task Setting 3</td><td>Closed Book</td><td>0.996</td><td>0.799</td></tr><tr><td>Context_len = 100%</td><td>0.996</td><td>0.794</td></tr><tr><td>Context_len = 60%</td><td>0.975</td><td>0.399</td></tr><tr><td>Context_len = 20%</td><td>0.987</td><td>0.316</td></tr><tr><td rowspan="3">Task Setting 2</td><td>Option Count 4</td><td>0.979</td><td>0.872</td></tr><tr><td>Option Count 3</td><td>1.0</td><td>0.799</td></tr><tr><td>Option Count 2</td><td>1.0</td><td>0.666</td></tr></table>
202
+
203
+ Table 2. Spearman's rank correlation of pruning and quantization for task with varying difficulty levels. Unlike quantization high Spearman correlation for pruning uniquely captures monotonic impairment induced by pruning.
204
+
205
+ downstream tasks involved (although they did not provide a concrete way to quantify such). As a modern LLM can perform an infinite range of downstream tasks in zero- or few-shot, Junk DNA Hypothesis can be viewed as a scaled extension of LTH, which suggests that: if the task difficulty spectrum (much broader than before) is taken into consideration, then there might not exist a single "lottery" subset of weight, that can be removed without causing irreparable damage for the performance of all tasks - although one might still be able to find a "lottery" for some (easy) tasks.
206
+
207
+ # 5. Are Pre-trained Magnitude Values Indeed the True Gem?
208
+
209
+ Having recognized the pivotal role of small weights in downstream adaptation, particularly in relation to task difficulty, our next objective is to delve into the foundational factors contributing to the crucial function of small weights and whether they can be recovered with fine-tuning. More specifically, we intend to validate if pruning leads to irreparable loss of knowledge. Our primary research inquiries are:
210
+
211
+ - Which one holds greater significance: the knowledge (weight-values) stored in pre-trained small-magnitude weights, or the potential to adjust these weights through fine-tuning?
212
+ - Is it possible to recover the knowledge embedded in pretrained small-magnitude weights if we prune them and allow them to grow freely during fine-tuning?
213
+
214
+ Method: We explore four comparison methods: (1) Dense Transfer: as described in Section 3.1.1; (2) Dense Transfer with (Partial) Freezing: a dense model where small-magnitude weights remain fixed during fine-tuning; (3) Sparse Transfer: as in Section 3.1.1; (4) Sparse to Dense Transfer: small-magnitude weights are initially pruned after pre-training, and subsequently during fine-tuning, those pruned weights are allowed to gradually regain non-zero values. This approach also aids in determining whether the knowledge within small-magnitude pre-trained weights is essential for performance or if their adaptability during fine-tuning takes precedence. We pick Task Setting 1 (within the same task) and Task Setting 5 (across different task), to report their performance using RoBERTa-Large, on MNLI, QNLI, SST-2, as well as CSQA and WinoGrande. The difficulty spectrum normalized by human performance for the
215
+
216
+ ![](images/9a256368c7013982fd1c1c61c9f3c82623f773b32924adf88222dde51b80b11e.jpg)
217
+ Figure 8. Varying target domain data adequacy: Four different fine-tuning settings with RoBERTa-Base on various downstream tasks. All performance is normalized by the one of Dense Transfer.
218
+
219
+ ![](images/f8ad2c840d00492942f8753a9b63d8db483339e8b2dc530e238a469e43025b57.jpg)
220
+ Figure 9. Across-Task Difficulty via Normalized Human-LLM Performance Gap: Four different fine-tuning settings with RoBERTa-Large on various downstream tasks. All performance is normalized by the one of Dense Transfer.
221
+
222
+ aforementioned tasks is presented in Appendix B.
223
+
224
+ Table 3. Measuring the Across-Task Difficulty by the Performance Difference between humans and models (normalized by human performance): the larger (positive) margin, the more difficult for the model.
225
+
226
+ <table><tr><td></td><td>PIQA</td><td>HellaSwag</td><td>OpenBookQA</td></tr><tr><td>Human</td><td>95.0</td><td>95.6</td><td>92.0</td></tr><tr><td>Vucuna13B</td><td>78.35</td><td>59.68</td><td>36.40</td></tr><tr><td>“Task Difficulty” (%)</td><td>[Easy] 17.53</td><td>[Medium] 37.57</td><td>[Hard] 60.43</td></tr></table>
227
+
228
+ Results: The outcomes for both within-task difficulty and across-task difficulty are illustrated in Figure 8 and Figure 9, respectively. Below, we outline our key observations:
229
+
230
+ 1 Pre-trained small weights harbor vital downstream knowledge, beyond mere free parameters. Across both task-difficulty metrics, it becomes evident that settings preserving the pre-trained values of small weights—namely, Dense Transfer and Dense Transfer with Freezing—achieve superior performance when compared to the other two settings. The removal of small-magnitude weights from pretrained models results in significant performance degradation, even when we permit the pruned weights to regenerate during fine-tuning. This observation strongly bolsters the Junk DNA Hypothesis, indicating that small-magnitude weights are far from redundant; rather, they house sophisticated knowledge crucial for downstream adaptation. This knowledge proves challenging to re-gain through fine-tuning, if these initial pre-trained weights are eliminated.
231
+
232
+ Freezing without updating yields commendable results. Remarkably, on simpler tasks like SST-2, MNLI, and QNLI, maintaining an overwhelmingly large portion (90%) of small-magnitude weights in a frozen state leads
233
+
234
+ to equally impressive performance without any loss. Even on more intricate tasks such as COLA, CSQA, and Wino-Grande, freezing up to $70\%$ of small-magnitude weights results in no discernible performance dip. This suggests that for easier tasks, the knowledge embedded in pre-trained small-magnitude weights is already more than sufficient. However, for more challenging tasks, allowing for moderate updates to all pre-trained weights remains essential.
235
+
236
+ # 6. Conclusion and Future Work
237
+
238
+ In this study, we embark on an exploration to validate the prevailing belief that deep network weights are excessively redundant, allowing for a substantial pruning of parameters without compromising performance. Our research presents a compelling counter-argument by unearthing the previously overlooked yet intricate role of small-magnitude weights, closely tied to the difficulty level of downstream tasks. We found small-magnitude pre-trained weights encode vital knowledge essential for tackling difficult downstream tasks - manifested as monotonic relationship between increasing task difficulty and impairment induced by removing small weights. Moreover, we argue that these seemingly inconsequential weights can result in irreparable loss of knowledge and performance degradation in difficult tasks, even if downstream continual training is allowed. Meanwhile, quantization fails to exhibit similar effects and hence does not as convincingly disentangle this task- difficulty information as pruning. As the number of parameters in deep networks continues to grow exponentially, our findings prompt the exploration of directions such as task-complexity-dependent dynamic inference and network self-slimmable properties.
239
+
240
+ # Impact Statement
241
+
242
+ This study presents the "Junk DNA Hypothesis," a nuanced perspective on the role of small-magnitude weights in large language models (LLMs), challenging the traditional view of their redundancy. Our findings highlight the importance of these weights in complex tasks and suggest the need for further exploration into dynamic inference and network slimming techniques based on task complexity. This could lead to improved methods for more efficient inference, and contribute to the "GreenAI" goal.
243
+
244
+ # Acknowledgments
245
+
246
+ Z. Wang is in part supported by NSF Award DMS-02133861 and the NSF AI Institute for Foundations of Machine Learning (IFML).
247
+
248
+ # References
249
+
250
+ Bisk, Y., Zellers, R., Gao, J., Choi, Y., et al. Piqa: Reasoning about physical commonsense in natural language. In Proceedings of the AAAI conference on artificial intelligence, volume 34, pp. 7432-7439, 2020.
251
+ Brown, T., Mann, B., Ryder, N., Subbiah, M., Kaplan, J. D., Dhariwal, P., Neelakantan, A., Shyam, P., Sastry, G., Askell, A., et al. Language models are few-shot learners. Advances in neural information processing systems, 33: 1877-1901, 2020.
252
+ Carey, N. Junk DNA: a journey through the dark matter of the genome. Columbia University Press, 2015.
253
+ Chen, T., Frankle, J., Chang, S., Liu, S., Zhang, Y., Wang, Z., and Carbin, M. The lottery ticket hypothesis for pretrained bert networks. Advances in neural information processing systems, 33:15834-15846, 2020.
254
+ Dettmers, T., Svirschevski, R., Egiazarian, V., Kuznedelev, D., Frantar, E., Ashkboos, S., Borzunov, A., Hoefler, T., and Alistarh, D. Spqr: A sparse-quantized representation for near-lossless llm weight compression. ArXiv, abs/2306.03078, 2023. URL https://api-semanticscholar.org/CorpusID:259076379.
255
+ Dong, X., Chen, S., and Pan, S. Learning to prune deep neural networks via layer-wise optimal brain surgeon. Advances in Neural Information Processing Systems, 30, 2017.
256
+ Evci, U., Gale, T., Menick, J., Castro, P. S., and Elsen, E. Rigging the lottery: Making all tickets winners. In International Conference on Machine Learning, pp. 2943-2952. PMLR, 2020.
257
+
258
+ Frankle, J. and Carbin, M. The lottery ticket hypothesis: Finding sparse, trainable neural networks. In International Conference on Learning Representations, 2019. URL https://openreview.net/forum?id=rJ1-b3RcF7.
259
+ Frankle, J., Dziugaite, G. K., Roy, D. M., and Carbin, M. The lottery ticket hypothesis at scale. arXiv preprint arXiv:1903.01611, 2019.
260
+ Frankle, J., Dziugaite, G. K., Roy, D., and Carbin, M. Linear mode connectivity and the lottery ticket hypothesis. In International Conference on Machine Learning, pp. 3259-3269. PMLR, 2020.
261
+ Frantar, E. and Alistarh, D. Sparsegpt: Massive language models can be accurately pruned in one-shot, 2023.
262
+ Frantar, E., Kurtic, E., and Alistarh, D. M-fac: Efficient matrix-free approximations of second-order information. Advances in Neural Information Processing Systems, 34: 14873-14886, 2021.
263
+ Frantar, E., Ashkboos, S., Hoefler, T., and Alistarh, D. Gptq: Accurate post-training quantization for generative pre-trained transformers. ArXiv, abs/2210.17323, 2022a. URL https://api.sementicscholar.org/CorpusID:253237200.
264
+ Frantar, E., Ashkboos, S., Hoefler, T., and Alistarh, D. Gptq: Accurate post-training quantization for generative pretrained transformers. arXiv preprint arXiv:2210.17323, 2022b.
265
+ Gale, T., Elsen, E., and Hooker, S. The state of sparsity in deep neural networks. arXiv preprint arXiv:1902.09574, 2019.
266
+ Hajimolahoseini, H., Rezagholizadeh, M., Partovinia, V., Tahaei, M., Awad, O. M., and Liu, Y. Compressing pretrained language models using progressive low rank decomposition. Advances in Neural Information Processing Systems, 2021.
267
+ Han, S., Mao, H., and Dally, W. J. Deep compression: Compressing deep neural networks with pruning, trained quantization and huffman coding. In International Conference on Learning Representations, 2016.
268
+ Hassibi, B. and Stork, D. Second order derivatives for network pruning: Optimal brain surgeon. Advances in neural information processing systems, 5, 1992.
269
+ Hendrycks, D., Burns, C., Basart, S., Zou, A., Mazeika, M., Song, D., and Steinhardt, J. Measuring massive multitask language understanding. arXiv preprint arXiv:2009.03300, 2020.
270
+
271
+ Hu, E. J., Shen, Y., Wallis, P., Allen-Zhu, Z., Li, Y., Wang, S., Wang, L., and Chen, W. Lora: Low-rank adaptation of large language models. arXiv preprint arXiv:2106.09685, 2021.
272
+ Jaiswal, A., Gan, Z., Du, X., Zhang, B., Wang, Z., and Yang, Y. Compressing llms: The truth is rarely pure and never simple. arXiv preprint arXiv:2310.01382, 2023a.
273
+ Jaiswal, A., Liu, S., Chen, T., and Wang, Z. The emergence of essential sparsity in large pre-trained models: The weights that matter. arXiv preprint arXiv:2306.03805, 2023b.
274
+ Jaiswal, A. K., Ma, H., Chen, T., Ding, Y., and Wang, Z. Training your sparse neural network better with any mask. In International Conference on Machine Learning, pp. 9833-9844. PMLR, 2022.
275
+ Jaiswal, A. K., Liu, S., Chen, T., Ding, Y., and Wang, Z. Instant soup: Cheap pruning ensembles in a single pass can draw lottery tickets from large models. In International Conference on Machine Learning, pp. 14691-14701. PMLR, 2023c.
276
+ Jiang, H., Zhan, K., Qu, J., Wu, Y., Fei, Z., Zhang, X., Chen, L., Dou, Z., Qiu, X., Guo, Z., et al. Towards more effective and economic sparsely-activated model. arXiv preprint arXiv:2110.07431, 2021.
277
+ Jiang, K., Wu, D., and Jiang, H. FreebaseQA: A new factoid QA data set matching trivia-style question-answer pairs with Freebase. pp. 318-323. Association for Computational Linguistics, June 2019. doi: 10.18653/v1/N19-1028. URL https://aclanthology.org/N19-1028.
278
+ Joshi, M., Choi, E., Weld, D. S., and Zettlemoyer, L. Triviaq: A large scale distantly supervised challenge dataset for reading comprehension. In Proceedings of the 55th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), pp. 1601-1611, 2017.
279
+ Kim, S., Gholami, A., Yao, Z., Mahoney, M. W., and Keutzer, K. I-bert: Integer-only bert quantization. In International conference on machine learning, pp. 5506-5518. PMLR, 2021.
280
+ Kundu, S., Nazemi, M., Beerel, P. A., and Pedram, M. Dnr: A tunable robust pruning framework through dynamic network rewiring of dnns. In Proceedings of the 26th Asia and South Pacific Design Automation Conference, pp. 344-350, 2021.
281
+ Kurtic, E., Campos, D., Nguyen, T., Frantar, E., Kurtz, M., Fineran, B., Goin, M., and Alistarh, D. The optimal bert surgeon: Scalable and accurate second-order pruning for
282
+
283
+ large language models. arXiv preprint arXiv:2203.07259, 2022.
284
+ Lagunas, F., Charlaix, E., Sanh, V., and Rush, A. M. Block pruning for faster transformers. arXiv preprint arXiv:2109.04838, 2021.
285
+ LeCun, Y., Denker, J. S., and Solla, S. A. Optimal brain damage. In Advances in neural information processing systems, pp. 598-605, 1990.
286
+ Li, Z., You, C., Bhojanapalli, S., Li, D., Rawat, A. S., Reddi, S. J., Ye, K., Chern, F., Yu, F., Guo, R., et al. Large models are parsimonious learners: Activation sparsity in trained transformers. arXiv preprint arXiv:2210.06313, 2022.
287
+ Lin, J., Tang, J., Tang, H., Yang, S., Dang, X., and Han, S. Awq: Activation-aware weight quantization for llm compression and acceleration. ArXiv, abs/2306.00978, 2023a. URL https://api-semanticscholar.org/CorpusID:258999941.
288
+ Lin, J., Tang, J., Tang, H., Yang, S., Dang, X., and Han, S. Awq: Activation-aware weight quantization for llm compression and acceleration. arXiv preprint arXiv:2306.00978, 2023b.
289
+ Liu, S., Yin, L., Mocanu, D. C., and Pechenizkiy, M. Do we actually need dense over-parameterization? in-time over-parameterization in sparse training. arXiv preprint arXiv:2102.02887, 2021.
290
+ Liu, S., Chen, T., Chen, X., Shen, L., Mocanu, D. C., Wang, Z., and Pechenizkiy, M. The unreasonable effectiveness of random pruning: Return of the most naive baseline for sparse training. arXiv preprint arXiv:2202.02643, 2022.
291
+ Liu, S., Chen, T., Zhang, Z., Chen, X., Huang, T., Jaiswal, A., and Wang, Z. Sparsity may cry: Let us fail (current) sparse neural networks together! arXiv preprint arXiv:2303.02141, 2023.
292
+ Liu, Y., Ott, M., Goyal, N., Du, J., Joshi, M., Chen, D., Levy, O., Lewis, M., Zettlemoyer, L., and Stoyanov, V. Roberta: A robustly optimized bert pretraining approach. arXiv preprint arXiv:1907.11692, 2019.
293
+ Lv, X., Zhang, P., Li, S., Gan, G., and Sun, Y. Lightformer: Light-weight transformer using svd-based weight transfer and parameter sharing. In Findings of the Association for Computational Linguistics: ACL 2023, pp. 10323-10335, 2023.
294
+ Ma, X., Fang, G., and Wang, X. Llm-pruner: On the structural pruning of large language models. arXiv preprint arXiv:2305.11627, 2023.
295
+
296
+ Mihaylov, T., Clark, P., Khot, T., and Sabharwal, A. Can a suit of armor conduct electricity? a new dataset for open book question answering. arXiv preprint arXiv:1809.02789, 2018.
297
+ Mocanu, D. C., Mocanu, E., Stone, P., Nguyen, P. H., Gibescu, M., and Liotta, A. Scalable training of artificial neural networks with adaptive sparse connectivity inspired by network science. Nature Communications, 9 (1):2383, 2018.
298
+ Molchanov, P., Tyree, S., Karras, T., Aila, T., and Kautz, J. Pruning convolutional neural networks for resource efficient inference. arXiv preprint arXiv:1611.06440, 2016.
299
+ Mosbach, M., Pimentel, T., Ravfogel, S., Klakow, D., and Elazar, Y. Few-shot fine-tuning vs. in-context learning: A fair comparison and evaluation. arXiv preprint arXiv:2305.16938, 2023.
300
+ Mostafa, H. and Wang, X. Parameter efficient training of deep convolutional neural networks by dynamic sparse reparameterization. In International Conference on Machine Learning, 2019.
301
+ Mozer, M. C. and Smolensky, P. Using relevance to reduce network size automatically. Connection Science, 1(1): 3-16, 1989.
302
+ Nangia, N. and Bowman, S. R. Human vs. muppet: A conservative estimate of human performance on the glue benchmark. arXiv preprint arXiv:1905.10425, 2019.
303
+ Nvidia. Nvidia a100 tensor coregpu architecture. https://www.nvidia.com/content/dam/enzz/Solutions/Data-Center/nvidia-ampere-architecture-whitepaper.pdf, 2020.
304
+ Ohno, S. So much "junk" dna in our genome. Brookhaven symposia in biology, 23:366-70, 1972.
305
+ Ram, O., Levine, Y., Dalmedigos, I., Muhlgay, D., Shashua, A., Leyton-Brown, K., and Shoham, Y. In-context retrieval-augmented language models. arXiv preprint arXiv:2302.00083, 2023.
306
+ Sanh, V., Wolf, T., and Rush, A. Movement pruning: Adaptive sparsity by fine-tuning. In Larochelle, H., Ranzato, M., Hadsell, R., Balcan, M. F., and Lin, H. (eds.), Advances in Neural Information Processing Systems, volume 33, pp. 20378-20389. Curran Associates, Inc., 2020. URL https://proceedings.neurips.cc/paper/2020/file/eea15aabaa768ae4a5993a8a4f4fa6e4-Paper.pdf.
307
+
308
+ Sharma, P., Ash, J. T., and Misra, D. The truth is in there: Improving reasoning in language models with layer-selective rank reduction. arXiv preprint arXiv:2312.13558, 2023.
309
+ Singh, S. P. and Alistarh, D. Woodfisher: Efficient second-order approximation for neural network compression. Advances in Neural Information Processing Systems, 33: 18098-18109, 2020.
310
+ Sun, M., Liu, Z., Bair, A., and Kolter, J. Z. A simple and effective pruning approach for large language models. arXiv preprint arXiv:2306.11695, 2023.
311
+ Wang, A., Singh, A., Michael, J., Hill, F., Levy, O., and Bowman, S. R. Glue: A multi-task benchmark and analysis platform for natural language understanding. arXiv preprint arXiv:1804.07461, 2018.
312
+ Wang, C., Grosse, R., Fidler, S., and Zhang, G. Eigendamage: Structured pruning in the kronecker-factored eigenbasis. In International Conference on Machine Learning, pp. 6566-6575. PMLR, 2019.
313
+ Xu, D., Yen, I. E., Zhao, J., and Xiao, Z. Rethinking network pruning-under the pre-train and fine-tune paradigm. arXiv preprint arXiv:2104.08682, 2021.
314
+ Yin, L., Li, G., Fang, M., Shen, L., Huang, T., Wang, Z., Menkovski, V., Ma, X., Pechenizkiy, M., and Liu, S. Dynamic sparsity is channel-level sparsity learner. arXiv preprint arXiv:2305.19454, 2023.
315
+ Yu, H., Edunov, S., Tian, Y., and Morcos, A. S. Playing the lottery with rewards and multiple languages: lottery tickets in rl and nlp. In 8th International Conference on Learning Representations, 2020.
316
+ Yu, X., Liu, T., Wang, X., and Tao, D. On compressing deep models by low rank and sparse decomposition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp. 7370-7379, 2017.
317
+ Yuan, G., Ma, X., Niu, W., Li, Z., Kong, Z., Liu, N., Gong, Y., Zhan, Z., He, C., Jin, Q., et al. Mest: Accurate and fast memory-economic sparse training framework on the edge. Advances in Neural Information Processing Systems, 34: 20838-20850, 2021.
318
+ Zafrir, O., Larey, A., Boudoukh, G., Shen, H., and Wasserblat, M. Prune once for all: Sparse pre-trained language models. arXiv preprint arXiv:2111.05754, 2021.
319
+ Zellers, R., Holtzman, A., Bisk, Y., Farhadi, A., and Choi, Y. Hellaswag: Can a machine really finish your sentence? arXiv preprint arXiv:1905.07830, 2019.
320
+ Zeng, W. and Urtasun, R. Mlprune: Multi-layer pruning for automated neural network compression. 2018.
321
+
322
+ Zhang, Q., Zuo, S., Liang, C., Bukharin, A., He, P., Chen, W., and Zhao, T. Platon: Pruning large transformer models with upper confidence bound of weight importance. In International Conference on Machine Learning, pp. 26809-26823. PMLR, 2022.
323
+ Zheng, Y., Josefowicz, S., Chaudhry, A., Peng, X. P., Forbush, K., and Rudensky, A. Y. Role of conserved noncoding dna elements in the foxp3 gene in regulatory t-cell fate. Nature, 463(7282):808-812, 2010.
324
+ Zhou, A., Ma, Y., Zhu, J., Liu, J., Zhang, Z., Yuan, K., Sun, W., and Li, H. Learning n: m fine-grained structured sparse neural networks from scratch. arXiv preprint arXiv:2102.04010, 2021.
325
+
326
+ # A. Related Work
327
+
328
+ # A.1. Classical Pruning and Sparse Neural Networks
329
+
330
+ Pruning removes specific parts of a deep neural network, such as weights, neurons, or filters. The initial purpose of pruning is retrospectively to accelerate the model at inference time (a.k.a., post-training sparsification (Mozer & Smolensky, 1989; LeCun et al., 1990). Post-training sparsification has been well studied and results in various mature criteria that can be generally categorized into zero-order methods (Han et al., 2016; Gale et al., 2019), first-order methods (Molchanov et al., 2016; Sanh et al., 2020; Jiang et al., 2021), and second-order methods (LeCun et al., 1990; Hassibi & Stork, 1992; Dong et al., 2017) - the last usually achieve higher performance but also are more expensive due to the Hessian calculation, leading to the development of many Hessian approximation approaches (Zeng & Urtasun, 2018; Wang et al., 2019; Singh & Alistarh, 2020; Kurtic et al., 2022). The Lottery Ticket Hypothesis (LTH) (Frankle & Carbin, 2019) utilizes iterative magnitude pruning (IMP) to identify a subnetwork at initialization that can be re-trained independently to the original dense network's performance. Sparse training (Mocanu et al., 2018; Jaiswal et al., 2022; Mostafa & Wang, 2019; Evci et al., 2020; Liu et al., 2021; Yuan et al., 2021; Yin et al., 2023; Kundu et al., 2021), on the other hand, starts with a (random) sparse network and updates network connectivity during training to search for good sparse neural network without any pre-training and dense training steps.
331
+
332
+ # A.2. Sparsity in Large-Scale Models
333
+
334
+ The advent of large-scale pre-trained models has led to the development of advanced post-training pruning methods, aiming to enhance the cost-effectiveness of these expansive models (Sanh et al., 2020; Chen et al., 2020; Jaiswal et al., 2023c; Zafrir et al., 2021; Kurtic et al., 2022; Xu et al., 2021; Lagunas et al., 2021; Zhang et al., 2022; Frantar et al., 2021; Jaiswal et al., 2023b; Ma et al., 2023). Among them, Frantar et al. (2021) extend second-order pruning to the BERT-level scale, enabling the pruning of blocks of weights and achieving state-of-the-art results for sparse BERT. Frantar & Alistarh (2023) introduce SparseGPT for pruning large language models (LLMs) in a single shot without requiring re-training or fine-tuning. They leverage column-wise second-order pruning, and successfully remove 100B weights from OPT-175B without a significant increase in perplexity. More recently, Sun et al. (2023) propose a straightforward pruning method that takes both weights and activations into account, demonstrating comparable performance to Frantar & Alistarh (2023). Li et al. (2022) reveal that activation sparsity is a prevalent phenomenon in Transformers (90% of intermediate output), yielding another opportunity for acceleration. Liu et al. (2023) introduce a large-scale SMC-Bench, indicating that state-of-the-art magnitude- and/or gradient-based sparse algorithms fall short when applied out-of-the-box to larger-scale models and a selected of complex downstream tasks. Our study is inspired by Liu et al. (2023), but with significantly expanded experiment scales, versatile task choices, concrete task difficulty definitions, and richer insights.
335
+
336
+ # B. Across-Task Difficulty by the Performance Difference between humans and models.
337
+
338
+ Table 4. Measuring the Across-Task Difficulty by the Performance Difference between humans and models (normalized by human performance): the larger (positive) margin, the more difficult for the machine. Human performance is obtained from Nangia & Bowman (2019). The more challenging task is marked in bold.
339
+
340
+ <table><tr><td></td><td colspan="2">Single Sentence SST-2 COLA</td><td colspan="2">Sentence Similarity QQP STS-B</td><td colspan="2">Natural Language Inference QNLI RTE</td><td colspan="2">Commonsense Reasoning WinoGrande CSQA</td></tr><tr><td>Human</td><td>97.8</td><td>66.4</td><td>80.4</td><td>92.7</td><td>91.2</td><td>93.6</td><td>94.0</td><td>89.0</td></tr><tr><td>RoBERTa-Large</td><td>96.2</td><td>64.9</td><td>91.8</td><td>92.2</td><td>94.4</td><td>84.3</td><td>78.1</td><td>72.1</td></tr><tr><td>&quot;Task Difficulty&quot; (%)</td><td>1.64</td><td>2.26</td><td>-14.18</td><td>0.54</td><td>-3.51</td><td>9.94</td><td>16.91</td><td>18.99</td></tr></table>
341
+
342
+ We acknowledge the limitations in our approach, such as when both humans and LLMs perform poorly on a task, potentially indicating high difficulty not reflected in our 'relative' gap metric. We hope our exploration can inspire more efforts in a more general and rigorous assessment of cross-task difficulty.
343
+
344
+ # C. Small-Magnitude Weights Contribute to Loss Basin Preservation
345
+
346
+ We also investigate the potential reasons behind the substantial performance drop resulting from the removal of small-magnitude weights on harder tasks. Our analysis revolves around the loss landscape, and we conjecture that small-magnitude weights play a significantly more crucial role in preserving the loss basin of the dense model on harder tasks compared to
347
+
348
+ ![](images/64ed83c3250589c29b3c65ac9e00dfca31333c1d30bf45a65b3bebabffa8b7e6.jpg)
349
+
350
+ ![](images/37bee0e194736dac9b8499e763040bc96d08b88db270e47b66e2c8a73c8b933e.jpg)
351
+
352
+ ![](images/6078c2925294cb6e7cdbbfa0ea5bf7dc82413705600d2b1eb77796e35ea065ce.jpg)
353
+ Figure 10. Linear interpolation from the Dense Transfer (Left) model to its corresponding Sparse Transfer models (Right) on easy and harder tasks (in terms of across-task difficulty).
354
+
355
+ ![](images/d13514d4a8ef31d9d0b5b8c45f721bbea17acb73293de32969616643c40707b1.jpg)
356
+
357
+ easier ones. Consequently, the absence of these small weights disrupts the optimal basin, leading to a considerable loss of performance.
358
+
359
+ To test our conjecture, we utilize the linear mode connectivity (LMC) metric proposed by (Frankle et al., 2020) between the solution produced by Sparse Transfer and that of Dense Transfer. Specifically, we perform linear interpolation between the fine-tuned model of Dense Transfer $(\theta_d)$ and the fine-tuned model of Sparse Transfer $(\theta_s)$ , denoted as $\tilde{\pmb{\theta}} = \alpha \pmb{\theta}_s + (1 - \alpha)\pmb{\theta}_d$ . We conduct two sets of comparisons, namely QQP vs. STS-B and QNLI vs. RTE, and report the performance and loss in Figure 5. Our findings reveal that both sparse and dense models remain linearly connected, with minimal or no increase in loss barrier for easy tasks (i.e., QQP and RTE) when a certain portion of small-magnitude weights is removed. However, a significant increase in the loss barrier is observed when the same number of weights is removed for harder tasks. This observation strongly supports the concept of "Junk DNA", emphasizing the vital role of small-magnitude weights in ensuring that the fine-tuned model resides in the optimal basin. In contrast, the removal of these weights would lead to the destruction of this optimal basin, which is challenging to fix through fine-tuning, causing a notable decline in performance.
360
+
361
+ # D. Dataset Details
362
+
363
+ # D.1. Massive Multitask Language Understanding (MMLU)
364
+
365
+ MMLU (Hendrycks et al., 2020) is a new benchmark designed to measure knowledge acquired during pretraining by evaluating models exclusively in zero-shot and few-shot settings. This makes the benchmark more challenging and more similar to how we evaluate humans. The benchmark covers 57 subjects across STEM, the humanities, the social sciences, and more. It ranges in difficulty from an elementary level to an advanced professional level, and it tests both world knowledge and problem solving ability. Subjects range from traditional areas, such as mathematics and history, to more specialized areas like law and ethics. The granularity and breadth of the subjects makes the benchmark ideal for identifying a model's blind spots.
366
+
367
+ # D.2. Freebase Factoid Question Answering
368
+
369
+ FreebaseQA (Jiang et al., 2019) is a data set for open-domain QA over the Freebase knowledge graph. The question-answer pairs in this data set are collected from various sources, including the TriviaQA data set and other trivia websites (QuizBalls, QuizZone, KnowQuiz), and are matched against Freebase to generate relevant subject-predicate-object triples that were further verified by human annotators. As all questions in FreebaseQA are composed independently for human contestants in various trivia-like competitions, this data set shows richer linguistic variation and complexity than existing QA data sets, making it a good test-bed for emerging KB-QA systems.
370
+
371
+ # D.3. TrviaQA Dataset
372
+
373
+ TriviaQA (Joshi et al., 2017) is a popular reading comprehension dataset which includes 95K question-answer pairs authored by trivia enthusiasts and independently gathered evidence documents, six per question on average, that provide
374
+
375
+ high-quality distant supervision for answering the questions. TriviaQA consists of fairly complex compositional questions with considerable syntactic and lexical variability between questions and corresponding answer-evidence sentences, making it a challenging testbed for our evaluation.
376
+
377
+ # D.4. Glue Benchmark
378
+
379
+ General Language Understanding Evaluation (GLUE) benchmark (Wang et al., 2018) is a collection of nine natural language understanding tasks, including single-sentence tasks CoLA and SST-2, similarity and paraphrasing tasks MRPC, STS-B and QQP, and natural language inference tasks MNLI, QNLI, RTE and WNLI. GLUE is designed to favor and encourage models that share general linguistic knowledge across tasks.
380
+
381
+ # D.5. OpenbookQA Benchmark
382
+
383
+ OpenBookQA (Mihaylov et al., 2018) is a new kind of question-answering dataset modeled after open book exams for assessing human understanding of a subject. It consists of 5,957 multiple-choice elementary-level science questions (4,957 train, 500 dev, 500 test), which probe the understanding of a small "book" of 1,326 core science facts and the application of these facts to novel situations. For training, the dataset includes a mapping from each question to the core science fact it was designed to probe. Answering OpenBookQA questions requires additional broad common knowledge, not contained in the book. The questions, by design, are answered incorrectly by both a retrieval-based algorithm and a word co-occurrence algorithm. Additionally, the dataset includes a collection of 5,167 crowd-sourced common knowledge facts, and an expanded version of the train/dev/test questions where each question is associated with its originating core fact, a human accuracy score, and a clarity score.
384
+
385
+ # D.6. HellaSwag
386
+
387
+ HellaSWAG (Zellers et al., 2019) is a dataset for studying grounded commonsense inference. It consists of 70k multiple choice questions about grounded situations: each question comes from one of two domains - activitynet or wikihow - with four answer choices about what might happen next in the scene. The correct answer is the (real) sentence for the next event; the three incorrect answers are adversarially generated and human verified, so as to fool machines but not humans.
388
+
389
+ # E. Low-Rank Compression
390
+
391
+ An alternative way of compressing the model is reducing the rank of weight matrices by retaining the top $k$ components identified through Singular Value Decomposition (SVD) (Lv et al., 2023; Hajimolahoseini et al., 2021; Sharma et al., 2023). In our study, we specifically modify the rank of $k$ using SVD decomposition across all linear layers in the transformer block of the Vicuna-7B model, ranging from 4000 to 100 ranks.. We then evaluate the compressed model's performance in two task difficulty settings: 1 Settings 2: Varying the Option Count in Multiple-choice QA Setting and Settings 3: Varying Context Length for Retrieval-Augmented QA.
392
+
393
+ ![](images/31d2f9291056e7f72747bee3c1d6c49ea9009113dc468ec435e6ca5622289d00.jpg)
394
+ Figure 11. Low-Rank Compression using SVD.
395
+
396
+ ![](images/494777505927f6b029c5f5d06cf2cf3f8a523bd57663529d8d1bff08fffda575.jpg)
397
+
398
+ We noticed the concurrent work (Sharma et al., 2023) suggesting layer-selective low-rank compression of weights often improves LLM reasoning and generalization, without needing no re-training needed. We however note that requires careful
399
+
400
+ Table 5. Low-Rank Compression using SVD.
401
+
402
+ <table><tr><td rowspan="2"></td><td colspan="4">Context Length</td><td colspan="3">Option Count</td></tr><tr><td>Closed Book</td><td>100%</td><td>60%</td><td>20%</td><td>2</td><td>3</td><td>4</td></tr><tr><td>Spearman&#x27;s Rank</td><td>0.899</td><td>0.942</td><td>0.905</td><td>0.912</td><td>0.933</td><td>0.956</td><td>0.956</td></tr></table>
403
+
404
+ selection of layer & rank. In comparison, we apply "uniform" SVD to all linear weight layers (except embedding), to make fair comparisons to pruning/quantization. We leave the examination of more sophisticated methods such as (Sharma et al., 2023) as future work.
2024/Junk DNA Hypothesis_ Pruning Small Pre-Trained Weights $_textitIrreversibly$ and $_textitMonotonically$ Impairs “Difficult_ Downstream Tasks in LLMs/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fbe3815593434850e307f2e4fb8f31ba27bea670f714cd2d007197fda1bd5f1e
3
+ size 791998
2024/Junk DNA Hypothesis_ Pruning Small Pre-Trained Weights $_textitIrreversibly$ and $_textitMonotonically$ Impairs “Difficult_ Downstream Tasks in LLMs/layout.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/Just Cluster It_ An Approach for Exploration in High-Dimensions using Clustering and Pre-Trained Representations/7b2f16fe-5bc7-4629-941e-77e88683d4e9_content_list.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/Just Cluster It_ An Approach for Exploration in High-Dimensions using Clustering and Pre-Trained Representations/7b2f16fe-5bc7-4629-941e-77e88683d4e9_model.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/Just Cluster It_ An Approach for Exploration in High-Dimensions using Clustering and Pre-Trained Representations/7b2f16fe-5bc7-4629-941e-77e88683d4e9_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b88548c7e3eab1cc1cfef04404a3d9933b7383abb92ee4afde4e4415d4e0a341
3
+ size 1815290
2024/Just Cluster It_ An Approach for Exploration in High-Dimensions using Clustering and Pre-Trained Representations/full.md ADDED
@@ -0,0 +1,549 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Just Cluster It: An Approach for Exploration in High-Dimensions using Clustering and Pre-Trained Representations
2
+
3
+ Stefan Sylvius Wagner<sup>1</sup> Stefan Harmeling<sup>2</sup>
4
+
5
+ # Abstract
6
+
7
+ In this paper we adopt a representation-centric perspective on exploration in reinforcement learning, viewing exploration fundamentally as a density estimation problem. We investigate the effectiveness of clustering representations for exploration in 3-D environments, based on the observation that the importance of pixel changes between transitions is less pronounced in 3-D environments compared to 2-D environments, where pixel changes between transitions are typically distinct and significant. We propose a method that performs episodic and global clustering on random representations and on pre-trained DINO representations to count states, i.e., estimate pseudocounts. Surprisingly, even random features can be clustered effectively to count states in 3-D environments, however when these become visually more complex, pre-trained DINO representations are more effective thanks to the pre-trained inductive biases in the representations. Overall, this presents a pathway for integrating pretrained biases into exploration. We evaluate our approach on the VizDoom and Habitat environments, demonstrating that our method surpasses other well-known exploration methods in these settings.
8
+
9
+ # 1. Introduction
10
+
11
+ Exploration in reinforcement learning can inherently be seen as a density estimation problem. Approximating the density of the state-space throughout learning, allows the agent to determine which parts of the environment it has visited. This paradigm is at the core of exploration via intrinsic moti
12
+
13
+ $^{1}$ Department of Computer Science, Heinrich Heine University Düsseldorf, Germany $^{2}$ Department of Computer Science, Technical University Dortmund, Germany. Correspondence to: Stefan Wagner <stefan.wagner@hhu.de>.
14
+
15
+ Proceedings of the $41^{st}$ International Conference on Machine Learning, Vienna, Austria. PMLR 235, 2024. Copyright 2024 by the author(s).
16
+
17
+ vation where an intrinsic reward signal is created to quantify novelty. A simple way to do this is by counting states (Tang et al., 2016). However, simply counting all states naively is not possible, since counts are very sparse in high-dimensional or stochastic settings and the memory requirements to store every distinct count for a given state are very high. There are several approaches to estimating the state density: One way is to use some density estimation model that given an observation assigns a pseudo-count (Bellemare et al., 2016), where a pseudo-count is an estimated count for a state given a density model. Other methods are based on using the prediction error, where the estimate for the state density is based on whether a model can predict fixed target features provided by a second model (Pathak et al., 2017; Burda et al., 2018; Raileanu & Rocktäschel, 2020). Established methods such as Random Network Distillation (Burda et al., 2018) show that novelty can be determined simply by calculating the prediction error of random features. Different states will provide different feature vectors hence the model learns an indirect density estimate of the state space. Recent methods such as BYOL-Explore (Guo et al., 2022) replace random features with trained features, with great success.
18
+
19
+ The need for state aggregation in 3-D vs. 2-D. Due to its inherent simplicity, counting states for exploration in non-tabular environments has been studied extensively (Bellemare et al., 2016; Tang et al., 2016; Ostrovski et al., 2017). While counting states for exploration works well in tabular settings, it becomes intractable in high dimensional settings if every state is counted explicitly. Bellemare et al. (2016) were among the first to propose the estimation of pseudo-counts, where the counts are modeled by some density model of the state-space. Essentially, this transforms the problem of exploration into a density estimation problem of the state-space. A central property for a density model in exploration is that the model should be able to distinguish different states, such that salient transitions can be identified in the intrinsic reward. In the case of counting states, the states should be aggregated in a sensible way such that the counts are not too granular, but also not too coarse (Ostrovski et al., 2017; Ecoffet et al., 2021). We identify a particular phenomenon regarding the importance of pixel changes
20
+
21
+ In 3-D Exploration:
22
+
23
+ Pixel change magnitude high, but saliency low.
24
+
25
+ Problem: Bad intrinsic reward
26
+
27
+ Solution? Just Cluster It!
28
+
29
+ ![](images/fba10150e533ebeed7dfcf4fdf5123c7c33031c9e280a314f53003caa70e64e4.jpg)
30
+ (a)
31
+
32
+ Cluster pre-trained embeddings for state aggregation
33
+
34
+ ![](images/4e2ef4969827d387562b5511f028faa3fa36d67b272e2f8b5db5965e2aadabdd.jpg)
35
+ (b)
36
+ Figure 1. "Just Cluster It" in a nutshell: (a) Density estimation for exploration in 3-D environments is challenging, because the magnitude of pixel change is large, but the saliency of a single transition is low. This is in contrast to 2-D environments where every transition is distinct and therefore salient. Therefore, we propose clustering representations on an episodic and global level to estimate accurate pseudo-counts that reflect the state-space distribution. (b) We show pre-trained representations from a DINO model. The embeddings from the DINO model are able to extract relevant features from the observations, which is useful for clustering. The bottom images are thresholded embeddings. (c) To estimate pseudo-counts, we store episodic cluster centers in a global cluster table over time by matching episodic cluster centers with previously added cluster centers in the cluster table. A new cluster center is added to the table, if the cosine similarity to existing cluster centers is below a threshold $\kappa$ .
37
+
38
+ Combine episodic and global clustering to estimate pseudo-counts
39
+
40
+ ![](images/bd26791d6c9934159a25f1da7bcb04f83cd656f81b774ee126c3a97f9f3a516e.jpg)
41
+ (c)
42
+
43
+ in 3-D environments that requires states to be aggregated in order to provide a salient intrinsic reward. We provide a straightforward example in Figure 1(a), to demonstrate that state aggregation is necessary in 3-D environments compared to 2-D enviroments and thus must be accounted for by a density model in 3-D environments. We characterize this via transition saliency of pixels, i.e., the significance of pixel changes between two observations. For instance, in 2-D environments pixel change between transitions is usually small, but the significance of the pixel change is large. As a consequence, almost every observation contains new information regarding the current state of an agent. One example is Montezumas Revenge where individual groups of pixels change substantially when an action is performed, since the playable character figure changes its pixels when e.g., moving from left to right or when interacting with an object. In 3-D environments by contrast, although the magnitude of pixel change is large, these pixel changes are usually not as significant, since after a single transition the relationship between the pixels in the observations remains largely the same. Rather, a more effective reference point for estimating the state density should be centered around salient features in the representations, such that observations with similar features are considered similar. In conclusion, in 2-D enviroments the transition saliency of pixels is high, whereas in 3-D environments the transition saliency of pixels is low. Thus, the underlying density model must account for this lack of saliency in 3-D environments to yield a meaningful
44
+
45
+ intrinsic reward. Similar thoughts have also been presented by Ecoffet et al. (2021); Ostrovski et al. (2017). We argue that tackling this transition saliency problem may bridge the gap from count-based methods to prediction-error-based methods which excel at providing a salient intrinsic reward signal when observations are discrete and pixel changes are meaningful. However, they perform worse when the observations are high-dimensional and individual transitions are not as meaningful. Overall, if an appropriate density model can be found to estimate pseudo-counts in high dimensional observations, we can exploit the favorable theoretical guarantees of count-based methods (Bellemare et al., 2016) and avoid catastrophic forgetting in neural networks. With this in mind, we deduce that a clustering-based approach, which is able to find the right level of state aggregation by finding shared features in the observations, may be much more effective in high-dimensional environments, provided the underlying representations are expressive enough. Ideally, the level of state aggregation should be determined from the underlying features contained in the observations.
46
+
47
+ Exploration through Episodic and Global Clustering of High-Dimensional Representations. To this end, we propose a method for exploration that performs episodic and global clustering of (pre-trained) representations to estimate pseudo-counts. More precisely, in each episode we fit a Gaussian mixture model on random features or on features from a pre-trained DINO (Oquab et al., 2023; Caron
48
+
49
+ et al., 2021) model to exploit the invariances contained in the representations. The Gaussian mixture model determines cluster means, i.e., centers for the observations in the current episode, which can then be compared with cluster centers previously stored in memory (see Figure 1(c)). Particularly when utilizing pre-trained representations, as demonstrated in Figure 1(b), we see that these features align well with objects in the scene. We consider these features as various modes in the observational distribution, which makes them well suited for a Gaussian mixture model. The global clustering is then done in the cluster table, where a cosine similarity threshold $\kappa$ is used to determine whether a new episodic cluster center should be added to memory or not. This is akin to the stick breaking process in Dirichlet processes and thus allows us to control the granularity of the inter-episodic clustering. We then calculate the intrinsic reward for each observation in the episode as the inverse square root of the pseudo-counts (Strehl & Littman, 2008). We conduct experiments on both the VizDoom (Kempka et al., 2016) and Habitat (Savva et al., 2019; Szot et al., 2021; Puig et al., 2023) environments, demonstrating that even features chosen at random outperform other exploration methods when dealing with 3-D environments.
50
+
51
+ Contributions: (i) We introduce an exploration method that determines novelty by estimating pseudo-counts of clustered pre-trained representations. We propose a method that involves both episodic and global clustering. The episodic clustering aggregates similar representations by fitting a Gaussian mixture model to pre-trained DINO representations or to random features for every episode. The global clustering is done over time by matching and storing episodic cluster centers in a global cluster table that aggregates pseudo-counts. Empirically, we demonstrate the effectiveness of this procedure in the chosen 3-D environments.
52
+
53
+ (ii) We show that both random and pre-trained DINO features can be clustered effectively to aggregate states in 3-D environments and thus estimate pseudo-counts effectively. While random features work well on a simpler 3-D environment (VizDoom environment), with real-world observations (Habitat environment), the priors contained in the pre-trained DINO representations improve performance substantially.
54
+
55
+ (iii) By ablating two components of our method - the cosine similarity threshold $\kappa$ and the episodic clusters, we show the effectiveness of clustering observations in high-dimensional 3-D environments.
56
+
57
+ # 2. Background
58
+
59
+ Count based methods and estimating pseudo-counts. Pseudo-counts as defined by Bellemare et al. (2016) stand at
60
+
61
+ the center of generalizing counts to high dimensional state spaces. They define state counts relative to density model that approximates the underlying state-space distribution. In principle, this definition of pseudo-counts is agnostic to the given state representation (Ostrovski et al., 2017). There are various exploration methods that rely on state counting, either to detect repeating observations or in order to normalize the intrinsic reward (Raileanu & Roktaschel, 2020; Zhang et al., 2021; Wagner et al., 2023; Parisi et al., 2021; Tang et al., 2016). These methods ultimately propose pseudo-counts when extending to high-dimensional state-spaces. Bellemare et al. (2016) also demonstrate that estimating pseudo-counts using a density model provides a measure of either information gain, i.e., prediction gain. This shows that pseudo-counts are related to intrinsic reward methods that utilize prediction error as an intrinsic reward signal. When calculating an intrinsic reward bonus based on pseudo-counts, a common choice to calculate the intrinsic bonus is the inverse square root of the pseudo-counts as proposed by Strehl & Littman (2008).
62
+
63
+ Novelty via prediction error. Most recent exploration methods fall under the category of exploration via prediction error. The idea is that the prediction error of a model with regard to some target features is a measure of novelty. Various versions of these methods exist, like Random Network Distillation (Burda et al., 2018) (RND), in which the target features come from a neural network that is both fixed and initialized randomly. Pathak et al. (2017) learns inverse dynamics with a separate model that learns to predict the correct actions between state transitions which makes the learned representations invariant to uncontrollable parts of the enviroment. Raileanu & Rocktäschel (2020) predict the target features of the next state given the current state instead of predicting the target features of the same state. Recent methods such as BYOL-Explore (Guo et al., 2022) learn representations online with BYOL (Grill et al., 2020) leading to better target features. Overall, these models estimate the density of the state space through the target features they approximate. Thus, the target features influence the state-space density that is learned. An advantage of prediction-error-methods is that since they are parametrized by a neural network they can generate an intrinsic reward signal ad-hoc from raw observations.
64
+
65
+ Density estimation via clustering representations. A basic method for estimating the density of the state-space involves the use of clustering. Ma et al. (2019) cluster the observations directly by performing k-means on the observations. Then they calculate the pseudo-counts on an episodic level and do not store the counts throughout the entirety of learning. "Never Give Up" (NGU, Puigdomènech Badia et al., 2020) also make use of episodic clustering to estimate episodic novelty. For each episode, NGU determines the
66
+
67
+ sum of squared errors between the k-nearest neighbors of the current state and the current state itself. To capture long-term dependencies a global intrinsic reward is calculated via random network distillation. E3B (Henaff et al., 2022) performs episodic clustering by fitting a covariance matrix at each step and computing eigenvalues of the updated covariance matrix. The scale of the eigenvalues then determines the novelty. Apart from episodic clustering methods there are also methods that perform global clustering. Go-Explore (Ecoffet et al., 2021) maps observations to cells, which can also be seen as a form of clustering. However, instead of performing explicit clustering, a heuristic is used to find suitable values for downscaling parameters such as width, height and depth. The idea is that similar observations are mapped to the same cell. RECODE (Saade et al., 2023) attempts to estimate pseudo-counts by approximating clusters via Kernel Density Estimation (KDE). The current embedding is taken as central point and a density is fitted to find the nearest approximated cluster means stored in a table. If a new embedding is significantly different from its neighbors in the table it replaces an old embedding. RECODE is closely related to our method, with its Dirichlet process inspired approach. However, RECODE is also somewhat susceptible to the problem of transition saliency in 3-D environments, since it updates the cluster means at every step with only a single embedding as reference point. We also simplify the stick breaking process for the cluster table, as we only have a single threshold $\kappa$ that determines whether a new cluster center should be added to the cluster table or not.
68
+
69
+ # 3. Just Cluster It: Exploration via Episodic and Global Clustering
70
+
71
+ In this section, we describe our exploration method "Just Cluster It!", which consists of a two-stage clustering: first, we cluster after each episode, which we call episodic clustering, and second, we collect the newly found clusters in a global table of cluster centers, which we call global clustering. The cluster centers of the global clustering maintain a list of pseudo-counts to approximate the state space distribution. Therefore, it is important that the episodic cluster centers are representative of the observational distribution in the current episode, in order to aggregate the pseudo-counts correctly. Over time, the cluster table will contain pseudocounts for the whole state-space distribution. Note that we call the counts pseudo, since they are defined relative to a mixture model.
72
+
73
+ For each episode, we employ a two-step process: first, we perform episodic clustering by fitting a Gaussian mixture model on the batch of representations of the current episode. This yields several episodic cluster centers. The second step updates the global cluster table that contains cluster centers
74
+
75
+ from previous episodes and their corresponding counts. For each episode, counts from episodic cluster centers are then either aggregated to existing cluster centers, or a new cluster center is added depending on a cosine similarity threshold. This process of adding cluster centers continuously is similar to the stick breaking procedure in Dirichlet processes. However, instead of sampling weights from a beta distribution to determine the new cluster size, we simply add a new cluster center if the maximum cosine similarity is below a threshold $0 \leq \kappa \leq 1$ . In this sense, $\kappa$ controls the granularity of the clusters in the cluster table and is related to the concentration parameter for the Beta distribution in Dirichlet processes. The closer $\kappa$ is to one, the more cluster centers are added to the cluster table as shown in Figure 4(a). The key insight resulting from our method is that (pre-trained) representations in high dimensions are expressive enough to be clustered effectively on an episodic level, while also contributing to the approximation of the global state space distribution.
76
+
77
+ Notation and Preliminaries. We define an MDP as a tuple $(S, \mathcal{A}, \mathcal{P}, \mathcal{R}, \gamma)$ with interactions at discrete time steps $t = 0, 1, 2, 3, \ldots$ . The agent receives a state from the environment as a random variable $S_t \in S$ , where $S_t = s$ is some representation of the state from the set of states $S$ at timestep $t$ . The agent then selects an action $A_t \in \mathcal{A}$ where $A_t = a$ is some action in the possible set of actions $\mathcal{A}$ for the agent at timestep $t$ . This action is selected according to a policy $\pi(a|s)$ or $\pi(s)$ if the policy is deterministic. One time step later after taking the action, the agent receives a numerical reward which is a random variable $R_{t+1} \in \mathbb{R}$ , where $R_{t+1} = r$ is some numerical reward at timestep $t+1$ . Finally, the agent is in a new state $S_{t+1} = s'$ . As usual $\gamma$ is the discount factor. Furthermore, we define a POMDP $(S, \mathcal{A}, \mathcal{O}, \mathcal{P}, \mathcal{R}, \mathcal{Q}, \gamma)$ for egocentric 3-D environments, where the true state $s$ is not known. Thus, the agent sees the state $s \in S$ through an observation $o \in \mathcal{O}$ , where an observation function $\mathcal{Q}: S \to \mathcal{O}$ maps the true state to the agent's observation. The components of our method are as follows: we define a policy network $\pi_\theta: \mathcal{O} \to \mathcal{A}$ with network parameters $\theta$ , which transforms an observation $o$ into an action $a$ .
78
+
79
+ We utilize a pre-trained model $f_{\nu}:\mathcal{O}\to \mathcal{E}$ with network parameters $\nu$ to project observations into a latent space $\mathcal{E}$ , which will be learned by self-supervised learning (e.g. DINO, Caron et al., 2021). A clustering algorithm $g:\mathcal{E}\rightarrow \{1,\dots M\}$ is also defined, which assigns a cluster label $m$ to an embedding $e$ .
80
+
81
+ Our method has two hyperparameters: the cosine similarity threshold $\kappa$ and the number of clusters $M$ for the episodic Gaussian mixture model. This is less than other exploration methods based on clustering. In the following we describe
82
+
83
+ our algorithm. We provide the Python implementation ${}^{1}$ for the following steps in Algorithm 1.
84
+
85
+ 1. Building episodic clusters. We define an episode as a sequence of transitions $\left\{(o^{(t)},a^{(t)},r^{(t)},o^{\prime}(t))\right\}_{t = 1}^{T}$ where $T$ is the length of the episode and $o^{\prime (t)}$ is the observation following $o^{(t)}$ . Moreover, we define the set of observations as $B = \{o^{(t)}\}_{t = 1}^{T}$ and let $\tilde{B} = \{e^{(t)}\}_{t = 1}^{T} = f_{\nu}(B)$ be the embeddings after passing them through the pre-trained model $f_{\nu}$ . We then fit a Gaussian mixture model (GMM) on the embeddings $\tilde{B}$ to obtain $M$ episodic cluster centers
86
+
87
+ $$
88
+ \left\{\mu_ {\mathrm {e p}} ^ {(m)} \right\} _ {m = 1} ^ {M}. \tag {1}
89
+ $$
90
+
91
+ The GMM induces the mapping $g: \mathcal{E} \to \{1, \ldots, M\}$ which assigns each embedding $e^{(t)}$ to one of the clusters, which defines a sequence of cluster labels $m_{*}(t) = g(e^{(t)})$ .
92
+
93
+ 2. Updating the global cluster table. The following steps 2.1 to 2.4 are repeated for every episodic cluster $m = 1, \ldots, M$ . This builds the global cluster table incrementally.
94
+
95
+ 2.1 Assigning an episodic cluster center to global cluster centers. Before the first episode, the global cluster table is empty. In step 2.3 new pairs will be added. Assume for now that we have already $K$ pairs $(\mu_{\mathrm{global}}^{(k)},\lambda_{\mathrm{global}}^{(k)})$ of global cluster centers and global cluster pseudo counts
96
+
97
+ $$
98
+ \left\{\left(\mu_ {\text {g l o b a l}} ^ {(k)}, \lambda_ {\text {g l o b a l}} ^ {(k)}\right) \right\} _ {k = 1} ^ {K}. \tag {2}
99
+ $$
100
+
101
+ Next, we calculate for fixed $m$ the pairwise cosine similarities between $\mu_{\mathrm{ep}}^{(m)}$ and $\mu_{\mathrm{global}}^{(k)}$ , which are collected in a $K$ -dimensional vector $\mathbf{D}$ . The maximum of $D$ gives us the maximal cosine similarity $d_{*}(m)$ and a corresponding global cluster label $k_{*}(m) \in \{1, \dots, K\}$ for each episodic cluster center.
102
+
103
+ 2.2 Calculating the intrinsic rewards. To calculate the intrinsic rewards along the episode, we assign the pseudo-counts for the embeddings $e^{(t)}$ that are assigned to cluster $m$ ,
104
+
105
+ $$
106
+ \rho^ {(t)} = \lambda_ {\text {g l o b a l}} ^ {(k _ {*} (m))} + \sum_ {t ^ {\prime} = 1} ^ {t} [ m _ {*} (t ^ {\prime}) = m ] \tag {3}
107
+ $$
108
+
109
+ such that the pseudo-counts increase for each time an embedding belonging to the cluster $m$ is seen in the episode.
110
+
111
+ For time steps $t$ where $\rho^{(t)}$ has just been assigned, we calculate the intrinsic rewards as the inverse square root of the pseudo-counts (Strehl & Littman, 2008),
112
+
113
+ $$
114
+ r _ {\text {i n t}} ^ {(t)} = \frac {1}{\sqrt {\rho^ {(t)}}}. \tag {4}
115
+ $$
116
+
117
+ 2.3 Growing the global cluster table. If the maximal cosine similarity $d_{*}(m)$ is smaller than the hyperparameter $\kappa$ (a fixed value between 0 and 1), we add $\mu_{\mathrm{ep}}^{(m)}$ to the list of global cluster centers and $K$ is increased by one. The corresponding global pseudo count is initialized to zero, but will get updated in the next step.
118
+ 2.4 Updating the global pseudo counts. The global pseudo count of the global cluster center that corresponds to $m$ , i.e., with index $k_{*}(m)$ , is simply updated using the episodic cluster counts for the assigned episodic cluster center $m$ :
119
+
120
+ $$
121
+ \lambda_ {\text {g l o b a l}} ^ {(k _ {*} (m))} := \lambda_ {\text {g l o b a l}} ^ {(k _ {*} (m))} + \lambda_ {\mathrm {e p}} ^ {(m)}. \tag {5}
122
+ $$
123
+
124
+ 3. Combining intrinsic and extrinsic rewards. Finally, the intrinsic and extrinsic rewards are simply added, and we update the policy network $\pi_{\theta}$ with the transitions
125
+
126
+ $$
127
+ \left\{\left(o ^ {(t)}, a ^ {(t)}, r _ {\text {i n t}} ^ {(t)} + r ^ {(t)}, o ^ {\prime (t))} \right\} _ {t = 1} ^ {T} \right. \tag {6}
128
+ $$
129
+
130
+ via Proximal Policy Optimization (PPO).
131
+
132
+ # 4. Experiments
133
+
134
+ Given our proposed ideas and method we aim to answer the following questions: (i) How well does clustering features perform in high-dimensional 3-D environments? (ii) Can our method leverage pre-trained representations to improve exploration? (iii) What effect do episodic clustering and global clustering have on the performance and robustness of our method? We present the environments, experiment setup and baselines, followed by results of our experiments and corresponding ablations.
135
+
136
+ **Environments.** We test our method on observationally complex environments like VizDoom (Kempka et al., 2016) and Habitat-Replica (Savva et al., 2019; Szot et al., 2021; Puig et al., 2023). In VizDoom every room has a different texture, where some moving textures are also present. In Habitat, the observations are real world scenes of apartments, hotels and office rooms which are very complex. The chosen environments are centered around navigation exploration tasks. This setup enables us to separate the issue of density estimation from the challenge of understanding complex environment dynamics. In general, all methods
137
+
138
+ ![](images/1d5d833d335cc2858d89c9b883912a10026ff42f6fc7802d0887a8caec0b85c3.jpg)
139
+ Figure 2. Clustering random features is effective for VizDoom: Our method with clustering outperforms other traditional exploration methods. Interestingly, random features perform slightly better than the DINO features for VizDoom. While the complexity of the observations is not trivial, in this setting the priors in the pre-trained representations seem to be not more informative than random features. This also shows that in 3-D high-dimensional environments random features are salient enough when clustered to estimate pseudo-counts.
140
+
141
+ we evaluate including ours focus solely on the problem of density estimation, and we thus share the same assumptions. More details regarding the environments and agent setup can be found in the Appendix D.
142
+
143
+ Experimental setup and baselines. We compare our method to both clustering and prediction-error-based exploration approaches. Thus, we split the experiments into two categories for both environments. Both Figures 2 and 3 show comparison to only (i) clustering-based methods on the left side and to (ii) prediction-error-based methods on the right side. For (i) we compare against RECODE (Saade et al., 2023) and E3B (Henaff et al., 2022). For (ii) we compare against Random Network Distillation (Burda et al., 2018), Curiosity-driven exploration (Pathak et al., 2017) and RIDE (Raileanu & Rocktäschel, 2020). To see how other methods leverage pre-trained representations, we also compare against RECODE with both random features and DINO features. For all configurations we perform 3 runs with different seeds. We use PPO (Schulman et al., 2017) to train the policy network for both our method and our implementation of RECODE. E3B (Henaff et al., 2023) also uses DD-PPO for the Habitat environment. For all other methods the learning method for the policy network is IMPALA (Espeholt et al., 2018). Specific implementation details and hyperparameters can be found in Appendix E.
144
+
145
+ Evaluation metrics. For VizDoom we use the extrinsic reward as a metric for performance. The extrinsic reward is defined from 0 to 1. For Habitat, we explore only using the intrinsic reward, we thus use the number of visited states as a metric for performance as in (Parisi et al., 2021). We show the exact formula in Appendix D.2.
146
+
147
+ # 4.1. VizDoom Results—The Suprising Effectiveness of Random Features
148
+
149
+ We plot results for "MyWayHome" in Figure 2, where we compare our method to both cluster-based (left) and prediction-error-based methods (right) for both the "Sparse" and "VerySparse" settings. We see that clustering random features with our method (dashed, green curve) is superior to all other methods converging at around 1.5M and 1.8M steps respectively. Interestingly, random features perform slightly better in VizDoom than the DINO features (dashed, blue curve) which converges slightly later at around 1.7M and 1.9M steps respectively. In this case, the priors in the DINO features do not seem to pose an advantage over random priors for the observations in the VizDoom environment. However, this also shows that random features in 3-D environments can be salient enough to be clustered effectively. When comparing our method to RECODE with DINO features (grey curve), we see that our method is better able to leverage the pre-trained features. For RECODE, DINO features converge at around 5M steps compared to the random features (purple curve) which converge at 3.8M steps, while for our method random features and DINO features converge at almost the same time. For "VerySparse" we could not get RECODE to converge within the specified number of steps. One explanation for this could be that in the "VerySparse" setting, the agent never reaches the goal by chance as opposed to in the "Sparse" setting, such that the agent never finds a sensible policy. The RE-CODE agent does however manage to reach the goal on a few occasions. Furthermore, comparing our method to the prediction-error-based methods such as RIDE and Curiosity, we see that these methods perform worse needing at least 5M steps to converge. Overall, both our clustering method and RE-CODE, outperform the prediction-error-based meth
150
+
151
+ ![](images/37d31c6d76a7f3ce28c51f44788e63a505b36b8dce080247a444f2d979895ebe.jpg)
152
+ Habitat - Apartment-0
153
+ Number of Steps (Millions)
154
+
155
+ ![](images/7ea1a0b5fa7cd3a5ed00cd5ba7d370eb5388ef8d4318ec8acc6b68152f6fb119.jpg)
156
+ Figure 3. Pre-trained DINO features excel with more complex observations: When training on the Habitat environment we see that clustering with DINO embeddings is more effective than clustering with random features. Furthermore, only our method is able to leverage the pre-trained DINO features effectively. We argue that the priors present in the DINO embeddings help in aggregating the representations when building the episodic clusters, which ultimately determine the pseudo-counts.
157
+
158
+ ![](images/7ebd444030a846e1fb6d1dadc8375883ee85f18a41c857364ab932de862cec1f.jpg)
159
+
160
+ ods. While E3B is a clustering method as well, it only performs episodic clustering as explained in Section 2. Usually, episodic clustering alone performs worse in singleton environments, such as VizDoom as explained in Henaff et al. (2023).
161
+
162
+ # 4.2. Habitat Results—Pre-trained features help in complex observations
163
+
164
+ To test our method on more complex observations we use the Habitat environment and adopt the experimental setting from Parisi et al. (2021). That is, we train the agent on the Habitat environment with only intrinsic rewards and plot the visitation counts (see Figure 3). We can see the benefit of using pre-trained DINO features in the visually more complex Habitat environment. When clustering pre-trained DINO features with our method (dashed, blue curve), we achieve 17K visitation counts on average, more than any other method. RECODE by comparison achieves only slightly under 15K visitation counts. Interestingly, our method with random features (dashed, green curve) performs slightly worse than RECODE at 14K visitation counts. We show in Figure 4(b) that for Habitat, episodic clustering of random features is not better than episodic clustering of DINO features, hence the reduced performance compared to DINO features. However, we see again that our method is able to better leverage the pre-trained features compared to RECODE. Again, E3B is not suited for singleton environments barely achieving 7K visitation counts. Looking at the prediction-error-based methods, although Random Network Distillation uses random features as well, it is vastly inferior to the clustering-based methods converging at around 5K visitation counts. This validates our hypothesis about transition saliency presented in Section 1: In 3-D environments, the clustering-based methods are able to exploit the
165
+
166
+ structure of the representations more effectively. We will expand on this in the following section.
167
+
168
+ # 4.3. The Effect of Episodic and Global Clustering
169
+
170
+ Next, we analyse the effect of the episodic clustering and the global clustering. To ablate the episodic clustering, we perform runs for both "MyWayHome-VerySparse" and "Apartment-0" with and without episodic clustering. To ablate the influence of the global clustering, we vary the cosine similarity threshold $\kappa$ and plot the number of cluster centers and visitation counts for "Apartment-0".
171
+
172
+ Increasing cosine similarity threshold $\kappa$ makes pseudocounts more granular, degrading performance. We plot the visitation counts and the number of clusters in the cluster table for different values of $\kappa$ in Figure 4(a). We see that increasing the cosine similarity threshold $\kappa$ increases the number of global cluster centers in the cluster table. If the number of clusters in the cluster table is too high, performance decreases as shown by lower visitation counts for higher values of $\kappa$ . We argue that the pseudo-counts become too sparse, and thus the intrinsic reward fails to provide a good approximation of the state-space distribution. This aligns with the transition saliency problem in Section 1. In this case we revert to the same setting of prediction-error-based methods where the intrinsic reward becomes too granular. Note that the performance at around 10K visitation counts is still better than random network distillation (Burda et al., 2018) in Figure 3, which is likely related to the fact that clustering-based methods are not affected by catastrophic forgetting.
173
+
174
+ Interestingly, for lower values of $\kappa$ performance does not degrade in the same way. We observe that the smaller the value of $\kappa$ is the less cluster centers get added to the cluster
175
+
176
+ ![](images/a6932d44c449d56a5ce38275284a313e02aa6927ca5aba4e7d31d1e45f98c622.jpg)
177
+ (a)
178
+
179
+ ![](images/95265a3aa116065a83d7efd38010618ff7af4ec6d23d171c839643496b75615e.jpg)
180
+ Figure 4. Ablation studies: We show the effectiveness of clustering, especially episodic clustering: (a) Increasing the cosine similarity threshold $\kappa$ increases the number of global clusters in the cluster table. If the number of clusters in the cluster table are too granular, performance decreases as shown by lower visitation counts for higher values of $\kappa$ . (b) Episodic clustering helps whenever there is structure in the representations. Especially for DINO in Habitat performance drops significantly, if episodic clustering is removed. This can also be seen in VizDoom (left panels) where episodic clustering helps both DINO and random features. For Habitat (right panels) with random features, episodic clustering has no large effect since the random features are not expressive enough for the complex observations.
181
+
182
+ ![](images/19635bce80a881e86e2491cd47eb7f4f30967342be9254eda8fcc34cc3350744.jpg)
183
+ (b)
184
+
185
+ table. Hence the intrinsic reward is defined over fewer cluster centers. We see in Figure 4(a) that up to $\kappa = 0.5$ performance remains comparable.
186
+
187
+ Episodic clustering is effective with good representations. We plot visitation counts and extrinsic reward with and without episodic clustering in Figure 4(b). We see that episodic clustering helps whenever the underlying representations are structured. This can be seen for Habitat (right panels) with DINO features where performance drops dramatically without episodic clustering (upper right). Even for VizDoom (left panels), episodic clustering helps both with DINO and random features, which shows that there is hidden structure to exploit in the comparatively simpler observations. For Habitat with random features, episodic clustering has no big effect since the random features are probably not expressive enough for the complex observations. We see this in Figure 9 (in the Appendix) where the random features are not clustered effectively compared to the DINO features. Overall, during our tests we found that $10\%$ of the total number of steps in an episode is a good number of clusters for the Gaussian mixture model.
188
+
189
+ # 4.4. Clustering is Robust to Environmental Noise
190
+
191
+ To the test the effect of random noise on exploration like in the noisy-TV problem (Pathak et al., 2017), we adopt the experimental setup of Saade et al. (2023), where a frame of random noise is concatenated to the current observation. Note that for each step the different frame with random
192
+
193
+ noise is sampled. We show an example of the observation with the concatenated noise in Figure 6.
194
+
195
+ Random noise does not affect exploration for clustering based methods. We rerun the Habitat Apartment-v0 with noisy observations for both our method and RECODE in Figure 7. We show that our method is unaffected by random noise in the observations. Interestingly, performance slightly increases with noisy observations for both our method and RECODE. When looking at the number of cluster entries, we observe that when using observations with random noise the amount of clusters in the cluster table is lower than without the random noise. We therefore suspect that the random noise has a regularising effect on the clustering.
196
+
197
+ We also show the saved cluster centers in the cluster table with noisy observations in Figure 5. The quality of the clustering seems unaffected since similar observations are still aggregated correctly despite the random noise.
198
+
199
+ # 5. Conclusion
200
+
201
+ The starting point of our work is the insight that the magnitude of pixel-changes can be large in 3-D environments, but usually lacks in saliency. This is problematic in exploration with sparse rewards, since the agent is not able to distinguish between important and unimportant changes in the observations. To mitigate this problem, we proposed a method for state aggregation based on episodic and global clustering of pre-trained representations. We have shown that pre-trained
202
+
203
+ ![](images/ee90f5c32848398ffa940d5001ef0aa3de0302868a0733725007d7bfd9798f57.jpg)
204
+ Figure 5. Visualization of DINO clusters for observations with random noise: We plot different samples from the cluster table for the noisy observations in Habitat. Each image represents the mean image of an episodic cluster that was aggregated to the cluster table. The clustering happens on the 384-dimensional embedding. Even with the concatenated random noise the embeddings are still clustered sensibly.
205
+
206
+ ![](images/f2b57e274fdd605445cd794328d014ca36c9f7d2b642376da10a131ce06b5101.jpg)
207
+
208
+ ![](images/cb39cd56e0449d4ed27db2ff3b267a1705d3d81826ea4517c27ee224b8e5eb8b.jpg)
209
+
210
+ ![](images/755848857070c5b2f93588ab8be02470b793c799beb31f5d1ad39226ec6daef8.jpg)
211
+
212
+ ![](images/f8345efee108c973dc4bc127ce9840cf88cc5a2482135f888c61a42365ed1212.jpg)
213
+
214
+ ![](images/679e774f71df704adf093ff59f4ec56ae307a9359d5abf4491e4680f3d86cd3c.jpg)
215
+
216
+ ![](images/ae194234912044ac68256f142f0c2a7420f29378f9b575d74ff94983f91f3105.jpg)
217
+ Observation with Random Noise
218
+ Figure 6. We concatenate random noise to the observations: To test the robustness of our method to observations with random noise, i.e., the noisy TV problem, we perform the same experiment as Saade et al. (2023) and concatenate a frame with random noise that changes after every step to the observation.
219
+
220
+ ![](images/205866e724de3e50f1a441135d8160c71a9cca5722d3c1052fbc7f67c729a204.jpg)
221
+ Apartment v0 - Exploration with noisy observations
222
+ Figure 7. Our method is robust to random noise in the observations: We see that our method is robust to random noise in the observations. As a sanity check we also evaluate RECODE on noisy observations and confirm the results from Saade et al. (2023). Suprprisingly, for both methods the performance increases when adding random noise. We suspect the random noise has a regularising effect on the clustering.
223
+
224
+ representations and also random features can be leveraged effectively in environments with complex observations. We ablated different components of our method: we show that the cosine similarity threshold $\kappa$ is vital to control the granularity of the clusters in the cluster table. We notice that performance degenerates if the number of clusters in the cluster table is too high, since the pseudo-counts become too sparse and the intrinsic reward too noisy. Furthermore, we found out that episodic clustering leverages the priors in the representations in order to produce better pseudo-count estimates, thus playing a crucial role for complex observations since the counts for the corresponding representations are aggregated more effectively.
225
+
226
+ Limitations and future work. So far, we tested our method on singleton MDP's. We believe our method can also be extended to contextual MDPs, possibly by counting states separately on an episodic level. Overall, our method sheds light onto the problem of transition saliency in 3-D environments which is ubiquitous in exploration with sparse-rewards. In this sense, an interesting direction for future work could be investigating whether mitigating the transition saliency problem can enhance the effectiveness of prediction-error-based methods in 3-D enviroments. Hypothetically, clustering representations and using them as fixed targets for prediction-error-based methods should result in a more salient intrinsic reward. Future research should continue investigating which kinds of representations contain the best priors for exploration with sparse rewards. Potentially, multi-modal generative models could be used to learn representations that not only capture visual invariances, but also environmental dynamics.
227
+
228
+ # Impact Statement
229
+
230
+ This paper presents work whose goal is to advance the field of Machine Learning. There are many potential societal consequences of our work, none which we feel must be specifically highlighted here.
231
+
232
+ # References
233
+
234
+ Bellemare, M. G., Srinivasan, S., Ostrovski, G., Schaul, T., Saxton, D., and Munos, R. Unifying Count-Based Exploration and Intrinsic Motivation. arXiv e-prints, art. arXiv:1606.01868, June 2016. doi: 10.48550/arXiv.1606.01868.
235
+ Burda, Y., Edwards, H., Storkey, A., and Klimov, O. Exploration by Random Network Distillation. arXiv e-prints, art. arXiv:1810.12894, October 2018. doi: 10.48550/arXiv.1810.12894.
236
+ Caron, M., Touvron, H., Misra, I., Jégou, H., Mairal, J., Bojanowski, P., and Joulin, A. Emerging Properties in Self-Supervised Vision Transformers. arXiv e-prints, art. arXiv:2104.14294, April 2021. doi: 10.48550/arXiv.2104.14294.
237
+ Ecoffet, A., Huizinga, J., Lehman, J., Stanley, K. O., and Clune, J. First return, then explore. nat, 590(7847):580-586, February 2021. doi: 10.1038/s41586-020-03157-9.
238
+ Espeholt, L., Soyer, H., Munos, R., Simonyan, K., Mnih, V., Ward, T., Doron, Y., Firoiu, V., Harley, T., Dunning, I., Legg, S., and Kavukcuoglu, K. IMPALA: Scalable Distributed Deep-RL with Importance Weighted Actor-Learner Architectures. arXiv e-prints, art. arXiv:1802.01561, February 2018. doi: 10.48550/arXiv.1802.01561.
239
+ Grill, J.-B., Strub, F., Altché, F., Tallec, C., Richemond, P. H., Buchatskaya, E., Doersch, C., Avila Pires, B., Guo, Z. D., Gheshlaghi Azar, M., Piot, B., Kavukcuoglu, K., Munos, R., and Valko, M. Bootstrap your own latent: A new approach to self-supervised Learning. arXiv e-prints, art. arXiv:2006.07733, June 2020. doi: 10.48550/arXiv.2006.07733.
240
+ Guo, Z. D., Thakoor, S., Pislar, M., Avila Pires, B., Altché, F., Tallec, C., Saade, A., Calandriello, D., Grill, J.-B., Tang, Y., Valko, M., Munos, R., Gheshlaghi Azar, M., and Piot, B. BYOL-Explore: Exploration by Bootstrapped Prediction. arXiv e-prints, art. arXiv:2206.08332, June 2022. doi: 10.48550/arXiv.2206.08332.
241
+ Henaff, M., Raileanu, R., Jiang, M., and Rocktäschel, T. Exploration via Elliptical Episodic Bonuses. arXiv eprints, art. arXiv:2210.05805, October 2022. doi: 10.48550/arXiv.2210.05805.
242
+ Henaff, M., Jiang, M., and Raileanu, R. A Study of Global and Episodic Bonuses for Exploration in Contextual MDPs. arXiv e-prints, art. arXiv:2306.03236, June 2023. doi: 10.48550/arXiv.2306.03236.
243
+ Kempka, M., Wydmuch, M., Runc, G., Toczek, J., and Jaskowski, W. ViZDoom: A Doom-based AI research
244
+
245
+ platform for visual reinforcement learning. In IEEE Conference on Computational Intelligence and Games, pp. 341-348, Santorini, Greece, Sep 2016. IEEE. doi: 10.1109/CIG.2016.7860433. The Best Paper Award.
246
+ Ma, X., Zhao, S.-Y., and Li, W.-J. Clustered Reinforcement Learning. arXiv e-prints, art. arXiv:1906.02457, June 2019. doi: 10.48550/arXiv.1906.02457.
247
+ Oquab, M., Darcet, T., Moutakanni, T., Vo, H., Szafraniec, M., Khalidov, V., Fernandez, P., Haziza, D., Massa, F., El-Nouby, A., Assran, M., Ballas, N., Galuba, W., Howes, R., Huang, P.-Y., Li, S.-W., Misra, I., Rabbat, M., Sharma, V., Synnaeve, G., Xu, H., Jegou, H., Mairal, J., Labatut, P., Joulin, A., and Bojanowski, P. DINOV2: Learning Robust Visual Features without Supervision. arXiv eprints, art. arXiv:2304.07193, April 2023. doi: 10.48550/arXiv.2304.07193.
248
+ Ostrovski, G., Bellemare, M. G., van den Oord, A., and Munos, R. Count-Based Exploration with Neural Density Models. arXiv e-prints, art. arXiv:1703.01310, March 2017. doi: 10.48550/arXiv.1703.01310.
249
+ Parisi, S., Dean, V., Pathak, D., and Gupta, A. Interesting object, curious agent: Learning task-agnostic exploration. In Beygelzimer, A., Dauphin, Y., Liang, P., and Vaughan, J. W. (eds.), Advances in Neural Information Processing Systems, 2021. URL https://openreview.net/forum?id=knKJgksd7kA.
250
+ Pathak, D., Agrawal, P., Efros, A. A., and Darrell, T. Curiosity-driven Exploration by Self-supervised Prediction. arXiv e-prints, art. arXiv:1705.05363, May 2017. doi: 10.48550/arXiv.1705.05363.
251
+ Puig, X., Undersander, E., Szot, A., Cote, M. D., Partsey, R., Yang, J., Desai, R., Clegg, A. W., Hlavac, M., Min, T., Gervet, T., Vondrus, V., Berges, V.-P., Turner, J., Maksymets, O., Kira, Z., Kalakrishnan, M., Malik, J., Chaplot, D. S., Jain, U., Batra, D., Rai, A., and Mottaghi, R. Habitat 3.0: A co-habitat for humans, avatars and robots, 2023.
252
+ Puigdomenech Badia, A., Sprechmann, P., Vitvitskyi, A., Guo, D., Piot, B., Kapturowski, S., Tieleman, O., Arjovsky, M., Pritzel, A., Bolt, A., and Blundell, C. Never Give Up: Learning Directed Exploration Strategies. arXiv e-prints, art. arXiv:2002.06038, February 2020. doi: 10.48550/arXiv.2002.06038.
253
+ Raileanu, R. and Rocktäschel, T. RIDE: Rewarding Impact-Driven Exploration for Procedurally-Generated Environments. arXiv e-prints, art. arXiv:2002.12292, February 2020. doi: 10.48550/arXiv.2002.12292.
254
+
255
+ Saade, A., Kapturowski, S., Calandriello, D., Blundell, C., Sprechmann, P., Sarra, L., Groth, O., Valko, M., and Piot, B. Unlocking the Power of Representations in Long-term Novelty-based Exploration. arXiv e-prints, art. arXiv:2305.01521, May 2023. doi: 10.48550/arXiv.2305.01521.
256
+ Savva, M., Kadian, A., Maksymets, O., Zhao, Y., Wijmans, E., Jain, B., Straub, J., Liu, J., Koltun, V., Malik, J., Parikh, D., and Batra, D. Habitat: A Platform for Embodied AI Research. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), 2019.
257
+ Schulman, J., Wolski, F., Dhariwal, P., Radford, A., and Klimov, O. Proximal Policy Optimization Algorithms. arXiv e-prints, art. arXiv:1707.06347, July 2017. doi: 10.48550/arXiv.1707.06347.
258
+ Straub, J., Whelan, T., Ma, L., Chen, Y., Wijmans, E., Green, S., Engel, J. J., Mur-Artal, R., Ren, C., Verma, S., Clarkson, A., Yan, M., Budge, B., Yan, Y., Pan, X., Yon, J., Zou, Y., Leon, K., Carter, N., Briales, J., Gillingham, T., Mueggler, E., Pesqueira, L., Savva, M., Batra, D., Strasdat, H. M., Nardi, R. D., Goesele, M., Lovegrove, S., and Newcombe, R. The Replica dataset: A digital replica of indoor spaces. arXiv preprint arXiv:1906.05797, 2019.
259
+ Strehl, A. L. and Littman, M. L. An analysis of model-based interval estimation for markov decision processes. Journal of Computer and System Sciences, 74(8):1309-1331, 2008. ISSN 0022-0000. doi: https://doi.org/10.1016/j.jcss.2007.08.009. URL https://www.sciencedirect.com/science/article/pii/S0022000008000767. Learning Theory 2005.
260
+ Szot, A., Clegg, A., Undersander, E., Wijmans, E., Zhao, Y., Turner, J., Maestre, N., Mukadam, M., Chaplot, D., Maksymets, O., Gokaslan, A., Vondrus, V., Dharur, S., Meier, F., Galuba, W., Chang, A., Kira, Z., Koltun, V., Malik, J., Savva, M., and Batra, D. Habitat 2.0: Training home assistants to rearrange their habitat. In Advances in Neural Information Processing Systems (NeurIPS), 2021.
261
+ Tang, H., Houthooft, R., Foote, D., Stooke, A., Chen, X., Duan, Y., Schulman, J., De Turck, F., and Abbeel, P. #Exploration: A Study of Count-Based Exploration for Deep Reinforcement Learning. arXiv e-prints, art. arXiv:1611.04717, November 2016. doi: 10.48550/arXiv.1611.04717.
262
+ Wagner, S. S., Arndt, P., Robine, J., and Harmeling, S. Cyclophobic Reinforcement Learning. arXiv e-prints, art. arXiv:2308.15911, August 2023. doi: 10.48550/arXiv.2308.15911.
263
+
264
+ Zhang, T., Xu, H., Wang, X., Wu, Y., Keutzer, K., Gonzalez, J. E., and Tian, Y. Noveld: A simple yet effective exploration criterion. In Ranzato, M., Beygelzimer, A., Dauphin, Y., Liang, P., and Vaughan, J. W. (eds.), Advances in Neural Information Processing Systems, volume 34, pp. 25217-25230. Curran Associates, Inc., 2021. URL https://proceedings.neurips.cc/paper_files/paper/2021/file/d428d070622e0f4363fceae11f4a3576-Paper.pdf.
265
+
266
+ A. Algorithm
267
+ ```txt
268
+ Hyperparameters
269
+ kappa $= 0.8$ # Cosine similarity threshold
270
+ M $= 250$ # Number of episodic clusters
271
+ # Global variables
272
+ self.gmm $=$ GaussianMixture(n_components $\equiv$ M,reg_covar $\coloneqq$ 1e-6,covariance_type $\equiv$ "full", random_state $\equiv$ 1,warm_start $\equiv$ False)
273
+ self.cluster_table $=$ [np.zeros(embedding_size),0] # (Equation 2)
274
+ def update_cluster_table(self,embeddings,rewards):
275
+ # Step 1 (Build episodic clusters)
276
+ self.gmm.fit(embeddings)#Fit GMM (Equation 1)
277
+ m_prime $=$ self.gmm.predict(embeddings)#Get cluster labels
278
+ # Assign embeddings to episodic clusters
279
+ cluster_dict $=$ {
280
+ for index,embedding in enumerate(embeddings): if m_prime[index] not in cluster_dict: cluster_dict[m_prime[index]] $=$ [] cluster_dict[m_prime[index]].append([embedding])
281
+ # Step 2 (Updating the global cluster table)
282
+ for m in cluster_dict:
283
+ episodic_cluster $=$ np.stack(cluster_dict[m]) lambda_ep $=$ episodic_cluster.shape[0]
284
+ # Calculate episodic cluster center
285
+ mu_ep $=$ np.mean(np.stack(episodic_cluster(:,0)],0)# (Equation 1) mu_globals $=$ np.stack(self.cluster_table(:,0))
286
+ # Step 2.1 (Assigning episodic cluster center(s) to global cluster centers) distances $=$ cosine_similarity(np-expand_dims(mu_ep,0),mu_globals) k_prime $=$ np.argmax(distance)
287
+ d_prime $=$ np.max(distance)
288
+ # Step 2.2 (Calculating intrinsic rewards)
289
+ iverson_bracket_count $= 0$
290
+ max_lambda_global $=$ self.cluster_table[k_prime,1]
291
+ lambda_global $= 0$ if d_prime $<$ kappa else max_lambda_global
292
+ for index,_in enumerate(embeddings): # (Equation 3) if m_prime[index] $= =$ m: iverson_bracket_count $+ = 1$ rho $=$ lambda_global $^+$ iverson_bracket_count
293
+ # (Equation 4) ir $= 1 / \mathrm{np}$ .sqrt(rho) rewards[index] $+ = 0.1*\mathrm{ir}$ # Scale intrinsic reward with O.1
294
+ # Step 2.3 (Growing the cluster table)
295
+ if d_prime $<$ kappa: self.cluster_table $=$ np.vstack((self.cluster_table,[mu_ep, lambda_ep])) else: # Step 2.4 (Updating the global pseudo counts) self.cluster_table[k_prime,1] $+ =$ lambda_ep # (Equation 5)
296
+ return rewards # Step 3
297
+ ```
298
+
299
+ # B. Visualizations
300
+
301
+ # B.1. What do the clusters look like?
302
+
303
+ ![](images/10ae410116f0cf9309f96da388b706996a99f33fba76bbc3420dc872dc63e3fc.jpg)
304
+
305
+ ![](images/31043a1371d950995e8f78988959a91511d2145bf03bd38867219111d83245e9.jpg)
306
+
307
+ ![](images/db1811065ef978226f6c7637853812178136570f586b52553e22a498beaddcc8.jpg)
308
+
309
+ ![](images/84bc307b0854d13ea1df98f66472d1fd8cf96998dce7f3c942ab8a9a770c1d14.jpg)
310
+
311
+ ![](images/90a59517c9a878ac82261bd924725af34fa7fbf7e268c09df1fc81ddec70d646.jpg)
312
+
313
+ ![](images/addf01a33fecb769f9cbae8195d1641d8e718dd12c315b745c69a7cddb32c9a8.jpg)
314
+
315
+ ![](images/4c9c39bbd8c150b9d548a2fef0c6b49fbac16f0808e79ce72af780ff94d99355.jpg)
316
+ Figure 8. Visualization of DINO clusters for VizDoom and Habitat: We plot different samples from the cluster table for VizDoom. Each image represents the mean image of an episodic cluster that was aggregated to the cluster table. The clustering happens on the 384-dimensional embedding. We can see that observations are aggregated sensibly and account for similar states, where having a separate pseudo-count would not be beneficial. By looking at the counts and appearances we can also see that the clusters are not too granular, since the counts are not too low and the same cluster center is encountered multiple times across different episodes.
317
+
318
+ ![](images/e967e712f5f792897bcff609e0bfcc5b6375ea09247f37e5443e1d0be3cb55ef.jpg)
319
+
320
+ ![](images/c747ce61844fd8b3708f1998d980ced86869e5e68375efadf6340fbaf25d0f04.jpg)
321
+
322
+ ![](images/feb6d4447c0f5a5c8d10c3a1635560e4b76a8a6968ba65671720ddad70bede49.jpg)
323
+
324
+ ![](images/bbc115ee26f74b44dfb73c6cbe773678cc6b862473d0fdd82c36c1345ab118c4.jpg)
325
+
326
+ ![](images/4eff8b389230c2f05d7a36b02517acf3b678fbcd6cc081a443384f9e5ad0d273.jpg)
327
+
328
+ We visualize some of the clusters centers stored in the global cluster table, which are technically episodic clusters centers that were aggregated to the global cluster table. We show the mean image of each cluster center in Figure 8 for VizDoom and for Habitat. Note that the actual clustering was performed with the 384-dimensional DINO embedding, but we show the images for better interpretability. We can see that the clusters are aggregated sensibly and account for similar states, where having a separate pseudo-count would not be beneficial. Especially for Habitat, the complex observations are aggregated to similar states, which is a testament to the effectiveness of the DINO features.
329
+
330
+ # B.2. Clustering DINO vs Random Features
331
+
332
+ We compare the clusters from DINO (magenta) and random features (cyan) in Figure 9. We can see that the episodic clusters from DINO and random features are fundamentally different. Overall, the DINO cluster centers are much less granular compared to the random features. This can be seen by the fact that the cluster mean images for the random features are free from distortions. Moreover, some cluster centers for the random features are very similar to each other, which is harder to find for the DINO features. From the counts we can see that random features still are able to aggregate counts, however very similar observations may not be aggregated as well as with the DINO clusters. This can be seen by the fact that some counts are unusually high for the random features indicating that some episodic clusters may be assigned erroneously to the same global cluster center. We were not able to find such high counts for the DINO features. Overall, we see that episodic clustering together with global clustering is effective for both DINO and random features, since episodic cluster centers are matched multiple times throughout learning to the global cluster centers, as can be seen by the number of appearances "Apps" in Figure 9.
333
+
334
+ ![](images/d3de5e5aa69eae19ff338728d2b1f25b408c31dc2a3a822e904adcc67fcf4f0a.jpg)
335
+ Counts $= 267$ Apps $= 60$
336
+
337
+ ![](images/c317dfe98f2516a9caea25c99d27daf0f523b4eb626eb4ee4f3f858d7a441e95.jpg)
338
+ Counts $= 686$ Apps $= 128$
339
+
340
+ ![](images/0223e86808b04ccabd9333e83ed0ffe48e1fad1c65fc23bbf41cd3c93193f8b8.jpg)
341
+ Counts $= 31481$ App $\mathrm{s} = 4014$
342
+
343
+ ![](images/57f158d25b898753dcfeeb2410a00e495fbc565440e020706b3447d0f4cefff8.jpg)
344
+ Counts $= 1949$ Apps $= 333$
345
+
346
+ ![](images/d6cee48ff9dc400b7bfdf115e525ad7dab2371a83eb1dc4b107c2344886802af.jpg)
347
+ Counts $= 2992$ Apps $= 483$
348
+
349
+ ![](images/cb963c1d56781ce07b00bed01c3df5699e7376f1ae02cb74b9c047263389f22c.jpg)
350
+ Counts $= 27886$ Apps $= 4909$
351
+
352
+ ![](images/0e87b2fdb9d05820ac903d942ccc6f663805b2c030cd6d0cf8b4ece6f7713532.jpg)
353
+ Counts $= 53$ Apps $= 9$
354
+
355
+ ![](images/732ec2224ba6a7e3d9d793feded364f358dab7a893cb90d70c4024a5150e2a7e.jpg)
356
+ Counts $= 620$ Apps $= 60$
357
+
358
+ ![](images/1dde44c6d56210954e15042aae084e02e6dc985367f9d0754650cb4643d1eb29.jpg)
359
+ Counts $= 814$ Apps $= 84$
360
+
361
+ ![](images/11ee704c1176c1a29c88831b320dba22e38bf16db34d498bbdd4b681d7010c52.jpg)
362
+ Figure 9. Comparison of DINO clusters and Random clusters: From the observations in the Habitat environment we plot different samples from the cluster table for DINO (magenta) and random features (cyan). The episodic clusters from DINO and random features are fundamentally different. While the DINO clusters aggregate more dissimilar observations that share common features, the random clusters are more granular seen by the fact that the cluster mean images are free from distortions. From the counts we can see that random features still are able to aggregate counts, however very similar observations may not be aggregated as well as with the DINO clusters.
363
+
364
+ ![](images/24ae0931eccf568954fceb5fb66a9f6ab37dfb6f1b807037e3a42f7b34bc09a6.jpg)
365
+ Counts $= 5551$ Apps $= 701$
366
+ Counts $= 1199$ Apps $= 186$
367
+
368
+ ![](images/44e1d9837f3bcbf773d731fe5901caba6f5848033073d06c5c7b7a9dd84e445d.jpg)
369
+ Counts $= 1366$ Apps $= 781$
370
+
371
+ # C. Further Ablations
372
+
373
+ # C.1. Comparing DINO model size
374
+
375
+ ![](images/a3cc3c9e4cf40f93ff4e367ca8015223fa8ddf2f2ef35065279262de64b2d2e7.jpg)
376
+ Figure 10. Comparing different model sizes for DINO: We test whether a larger model size for DINO improves performance for Habitat. Our findings reveal that a larger model size does not improve performance by large margin. We argue that the model size is already large enough to capture the priors in the observations for clustering. This is also indicated by the rather small performance gap between DINOv2 small and DINOv2 large (Caron et al., 2021).
377
+
378
+ In our experiments we use DINOv2 small (Caron et al., 2021) for the pre-trained representations. We test whether a larger model size for DINO improves performance for Habitat. We plot the visitation counts for the "small" and "large" model sizes in Figure 11. Our findings reveal that a larger model size does not improve performance by large margin. The model
379
+
380
+ size is likely already large enough to capture the priors in the observations for clustering. This is also indicated by the rather small performance gap between DINOv2 small and DINOv2 large (Caron et al., 2021). However, inference time does increase substantially with larger model sizes, which is why we use DINOv2 small for our experiments.
381
+
382
+ # C.2. Cluster Counts with and without episodic clustering
383
+
384
+ ![](images/92c4f8efaeffae7ac861950fe3d743d85f832ecafc595452198cce216774289b.jpg)
385
+ Figure 11. Without episodic clustering the number of cluster centers is higher: We plot the number of cluster centers in the cluster table with and without episodic clustering. We see that without episodic clustering the number of cluster centers is higher. This is because the episodic clusters are not aggregated as well as with episodic clustering to the cluster table.
386
+
387
+ We also investigate the effect of episodic clustering on the number of cluster centers in the cluster table. We plot the number of cluster centers in the cluster table with and without episodic clustering in Figure 11. We see that without episodic clustering the number of cluster centers is higher. This is because the episodic clusters are not aggregated as well as with episodic clustering to the cluster table. This means that not performing episodic clustering leads to a more granular cluster table, since the cluster centers in this case only represent a single embedding for every step.
388
+
389
+ # C.3. Progression of the cluster table throughout learning
390
+
391
+ To give insight into how exploration progresses with episodic and global clustering we show the progression of the added cluster centers to the cluster table during training in Figure ??. To locate the cluster centers within the VizDoom environment we additionally track the position of each observation and calculate the mean position of all observations in the cluster as the position for the cluster center. For visualization purposes we show the progression of the cluster table for $\kappa = 0.5$
392
+
393
+ Already after 50K steps of training the first 4 are represented in the cluster table. At 500K steps almost all rooms are represented in the cluster table. This means that the intrinsic reward will be calculated from these cluster centers as reference points, effectively abstracting the state space. After convergence, the number of cluster centers barely changes since an optimal policy has been found.
394
+
395
+ ![](images/7c3a8e5e1851730ca2e3eb780c49d5128889c69c7d451adee9ccc1fefe7068ec.jpg)
396
+ 50k steps
397
+
398
+ ![](images/c8526b383de4536d491dd7aa4b8936b3f4df67dd6746e55f29cca0aa320a7eee.jpg)
399
+ 250k steps
400
+
401
+ ![](images/10085535a2470c59a81123979573acfbf18d519acc00db8343d91511ba870d3d.jpg)
402
+ 500k steps
403
+
404
+ ![](images/84cb03a49e1699b9c79fe948a37bb93f042c291bd7d736f64f26d3ebfc262ccf.jpg)
405
+ 1M steps
406
+
407
+ ![](images/bda1e249449641b897d89eb51f87763a85ace7f5831471264f75d0e5b746f19c.jpg)
408
+ 1.6M steps (before convergence)
409
+
410
+ ![](images/0fec7f55d3446ef6abb6f26e7ca676b0dc37878c5d6f866d3ea48ea38f44e3cd.jpg)
411
+ 5M steps
412
+ Figure 12. Cluster centers emerge in previously unexplored areas: We visualize the progression of the cluster table throughout learning for VizDoom. At the beginning of training the cluster table is empty, but as the agent explores the environment, cluster centers emerge in previously unexplored areas. Already at 50k steps the cluster table starts to fill up with cluster centers, mapping out the first 5 rooms of the environment. At convergence for all rooms there is at least a cluster center in the cluster table. After convergence the cluster table is stable since the optimal policy has been found.
413
+
414
+ # D. Environments
415
+
416
+ # D.1. VizDoom Environment Details
417
+
418
+ ![](images/78379e4989b3587069856dab255b3abf4bcdff8bff1df1e6708b000659a14637.jpg)
419
+
420
+ ![](images/7940ebc45ee0025f79d11bb78d4ac88d59d034238a6b401c05e1ad4805d94887.jpg)
421
+
422
+ ![](images/654ba6cdae54a73923594549b71b3072fbb2402f1efe300e5094cdbe7b8678dc.jpg)
423
+
424
+ ![](images/45474a4934cc7a617b2a9295061ee86b9889d2d59ecb7827b78a8fca409e9b3e.jpg)
425
+ Figure 13. VizDoom: The VizDoom environment is a 3-D environment based on the 3-D game Doom. The observations are rooms with different textures, where some textures even move. The agent starts in the room on the left and has to reach the armor in the room on the right. There are two configurations for this enviroments: "Sparse" and "VerySparse", which differ in the starting position of the agent.
426
+
427
+ ![](images/2d3ed71d430f3bfd86a7d0fbf2ff4f8f256d14c8a4e246f826d9954831c8611b.jpg)
428
+
429
+ ![](images/0000ac71550c6c4dd132c886438f3982607fd68adc2f3ce541242cf844ec7f7d.jpg)
430
+
431
+ ![](images/61c1309a6ebc8e90cf7ecd6bcf3ced5e79906bd2bd40e5f770229bd70261e25e.jpg)
432
+
433
+ We use the "MyWayHome" environment from VizDoom (Kempka et al., 2016) in both its sparse reward configurations "Sparse" and "VerySparse". In this environment the agent has to reach a piece of armor located in the farthest accessible room of the environment. The configurations differ in the starting position of the agent, one being further away from the goal than the other. In "Sparse", 270 steps away from goal and in "VerySparse", 340 steps away from goal. The agent has an action space of Wait, Left, Right, Forward and an episode has a length of 2100 steps. We use a standard frame skip of 4. The agent receives a reward of $+1$ when it reaches the armor and a $-0.0001$ penalty for every timestep.
434
+
435
+ # D.1.1. HYPERPARAMETERS-VIZDOOM
436
+
437
+ For VizDoom, we show the hyperparameters for PPO in Table 1 and the hyperparameters for the episodic clustering in Table 2. Additionally, we also show the hyperparameters for RECODE in Table 3. We use the same hyperparameters for both "Sparse" and "VerySparse" configurations. Note that in Table 3 we tried different sizes for the RECODE memory as we found this had the most predictable effect on performance, however for VerySparse even with different memory sizes we were not able to get RECODE to work.
438
+
439
+ <table><tr><td>Hyperparameter</td><td>Value</td></tr><tr><td>Learning rate</td><td>0.0001</td></tr><tr><td>Batch size</td><td>256</td></tr><tr><td>Epochs</td><td>4</td></tr><tr><td>Gamma</td><td>0.99</td></tr><tr><td>Clip epsilon</td><td>0.1</td></tr><tr><td>Entropy coefficient</td><td>0.005</td></tr><tr><td>Value function coefficient</td><td>0.5</td></tr><tr><td>Workers</td><td>32</td></tr><tr><td>Recurrence</td><td>64</td></tr><tr><td>Intrinsic Reward Scaling</td><td>0.1</td></tr></table>
440
+
441
+ Table 1. PPO Hyperparameters for VizDoom
442
+
443
+ <table><tr><td>Parameter</td><td>Value</td></tr><tr><td>Cosine Similarity Threshold κ (DINO)</td><td>0.8</td></tr><tr><td>Cosine Similarity Threshold κ (Random)</td><td>0.8</td></tr><tr><td>Number of Clusters M</td><td>250</td></tr></table>
444
+
445
+ Table 2. Cosine Similarity and Episodic Clustering Parameters
446
+
447
+ <table><tr><td>Parameter</td><td>Value</td></tr><tr><td>RECODE memory size</td><td>{100, 700, 1 × 104}</td></tr><tr><td>RECODE discount γ</td><td>0.999</td></tr><tr><td>RECODE insertion probability η</td><td>0.05</td></tr><tr><td>RECODE relative tolerance κ</td><td>0.2</td></tr><tr><td>RECODE reward constant c</td><td>0.01</td></tr><tr><td>RECODE decay rate τ</td><td>0.9999</td></tr><tr><td>RECODE neighbors k</td><td>20</td></tr></table>
448
+
449
+ Table 3. RECODE Parameters VizDoom - Bold value is used for experiments
450
+
451
+ # D.2. Habitat Environment Details
452
+
453
+ ![](images/6ebaf667fbc0d1bac516c084f793d2aa00d7c96c07d6c4596f02eee1ff19ab97.jpg)
454
+
455
+ ![](images/3d4a8da5be2bedbd67fe6c6f9b1371d4c6993b258b4f313119c6c9628daeff53.jpg)
456
+
457
+ ![](images/a64bff32157d99bea23f4ed22f974d82ee568d334f9a91cb96eb364a89a8d183.jpg)
458
+
459
+ ![](images/a369d5ce923c287d9fb660f60600201b2da4355938dc2fc427cdfb6b942d77e9.jpg)
460
+ Figure 14. Habitat (Apartment-0): The Habitat environment is a real world 3-D environment with complex observations. The observations are real world scenes of apartments, hotels and office rooms. The observations are very complex and thus we expect the pre-trained representations to be more effective than random features.
461
+
462
+ ![](images/2131e3e7ed739e5080fd2df219c6d5cedfa2d34ac1d9c13944d497d415530709.jpg)
463
+
464
+ ![](images/d25c5625b91207bc2a3b57a2d8c92b5f7b757347cb6cc6d56740c4f6f26a3dbd.jpg)
465
+
466
+ ![](images/7a8e68958e37fbd7115b07bc7543e65f0f1e370598df8c3d549d074e2b9b1e88.jpg)
467
+
468
+ Habitat-Replica (Savva et al., 2019; Szot et al., 2021; Puig et al., 2023) is a framework for exploration in real world 3-D scenes. The Habitat-Lab API is made to be used with different datasets. We use the Replica dataset (Straub et al., 2019) as in Parisi et al. (2021), where we train on the "Apartment-0" environment, which is the biggest room in the Replica dataset. The agent has an action space of Forward by 0.25 coordinate points, Left $10^{\circ}$ and Right $10^{\circ}$ and the episode has a length of 500 steps. The agent is rewarded with intrinsic reward only, where the count of visited locations is the performance metric.
469
+
470
+ # D.2.1. CALCULATING AGENT POSITION FOR VISITATION COUNTS
471
+
472
+ We calculate the position of the agent for the visitation counts as follows:
473
+
474
+ $$
475
+ \text {p o s i t i o n} = \text {r o u n d} \left(\frac {\text {r o u n d (p o s i t i o n , 2)} \times 2 0}{2 0}\right).
476
+ $$
477
+
478
+ This is directly taken from (Parisi et al., 2021)'s experiments. The position is a tuple $(x,y,z)$ . We round the position to two decimal places and then multiply it by 20. This is done to get a more granular position, since the agent moves by 0.25 coordinate points. Finally we round the position to the nearest integer, which is the position we use for the visitation counts. The visitations counts are then simply counted by aggregating them in a Python dictionary.
479
+
480
+ # D.2.2. HYPERPARAMETERS
481
+
482
+ We show the hyperparameters for PPO in Table 4 and the hyperparameters for the episodic clustering in Table 5. Again, we also show the hyperparameters for RECODE in Table 6. For our method with random features we had to increase $\kappa = 0.9$ (compared to $\kappa = 0.8$ in VizDoom) for adequate performance. For the DINO features $\kappa = 0.8$ works well for both environments.
483
+
484
+ <table><tr><td>Hyperparameter</td><td>Value</td></tr><tr><td>Learning rate</td><td>0.0001</td></tr><tr><td>Batch size</td><td>256</td></tr><tr><td>Epochs</td><td>4</td></tr><tr><td>Gamma</td><td>0.99</td></tr><tr><td>Clip epsilon</td><td>0.1</td></tr><tr><td>Entropy coefficient</td><td>0.005</td></tr><tr><td>Value function coefficient</td><td>0.5</td></tr><tr><td>Workers</td><td>1</td></tr><tr><td>Recurrence</td><td>64</td></tr><tr><td>Intrinsic Reward Scaling</td><td>0.1</td></tr></table>
485
+
486
+ Table 4. PPO Hyperparameters for Habitat
487
+
488
+ <table><tr><td>Parameter</td><td>Value</td></tr><tr><td>Cosine Similarity Threshold κ (DINO)</td><td>0.8</td></tr><tr><td>Cosine Similarity Threshold κ (Random)</td><td>0.9</td></tr><tr><td>Number of Clusters M</td><td>30</td></tr></table>
489
+
490
+ Table 5. Cosine Similarity and Episodic Clustering Parameters
491
+
492
+ <table><tr><td>Parameter</td><td>Value</td></tr><tr><td>RECODE memory size</td><td>{100, 700, 1 × 104, 5 × 104}</td></tr><tr><td>RECODE discount γ</td><td>0.999</td></tr><tr><td>RECODE insertion probability η</td><td>0.05</td></tr><tr><td>RECODE relative tolerance κ</td><td>0.2</td></tr><tr><td>RECODE reward constant c</td><td>0.01</td></tr><tr><td>RECODE decay rate τ</td><td>0.9999</td></tr><tr><td>RECODE neighbors k</td><td>20</td></tr></table>
493
+
494
+ Table 6. RECODE Parameters Habitat - Bold value is used for the experiments.
495
+
496
+ # E. Implementation Details
497
+
498
+ # E.1. Observation encoding and network architecture.
499
+
500
+ ![](images/28ea395e81debb149722f9b47ffb1db3323bab21f45d043f6e112334863e2cdc.jpg)
501
+ Figure 15. High level overview of policy network: The policy network receives the observations and outputs the logits for the action probabilities and the value function.
502
+
503
+ As policy network we take the Proximal Policy Optimization (PPO) (Schulman et al., 2017) implementation from lcswillems and modify it to our needs. As shown in Figure 15, we downscale the observations to $42 \times 42 \times 3$ and feed the downscaled observations to the following network architecture,
504
+
505
+ ```python
506
+ 1 [..
507
+ 2 ACModel(
508
+ 3 (image_conv): Sequential(
509
+ 4 (0): Conv2d(3, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
510
+ 5 (1): ELU(alpha=1.0)
511
+ 6 (2): Conv2d(32, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
512
+ 7 (3): ELU(alpha=1.0)
513
+ 8 (4): Conv2d(32, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
514
+ 9 (5): ELU(alpha=1.0)
515
+ 10 (6): Conv2d(32, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1))
516
+ 11 (7): ELU(alpha=1.0)
517
+ 12 )
518
+ 13 (memory_rnn1): LSTMCell(288, 256)
519
+ 14 (memory_rnn2): LSTMCell(288, 256)
520
+ 15 (actor): Sequential(
521
+ 16 (0): Linear(in_features=256, out_features=64, bias=True)
522
+ 17 (1): Tanh()
523
+ 18 (2): Linear(in_features=64, out_features=4, bias=True)
524
+ 19 )
525
+ ```
526
+
527
+ ```python
528
+ (critic): Sequential(0): Linear(in_features=256, out_features=64, bias=True) (1): Tanh() (2): Linear(in_features=64, out_features=1, bias=True) )
529
+ 25
530
+ ```
531
+
532
+ # Listing 2. PPO Network Architecture
533
+
534
+ where the "out_features" for the actor and critic are the number of actions and 1, respectively. Since we have partial observability in our 3-D environments, we additionally use two LSTM cells after the convolutional encoder.
535
+
536
+ # E.2. DINO Setup
537
+
538
+ ![](images/a14eb7ab1e1b81fac5fd87944a4e50b3413336f38fabc4790dbc01f39bc80e6b.jpg)
539
+ Figure 16. High level overview of how we use DINO: We use the pre-trained DINO model to extract embeddings from the observations. We then use the cosine similarity to cluster the embeddings.
540
+
541
+ For the pre-trained DINO representations we use the "small" version of the "dino-v2" (Oquab et al., 2023) model. As shown in Figure 16, the model receives an input of size $98 \times 98 \times 3$ since it splits the observation into $14 \times 14$ patches. After passing the observations through the model, we take the CLS token of the DINO model as feature vector which is 384-dimensional. For the model size ablation, we use the "large" model instead which has a 1024-dimensional feature vector with $196 \times 196 \times 3$ sized observations as input.
542
+
543
+ # E.3. Random Features Setup
544
+
545
+ For the random features we use the target network in Random Network Distillation which is analogous to Listing 2 without the LSTM cells. After the convolutional encoder we simply output a 384-dimensional feature vector. As a consequence, the embeddings, i.e., the cluster means are also 384-dimensional.
546
+
547
+ # E.4. Other Libraries
548
+
549
+ For the Gaussian mixture model we simply use the implementation from scikit-learn.
2024/Just Cluster It_ An Approach for Exploration in High-Dimensions using Clustering and Pre-Trained Representations/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:352546f17a299cea01435e6a8e0876dde3ee9c7fa1ad76ebcc7a23dddd61556e
3
+ size 854637
2024/Just Cluster It_ An Approach for Exploration in High-Dimensions using Clustering and Pre-Trained Representations/layout.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/KISA_ A Unified Keyframe Identifier and Skill Annotator for Long-Horizon Robotics Demonstrations/19643242-51ec-4da6-992b-7ebd922e8eaa_content_list.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/KISA_ A Unified Keyframe Identifier and Skill Annotator for Long-Horizon Robotics Demonstrations/19643242-51ec-4da6-992b-7ebd922e8eaa_model.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/KISA_ A Unified Keyframe Identifier and Skill Annotator for Long-Horizon Robotics Demonstrations/19643242-51ec-4da6-992b-7ebd922e8eaa_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4a03e86766fbdfb33d9521bd949feab8c2b15cae095e69fad2691d56f670da8a
3
+ size 9310088
2024/KISA_ A Unified Keyframe Identifier and Skill Annotator for Long-Horizon Robotics Demonstrations/full.md ADDED
The diff for this file is too large to render. See raw diff
 
2024/KISA_ A Unified Keyframe Identifier and Skill Annotator for Long-Horizon Robotics Demonstrations/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2a873a82d84c6d7df23d200d42a86cc7dbf1cef6752c583d3a8c1693b084803c
3
+ size 2973020
2024/KISA_ A Unified Keyframe Identifier and Skill Annotator for Long-Horizon Robotics Demonstrations/layout.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/KIVI_ A Tuning-Free Asymmetric 2bit Quantization for KV Cache/b0cf2b04-a9b0-4077-9961-397b48206580_content_list.json ADDED
@@ -0,0 +1,1940 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "type": "text",
4
+ "text": "Zirui Liu $^{1}$ Jiayi Yuan $^{1}$ Hongye Jin $^{2}$ Shaochen (Henry) Zhong $^{1}$ Zhaozhuo Xu $^{3}$ Vladimir Braverman $^{1}$ Beidi Chen $^{4}$ Xia Hu $^{1}$",
5
+ "bbox": [
6
+ 243,
7
+ 176,
8
+ 725,
9
+ 207
10
+ ],
11
+ "page_idx": 0
12
+ },
13
+ {
14
+ "type": "text",
15
+ "text": "Abstract",
16
+ "text_level": 1,
17
+ "bbox": [
18
+ 241,
19
+ 232,
20
+ 320,
21
+ 248
22
+ ],
23
+ "page_idx": 0
24
+ },
25
+ {
26
+ "type": "text",
27
+ "text": "Efficiently serving large language models (LLMs) requires batching many requests together to reduce the cost per request. Yet, the key-value (KV) cache, which stores attention keys and values to avoid re-computations, significantly increases memory demands and becomes the new bottleneck in speed and memory usage. This memory demand increases with larger batch sizes and longer context lengths. Additionally, the inference speed is limited by the size of KV cache, as the GPU's SRAM must load the entire KV cache from the main GPU memory for each token generated, causing the computational core to be idle during this process. A straightforward and effective solution to reduce KV cache size is quantization, which decreases the total bytes taken by KV cache. However, there is a lack of in-depth studies that explore the element distribution of KV cache to understand the hardness and limitation of KV cache quantization. To fill the gap, we conducted a comprehensive study on the element distribution in KV cache of popular LLMs. Our findings indicate that the key cache should be quantized per-channel, i.e., group elements along the channel dimension and quantize them together. In contrast, the value cache should be quantized per-token. From this analysis, we developed a tuning-free 2bit KV cache quantization algorithm, named KIVI. With the hardware-friendly implementation, KIVI can enable Llama (Llama-2), Falcon, and Mistral models to maintain almost the same quality while using $2.6 \\times$ less peak memory usage (including the",
28
+ "bbox": [
29
+ 117,
30
+ 257,
31
+ 444,
32
+ 758
33
+ ],
34
+ "page_idx": 0
35
+ },
36
+ {
37
+ "type": "text",
38
+ "text": "model weight). This reduction in memory usage enables up to $4 \\times$ larger batch size, bringing $2.35 \\times \\sim 3.47 \\times$ throughput on real LLM inference workload. The source code is available at https://github.com/jy-yuan/KIVI.",
39
+ "bbox": [
40
+ 529,
41
+ 234,
42
+ 856,
43
+ 310
44
+ ],
45
+ "page_idx": 0
46
+ },
47
+ {
48
+ "type": "text",
49
+ "text": "1. Introduction",
50
+ "text_level": 1,
51
+ "bbox": [
52
+ 498,
53
+ 335,
54
+ 629,
55
+ 351
56
+ ],
57
+ "page_idx": 0
58
+ },
59
+ {
60
+ "type": "text",
61
+ "text": "Large Language Models (LLMs) have demonstrated strong performance across a wide range of tasks (Brown et al., 2020; Taylor et al., 2022; Yuan et al., 2023). However, their deployment is very costly, requiring a large number of hardware accelerators such as GPUs. Given these substantial costs, one natural way to reduce the cost per request is to combine a sufficient number of requests together for batch processing. However, in this batch inference scenario, the key-value cache (KV cache), which holds the attention keys and values during generation to prevent re-computations, is becoming the new memory and speed bottleneck. This bottleneck becomes more pronounced with larger batch sizes and longer context lengths. For instance, in 540B PaLM, with a batch size of 512 and a context length of 2048, KV cache alone can take 3TB. This is 3 times the size of the model's parameters (Pope et al., 2023). Also, the GPU SRAM has to load the whole KV cache from the GPU device memory for every token generated, during which the computational cores are idle. Thus, reducing KV cache size in LLMs while maintaining accuracy is important.",
62
+ "bbox": [
63
+ 495,
64
+ 361,
65
+ 887,
66
+ 664
67
+ ],
68
+ "page_idx": 0
69
+ },
70
+ {
71
+ "type": "text",
72
+ "text": "Existing works towards this problem can be roughly divided into three categories. First, some work suggests reducing the number of heads in KV cache, such as multi-query attention (Shazeer, 2019) and multi-group attention (Ainslie et al., 2023). However, these methods require either training the model from scratch or fine-tuning the existing model. Second, another research line reduces KV cache size by evicting unimportant tokens (Zhang et al., 2023). Third, some other works try to solve this problem from the system perspective, e.g., offloading KV cache (Sheng et al., 2023) or extending virtual memory and paging techniques into the attention mechanism (Kwon et al., 2023).",
73
+ "bbox": [
74
+ 495,
75
+ 671,
76
+ 888,
77
+ 852
78
+ ],
79
+ "page_idx": 0
80
+ },
81
+ {
82
+ "type": "text",
83
+ "text": "To reduce the size of KV cache, the most simple and effective way is to reduce the total bytes taken by KV cache, namely, quantization. Unlike the well-studied weight quan",
84
+ "bbox": [
85
+ 495,
86
+ 859,
87
+ 888,
88
+ 906
89
+ ],
90
+ "page_idx": 0
91
+ },
92
+ {
93
+ "type": "header",
94
+ "text": "KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache",
95
+ "bbox": [
96
+ 147,
97
+ 109,
98
+ 825,
99
+ 131
100
+ ],
101
+ "page_idx": 0
102
+ },
103
+ {
104
+ "type": "page_footnote",
105
+ "text": "*Equal contribution. The order of authors is determined by flipping a coin. ${}^{1}$ Department of Computer Science,Rice University ${}^{2}$ Department of Computer Science,Texas A&M University ${}^{3}$ Department of Computer Science,Stevens Institute of Technology ${}^{4}$ Department of Electrical and Computer Engineering,Carnegie Mellon University. Correspondence to: Zirui Liu <zl105@rice.edu>, Jiayi Yuan <jy101@rice.edu>.",
106
+ "bbox": [
107
+ 84,
108
+ 765,
109
+ 475,
110
+ 854
111
+ ],
112
+ "page_idx": 0
113
+ },
114
+ {
115
+ "type": "page_footnote",
116
+ "text": "Proceedings of the $41^{st}$ International Conference on Machine Learning, Vienna, Austria. PMLR 235, 2024. Copyright 2024 by the author(s).",
117
+ "bbox": [
118
+ 84,
119
+ 866,
120
+ 475,
121
+ 905
122
+ ],
123
+ "page_idx": 0
124
+ },
125
+ {
126
+ "type": "page_number",
127
+ "text": "1",
128
+ "bbox": [
129
+ 480,
130
+ 922,
131
+ 491,
132
+ 934
133
+ ],
134
+ "page_idx": 0
135
+ },
136
+ {
137
+ "type": "image",
138
+ "img_path": "images/c8db393869c237be8c2d59e8226db1629489aee66b746ce1a8714204d70f22e2.jpg",
139
+ "image_caption": [
140
+ "Figure 1: Definition of per-token and per-channel quantization. $X \\in \\mathbb{R}^{l_{\\mathrm{prompt}} \\times d}$ is key/value cache where $l_{\\mathrm{prompt}}$ is the number of tokens and $d$ is the number of channels. $z_{X}$ is the zero-point, $s_{X}$ is the scaling factor."
141
+ ],
142
+ "image_footnote": [],
143
+ "bbox": [
144
+ 155,
145
+ 84,
146
+ 395,
147
+ 223
148
+ ],
149
+ "page_idx": 1
150
+ },
151
+ {
152
+ "type": "text",
153
+ "text": "tization (Lin et al., 2023; Xiao et al., 2023a; Zhao et al., 2024), to the best of our knowledge, only a few studies applied the vanilla 4bit round-to-nearest quantization to KV cache (Sheng et al., 2023; Zhang et al., 2023; Zhao et al., 2024) due to the streaming nature of KV cache or other complications. There is a lack of in-depth studies that explore the element distribution of KV cache to understand the hardness and limitation of KV cache quantization. To fill the gap, we study the element distribution of KV cache. Our analysis suggests:",
154
+ "bbox": [
155
+ 84,
156
+ 303,
157
+ 475,
158
+ 455
159
+ ],
160
+ "page_idx": 1
161
+ },
162
+ {
163
+ "type": "list",
164
+ "sub_type": "text",
165
+ "list_items": [
166
+ "- For the key cache, there are a few fixed channels whose magnitudes are very large, which is consistent with previous finding (Lin et al., 2023; Xiao et al., 2023a). Thus, as shown in Figure 1 right, key cache should be quantized per-channel, i.e., group elements along the channel dimension and quantize them together. In this way, it can confine the error to each individual channel, without impacting the other normal channels.",
167
+ "- For the value cache, there is no obvious outlier pattern. Although value cache has no obvious outlier pattern, we experimentally show that it can only be quantized per-token because it is used to calculate the attention output, which is essentially a value cache mixer. As shown in Figure 1 left, the per-token quantization can confine the error inside each individual token and ensure that the quantization of one token does not adversely impact the others."
168
+ ],
169
+ "bbox": [
170
+ 104,
171
+ 470,
172
+ 473,
173
+ 736
174
+ ],
175
+ "page_idx": 1
176
+ },
177
+ {
178
+ "type": "text",
179
+ "text": "Based on the above insights, we propose KIVI, a plug-and-play extreme low-bit KV cache quantization method. KIVI quantizes key cache per-channel and quantizes value cache per-token. The per-token value cache quantization aligns well with the streaming nature of auto-regressive inference, allowing newly quantized tensors to be directly appended to the existing quantized value cache by token dimension. However, for per-channel key cache quantization, the quantization process spans different tokens, which cannot be directly implemented in this streaming setting. Since the",
180
+ "bbox": [
181
+ 84,
182
+ 753,
183
+ 475,
184
+ 905
185
+ ],
186
+ "page_idx": 1
187
+ },
188
+ {
189
+ "type": "text",
190
+ "text": "number of tokens in key cache can be arbitrary, our key idea is to split key cache into two parts. The first part is the grouped key cache, which contains several groups of tokens and each group has a certain number of tokens. The second part is the residual key cache, which does not have a sufficient number of tokens to form a complete group. Similarly, we split value cache into the grouped and residual parts to maintain the accuracy. We only apply group-wise quantization to the grouped key cache and value cache, while the residual key cache and value cache are kept in full precision. The grouped and residual parts can be combined using tiled matrix multiplication when computing attention scores. Our contributions are summarized as follows:",
191
+ "bbox": [
192
+ 496,
193
+ 84,
194
+ 887,
195
+ 281
196
+ ],
197
+ "page_idx": 1
198
+ },
199
+ {
200
+ "type": "list",
201
+ "sub_type": "text",
202
+ "list_items": [
203
+ "- Extensive analysis regarding the outlier patterns and quantization error of KV cache in commonly-used LLMs. Our observations suggest that key cache should be quantized per-channel and value cache should be quantized per-token. We also explain in depth why these caches require different quantization approaches.",
204
+ "- A new plug-and-play 2bit KV cache quantization algorithm without any fine-tuning, KIVI, with hardware-friendly implementation. We conduct an extensive evaluation for KIVI with Llama (Llama2), Mistral, and Falcon on popular generation tasks. KIVI can efficiently compress KV cache to 2bit and bring $2.6 \\times$ peak memory usage reduction for Llama2-7B, with little to no accuracy drop. With our efficient system implementation, this memory reduction, in return, enables up to $4 \\times$ larger batch size and brings $2.35 \\times \\sim 3.47 \\times$ throughput."
205
+ ],
206
+ "bbox": [
207
+ 514,
208
+ 304,
209
+ 887,
210
+ 594
211
+ ],
212
+ "page_idx": 1
213
+ },
214
+ {
215
+ "type": "text",
216
+ "text": "2. Background: Attention Inference-Time Workflow",
217
+ "text_level": 1,
218
+ "bbox": [
219
+ 496,
220
+ 617,
221
+ 851,
222
+ 651
223
+ ],
224
+ "page_idx": 1
225
+ },
226
+ {
227
+ "type": "text",
228
+ "text": "The LLM attention inference-time workflow involves two phases: i) the prefetch phase, where the input prompt is used to generate KV cache for each transformer layer of LLMs; and ii) the decoding phase, where the model uses and updates KV cache to generate the next token, one at a time.",
229
+ "bbox": [
230
+ 496,
231
+ 661,
232
+ 885,
233
+ 737
234
+ ],
235
+ "page_idx": 1
236
+ },
237
+ {
238
+ "type": "text",
239
+ "text": "Prefill Phase. Let $X \\in \\mathbb{R}^{b \\times l_{\\text{prompt}} \\times d}$ be the input tensor, where $b$ is the batch size, $l_{\\text{prompt}}$ is the length of the input prompt, and $d$ is the model hidden size. For convenience, we ignore the layer index here. The key, value tensors can be computed by",
240
+ "bbox": [
241
+ 495,
242
+ 755,
243
+ 885,
244
+ 832
245
+ ],
246
+ "page_idx": 1
247
+ },
248
+ {
249
+ "type": "equation",
250
+ "text": "\n$$\n\\boldsymbol {X} _ {K} = \\boldsymbol {X} \\boldsymbol {W} _ {K}, \\boldsymbol {X} _ {V} = \\boldsymbol {X} \\boldsymbol {W} _ {V},\n$$\n",
251
+ "text_format": "latex",
252
+ "bbox": [
253
+ 586,
254
+ 834,
255
+ 795,
256
+ 851
257
+ ],
258
+ "page_idx": 1
259
+ },
260
+ {
261
+ "type": "text",
262
+ "text": "where $W_{K}, W_{V} \\in \\mathbb{R}^{d \\times d}$ are the key and value layer weight, respectively. After obtaining $X_{K}$ and $X_{V}$ , they are cached in the memory for the ease of decoding.",
263
+ "bbox": [
264
+ 495,
265
+ 859,
266
+ 885,
267
+ 905
268
+ ],
269
+ "page_idx": 1
270
+ },
271
+ {
272
+ "type": "header",
273
+ "text": "KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache",
274
+ "bbox": [
275
+ 272,
276
+ 56,
277
+ 699,
278
+ 70
279
+ ],
280
+ "page_idx": 1
281
+ },
282
+ {
283
+ "type": "page_number",
284
+ "text": "2",
285
+ "bbox": [
286
+ 480,
287
+ 922,
288
+ 491,
289
+ 934
290
+ ],
291
+ "page_idx": 1
292
+ },
293
+ {
294
+ "type": "text",
295
+ "text": "Decoding Phase. Let $t \\in \\mathbb{R}^{b \\times 1 \\times d}$ be the current input token embedding. Let $t_K = tW_K$ and $t_V = tW_V$ be the key and value layer output, respectively. We first update KV cache:",
296
+ "bbox": [
297
+ 84,
298
+ 84,
299
+ 473,
300
+ 143
301
+ ],
302
+ "page_idx": 2
303
+ },
304
+ {
305
+ "type": "equation",
306
+ "text": "\n$$\n\\boldsymbol {X} _ {K} \\leftarrow \\operatorname {C o n c a t} \\left(\\boldsymbol {X} _ {K}, \\boldsymbol {t} _ {K}\\right),\n$$\n",
307
+ "text_format": "latex",
308
+ "bbox": [
309
+ 191,
310
+ 146,
311
+ 367,
312
+ 162
313
+ ],
314
+ "page_idx": 2
315
+ },
316
+ {
317
+ "type": "equation",
318
+ "text": "\n$$\n\\boldsymbol {X} _ {V} \\leftarrow \\operatorname {C o n c a t} \\left(\\boldsymbol {X} _ {V}, \\boldsymbol {t} _ {V}\\right),\n$$\n",
319
+ "text_format": "latex",
320
+ "bbox": [
321
+ 194,
322
+ 164,
323
+ 364,
324
+ 181
325
+ ],
326
+ "page_idx": 2
327
+ },
328
+ {
329
+ "type": "text",
330
+ "text": "then calculate the attention output as:",
331
+ "bbox": [
332
+ 84,
333
+ 194,
334
+ 334,
335
+ 209
336
+ ],
337
+ "page_idx": 2
338
+ },
339
+ {
340
+ "type": "equation",
341
+ "text": "\n$$\n\\boldsymbol {t} _ {Q} = \\boldsymbol {t} \\boldsymbol {W} _ {Q},\n$$\n",
342
+ "text_format": "latex",
343
+ "bbox": [
344
+ 196,
345
+ 223,
346
+ 282,
347
+ 239
348
+ ],
349
+ "page_idx": 2
350
+ },
351
+ {
352
+ "type": "equation",
353
+ "text": "\n$$\n\\boldsymbol {A} = \\operatorname {S o f t m a x} \\left(\\boldsymbol {t} _ {Q} \\boldsymbol {X} _ {K} ^ {\\top}\\right),\n$$\n",
354
+ "text_format": "latex",
355
+ "bbox": [
356
+ 202,
357
+ 242,
358
+ 359,
359
+ 260
360
+ ],
361
+ "page_idx": 2
362
+ },
363
+ {
364
+ "type": "equation",
365
+ "text": "\n$$\n\\boldsymbol {t} _ {O} = \\boldsymbol {A} \\boldsymbol {X} _ {V}, \\tag {1}\n$$\n",
366
+ "text_format": "latex",
367
+ "bbox": [
368
+ 197,
369
+ 263,
370
+ 473,
371
+ 279
372
+ ],
373
+ "page_idx": 2
374
+ },
375
+ {
376
+ "type": "text",
377
+ "text": "where $W_{Q}$ is the weight matrix of the query layer. For ease of illustration, we ignore the attention output layer and the other parts of the inference workflow.",
378
+ "bbox": [
379
+ 84,
380
+ 289,
381
+ 475,
382
+ 335
383
+ ],
384
+ "page_idx": 2
385
+ },
386
+ {
387
+ "type": "text",
388
+ "text": "Memory and Speed Analysis. The above process is repeated until a special token indicating the sentence's conclusion is reached. Let $l_{\\mathrm{gen}}$ be the number of generated tokens. From the above analysis, the shape of KV cache is $b \\times (l_{\\mathrm{prompt}} + l_{\\mathrm{gen}}) \\times d$ . To get a sense of the scale, consider the OPT-175B model with a batch size $b$ 512, a prompt length $l_{\\mathrm{prompt}}$ 512, and an output length $l_{\\mathrm{gen}}$ 32. The KV cache requires 1.2TB, which is 3.8 times the model weights (Sheng et al., 2023). Besides the memory, the inference speed is also decided by the KV cache size. The GPU needs to load KV cache from GPU main memory to GPU SRAM once for every token generated during which the computational core of the chip is essentially idle (Pope et al., 2023; Kwon et al., 2023).",
389
+ "bbox": [
390
+ 84,
391
+ 352,
392
+ 475,
393
+ 563
394
+ ],
395
+ "page_idx": 2
396
+ },
397
+ {
398
+ "type": "text",
399
+ "text": "3. Methodology",
400
+ "text_level": 1,
401
+ "bbox": [
402
+ 84,
403
+ 582,
404
+ 220,
405
+ 599
406
+ ],
407
+ "page_idx": 2
408
+ },
409
+ {
410
+ "type": "text",
411
+ "text": "In scenarios with long contexts or batched inferences, the memory and speed bottlenecks are storing and loading KV cache. The most simple and effective way to alleviate this problem is to reduce the total bytes occupied by KV cache, specifically, quantization. Following this motivation, we first evaluate the performance of the existing quantization method in Section 3.1. Our observations suggest that key and value cache should be quantized along different dimensions. We analyze the rationale behind this observation in Section 3.2. Then based on the analysis, we propose KIVI, a new KV cache quantization method along with its streaming data structure, detailed in Section 3.3.",
412
+ "bbox": [
413
+ 84,
414
+ 608,
415
+ 475,
416
+ 789
417
+ ],
418
+ "page_idx": 2
419
+ },
420
+ {
421
+ "type": "text",
422
+ "text": "3.1. Preliminary Study of KV Cache Quantization",
423
+ "text_level": 1,
424
+ "bbox": [
425
+ 84,
426
+ 806,
427
+ 437,
428
+ 821
429
+ ],
430
+ "page_idx": 2
431
+ },
432
+ {
433
+ "type": "text",
434
+ "text": "As we analyzed in Section 2, KV cache functions as a streaming data structure, where the new tensor arrives sequentially. Thus, optimization-based methods like GPTQ (Frantar et al., 2022) are unsuitable for quantizing KV cache due to the overhead. To the best of our knowledge, the",
435
+ "bbox": [
436
+ 84,
437
+ 830,
438
+ 475,
439
+ 905
440
+ ],
441
+ "page_idx": 2
442
+ },
443
+ {
444
+ "type": "text",
445
+ "text": "Table 1: The results of simulated KV cache group-wise quantization with various configurations. The group size is set as 32. $\\mathbb{C}$ stands for per-channel quantization and $\\mathbb{T}$ stands for per-token quantization. Please check the whole evaluation in Table 3.",
446
+ "bbox": [
447
+ 496,
448
+ 82,
449
+ 885,
450
+ 157
451
+ ],
452
+ "page_idx": 2
453
+ },
454
+ {
455
+ "type": "table",
456
+ "img_path": "images/3b94e026bcf48091d94dc7f6b2601353c3a3cb949b5df27f3d0f22cd57490686.jpg",
457
+ "table_caption": [],
458
+ "table_footnote": [],
459
+ "table_body": "<table><tr><td>Llama-2-13B</td><td>CoQA</td><td>TruthfulQA</td></tr><tr><td>16bit</td><td>66.37</td><td>29.53</td></tr><tr><td>4bit (K - T, V - T)</td><td>66.48</td><td>29.51</td></tr><tr><td>2bit (K - T, V - T)</td><td>52.93</td><td>24.98</td></tr><tr><td>2bit (K - C, V - C)</td><td>2.88</td><td>0.74</td></tr><tr><td>2bit (K - T, V - C)</td><td>2.80</td><td>0.26</td></tr><tr><td>2bit (K - C, V - T)</td><td>63.53</td><td>28.60</td></tr></table>",
460
+ "bbox": [
461
+ 547,
462
+ 164,
463
+ 836,
464
+ 276
465
+ ],
466
+ "page_idx": 2
467
+ },
468
+ {
469
+ "type": "text",
470
+ "text": "most flexible way for quantizing KV cache is the round-to-nearest quantization. The $B$ -bit integer quantization-dequantization process can be expressed as:",
471
+ "bbox": [
472
+ 496,
473
+ 300,
474
+ 888,
475
+ 345
476
+ ],
477
+ "page_idx": 2
478
+ },
479
+ {
480
+ "type": "equation",
481
+ "text": "\n$$\nQ (\\boldsymbol {X}) = \\left\\lfloor \\frac {\\boldsymbol {X} - z _ {X}}{s _ {X}} \\right\\rceil , \\quad \\boldsymbol {X} ^ {\\prime} = Q (\\boldsymbol {X}) \\cdot s _ {X} + z _ {X},\n$$\n",
482
+ "text_format": "latex",
483
+ "bbox": [
484
+ 526,
485
+ 349,
486
+ 854,
487
+ 382
488
+ ],
489
+ "page_idx": 2
490
+ },
491
+ {
492
+ "type": "text",
493
+ "text": "where $z_{X} = \\min X$ is the zero-point, $s_{X} = (\\max X - \\min X) / (2^{B} - 1)$ is the scaling factor, and $\\lfloor \\cdot \\rceil$ is the rounding operation. Here we ignore the batch size for ease of understanding. As shown in Figure 1, $X$ is quantized along either the token or channel dimension group-wisely.",
494
+ "bbox": [
495
+ 495,
496
+ 383,
497
+ 887,
498
+ 460
499
+ ],
500
+ "page_idx": 2
501
+ },
502
+ {
503
+ "type": "text",
504
+ "text": "Considering the streaming nature of KV cache, previous studies often apply per-token quantization to both key and value cache since the newly quantized KV cache can be naively added to the existing quantized one along the token dimension (Sheng et al., 2023). While per-channel quantization is non-trivial, we have designed a padding method to implement per-channel quantization to explore its effect on both key and value cache.",
505
+ "bbox": [
506
+ 495,
507
+ 465,
508
+ 887,
509
+ 588
510
+ ],
511
+ "page_idx": 2
512
+ },
513
+ {
514
+ "type": "text",
515
+ "text": "Setting. In Table 1, we show the results of fake KV cache group-wise quantization with different configurations on the Llama-2-13B model for the CoQA and TruthfulQA tasks. We use a group size of 32 for all configurations. Here fake quantization means we simulate the quantization process by first quantizing KV cache into lower precision and then dequantizing it in the attention layer. For per-channel quantization, if the number of tokens is not divided evenly into groups, we add zero-padding to ensure it can be grouped perfectly. In this way, we ensure that all tokens in KV cache are quantized for a fair comparison. The detailed experimental setting can be found in Section 4.1. Specifically, we observe that:",
516
+ "bbox": [
517
+ 495,
518
+ 603,
519
+ 887,
520
+ 799
521
+ ],
522
+ "page_idx": 2
523
+ },
524
+ {
525
+ "type": "text",
526
+ "text": "OB 1. When using the commonly used per-token quantization to both key and value caches, INT4 precision can maintain accuracy. However, reducing it to INT2 results in a notable accuracy drop.",
527
+ "bbox": [
528
+ 495,
529
+ 806,
530
+ 887,
531
+ 868
532
+ ],
533
+ "page_idx": 2
534
+ },
535
+ {
536
+ "type": "text",
537
+ "text": "OB 2. When value cache is quantized per-channel, the accuracy significantly worsens regardless of how key cache",
538
+ "bbox": [
539
+ 496,
540
+ 875,
541
+ 885,
542
+ 906
543
+ ],
544
+ "page_idx": 2
545
+ },
546
+ {
547
+ "type": "header",
548
+ "text": "KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache",
549
+ "bbox": [
550
+ 272,
551
+ 56,
552
+ 699,
553
+ 70
554
+ ],
555
+ "page_idx": 2
556
+ },
557
+ {
558
+ "type": "page_number",
559
+ "text": "3",
560
+ "bbox": [
561
+ 480,
562
+ 922,
563
+ 491,
564
+ 934
565
+ ],
566
+ "page_idx": 2
567
+ },
568
+ {
569
+ "type": "image",
570
+ "img_path": "images/5964e9c36bb7d2eefc4ddad34245632f31941a3dd51110d9091ef21eef1bbca3.jpg",
571
+ "image_caption": [
572
+ "Llama-2-13B Layer 16 \nHead 0 Key Cache"
573
+ ],
574
+ "image_footnote": [],
575
+ "bbox": [
576
+ 94,
577
+ 126,
578
+ 287,
579
+ 253
580
+ ],
581
+ "page_idx": 3
582
+ },
583
+ {
584
+ "type": "image",
585
+ "img_path": "images/2067871987ce30bf5e06653b43f1a593b31126a3c5b529a9afaba7eaf770a1a3.jpg",
586
+ "image_caption": [
587
+ "Llama-2-13B Layer 16 \nHead 0 Value Cache"
588
+ ],
589
+ "image_footnote": [],
590
+ "bbox": [
591
+ 290,
592
+ 125,
593
+ 483,
594
+ 253
595
+ ],
596
+ "page_idx": 3
597
+ },
598
+ {
599
+ "type": "image",
600
+ "img_path": "images/db358606b84710de97bad0fa00770e909377e613afafb9da5bb7dcaf83cc432d.jpg",
601
+ "image_caption": [
602
+ "Llama-2-13B Layer 31 Head 0 Key Cache"
603
+ ],
604
+ "image_footnote": [],
605
+ "bbox": [
606
+ 490,
607
+ 126,
608
+ 678,
609
+ 253
610
+ ],
611
+ "page_idx": 3
612
+ },
613
+ {
614
+ "type": "image",
615
+ "img_path": "images/fc6a1235fa8b88cac60ec799bfda423fd336c5e837dfac759b86948f05a52bda.jpg",
616
+ "image_caption": [
617
+ "Llama-2-13B Layer 31 Head 0 Value Cache"
618
+ ],
619
+ "image_footnote": [],
620
+ "bbox": [
621
+ 687,
622
+ 125,
623
+ 875,
624
+ 253
625
+ ],
626
+ "page_idx": 3
627
+ },
628
+ {
629
+ "type": "image",
630
+ "img_path": "images/c998fa711988d0edfa1a7b5f2ccd868bff9960e0d0d707f5f18ed83024b03655.jpg",
631
+ "image_caption": [
632
+ "Falcon-7B Layer 16 \nHead 0 Key Cache"
633
+ ],
634
+ "image_footnote": [],
635
+ "bbox": [
636
+ 88,
637
+ 305,
638
+ 282,
639
+ 435
640
+ ],
641
+ "page_idx": 3
642
+ },
643
+ {
644
+ "type": "image",
645
+ "img_path": "images/6f4bdb304208b9f1786715eecb72de682d145ad0d7afa83271efcf7ab45f92b0.jpg",
646
+ "image_caption": [
647
+ "Falcon-7B Layer 16 Head 0 Value Cache"
648
+ ],
649
+ "image_footnote": [],
650
+ "bbox": [
651
+ 284,
652
+ 306,
653
+ 478,
654
+ 436
655
+ ],
656
+ "page_idx": 3
657
+ },
658
+ {
659
+ "type": "image",
660
+ "img_path": "images/fa9bd0618aa1454dfbb4603c7e05f9a58beefb050896dc7faa1262acadcee697.jpg",
661
+ "image_caption": [
662
+ "Falcon-7B Layer 20 \nHead 0 Key Cache"
663
+ ],
664
+ "image_footnote": [],
665
+ "bbox": [
666
+ 486,
667
+ 309,
668
+ 671,
669
+ 435
670
+ ],
671
+ "page_idx": 3
672
+ },
673
+ {
674
+ "type": "image",
675
+ "img_path": "images/113a02159cf4629335ee4fe90d68e8487fc2322aa8b8334df3b1289c3fb0ce3f.jpg",
676
+ "image_caption": [
677
+ "Falcon-7B Layer 20 \nHead 0 Value Cache",
678
+ "Figure 2: Magnitude of key and value cache for Llama-2-13B and Falcon-7B. We observe (1) for key cache, there are a few channels whose magnitudes are very large. (2) for value cache, there is no obvious outlier pattern."
679
+ ],
680
+ "image_footnote": [],
681
+ "bbox": [
682
+ 684,
683
+ 306,
684
+ 870,
685
+ 436
686
+ ],
687
+ "page_idx": 3
688
+ },
689
+ {
690
+ "type": "text",
691
+ "text": "is quantized.",
692
+ "bbox": [
693
+ 84,
694
+ 512,
695
+ 171,
696
+ 527
697
+ ],
698
+ "page_idx": 3
699
+ },
700
+ {
701
+ "type": "text",
702
+ "text": "OB 3. When using a lower numerical precision such as INT2, the most accurate approach is to quantize key cache per-channel and value cache per-token.",
703
+ "bbox": [
704
+ 84,
705
+ 535,
706
+ 473,
707
+ 580
708
+ ],
709
+ "page_idx": 3
710
+ },
711
+ {
712
+ "type": "text",
713
+ "text": "3.2. Why Key and Value Cache Should Quantize Along Different Dimensions?",
714
+ "text_level": 1,
715
+ "bbox": [
716
+ 84,
717
+ 597,
718
+ 470,
719
+ 626
720
+ ],
721
+ "page_idx": 3
722
+ },
723
+ {
724
+ "type": "text",
725
+ "text": "In Table 1, we observe that quantizing key cache per-channel and value cache per-token to 2bit results in a very small accuracy drop. Here we analyze why this configuration delivers better accuracy. In Figure 2 we visualize the original KV cache distribution at different layers. We observe that in key cache, some fixed channels exhibit very large magnitudes, whereas in value cache, there is no significant pattern for outliers.",
726
+ "bbox": [
727
+ 84,
728
+ 635,
729
+ 475,
730
+ 755
731
+ ],
732
+ "page_idx": 3
733
+ },
734
+ {
735
+ "type": "text",
736
+ "text": "Analysis of Key Cache. The above observation for key cache aligns with previous findings that certain fixed columns in activations exhibit larger outliers (Dettmers et al., 2022; Lin et al., 2023). The persistence of outliers within each channel means that per-channel quantization can confine the quantization error to each individual channel without impacting the other normal channels. Thus, Figure 2 explains why key cache should be quantized per-channel. In Table 2 we show key cache relative reconstruction error",
737
+ "bbox": [
738
+ 84,
739
+ 768,
740
+ 475,
741
+ 905
742
+ ],
743
+ "page_idx": 3
744
+ },
745
+ {
746
+ "type": "text",
747
+ "text": "$\\| \\frac{\\pmb{X}_K - \\pmb{X}_K'}{\\pmb{X}_K}\\| _F$ , along with the relative attention score error $\\| \\frac{\\pmb{A} - \\pmb{A}'}{\\pmb{A}}\\| _F$ where $A^{\\prime} = \\mathrm{Softmax}(t_{Q}\\pmb{X}_{K}^{\\prime \\top})$ . We observe that the per-token quantization can lead to almost $5\\times$ larger attention score error than per-channel quantization, which is consistent with Figure 2.",
748
+ "bbox": [
749
+ 496,
750
+ 510,
751
+ 887,
752
+ 593
753
+ ],
754
+ "page_idx": 3
755
+ },
756
+ {
757
+ "type": "table",
758
+ "img_path": "images/04bed9780f43e60d29ae8005fb6a7e03ef2843667d6d6589f22097e9ee9d84fc.jpg",
759
+ "table_caption": [
760
+ "Table 2: The relative error statistics averaged over all layers and all heads"
761
+ ],
762
+ "table_footnote": [],
763
+ "table_body": "<table><tr><td>Llama-2-13B</td><td>K Per-Token</td><td>K Per-Channel</td></tr><tr><td>Avg. ||X_K-X&#x27;_K|_F</td><td>13.67</td><td>4.55</td></tr><tr><td>Avg. ||A-A&#x27;/A|_F</td><td>47.0</td><td>9.6</td></tr><tr><td>Attention sparsity</td><td colspan=\"2\">84.3%</td></tr></table>",
764
+ "bbox": [
765
+ 522,
766
+ 654,
767
+ 862,
768
+ 731
769
+ ],
770
+ "page_idx": 3
771
+ },
772
+ {
773
+ "type": "table",
774
+ "img_path": "images/eeffd0a8dbfa2bff7237bc3f0a59cf2087b2fa3803bd3ae34f6c79a3ce7706f2.jpg",
775
+ "table_caption": [],
776
+ "table_footnote": [],
777
+ "table_body": "<table><tr><td></td><td>V Per-Token</td><td>V Per-Channel</td></tr><tr><td>Avg. ||Xv-X&#x27;v/V|F</td><td>4.57</td><td>3.73</td></tr><tr><td>Avg. Δ</td><td>3.55</td><td>49.89</td></tr></table>",
778
+ "bbox": [
779
+ 522,
780
+ 732,
781
+ 861,
782
+ 792
783
+ ],
784
+ "page_idx": 3
785
+ },
786
+ {
787
+ "type": "text",
788
+ "text": "Analysis of Value Cache. Unlike key cache, value cache does not show the channel-wise outlier pattern. Furthermore, Figure 2 alone cannot explain OB2, which indicates value cache should only be quantized per-token. This is because Figure 2 implies that errors should be comparable for both per-token and per-channel quantization, given the absence",
789
+ "bbox": [
790
+ 495,
791
+ 814,
792
+ 885,
793
+ 905
794
+ ],
795
+ "page_idx": 3
796
+ },
797
+ {
798
+ "type": "header",
799
+ "text": "KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache",
800
+ "bbox": [
801
+ 272,
802
+ 56,
803
+ 699,
804
+ 70
805
+ ],
806
+ "page_idx": 3
807
+ },
808
+ {
809
+ "type": "page_number",
810
+ "text": "4",
811
+ "bbox": [
812
+ 480,
813
+ 922,
814
+ 491,
815
+ 934
816
+ ],
817
+ "page_idx": 3
818
+ },
819
+ {
820
+ "type": "image",
821
+ "img_path": "images/4fa791fb493a3fb009a1ee38c04b0d080397c81ffdfca5bc3f23eb343a48aacf.jpg",
822
+ "image_caption": [
823
+ "Figure 3: The overview of KIVI algorithm. For ease of illustration, we omit the value cache and attention output parts. The detailed pseudo-code is provided in Algorithm 1. Here “Q_Matmul” is the mix-precision matrix multiplication which fuses the dequantization with matrix multiplication at the tiling level."
824
+ ],
825
+ "image_footnote": [],
826
+ "bbox": [
827
+ 122,
828
+ 80,
829
+ 844,
830
+ 258
831
+ ],
832
+ "page_idx": 4
833
+ },
834
+ {
835
+ "type": "text",
836
+ "text": "of a clear pattern. As shown in Equation (1), value cache is used to calculate the attention output $t_{O}$ . Instead of analyzing the quantization error of value cache $X_{V}$ , in Table 2 we analyze the relative error $\\Delta = \\| \\frac{AX_V - AX_V'}{AX_V}\\| _F$ with different quantization configurations. Surprisingly, we observe that the per-token quantization error is almost $15\\times$ smaller than per-channel quantization, which explains why OB2 happens. The intuition behind this observation stems from the attention sparsity. Equation (1) can be written as:",
837
+ "bbox": [
838
+ 84,
839
+ 323,
840
+ 475,
841
+ 462
842
+ ],
843
+ "page_idx": 4
844
+ },
845
+ {
846
+ "type": "equation",
847
+ "text": "\n$$\n\\left[ \\boldsymbol {A} \\boldsymbol {X} _ {V} \\right] _ {i *} = \\sum_ {j = 1} ^ {l _ {\\text {p r o m p t}}} \\boldsymbol {A} _ {i j} \\left[ \\boldsymbol {X} _ {V} \\right] _ {j *}, \\tag {2}\n$$\n",
848
+ "text_format": "latex",
849
+ "bbox": [
850
+ 179,
851
+ 465,
852
+ 475,
853
+ 505
854
+ ],
855
+ "page_idx": 4
856
+ },
857
+ {
858
+ "type": "text",
859
+ "text": "where $[X_V]_{j*}$ is the $j$ -th row of $X_V$ . From Equation (2), the attention output is the weighted summation of value cache across various tokens, with the weights being the attention scores. Since the attention score is highly sparse (Tian et al., 2023), the output is just the combination of value caches of a few important tokens. The per-token quantization can confine the error to each individual token. Thus, quantizing other tokens does not affect the accuracy of important tokens. Consequently, per-token quantization leads to a much smaller relative error $\\Delta$ .",
860
+ "bbox": [
861
+ 84,
862
+ 503,
863
+ 475,
864
+ 654
865
+ ],
866
+ "page_idx": 4
867
+ },
868
+ {
869
+ "type": "text",
870
+ "text": "3.3. KIVI: Algorithm and System Support",
871
+ "text_level": 1,
872
+ "bbox": [
873
+ 84,
874
+ 670,
875
+ 387,
876
+ 686
877
+ ],
878
+ "page_idx": 4
879
+ },
880
+ {
881
+ "type": "text",
882
+ "text": "Algorithm. As we previously analyzed, key cache should be quantized per-channel and value cache should be quantized per-token. Recall that key and value cache of newly generated tokens arrive sequentially. From the implementation perspective, per-token quantization aligns well with streaming settings, allowing newly quantized tensors to be directly appended to the existing quantized value cache by token dimension. However, for per-channel quantization, the quantization process spans across different tokens, which cannot be directly implemented in the streaming setting. As shown in Figure 3, our key idea to solve this problem is to group key cache every $G$ tokens and quantize them separately. Because the number of tokens in $X_{K}$ can be arbitrary, we split $X_{K}$ into two parts, namely, the grouped part",
883
+ "bbox": [
884
+ 84,
885
+ 694,
886
+ 478,
887
+ 906
888
+ ],
889
+ "page_idx": 4
890
+ },
891
+ {
892
+ "type": "text",
893
+ "text": "$\\mathbf{X}_{K_g} = \\mathbf{X}_K[:l - r]$ and residual part $\\mathbf{X}_{K_r} = \\mathbf{X}_K[l - r:],$ where $l$ is the number of tokens inside the current key cache $\\mathbf{X}_K,r$ is the number of residual tokens, where $l - r$ can be divisible by $G$",
894
+ "bbox": [
895
+ 496,
896
+ 321,
897
+ 887,
898
+ 383
899
+ ],
900
+ "page_idx": 4
901
+ },
902
+ {
903
+ "type": "text",
904
+ "text": "Since $X_{K_g}$ can be evenly divided into $(l - r) / G$ groups, we only store $Q(X_{K_g})$ with group-wise quantization, while $X_{K_r}$ is kept in full precision. During the decoding process, each newly arrived key cache $t_K$ is added to $X_{K_r}$ and once $X_{K_r}$ reaches $R$ tokens, which is a hyperparameter - residual length, we quantize and concatenate it with the previously quantized $Q(X_{K_G})$ . Then we reset $X_{K_r}$ to an empty tensor. We note that $R$ should be divisible by $G$ . With tiled matrix multiplication, the raw attention logits is then calculated as:",
905
+ "bbox": [
906
+ 496,
907
+ 391,
908
+ 888,
909
+ 527
910
+ ],
911
+ "page_idx": 4
912
+ },
913
+ {
914
+ "type": "equation",
915
+ "text": "\n$$\n\\boldsymbol {A} _ {g} = t _ {Q} Q \\left(\\boldsymbol {X} _ {K _ {g}} ^ {\\top}\\right),\n$$\n",
916
+ "text_format": "latex",
917
+ "bbox": [
918
+ 604,
919
+ 535,
920
+ 736,
921
+ 556
922
+ ],
923
+ "page_idx": 4
924
+ },
925
+ {
926
+ "type": "equation",
927
+ "text": "\n$$\n\\boldsymbol {X} _ {K _ {r}} = \\operatorname {C o n c a t} \\left(\\left[ \\boldsymbol {X} _ {K _ {r}}, \\boldsymbol {t} _ {K} \\right]\\right),\n$$\n",
928
+ "text_format": "latex",
929
+ "bbox": [
930
+ 596,
931
+ 558,
932
+ 787,
933
+ 575
934
+ ],
935
+ "page_idx": 4
936
+ },
937
+ {
938
+ "type": "equation",
939
+ "text": "\n$$\n\\boldsymbol {A} _ {r} = \\boldsymbol {t} _ {Q} \\boldsymbol {X} _ {K _ {r}} ^ {\\top},\n$$\n",
940
+ "text_format": "latex",
941
+ "bbox": [
942
+ 607,
943
+ 578,
944
+ 712,
945
+ 597
946
+ ],
947
+ "page_idx": 4
948
+ },
949
+ {
950
+ "type": "equation",
951
+ "text": "\n$$\n\\boldsymbol {A} = \\operatorname {C o n c a t} \\left(\\left[ \\boldsymbol {A} _ {g}, \\boldsymbol {A} _ {r} \\right]\\right). \\tag {3}\n$$\n",
952
+ "text_format": "latex",
953
+ "bbox": [
954
+ 614,
955
+ 598,
956
+ 885,
957
+ 616
958
+ ],
959
+ "page_idx": 4
960
+ },
961
+ {
962
+ "type": "text",
963
+ "text": "For value cache, similar to key cache, we also split it into two parts and keep the most recent value cache in full precision, namely, $X_{V_g}$ and $X_{V_r}$ . Specifically, we maintain a queue and each newly arrived value cache is pushed into the queue. Once the queue reaches the predefined residual length $R$ , the most outdated value cache is popped. Then the popped value cache is quantized per-token and concatenated with the previously quantized value cache along the token dimension.",
964
+ "bbox": [
965
+ 495,
966
+ 625,
967
+ 885,
968
+ 758
969
+ ],
970
+ "page_idx": 4
971
+ },
972
+ {
973
+ "type": "text",
974
+ "text": "As shown in Figure 3, we also emphasize that during the prefill phase, the exact key and value tensors are passed to the next layers, although only the quantized KV cache is retained in memory. The whole algorithm can be found in Appendix A Algorithm 1.",
975
+ "bbox": [
976
+ 495,
977
+ 767,
978
+ 885,
979
+ 844
980
+ ],
981
+ "page_idx": 4
982
+ },
983
+ {
984
+ "type": "text",
985
+ "text": "Analysis. In KIVI, the grouped key cache $X_{K_g}$ and value cache $X_{V_g}$ is quantized, while the residual key cache $X_{K_r}$ and value cache $X_{V_r}$ is kept in full precision. By design,",
986
+ "bbox": [
987
+ 495,
988
+ 859,
989
+ 887,
990
+ 906
991
+ ],
992
+ "page_idx": 4
993
+ },
994
+ {
995
+ "type": "header",
996
+ "text": "KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache",
997
+ "bbox": [
998
+ 272,
999
+ 56,
1000
+ 699,
1001
+ 70
1002
+ ],
1003
+ "page_idx": 4
1004
+ },
1005
+ {
1006
+ "type": "page_number",
1007
+ "text": "5",
1008
+ "bbox": [
1009
+ 480,
1010
+ 922,
1011
+ 491,
1012
+ 934
1013
+ ],
1014
+ "page_idx": 4
1015
+ },
1016
+ {
1017
+ "type": "text",
1018
+ "text": "there are at most $R$ tokens inside $X_{K_r}$ or $X_{V_r}$ . In practice, we set $R \\leq 128$ and the sequence length $l_{\\mathrm{prompt}} + l_{\\mathrm{gen}}$ is often much longer than $R$ . Thus the memory overhead from $X_{K_r}$ and $X_{V_r}$ is negligible when considering the benefit from extreme low-bit quantization, especially for the long context scenarios. Also, since the newly arrived key and value tensors are added to $X_{K_r}$ and $X_{V_r}$ in full precision, KIVI maintains a full precision KV cache sliding window for the local relevant tokens. This window size is expected to be $\\frac{R}{2}$ for key cache, and $R$ for value cache. Later in the experiment section, we show that this full precision sliding window is crucial for obtaining desirable performance on hard tasks, such as GSM8K.",
1019
+ "bbox": [
1020
+ 84,
1021
+ 85,
1022
+ 475,
1023
+ 282
1024
+ ],
1025
+ "page_idx": 5
1026
+ },
1027
+ {
1028
+ "type": "text",
1029
+ "text": "System Support. We provide a hardware-friendly implementation for running KIVI on GPUs. To minimize the overhead, we have fused the dequantization process with matrix multiplication, e.g., Q_MatMul in Figure 3, using CUDA. We also implement the group-wise quantization kernel in Triton. Our method is fully compatible with weight-only quantization.",
1030
+ "bbox": [
1031
+ 84,
1032
+ 301,
1033
+ 477,
1034
+ 407
1035
+ ],
1036
+ "page_idx": 5
1037
+ },
1038
+ {
1039
+ "type": "text",
1040
+ "text": "4. Experiments",
1041
+ "text_level": 1,
1042
+ "bbox": [
1043
+ 84,
1044
+ 426,
1045
+ 218,
1046
+ 444
1047
+ ],
1048
+ "page_idx": 5
1049
+ },
1050
+ {
1051
+ "type": "text",
1052
+ "text": "4.1. Settings",
1053
+ "text_level": 1,
1054
+ "bbox": [
1055
+ 84,
1056
+ 453,
1057
+ 176,
1058
+ 468
1059
+ ],
1060
+ "page_idx": 5
1061
+ },
1062
+ {
1063
+ "type": "text",
1064
+ "text": "Models. We evaluate KIVI using three popular model families: Llama/Llama-2 (Touvron et al., 2023a,b)), Falcon (Penedo et al., 2023) and Mistral (Jiang et al., 2023). Llama and Mistral model is based on multi-head attention, while Falcon is based on multi-query attention (Shazeer, 2019). We use the Hugging Face Transformers codebase and implement the KIVI algorithm upon it. Following previous work (Sheng et al., 2023), the group size $G$ in Algorithm 1 for quantization is set as 32 across all experiments, the residual length $R$ for key and value cache is set to 128.",
1065
+ "bbox": [
1066
+ 84,
1067
+ 476,
1068
+ 475,
1069
+ 642
1070
+ ],
1071
+ "page_idx": 5
1072
+ },
1073
+ {
1074
+ "type": "text",
1075
+ "text": "Tasks. As we analyzed in Section 2, the KV cache size grows larger with a longer context. Thus, we evaluate KIVI under the normal context length and long context setting, respectively. Specifically, we adopt generation tasks from LM-Eval (Gao et al., 2021) for normal context length evaluation and LongBench (Bai et al., 2023) for long context evaluation, respectively<sup>1</sup>. For LM-eval, we adopt CoQA (Exact match accuracy), TruthfulQA (BLEU score), and GSM8K (Exact match accuracy). For LongBench, we chose tasks from four subgroups. Specifically, Qasper (F1 score) is a Single-Document QA task; QMSum (ROUGE score) and MultiNews (ROUGE score) are Summarization tasks;",
1076
+ "bbox": [
1077
+ 84,
1078
+ 662,
1079
+ 475,
1080
+ 844
1081
+ ],
1082
+ "page_idx": 5
1083
+ },
1084
+ {
1085
+ "type": "text",
1086
+ "text": "TREC (classification score), TriviaQA (F1 score), and SAM-Sum (ROUGE score) are Few-shot Learning tasks; and LCC (similarity score) and RepoBench-P (similarity score) is Code Completion task. The maximum sequence length in LongBench was set to 8192 for the Mistral model and 4096 for other models.",
1087
+ "bbox": [
1088
+ 496,
1089
+ 84,
1090
+ 887,
1091
+ 175
1092
+ ],
1093
+ "page_idx": 5
1094
+ },
1095
+ {
1096
+ "type": "text",
1097
+ "text": "4.2. Accuracy and Efficiency Analysis",
1098
+ "text_level": 1,
1099
+ "bbox": [
1100
+ 496,
1101
+ 191,
1102
+ 764,
1103
+ 208
1104
+ ],
1105
+ "page_idx": 5
1106
+ },
1107
+ {
1108
+ "type": "text",
1109
+ "text": "4.2.1. COMPARISON BETWEEN DIFFERENT QUANTIZATION CONFIGURATIONS",
1110
+ "text_level": 1,
1111
+ "bbox": [
1112
+ 496,
1113
+ 215,
1114
+ 800,
1115
+ 244
1116
+ ],
1117
+ "page_idx": 5
1118
+ },
1119
+ {
1120
+ "type": "text",
1121
+ "text": "We first utilize the fake quantization to demonstrate the effectiveness of our asymmetric quantization, namely, quantizing key cache per-channel and value cache per-token. Here fake quantization is exactly the same as in Table 1. The results are shown in Table 3. We observe that \"2bit (K per-channel, V per-token)\" consistently achieves the best results compared to all other configurations. This is consistent with our previous analysis. We also note that for hard generation tasks such as GSM8K, the fake \"2bit (K per-channel, V per-token)\" quantization results are significantly worse than the full precision counterparts. However, for KIVI in Table 3, we observe that the accuracy drop is only around $2\\%$ for GSM8K across different models. As we analyzed in Section 3.3, the difference between fake \"2bit (K per-channel, V per-token)\" quantization and KIVI is that KIVI maintains a full precision key and value cache sliding window for the local relevant tokens. This sliding window is crucial to maintaining accuracy for hard generation tasks such as mathematical reasoning.",
1122
+ "bbox": [
1123
+ 495,
1124
+ 253,
1125
+ 887,
1126
+ 541
1127
+ ],
1128
+ "page_idx": 5
1129
+ },
1130
+ {
1131
+ "type": "text",
1132
+ "text": "4.2.2. ACCURACY COMPARISON ON GENERATION TASKS",
1133
+ "text_level": 1,
1134
+ "bbox": [
1135
+ 496,
1136
+ 556,
1137
+ 848,
1138
+ 584
1139
+ ],
1140
+ "page_idx": 5
1141
+ },
1142
+ {
1143
+ "type": "text",
1144
+ "text": "LM-Eval Results. We benchmark KIVI on CoQA, TruthfulQA, and GSM8K tasks using LM-Eval framework. All dataset parameters were set to default. We compare the standard 16bit configuration with our KIVI compression techniques across Llama-2-7B, Llama-2-13B, Falcon-7B, and Mistral-7B. As shown in Table 3, we observe that for the Llama and Mistral model, KIVI only has up to $2\\%$ accuracy drop despite the KV cache being stored in 2bit. For instance, in the Llama-2-7B model, the transition from 16bit to 2bit only slightly decreases accuracy. Similar trends are observed in other Llama-family models. Since Falcon-7B adopts multi-query attention and only has one head for KV cache, it is already highly compressed compared to Llama-based models. Thus, in Table 3, 4bit KIVI is needed to maintain the accuracy, while 2bit KIVI may have a large accuracy drop in this case.",
1145
+ "bbox": [
1146
+ 495,
1147
+ 594,
1148
+ 887,
1149
+ 835
1150
+ ],
1151
+ "page_idx": 5
1152
+ },
1153
+ {
1154
+ "type": "text",
1155
+ "text": "LongBench Results. The performance of KIVI over various models in the LongBench dataset is summarised in Table 4. We apply KIVI over Llama2-7B, Llama2-13B, Llama2-",
1156
+ "bbox": [
1157
+ 495,
1158
+ 859,
1159
+ 888,
1160
+ 905
1161
+ ],
1162
+ "page_idx": 5
1163
+ },
1164
+ {
1165
+ "type": "header",
1166
+ "text": "KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache",
1167
+ "bbox": [
1168
+ 272,
1169
+ 56,
1170
+ 699,
1171
+ 70
1172
+ ],
1173
+ "page_idx": 5
1174
+ },
1175
+ {
1176
+ "type": "page_footnote",
1177
+ "text": "<sup>1</sup>The closed-end tasks such as MMLU are not ideal to evaluate KIVI since they only involve one decoding step and directly fetch the output logits, which is not suitable for studying the impact of compressed KV cache.",
1178
+ "bbox": [
1179
+ 84,
1180
+ 852,
1181
+ 475,
1182
+ 906
1183
+ ],
1184
+ "page_idx": 5
1185
+ },
1186
+ {
1187
+ "type": "page_number",
1188
+ "text": "6",
1189
+ "bbox": [
1190
+ 480,
1191
+ 922,
1192
+ 491,
1193
+ 934
1194
+ ],
1195
+ "page_idx": 5
1196
+ },
1197
+ {
1198
+ "type": "text",
1199
+ "text": "Table 3: Performance comparison between 16bit, 4-bit pentoken quantization, four fake 2bit KV cache quantization similar to those in Table 1, KIVI-2 (2bit) / KIVI-4 (4bit) across various models. We emphasize that unlike KIVI, which preserves a small portion of full precision key cache $\\mathbf{X}_{K_r}$ and value cache $\\mathbf{X}_{V_r}$ , all tokens in fake KV cache quantization are quantized for a fair comparison. $\\mathbb{C}$ stands for per-channel quantization and $\\mathbb{T}$ stands for per-token quantization.",
1200
+ "bbox": [
1201
+ 84,
1202
+ 82,
1203
+ 475,
1204
+ 219
1205
+ ],
1206
+ "page_idx": 6
1207
+ },
1208
+ {
1209
+ "type": "table",
1210
+ "img_path": "images/b9d5fd1df192324551431913bf7a9fa789e7ea8f46bf084595d8a4d63e6fb24a.jpg",
1211
+ "table_caption": [],
1212
+ "table_footnote": [],
1213
+ "table_body": "<table><tr><td>Model</td><td></td><td>CoQA</td><td>TruthfulQA</td><td>GSM8K</td></tr><tr><td rowspan=\"8\">Llama-2-7B</td><td>16bit</td><td>63.88</td><td>30.76</td><td>13.50</td></tr><tr><td>4bit (K - T, V - T)</td><td>64.82</td><td>29.85</td><td>12.28</td></tr><tr><td>2bit (K - C, V - T)</td><td>59.08</td><td>33.10</td><td>5.76</td></tr><tr><td>2bit (K - T, V - T)</td><td>39.88</td><td>18.29</td><td>0.83</td></tr><tr><td>2bit (K - C, V - C)</td><td>3.60</td><td>0.27</td><td>0.00</td></tr><tr><td>2bit (K - T, V - C)</td><td>1.30</td><td>0.49</td><td>0.08</td></tr><tr><td>KIVI-4</td><td>63.78</td><td>30.80</td><td>13.80</td></tr><tr><td>KIVI-2</td><td>63.05</td><td>33.95</td><td>12.74</td></tr><tr><td rowspan=\"8\">Llama-2-13B</td><td>16bit</td><td>66.37</td><td>29.53</td><td>22.67</td></tr><tr><td>4bit (K - T, V - T)</td><td>66.73</td><td>29.14</td><td>20.92</td></tr><tr><td>2bit (K - C, V - T)</td><td>63.53</td><td>28.60</td><td>12.21</td></tr><tr><td>2bit (K - T, V - T)</td><td>52.93</td><td>24.98</td><td>4.55</td></tr><tr><td>2bit (K - C, V - C)</td><td>2.88</td><td>0.74</td><td>0.00</td></tr><tr><td>2bit (K - T, V - C)</td><td>2.80</td><td>0.26</td><td>0.08</td></tr><tr><td>KIVI-4</td><td>66.38</td><td>29.49</td><td>23.65</td></tr><tr><td>KIVI-2</td><td>66.23</td><td>29.84</td><td>20.77</td></tr><tr><td rowspan=\"8\">Falcon-7B</td><td>16bit</td><td>59.83</td><td>23.20</td><td>4.55</td></tr><tr><td>4bit (K - T, V - T)</td><td>58.53</td><td>22.94</td><td>3.26</td></tr><tr><td>2bit (K - C, V - T)</td><td>43.93</td><td>20.82</td><td>1.29</td></tr><tr><td>2bit (K - T, V - T)</td><td>25.72</td><td>0.91</td><td>0.53</td></tr><tr><td>2bit (K - C, V - C)</td><td>41.95</td><td>17.11</td><td>1.52</td></tr><tr><td>2bit (K - T, V - C)</td><td>19.53</td><td>0.94</td><td>0.15</td></tr><tr><td>KIVI-4</td><td>59.67</td><td>22.58</td><td>4.47</td></tr><tr><td>KIVI-2</td><td>57.48</td><td>24.98</td><td>3.41</td></tr><tr><td rowspan=\"8\">Mistral-7B</td><td>16bit</td><td>67.40</td><td>30.45</td><td>38.36</td></tr><tr><td>4bit (K - T, V - T)</td><td>67.80</td><td>29.83</td><td>36.85</td></tr><tr><td>2bit (K - C, V - T)</td><td>61.65</td><td>29.64</td><td>26.46</td></tr><tr><td>2bit (K - T, V - T)</td><td>54.55</td><td>25.86</td><td>5.00</td></tr><tr><td>2bit (K - C, V - C)</td><td>24.40</td><td>24.86</td><td>2.27</td></tr><tr><td>2bit (K - T, V - C)</td><td>10.73</td><td>19.12</td><td>0.99</td></tr><tr><td>KIVI-4</td><td>66.95</td><td>30.49</td><td>37.30</td></tr><tr><td>KIVI-2</td><td>66.35</td><td>32.17</td><td>36.01</td></tr></table>",
1214
+ "bbox": [
1215
+ 89,
1216
+ 229,
1217
+ 470,
1218
+ 657
1219
+ ],
1220
+ "page_idx": 6
1221
+ },
1222
+ {
1223
+ "type": "text",
1224
+ "text": "7B-Chat, Llama2-13B-Chat, Falcon-7B and Mistral-7B. Table 4 suggests that KIVI is an effective method for KV cache compression with minimal impact on accuracy across various hard long context generation tasks. We also present additional results using Mistral-7B-v0.2 and LongChat-7B-v1.5 on LongBench, which can be found in Table 8 and Table 9, respectively.",
1225
+ "bbox": [
1226
+ 84,
1227
+ 686,
1228
+ 475,
1229
+ 792
1230
+ ],
1231
+ "page_idx": 6
1232
+ },
1233
+ {
1234
+ "type": "text",
1235
+ "text": "4.2.3. ABLATION",
1236
+ "text_level": 1,
1237
+ "bbox": [
1238
+ 84,
1239
+ 806,
1240
+ 210,
1241
+ 820
1242
+ ],
1243
+ "page_idx": 6
1244
+ },
1245
+ {
1246
+ "type": "text",
1247
+ "text": "In this section, we benchmark KIVI on GSM8K, one of the hardest generation tasks, to show the effect of hyperparameters group size $G$ and residual length $R$ on the model performance. For full results of KIVI with a residual length of 32, please refer to Appendix B.",
1248
+ "bbox": [
1249
+ 84,
1250
+ 829,
1251
+ 475,
1252
+ 906
1253
+ ],
1254
+ "page_idx": 6
1255
+ },
1256
+ {
1257
+ "type": "image",
1258
+ "img_path": "images/a4bede7aeed2fd43682a6ee9a10b3bc87482a2ed8c4466780a118c60101a7638.jpg",
1259
+ "image_caption": [],
1260
+ "image_footnote": [],
1261
+ "bbox": [
1262
+ 547,
1263
+ 85,
1264
+ 844,
1265
+ 237
1266
+ ],
1267
+ "page_idx": 6
1268
+ },
1269
+ {
1270
+ "type": "image",
1271
+ "img_path": "images/0f6d1c78dab71d173df268013d7d78384803c2a0fa53d32e7c778746c8d000b3.jpg",
1272
+ "image_caption": [
1273
+ "Figure 4: Memory usage and throughput comparison between 2bit KIVI and 16bit baseline. KIVI can achieve higher throughput by enabling a larger batch size."
1274
+ ],
1275
+ "image_footnote": [],
1276
+ "bbox": [
1277
+ 540,
1278
+ 239,
1279
+ 841,
1280
+ 391
1281
+ ],
1282
+ "page_idx": 6
1283
+ },
1284
+ {
1285
+ "type": "text",
1286
+ "text": "The effect of group size. We fix the residual length at 128 and vary the group sizes to 32, 64, and 128. From Table 5, we observe that group sizes 32 and 64 yield similar results, whereas the performance significantly decreases when the group size reaches 128. Note the zero-point and the scaling factor mentioned in Section 3.1 are calculated according to this group size; where the choice of group size will greatly impact the KV cache compression effect under a long input.",
1287
+ "bbox": [
1288
+ 495,
1289
+ 481,
1290
+ 887,
1291
+ 603
1292
+ ],
1293
+ "page_idx": 6
1294
+ },
1295
+ {
1296
+ "type": "text",
1297
+ "text": "The effect of residual length. We fix the group size at 32 and vary the residual length across 32, 64, 96, and 128. As shown in Table 5, there is no consistent pattern between residual lengths and model accuracy. Namely, while a residual length of 128 achieves good results, 32 and 96 yield similar outcomes, but a residual length of 64 results in the worst performance. We emphasize that while we observe no significance among residual lengths of $\\{32, 96, 128\\}$ , having a reasonably large residual length is important; as it brings much performance boosts on hard tasks like GSM8K, again as shown in Table 5.",
1298
+ "bbox": [
1299
+ 495,
1300
+ 609,
1301
+ 888,
1302
+ 777
1303
+ ],
1304
+ "page_idx": 6
1305
+ },
1306
+ {
1307
+ "type": "text",
1308
+ "text": "4.2.4. EFFICIENCY COMPARISON",
1309
+ "text_level": 1,
1310
+ "bbox": [
1311
+ 496,
1312
+ 791,
1313
+ 732,
1314
+ 805
1315
+ ],
1316
+ "page_idx": 6
1317
+ },
1318
+ {
1319
+ "type": "text",
1320
+ "text": "To evaluate the wall-clock time efficiency of KIVI, following vLLM (Kwon et al., 2023), we synthesize workloads based on ShareGPT (sha, 2023), which contain input and output texts of real LLM services. On average, the data set has an input prompt length $l_{\\mathrm{prompt}}$ of 161 and an output length $l_{\\mathrm{gen}}$ of 338 (Kwon et al., 2023). We increase the batch",
1321
+ "bbox": [
1322
+ 495,
1323
+ 814,
1324
+ 888,
1325
+ 906
1326
+ ],
1327
+ "page_idx": 6
1328
+ },
1329
+ {
1330
+ "type": "header",
1331
+ "text": "KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache",
1332
+ "bbox": [
1333
+ 272,
1334
+ 56,
1335
+ 699,
1336
+ 70
1337
+ ],
1338
+ "page_idx": 6
1339
+ },
1340
+ {
1341
+ "type": "page_number",
1342
+ "text": "7",
1343
+ "bbox": [
1344
+ 480,
1345
+ 922,
1346
+ 491,
1347
+ 934
1348
+ ],
1349
+ "page_idx": 6
1350
+ },
1351
+ {
1352
+ "type": "table",
1353
+ "img_path": "images/79c4fbee5e14fffaa2814def7074f6c8e5a3b8a6156f1649bdc03b3cc2b9507d.jpg",
1354
+ "table_caption": [
1355
+ "Table 4: Performance evaluation of KIVI on various models across a range of benchmarks in LongBench. We highlight the average performance of our method. More similar results on Mistral-7B-v0.2 and LongChat-7b-v1.5 can be found in Table 8 and Table 9"
1356
+ ],
1357
+ "table_footnote": [],
1358
+ "table_body": "<table><tr><td>Model</td><td></td><td>Qasper</td><td>QMSum</td><td>MultiNews</td><td>TREC</td><td>TriviaQA</td><td>SAMSum</td><td>LCC</td><td>RepoBench-P</td><td>Average</td></tr><tr><td rowspan=\"3\">Llama2-7B</td><td>16bit</td><td>9.52</td><td>21.28</td><td>3.51</td><td>66</td><td>87.72</td><td>41.69</td><td>66.66</td><td>59.82</td><td>44.52</td></tr><tr><td>KIVI-4</td><td>9.28</td><td>21.42</td><td>3.88</td><td>66</td><td>87.72</td><td>41.82</td><td>66.8</td><td>59.83</td><td>44.59</td></tr><tr><td>KIVI-2</td><td>9.31</td><td>20.5</td><td>1.14</td><td>66</td><td>87.42</td><td>42.71</td><td>66.88</td><td>60.23</td><td>44.27</td></tr><tr><td rowspan=\"3\">Llama2-13B</td><td>16bit</td><td>9.32</td><td>21.38</td><td>3.71</td><td>70</td><td>87.87</td><td>43.55</td><td>66.61</td><td>56.42</td><td>44.85</td></tr><tr><td>KIVI-4</td><td>9.16</td><td>20.86</td><td>3.21</td><td>69</td><td>86.97</td><td>44.26</td><td>65.3</td><td>57.08</td><td>44.48</td></tr><tr><td>KIVI-2</td><td>8.58</td><td>20.69</td><td>6.19</td><td>69.5</td><td>87.78</td><td>44.3</td><td>65.08</td><td>55.46</td><td>44.69</td></tr><tr><td rowspan=\"3\">Llama2-7B-Chat</td><td>16bit</td><td>19.65</td><td>20.54</td><td>26.36</td><td>63</td><td>84.28</td><td>41.12</td><td>59.75</td><td>52.93</td><td>45.95</td></tr><tr><td>KIVI-4</td><td>19.62</td><td>20.7</td><td>25.49</td><td>63</td><td>84.13</td><td>40.87</td><td>59.27</td><td>53.56</td><td>45.83</td></tr><tr><td>KIVI-2</td><td>19.32</td><td>20.46</td><td>25.48</td><td>63</td><td>84.84</td><td>40.6</td><td>58.71</td><td>52.97</td><td>45.67</td></tr><tr><td rowspan=\"3\">Llama2-13B-Chat</td><td>16bit</td><td>24.18</td><td>20.37</td><td>25.69</td><td>67.5</td><td>86.9</td><td>42.18</td><td>50.23</td><td>50.64</td><td>45.96</td></tr><tr><td>KIVI-4</td><td>23</td><td>20.36</td><td>26.06</td><td>67.5</td><td>87.2</td><td>42.04</td><td>52.55</td><td>52.77</td><td>46.44</td></tr><tr><td>KIVI-2</td><td>23.59</td><td>20.76</td><td>25.25</td><td>67.5</td><td>87.17</td><td>41.56</td><td>49.93</td><td>48.45</td><td>45.52</td></tr><tr><td rowspan=\"3\">Falcon-7B</td><td>16bit</td><td>1.48</td><td>2.35</td><td>11.09</td><td>13</td><td>5.84</td><td>2.44</td><td>23.86</td><td>9.69</td><td>8.71</td></tr><tr><td>KIVI-4</td><td>1.04</td><td>2.41</td><td>11.98</td><td>13</td><td>5.84</td><td>2.36</td><td>23.72</td><td>9.92</td><td>8.78</td></tr><tr><td>KIVI-2</td><td>1.98</td><td>3.61</td><td>6.78</td><td>10</td><td>6.24</td><td>2.73</td><td>22.18</td><td>10.12</td><td>7.95</td></tr><tr><td rowspan=\"3\">Mistral-7B</td><td>16bit</td><td>8.12</td><td>19.98</td><td>19.99</td><td>67.5</td><td>89.8</td><td>41.69</td><td>66.59</td><td>58.99</td><td>46.58</td></tr><tr><td>KIVI-4</td><td>7.89</td><td>20.06</td><td>20.58</td><td>67.5</td><td>89.8</td><td>41.56</td><td>66.45</td><td>58.62</td><td>46.56</td></tr><tr><td>KIVI-2</td><td>6.92</td><td>19.71</td><td>17.92</td><td>66.5</td><td>89.63</td><td>41.66</td><td>65.52</td><td>58.99</td><td>45.85</td></tr></table>",
1359
+ "bbox": [
1360
+ 89,
1361
+ 138,
1362
+ 883,
1363
+ 420
1364
+ ],
1365
+ "page_idx": 7
1366
+ },
1367
+ {
1368
+ "type": "table",
1369
+ "img_path": "images/1abeadc983abf1f72c99154af2f904fe6e6cc9e42aea035ce46caa19c7f5761a.jpg",
1370
+ "table_caption": [
1371
+ "Table 5: Ablation study of KIVI by changing group size $G$ and residual length $R$ ."
1372
+ ],
1373
+ "table_footnote": [],
1374
+ "table_body": "<table><tr><td>Model</td><td>Group Size</td><td>GSM8K</td></tr><tr><td rowspan=\"3\">Llama2-13B</td><td>32</td><td>20.77</td></tr><tr><td>64</td><td>21.00</td></tr><tr><td>128</td><td>17.29</td></tr><tr><td>Model</td><td>Residual Length</td><td>GSM8K</td></tr><tr><td rowspan=\"4\">Llama2-13B</td><td>32</td><td>20.62</td></tr><tr><td>64</td><td>19.86</td></tr><tr><td>96</td><td>20.55</td></tr><tr><td>128</td><td>20.77</td></tr></table>",
1375
+ "bbox": [
1376
+ 133,
1377
+ 483,
1378
+ 424,
1379
+ 631
1380
+ ],
1381
+ "page_idx": 7
1382
+ },
1383
+ {
1384
+ "type": "text",
1385
+ "text": "size until out of memory and report the peak memory usage and throughput between KIVI (with residual length 32 and 128) and FP16 baseline for the Llama-2-7B model. The hardware here is a single NVIDIA A100 GPU (80GB).",
1386
+ "bbox": [
1387
+ 84,
1388
+ 641,
1389
+ 473,
1390
+ 702
1391
+ ],
1392
+ "page_idx": 7
1393
+ },
1394
+ {
1395
+ "type": "text",
1396
+ "text": "As shown in Figure 4, with similar maximum memory usage, KIVI enables up to $4 \\times$ larger batch size and gives $2.35 \\times \\sim 3.47 \\times$ larger throughput. This throughput number can grow larger with longer context length and output length. We also note that this speed-up can be greatly increased if we further fuse the KV cache quantization process with previous operations. We leave it as one of future work.",
1397
+ "bbox": [
1398
+ 84,
1399
+ 708,
1400
+ 475,
1401
+ 829
1402
+ ],
1403
+ "page_idx": 7
1404
+ },
1405
+ {
1406
+ "type": "text",
1407
+ "text": "5. Related Work",
1408
+ "text_level": 1,
1409
+ "bbox": [
1410
+ 84,
1411
+ 849,
1412
+ 227,
1413
+ 864
1414
+ ],
1415
+ "page_idx": 7
1416
+ },
1417
+ {
1418
+ "type": "text",
1419
+ "text": "Many machine learning system work have been proposed to scale up LLM training and inference process (Pope",
1420
+ "bbox": [
1421
+ 84,
1422
+ 875,
1423
+ 473,
1424
+ 906
1425
+ ],
1426
+ "page_idx": 7
1427
+ },
1428
+ {
1429
+ "type": "text",
1430
+ "text": "et al., 2023; Wang et al., 2023; 2022). Among them, quantization techniques have been widely applied (Frantar et al., 2022; Lin et al., 2023; Kim et al., 2023; Xu et al., 2023). A main branch of LLM quantization is weight-only quantization, which involves the quantization of model weights to lower precision. For instance, AWQ (Lin et al., 2023) cleverly quantizes model weights to INT4 and INT3 using an activation-aware manner. GPTQ (Frantar et al., 2022) utilizes approximate second-order information to quantize model weights both accurately and efficiently. SqueezeLLM (Kim et al., 2023) adopts the concept of sensitivity-based non-uniform quantization along with Dense-and-Sparse decomposition. This line of work is orthogonal to ours, as they can be combined together.",
1431
+ "bbox": [
1432
+ 495,
1433
+ 444,
1434
+ 887,
1435
+ 656
1436
+ ],
1437
+ "page_idx": 7
1438
+ },
1439
+ {
1440
+ "type": "text",
1441
+ "text": "SmoothQuant (Xiao et al., 2023a) is a post-training quantization method that is more closely related to our work. This method uses equivalent transformations to balance the quantization complexity for both activation and weight, making the activation easier to quantize. SmoothQuant can compress KV cache to 8bit with minor performance loss. However, it faces a significant accuracy drop when scaled down to 4bit or less (Zhao et al., 2024). FlexGen adopts 4-bit per-token quantization for both key and value cache.",
1442
+ "bbox": [
1443
+ 495,
1444
+ 662,
1445
+ 887,
1446
+ 800
1447
+ ],
1448
+ "page_idx": 7
1449
+ },
1450
+ {
1451
+ "type": "text",
1452
+ "text": "One important recipe of KIVI is the per-channel quantization scheme designed base on observation made in Section 3.2 and Figure 2. ATOM (Zhao et al., 2024) also identifies that the Key cache exhibits more outliers compared to the Value cache. KIVI provides further extensive analysis and leverages this observation to implement per-channel",
1453
+ "bbox": [
1454
+ 495,
1455
+ 806,
1456
+ 888,
1457
+ 898
1458
+ ],
1459
+ "page_idx": 7
1460
+ },
1461
+ {
1462
+ "type": "header",
1463
+ "text": "KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache",
1464
+ "bbox": [
1465
+ 272,
1466
+ 56,
1467
+ 699,
1468
+ 70
1469
+ ],
1470
+ "page_idx": 7
1471
+ },
1472
+ {
1473
+ "type": "page_number",
1474
+ "text": "8",
1475
+ "bbox": [
1476
+ 480,
1477
+ 922,
1478
+ 491,
1479
+ 934
1480
+ ],
1481
+ "page_idx": 7
1482
+ },
1483
+ {
1484
+ "type": "text",
1485
+ "text": "quantization. A similar observation and approach have been independently discovered and developed in the concurrent work KVQuant (Hooper et al., 2024).",
1486
+ "bbox": [
1487
+ 84,
1488
+ 85,
1489
+ 473,
1490
+ 131
1491
+ ],
1492
+ "page_idx": 8
1493
+ },
1494
+ {
1495
+ "type": "text",
1496
+ "text": "vLLM (Kwon et al., 2023) and S3 (Jin et al., 2023) are system-level works, which include memory management through the use of PagedAttention or memory usage prediction. They can lower the memory requirements of KV cache and simultaneously increase model throughput. This research direction is orthogonal to our work, since system-level optimizations can also be applied upon our algorithm.",
1497
+ "bbox": [
1498
+ 84,
1499
+ 137,
1500
+ 475,
1501
+ 243
1502
+ ],
1503
+ "page_idx": 8
1504
+ },
1505
+ {
1506
+ "type": "text",
1507
+ "text": "Several other works also consider compressing KV cache by evicting tokens. H2O (Zhang et al., 2023) retains only a small portion of tokens that contribute significantly to the attention scores. Similarly, Scissorhands (Liu et al., 2024) exploit the persistence of the importance hypothesis in KV cache sparsification. StreamingLLM (Xiao et al., 2023b) is based on the observation of \"attention sink\" and maintains only a few initial tokens to preserve performance. Unlike these works, our KIVI retains all input tokens and compresses them into lower precision. This line of work is orthogonal to ours, as they also can be combined together.",
1508
+ "bbox": [
1509
+ 84,
1510
+ 250,
1511
+ 475,
1512
+ 417
1513
+ ],
1514
+ "page_idx": 8
1515
+ },
1516
+ {
1517
+ "type": "text",
1518
+ "text": "6. Conclusion and Future Work",
1519
+ "text_level": 1,
1520
+ "bbox": [
1521
+ 84,
1522
+ 436,
1523
+ 354,
1524
+ 452
1525
+ ],
1526
+ "page_idx": 8
1527
+ },
1528
+ {
1529
+ "type": "text",
1530
+ "text": "In this paper, we systematically analyze KV cache element distribution in popular LLMs. We conclude that key cache should be quantized per-channel and value cache should be quantized per token. Based on these observations, we propose KIVI, a plug-and-play 2bit KV cache quantization algorithm without the need for any tuning. In real LLM workload, KIVI allows up to $4 \\times$ larger batch sizes and $3.47 \\times$ throughput. In the future, we will further optimize the implementation to reduce the overhead of quantization process during the prefetch and decoding phase.",
1531
+ "bbox": [
1532
+ 84,
1533
+ 462,
1534
+ 475,
1535
+ 613
1536
+ ],
1537
+ "page_idx": 8
1538
+ },
1539
+ {
1540
+ "type": "text",
1541
+ "text": "Acknowledgments",
1542
+ "text_level": 1,
1543
+ "bbox": [
1544
+ 86,
1545
+ 633,
1546
+ 243,
1547
+ 648
1548
+ ],
1549
+ "page_idx": 8
1550
+ },
1551
+ {
1552
+ "type": "text",
1553
+ "text": "The authors thank the anonymous reviewers for their helpful comments. Dr. Beidi Chen is supported by a research gift from Moffett.AI. Dr. Vladimir Braverman is partially supported by the Ministry of Trade, Industry and Energy (MOTIE) and Korea Institute for Advancement of Technology (KIAT) through the International Cooperative R&D program, the Naval Research (ONR) grant N00014-23-1-2737, and NSF CNS 2333887 award. Dr. Xia Hu is supported by NSF grants NSF IIS-2224843. The views and conclusions contained in this paper are those of the authors and should not be interpreted as representing any funding agencies.",
1554
+ "bbox": [
1555
+ 84,
1556
+ 659,
1557
+ 475,
1558
+ 825
1559
+ ],
1560
+ "page_idx": 8
1561
+ },
1562
+ {
1563
+ "type": "text",
1564
+ "text": "Impact Statement",
1565
+ "text_level": 1,
1566
+ "bbox": [
1567
+ 84,
1568
+ 844,
1569
+ 240,
1570
+ 861
1571
+ ],
1572
+ "page_idx": 8
1573
+ },
1574
+ {
1575
+ "type": "text",
1576
+ "text": "This paper presents work whose goal is to advance the field of Machine Learning. There are many potential societal",
1577
+ "bbox": [
1578
+ 84,
1579
+ 869,
1580
+ 473,
1581
+ 900
1582
+ ],
1583
+ "page_idx": 8
1584
+ },
1585
+ {
1586
+ "type": "text",
1587
+ "text": "consequences of our work, none which we feel must be specifically highlighted here.",
1588
+ "bbox": [
1589
+ 496,
1590
+ 85,
1591
+ 885,
1592
+ 114
1593
+ ],
1594
+ "page_idx": 8
1595
+ },
1596
+ {
1597
+ "type": "text",
1598
+ "text": "References",
1599
+ "text_level": 1,
1600
+ "bbox": [
1601
+ 498,
1602
+ 133,
1603
+ 593,
1604
+ 148
1605
+ ],
1606
+ "page_idx": 8
1607
+ },
1608
+ {
1609
+ "type": "list",
1610
+ "sub_type": "ref_text",
1611
+ "list_items": [
1612
+ "ShareGPT Team. https://sharegpt.com/, 2023.",
1613
+ "Joshua Ainslie, James Lee-Thorp, Michiel de Jong, Yury Zemlyanskiy, Federico Lebrón, and Sumit Sanghai. Gqa: Training generalized multi-query transformer models from multi-head checkpoints. arXiv preprint arXiv:2305.13245, 2023.",
1614
+ "Yushi Bai, Xin Lv, Jiajie Zhang, Hongchang Lyu, Jiankai Tang, Zhidian Huang, Zhengxiao Du, Xiao Liu, Aohan Zeng, Lei Hou, Yuxiao Dong, Jie Tang, and Juanzi Li. Longbench: A bilingual, multitask benchmark for long context understanding. arXiv preprint arXiv:2308.14508, 2023.",
1615
+ "Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. Advances in neural information processing systems, 33:1877-1901, 2020.",
1616
+ "Tim Dettmers, Mike Lewis, Younes Belkada, and Luke Zettlemoyer. Llm. int8(): 8-bit matrix multiplication for transformers at scale. arXiv preprint arXiv:2208.07339, 2022.",
1617
+ "Elias Frantar, Saleh Ashkboos, Torsten Hoefler, and Dan Alistarh. Gptq: Accurate post-training quantization for generative pre-trained transformers. arXiv preprint arXiv:2210.17323, 2022.",
1618
+ "Leo Gao, Jonathan Tow, Stella Biderman, Sid Black, Anthony DiPofi, Charles Foster, Laurence Golding, Jeffrey Hsu, Kyle McDonell, Niklas Muennighoff, et al. A framework for few-shot language model evaluation. Version v0. 0.1. Sept, page 8, 2021.",
1619
+ "Coleman Hooper, Sehoon Kim, Hiva Mohammadzadeh, Michael W Mahoney, Yakun Sophia Shao, Kurt Keutzer, and Amir Gholami. Kvquant: Towards 10 million context length llm inference with kv cache quantization. arXiv preprint arXiv:2401.18079, 2024.",
1620
+ "Albert Q Jiang, Alexandre Sablayrolles, Arthur Mensch, Chris Bamford, Devendra Singh Chaplot, Diego de las Casas, Florian Bressand, Gianna Lengyel, Guillaume Lample, Lucile Saulnier, et al. Mistral 7b. arXiv preprint arXiv:2310.06825, 2023.",
1621
+ "Yunho Jin, Chun-Feng Wu, David Brooks, and Gu-Yeon Wei. S3: Increasing gpu utilization during generative inference for higher throughput. arXiv preprint arXiv:2306.06000, 2023."
1622
+ ],
1623
+ "bbox": [
1624
+ 496,
1625
+ 157,
1626
+ 887,
1627
+ 905
1628
+ ],
1629
+ "page_idx": 8
1630
+ },
1631
+ {
1632
+ "type": "header",
1633
+ "text": "KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache",
1634
+ "bbox": [
1635
+ 272,
1636
+ 56,
1637
+ 699,
1638
+ 70
1639
+ ],
1640
+ "page_idx": 8
1641
+ },
1642
+ {
1643
+ "type": "page_number",
1644
+ "text": "9",
1645
+ "bbox": [
1646
+ 480,
1647
+ 922,
1648
+ 491,
1649
+ 934
1650
+ ],
1651
+ "page_idx": 8
1652
+ },
1653
+ {
1654
+ "type": "list",
1655
+ "sub_type": "ref_text",
1656
+ "list_items": [
1657
+ "Sehoon Kim, Coleman Hooper, Amir Gholami, Zhen Dong, Xiuyu Li, Sheng Shen, Michael W Mahoney, and Kurt Keutzer. Squeezeellm: Dense-and-sparse quantization. arXiv preprint arXiv:2306.07629, 2023.",
1658
+ "Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph Gonzalez, Hao Zhang, and Ion Stoica. Efficient memory management for large language model serving with pagedattention. In Proceedings of the 29th Symposium on Operating Systems Principles, pages 611-626, 2023.",
1659
+ "Ji Lin, Jiaming Tang, Haotian Tang, Shang Yang, Xingyu Dang, and Song Han. Awq: Activation-aware weight quantization for llm compression and acceleration. arXiv preprint arXiv:2306.00978, 2023.",
1660
+ "Zichang Liu, Aditya Desai, Fangshuo Liao, Weitao Wang, Victor Xie, Zhaozhuo Xu, Anastasios Kyrillidis, and Anshumali Shrivastava. Scissorhands: Exploiting the persistence of importance hypothesis for llm kv cache compression at test time. Advances in Neural Information Processing Systems, 36, 2024.",
1661
+ "Guilherme Penedo, Quentin Malartic, Daniel Hesslow, Ruxandra Cojocaru, Alessandro Cappelli, Hamza Alobeidli, Baptiste Pannier, Ebtesam Almazrouei, and Julien Launay. The refinedweb dataset for falcon llm: outperforming curated corpora with web data, and web data only. arXiv preprint arXiv:2306.01116, 2023.",
1662
+ "Reiner Pope, Sholto Douglas, Aakanksha Chowdhery, Jacob Devlin, James Bradbury, Jonathan Heek, Kefan Xiao, Shivani Agrawal, and Jeff Dean. Efficiently scaling transformer inference. Proceedings of Machine Learning and Systems, 5, 2023.",
1663
+ "Noam Shazeer. Fast transformer decoding: One write-head is all you need. arXiv preprint arXiv:1911.02150, 2019.",
1664
+ "Ying Sheng, Lianmin Zheng, Binhang Yuan, Zhuohan Li, Max Ryabinin, Beidi Chen, Percy Liang, Christopher Ré, Ion Stoica, and Ce Zhang. Flexgen: High-throughput generative inference of large language models with a singlegpu. In International Conference on Machine Learning, pages 31094-31116. PMLR, 2023.",
1665
+ "Ross Taylor, Marcin Kardas, Guillem Cucurull, Thomas Scialom, Anthony Hartshorn, Elvis Saravia, Andrew Poulton, Viktor Kerkez, and Robert Stojnic. Galactica: A large language model for science. arXiv preprint arXiv:2211.09085, 2022.",
1666
+ "Yuandong Tian, Yiping Wang, Beidi Chen, and Simon Du. Scan and snap: Understanding training dynamics and token composition in 1-layer transformer. arXiv preprint arXiv:2305.16380, 2023."
1667
+ ],
1668
+ "bbox": [
1669
+ 86,
1670
+ 84,
1671
+ 478,
1672
+ 905
1673
+ ],
1674
+ "page_idx": 9
1675
+ },
1676
+ {
1677
+ "type": "list",
1678
+ "sub_type": "ref_text",
1679
+ "list_items": [
1680
+ "Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothee Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, et al. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971, 2023a.",
1681
+ "Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, et al. Llama 2: Open foundation and fine-tuned chat models. arXiv preprint arXiv:2307.09288, 2023b.",
1682
+ "Zhuang Wang, Zhaozhuo Xu, Xinyu Wu, Anshumali Shrivastava, and TS Eugene Ng. *Dragonn: Distributed randomized approximate gradients of neural networks*. In International Conference on Machine Learning, pages 23274-23291. PMLR, 2022.",
1683
+ "Zhuang Wang, Zhen Jia, Shuai Zheng, Zhen Zhang, Xinwei Fu, T. S. Eugene Ng, and Yida Wang. Gemini: Fast failure recovery in distributed training with in-memory checkpoints. In Proceedings of the 29th Symposium on Operating Systems Principles, 2023.",
1684
+ "Guangxuan Xiao, Ji Lin, Mickael Seznec, Hao Wu, Julien Demouth, and Song Han. Smoothquant: Accurate and efficient post-training quantization for large language models. In International Conference on Machine Learning, pages 38087-38099. PMLR, 2023a.",
1685
+ "Guangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han, and Mike Lewis. Efficient streaming language models with attention sinks. arXiv preprint arXiv:2309.17453, 2023b.",
1686
+ "Zhaozhuo Xu, Zirui Liu, Beidi Chen, Yuxin Tang, Jue Wang, Kaixiong Zhou, Xia Hu, and Anshumali Shrivastava. Compress, then prompt: Improving accuracy-efficiency trade-off of llm inference with transferable prompt. arXiv preprint arXiv:2305.11186, 2023.",
1687
+ "Jiayi Yuan, Ruixiang Tang, Xiaogian Jiang, and Xia Hu. Large language models for healthcare data augmentation: An example on patient-trial matching. In AMIA Annual Symposium Proceedings, volume 2023, page 1324. American Medical Informatics Association, 2023.",
1688
+ "Zhenyu Zhang, Ying Sheng, Tianyi Zhou, Tianlong Chen, Lianmin Zheng, Ruisi Cai, Zhao Song, Yuandong Tian, Christopher Ré, Clark Barrett, et al. H _2 o: Heavy-hitter oracle for efficient generative inference of large language models. arXiv preprint arXiv:2306.14048, 2023.",
1689
+ "Yilong Zhao, Chien-Yu Lin, Kan Zhu, Zihao Ye, Lequn Chen, Size Zheng, Luis Ceze, Arvind Krishnamurthy, Tianqi Chen, and Baris Kasikci. Atom: Low-bit quantization for efficient and accurate llm serving. Proceedings of Machine Learning and Systems, 6:196-209, 2024."
1690
+ ],
1691
+ "bbox": [
1692
+ 498,
1693
+ 84,
1694
+ 888,
1695
+ 905
1696
+ ],
1697
+ "page_idx": 9
1698
+ },
1699
+ {
1700
+ "type": "header",
1701
+ "text": "KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache",
1702
+ "bbox": [
1703
+ 272,
1704
+ 56,
1705
+ 699,
1706
+ 71
1707
+ ],
1708
+ "page_idx": 9
1709
+ },
1710
+ {
1711
+ "type": "page_number",
1712
+ "text": "10",
1713
+ "bbox": [
1714
+ 478,
1715
+ 922,
1716
+ 495,
1717
+ 934
1718
+ ],
1719
+ "page_idx": 9
1720
+ },
1721
+ {
1722
+ "type": "text",
1723
+ "text": "A. Detailed Implementations",
1724
+ "text_level": 1,
1725
+ "bbox": [
1726
+ 86,
1727
+ 83,
1728
+ 331,
1729
+ 101
1730
+ ],
1731
+ "page_idx": 10
1732
+ },
1733
+ {
1734
+ "type": "text",
1735
+ "text": "In this section, we present the algorithm for KIVI as discussed in Section 3.3. Specifically, we provide the pseudocode for KIVI when calculating the attention output in the prefetch and decoding phases.",
1736
+ "bbox": [
1737
+ 84,
1738
+ 109,
1739
+ 887,
1740
+ 141
1741
+ ],
1742
+ "page_idx": 10
1743
+ },
1744
+ {
1745
+ "type": "code",
1746
+ "sub_type": "code",
1747
+ "code_caption": [
1748
+ "Algorithm 1: The KIVI Prefix & Decoding Algorithm"
1749
+ ],
1750
+ "code_body": "parameter: group size $G$ ,residual length $R$ \nprocedure Prefill: Input: $\\pmb {X}\\in \\mathbb{R}^{l_{\\mathrm{prompt}}\\times d}$ $\\begin{array}{rl} & {\\pmb {X}_K = \\pmb {X}\\pmb {W}_K,\\pmb {X}_V = \\pmb {X}\\pmb {W}_V}\\\\ & {\\pmb {X}_{V_g} = \\pmb {X}_V[:l_{\\mathrm{prompt}} - R],\\pmb {X}_{V_r} = \\pmb {X}_V[l_{\\mathrm{prompt}} - R:]}\\\\ & {Q(\\pmb {X}_{V_g})\\leftarrow \\mathrm{GroupQuant}(\\pmb {X}_{V_g},\\mathrm{dim} = \\mathrm{token},\\mathrm{numGroup} = d / / }\\\\ & {Q(\\pmb {X}_{K_g}),\\pmb {X}_{K_r}\\leftarrow \\mathrm{KeyQuant}(\\pmb {X}_K)}\\\\ & {\\mathrm{KV~cache}\\leftarrow Q(\\pmb {X}_{K_g}),\\pmb {X}_{K_r},Q(\\pmb {X}_{V_g}),\\pmb {X}_{V_r}}\\\\ & {\\mathrm{return} \\pmb {X}_K,\\pmb {X}_V} \\end{array}$",
1751
+ "guess_lang": "txt",
1752
+ "bbox": [
1753
+ 86,
1754
+ 172,
1755
+ 501,
1756
+ 309
1757
+ ],
1758
+ "page_idx": 10
1759
+ },
1760
+ {
1761
+ "type": "code",
1762
+ "sub_type": "code",
1763
+ "code_caption": [
1764
+ "end"
1765
+ ],
1766
+ "code_body": "procedure Decoding: \nInput: KV cache, $t \\in \\mathbb{R}^{1 \\times d}$ $t_{Q} = tW_{Q}, t_{K} = tW_{K}, t_{V} = tW_{V}$ $Q(\\boldsymbol{X}_{K_{g}}), \\boldsymbol{X}_{K_{r}}, Q(\\boldsymbol{X}_{V_{g}}), \\boldsymbol{X}_{V_{r}} \\gets \\mathrm{KV~cache}$ $\\boldsymbol{X}_{K_{r}} \\gets \\mathrm{Concat}([\\boldsymbol{X}_{K_{r}}, t_{K}], \\dim=token)$ $\\boldsymbol{X}_{V_{r}} \\gets \\mathrm{Concat}([\\boldsymbol{X}_{V_{r}}, t_{V}], \\dim=token)$ \nif len( $X_{K_{r}}$ ) = R then \n $Q(\\boldsymbol{X}_{K_{r}}), -\\leftarrow \\mathrm{KeyQuant}(\\boldsymbol{X}_{K_{r}})$ $Q(\\boldsymbol{X}_{K_{g}}) \\gets \\mathrm{Concat}([Q(\\boldsymbol{X}_{K_{g}}), Q(\\boldsymbol{X}_{K_{r}})], \\dim=token)$ $\\boldsymbol{X}_{K_{r}} \\gets \\mathrm{empty~tensor}.$ \nend \nif len( $X_{V_{r}}$ ) > R then \n $Q(\\boldsymbol{X}_{V_{r}^{\\prime}}) \\gets \\mathrm{GroupQuant}(\\boldsymbol{X}_{V_{r}}[: -R], \\dim=token, \\mathrm{numGroup} = d // G)$ $Q(\\boldsymbol{X}_{V_{g}}) \\gets \\mathrm{Concat}([Q(\\boldsymbol{X}_{V_{g}}), Q(\\boldsymbol{X}_{V_{r}^{\\prime}})], \\dim=token)$ $\\boldsymbol{X}_{V_{r}} \\gets \\boldsymbol{X}_{V_{r}}[-R:]$ \nend \nA ← Concat([tQ(Q(\\boldsymbol{X}_{K_{g}})^{\\top}, tQ\\boldsymbol{X}_{K_{r}}^{\\top}], \\dim=token) \nA_g = Softmax(A)[-R], A_r = Softmax(A)[-R:] \ntO ← A_gQ(\\boldsymbol{X}_{V_{g}}) + A_r\\boldsymbol{X}_{V_{r}} \nKV cache ← Q(\\boldsymbol{X}_{K_{g}}, \\boldsymbol{X}_{K_{r}}, Q(\\boldsymbol{X}_{V_{g}}), \\boldsymbol{X}_{V_{r}}) \nreturn tO \nend \nfunction KeyQuant(\\boldsymbol{X}_k \\in \\mathbb{R}^{l \\times d}): \n r = l%R, \n X_K_g = X_K[: l-r], X_K_r = X_K[l-r:] \n Q(\\boldsymbol{X}_{K_g}) ← GroupQuant(X_K_g, dim=channel, numGroup=l // G) \n return Q(\\boldsymbol{X}_{K_g}), X_K_r \nend",
1767
+ "guess_lang": "julia",
1768
+ "bbox": [
1769
+ 86,
1770
+ 324,
1771
+ 607,
1772
+ 743
1773
+ ],
1774
+ "page_idx": 10
1775
+ },
1776
+ {
1777
+ "type": "text",
1778
+ "text": "B. More Experimental Results",
1779
+ "text_level": 1,
1780
+ "bbox": [
1781
+ 86,
1782
+ 766,
1783
+ 344,
1784
+ 784
1785
+ ],
1786
+ "page_idx": 10
1787
+ },
1788
+ {
1789
+ "type": "text",
1790
+ "text": "In our efficiency evaluation, we observe that with a residual length of 32, KIVI achieves a significantly higher memory compression rate, which in turn leads to increased throughput. Additionally, our ablation study reveals that changing the residual length from 128 to 32 does not result in a substantial performance gap. We demonstrate KIVI with a residual length of 32 across all benchmark datasets. As shown in Tables 6 and 7, KIVI with a residual length of 32 also delivers performance comparable to that of the 16-bit full model.",
1791
+ "bbox": [
1792
+ 84,
1793
+ 792,
1794
+ 887,
1795
+ 868
1796
+ ],
1797
+ "page_idx": 10
1798
+ },
1799
+ {
1800
+ "type": "text",
1801
+ "text": "We also present additional results using Mistral-7B-v0.2 and LongChat-7B-v1.5 on LongBench, which can be found in Table 8 and Table 9, respectively.",
1802
+ "bbox": [
1803
+ 84,
1804
+ 875,
1805
+ 887,
1806
+ 906
1807
+ ],
1808
+ "page_idx": 10
1809
+ },
1810
+ {
1811
+ "type": "header",
1812
+ "text": "KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache",
1813
+ "bbox": [
1814
+ 272,
1815
+ 56,
1816
+ 699,
1817
+ 70
1818
+ ],
1819
+ "page_idx": 10
1820
+ },
1821
+ {
1822
+ "type": "page_number",
1823
+ "text": "11",
1824
+ "bbox": [
1825
+ 477,
1826
+ 922,
1827
+ 493,
1828
+ 934
1829
+ ],
1830
+ "page_idx": 10
1831
+ },
1832
+ {
1833
+ "type": "table",
1834
+ "img_path": "images/02ecb7bb8eb979bcd4ef1a4cf6953d4415012281c4a83bbbe600fe68d166f873.jpg",
1835
+ "table_caption": [
1836
+ "Table 6: Performance comparison between 16bit, KIVI-2 (2bit) / KIVI-4 (4bit) with residual length 128 and 32 across various models. R32 stands for residual length 32."
1837
+ ],
1838
+ "table_footnote": [],
1839
+ "table_body": "<table><tr><td>Model</td><td></td><td>CoQA</td><td>TruthfulQA</td><td>GSM8K</td></tr><tr><td rowspan=\"3\">Llama-2-7B</td><td>16bit</td><td>63.88</td><td>30.76</td><td>13.50</td></tr><tr><td>KIVI-2 R128</td><td>63.05</td><td>33.95</td><td>12.74</td></tr><tr><td>KIVI-2 R32</td><td>62.85</td><td>33.01</td><td>13.57</td></tr><tr><td rowspan=\"3\">Llama-2-13B</td><td>16bit</td><td>66.37</td><td>29.53</td><td>22.67</td></tr><tr><td>KIVI-2 R128</td><td>66.23</td><td>29.84</td><td>20.77</td></tr><tr><td>KIVI-2 R32</td><td>66.57</td><td>29.35</td><td>20.62</td></tr><tr><td rowspan=\"5\">Falcon-7B</td><td>16bit</td><td>59.83</td><td>23.20</td><td>4.55</td></tr><tr><td>KIVI-4 R128</td><td>59.67</td><td>22.58</td><td>4.47</td></tr><tr><td>KIVI-4 R32</td><td>59.73</td><td>22.96</td><td>3.94</td></tr><tr><td>KIVI-2 R128</td><td>57.48</td><td>24.98</td><td>3.41</td></tr><tr><td>KIVI-2 R32</td><td>57.50</td><td>25.70</td><td>2.20</td></tr><tr><td rowspan=\"3\">Mistral-7B</td><td>16bit</td><td>67.40</td><td>30.45</td><td>38.36</td></tr><tr><td>KIVI-2 R128</td><td>66.35</td><td>32.17</td><td>36.01</td></tr><tr><td>KIVI-2 R32</td><td>65.90</td><td>31.21</td><td>34.34</td></tr></table>",
1840
+ "bbox": [
1841
+ 250,
1842
+ 167,
1843
+ 723,
1844
+ 429
1845
+ ],
1846
+ "page_idx": 11
1847
+ },
1848
+ {
1849
+ "type": "table",
1850
+ "img_path": "images/c24b315f39cc4e9501dd7067c945671a83ae8bedc19b396b10b9bd2e81e98503.jpg",
1851
+ "table_caption": [
1852
+ "Table 7: Performance evaluation of KIVI with residual length 128 and 32 on various models across a range of benchmarks in LongBench. $R32$ stands for residual length 32."
1853
+ ],
1854
+ "table_footnote": [],
1855
+ "table_body": "<table><tr><td>Model</td><td></td><td>Qasper</td><td>QMSum</td><td>MultiNews</td><td>TREC</td><td>TriviaQA</td><td>SAMSum</td><td>LCC</td><td>RepoBench-P</td><td>Average</td></tr><tr><td rowspan=\"3\">Llama2-7B</td><td>16bit</td><td>9.52</td><td>21.28</td><td>3.51</td><td>66</td><td>87.72</td><td>41.69</td><td>66.66</td><td>59.82</td><td>44.52</td></tr><tr><td>KIVI-2 R128</td><td>9.31</td><td>20.5</td><td>1.14</td><td>66</td><td>87.42</td><td>42.71</td><td>66.88</td><td>60.23</td><td>44.27</td></tr><tr><td>KIVI-2 R32</td><td>9.26</td><td>20.53</td><td>0.97</td><td>66</td><td>87.42</td><td>42.61</td><td>66.22</td><td>59.67</td><td>44.08</td></tr><tr><td rowspan=\"3\">Llama2-13B</td><td>16bit</td><td>9.32</td><td>21.38</td><td>3.71</td><td>70</td><td>87.87</td><td>43.55</td><td>66.61</td><td>56.42</td><td>44.85</td></tr><tr><td>KIVI-2 R128</td><td>8.58</td><td>20.69</td><td>6.19</td><td>69.5</td><td>87.78</td><td>44.3</td><td>65.08</td><td>55.46</td><td>44.69</td></tr><tr><td>KIVI-2 R32</td><td>8.38</td><td>20.74</td><td>7.01</td><td>69.5</td><td>87.78</td><td>44.43</td><td>64.89</td><td>55.31</td><td>44.75</td></tr><tr><td rowspan=\"3\">Llama2-7B-Chat</td><td>16bit</td><td>19.65</td><td>20.54</td><td>26.36</td><td>63</td><td>84.28</td><td>41.12</td><td>59.75</td><td>52.93</td><td>45.95</td></tr><tr><td>KIVI-2 R128</td><td>19.32</td><td>20.46</td><td>25.48</td><td>63</td><td>84.84</td><td>40.6</td><td>58.71</td><td>52.97</td><td>45.67</td></tr><tr><td>KIVI-2 R32</td><td>19.1</td><td>20.08</td><td>25.33</td><td>63</td><td>85.04</td><td>39.8</td><td>57.91</td><td>52.38</td><td>45.33</td></tr><tr><td rowspan=\"3\">Llama2-13B-Chat</td><td>16bit</td><td>24.18</td><td>20.37</td><td>25.69</td><td>67.5</td><td>86.9</td><td>42.18</td><td>50.23</td><td>50.64</td><td>45.96</td></tr><tr><td>KIVI-2 R128</td><td>23.59</td><td>20.76</td><td>25.25</td><td>67.5</td><td>87.17</td><td>41.56</td><td>49.93</td><td>48.45</td><td>45.52</td></tr><tr><td>KIVI-2 R32</td><td>23.56</td><td>20.9</td><td>25.45</td><td>67.5</td><td>87.42</td><td>41.4</td><td>48.93</td><td>48.81</td><td>45.49</td></tr><tr><td rowspan=\"5\">Falcon-7B</td><td>16bit</td><td>1.48</td><td>2.35</td><td>11.09</td><td>13</td><td>5.84</td><td>2.44</td><td>23.86</td><td>9.69</td><td>8.71</td></tr><tr><td>KIVI-4 R128</td><td>1.04</td><td>2.41</td><td>11.98</td><td>13</td><td>5.84</td><td>2.36</td><td>23.72</td><td>9.92</td><td>8.78</td></tr><tr><td>KIVI-4 R32</td><td>1.03</td><td>2.45</td><td>11.99</td><td>13.5</td><td>5.84</td><td>2.46</td><td>23.88</td><td>9.95</td><td>8.88</td></tr><tr><td>KIVI-2 R128</td><td>1.98</td><td>3.61</td><td>6.78</td><td>10</td><td>6.24</td><td>2.73</td><td>22.18</td><td>10.12</td><td>7.95</td></tr><tr><td>KIVI-2 R32</td><td>2.28</td><td>3.23</td><td>6.73</td><td>10</td><td>6.31</td><td>2.88</td><td>22.71</td><td>10.45</td><td>8.07</td></tr><tr><td rowspan=\"3\">Mistral-7B</td><td>16bit</td><td>8.12</td><td>19.98</td><td>19.99</td><td>67.5</td><td>89.8</td><td>41.69</td><td>66.59</td><td>58.99</td><td>46.58</td></tr><tr><td>KIVI-2 R128</td><td>6.92</td><td>19.71</td><td>17.92</td><td>66.5</td><td>89.63</td><td>41.66</td><td>65.52</td><td>58.99</td><td>45.85</td></tr><tr><td>KIVI-2 R32</td><td>6.84</td><td>19.81</td><td>17.2</td><td>66.5</td><td>89.63</td><td>42.82</td><td>65.13</td><td>58.06</td><td>45.74</td></tr></table>",
1856
+ "bbox": [
1857
+ 89,
1858
+ 566,
1859
+ 883,
1860
+ 859
1861
+ ],
1862
+ "page_idx": 11
1863
+ },
1864
+ {
1865
+ "type": "header",
1866
+ "text": "KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache",
1867
+ "bbox": [
1868
+ 272,
1869
+ 56,
1870
+ 699,
1871
+ 70
1872
+ ],
1873
+ "page_idx": 11
1874
+ },
1875
+ {
1876
+ "type": "page_number",
1877
+ "text": "12",
1878
+ "bbox": [
1879
+ 477,
1880
+ 922,
1881
+ 495,
1882
+ 934
1883
+ ],
1884
+ "page_idx": 11
1885
+ },
1886
+ {
1887
+ "type": "table",
1888
+ "img_path": "images/dbc25b2543b660b48bddb142371cffe8f9f1142100c004894da61afca801c304.jpg",
1889
+ "table_caption": [
1890
+ "Table 8: The results of LongChat-7B-v1.5-32K with KIVI on LongBench. The model has 32K context length. We use a 32 group size and 128 residual length for both KIVI-2 and KIVI-4. The baseline is of full precision."
1891
+ ],
1892
+ "table_footnote": [],
1893
+ "table_body": "<table><tr><td></td><td>NarrativeQA</td><td>Qasper</td><td>MultiFieldQA</td><td>HotpotQA</td><td>MuSiQue</td><td>2WikiMQA</td><td>GovReport</td><td>QMSum</td></tr><tr><td>Baseline</td><td>20.65</td><td>29.42</td><td>43.15</td><td>33.05</td><td>14.66</td><td>24.14</td><td>30.85</td><td>22.84</td></tr><tr><td>w./ KIVI-2</td><td>20.79</td><td>28.69</td><td>41.02</td><td>32.91</td><td>13.82</td><td>23.00</td><td>30.47</td><td>22.59</td></tr><tr><td>w./ KIVI-4</td><td>20.49</td><td>28.90</td><td>43.24</td><td>33.07</td><td>14.66</td><td>24.86</td><td>31.40</td><td>22.84</td></tr><tr><td></td><td>MultiNews</td><td>LCC</td><td>RepoBench-P</td><td>TriviaQA</td><td>SAMSum</td><td>TRec</td><td>PR</td><td>Avg</td></tr><tr><td>Baseline</td><td>26.55</td><td>54.83</td><td>58.94</td><td>83.99</td><td>40.75</td><td>66.50</td><td>30.50</td><td>38.72</td></tr><tr><td>w./ KIVI-2</td><td>26.28</td><td>54.11</td><td>57.62</td><td>83.19</td><td>41.28</td><td>66.50</td><td>32.25</td><td>38.30</td></tr><tr><td>w./ KIVI-4</td><td>26.52</td><td>54.06</td><td>58.77</td><td>83.88</td><td>40.62</td><td>67.00</td><td>31.50</td><td>38.79</td></tr></table>",
1894
+ "bbox": [
1895
+ 91,
1896
+ 233,
1897
+ 880,
1898
+ 371
1899
+ ],
1900
+ "page_idx": 12
1901
+ },
1902
+ {
1903
+ "type": "table",
1904
+ "img_path": "images/86f135f53b9c56510e1561e516d421bd4819d7332089137c0dd924db493e940c.jpg",
1905
+ "table_caption": [
1906
+ "Table 9: The results of Mistral-7B-Instruct-v0.2 with KIVI on LongBench. The model has 32K context length and applies group query attention, which uses 8 heads for KV Cache instead of the full 32 heads. We use a 32 group size and 128 residual length for both KIVI-2 and KIVI-4. The baseline is of full precision."
1907
+ ],
1908
+ "table_footnote": [],
1909
+ "table_body": "<table><tr><td></td><td>NarrativeQA</td><td>Qasper</td><td>MultiFieldQA</td><td>HotpotQA</td><td>MuSiQue</td><td>2WikiMQA</td><td>GovReport</td><td>QMSum</td></tr><tr><td>Baseline</td><td>21.02</td><td>29.41</td><td>47.13</td><td>36.53</td><td>19.13</td><td>21.76</td><td>32.59</td><td>23.99</td></tr><tr><td>w./ KIVI-2</td><td>20.61</td><td>28.73</td><td>44.88</td><td>35.47</td><td>17.95</td><td>20.68</td><td>32.55</td><td>23.65</td></tr><tr><td>w./ KIVI-4</td><td>20.97</td><td>29.41</td><td>46.52</td><td>36.25</td><td>19.53</td><td>21.66</td><td>32.97</td><td>24.06</td></tr><tr><td></td><td>MultiNews</td><td>LCC</td><td>RepoBench-P</td><td>TriviaQA</td><td>SAMSum</td><td>TRec</td><td>PR</td><td>Avg</td></tr><tr><td>Baseline</td><td>27.09</td><td>53.49</td><td>51.40</td><td>86.23</td><td>43.04</td><td>71.00</td><td>89.33</td><td>43.54</td></tr><tr><td>w./ KIVI-2</td><td>26.54</td><td>53.03</td><td>51.16</td><td>86.00</td><td>43.34</td><td>71.00</td><td>80.83</td><td>42.43</td></tr><tr><td>w./ KIVI-4</td><td>26.89</td><td>53.33</td><td>51.41</td><td>86.23</td><td>43.34</td><td>71.00</td><td>89.42</td><td>43.53</td></tr></table>",
1910
+ "bbox": [
1911
+ 91,
1912
+ 655,
1913
+ 880,
1914
+ 792
1915
+ ],
1916
+ "page_idx": 12
1917
+ },
1918
+ {
1919
+ "type": "header",
1920
+ "text": "KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cache",
1921
+ "bbox": [
1922
+ 272,
1923
+ 56,
1924
+ 699,
1925
+ 70
1926
+ ],
1927
+ "page_idx": 12
1928
+ },
1929
+ {
1930
+ "type": "page_number",
1931
+ "text": "13",
1932
+ "bbox": [
1933
+ 477,
1934
+ 922,
1935
+ 495,
1936
+ 934
1937
+ ],
1938
+ "page_idx": 12
1939
+ }
1940
+ ]
2024/KIVI_ A Tuning-Free Asymmetric 2bit Quantization for KV Cache/b0cf2b04-a9b0-4077-9961-397b48206580_model.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/KIVI_ A Tuning-Free Asymmetric 2bit Quantization for KV Cache/b0cf2b04-a9b0-4077-9961-397b48206580_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:21afcd5ec1633c722ce2a495a3db636c558d58457b7093c0b3389768a1173fba
3
+ size 2039278
2024/KIVI_ A Tuning-Free Asymmetric 2bit Quantization for KV Cache/full.md ADDED
@@ -0,0 +1,371 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Zirui Liu $^{1}$ Jiayi Yuan $^{1}$ Hongye Jin $^{2}$ Shaochen (Henry) Zhong $^{1}$ Zhaozhuo Xu $^{3}$ Vladimir Braverman $^{1}$ Beidi Chen $^{4}$ Xia Hu $^{1}$
2
+
3
+ # Abstract
4
+
5
+ Efficiently serving large language models (LLMs) requires batching many requests together to reduce the cost per request. Yet, the key-value (KV) cache, which stores attention keys and values to avoid re-computations, significantly increases memory demands and becomes the new bottleneck in speed and memory usage. This memory demand increases with larger batch sizes and longer context lengths. Additionally, the inference speed is limited by the size of KV cache, as the GPU's SRAM must load the entire KV cache from the main GPU memory for each token generated, causing the computational core to be idle during this process. A straightforward and effective solution to reduce KV cache size is quantization, which decreases the total bytes taken by KV cache. However, there is a lack of in-depth studies that explore the element distribution of KV cache to understand the hardness and limitation of KV cache quantization. To fill the gap, we conducted a comprehensive study on the element distribution in KV cache of popular LLMs. Our findings indicate that the key cache should be quantized per-channel, i.e., group elements along the channel dimension and quantize them together. In contrast, the value cache should be quantized per-token. From this analysis, we developed a tuning-free 2bit KV cache quantization algorithm, named KIVI. With the hardware-friendly implementation, KIVI can enable Llama (Llama-2), Falcon, and Mistral models to maintain almost the same quality while using $2.6 \times$ less peak memory usage (including the
6
+
7
+ model weight). This reduction in memory usage enables up to $4 \times$ larger batch size, bringing $2.35 \times \sim 3.47 \times$ throughput on real LLM inference workload. The source code is available at https://github.com/jy-yuan/KIVI.
8
+
9
+ # 1. Introduction
10
+
11
+ Large Language Models (LLMs) have demonstrated strong performance across a wide range of tasks (Brown et al., 2020; Taylor et al., 2022; Yuan et al., 2023). However, their deployment is very costly, requiring a large number of hardware accelerators such as GPUs. Given these substantial costs, one natural way to reduce the cost per request is to combine a sufficient number of requests together for batch processing. However, in this batch inference scenario, the key-value cache (KV cache), which holds the attention keys and values during generation to prevent re-computations, is becoming the new memory and speed bottleneck. This bottleneck becomes more pronounced with larger batch sizes and longer context lengths. For instance, in 540B PaLM, with a batch size of 512 and a context length of 2048, KV cache alone can take 3TB. This is 3 times the size of the model's parameters (Pope et al., 2023). Also, the GPU SRAM has to load the whole KV cache from the GPU device memory for every token generated, during which the computational cores are idle. Thus, reducing KV cache size in LLMs while maintaining accuracy is important.
12
+
13
+ Existing works towards this problem can be roughly divided into three categories. First, some work suggests reducing the number of heads in KV cache, such as multi-query attention (Shazeer, 2019) and multi-group attention (Ainslie et al., 2023). However, these methods require either training the model from scratch or fine-tuning the existing model. Second, another research line reduces KV cache size by evicting unimportant tokens (Zhang et al., 2023). Third, some other works try to solve this problem from the system perspective, e.g., offloading KV cache (Sheng et al., 2023) or extending virtual memory and paging techniques into the attention mechanism (Kwon et al., 2023).
14
+
15
+ To reduce the size of KV cache, the most simple and effective way is to reduce the total bytes taken by KV cache, namely, quantization. Unlike the well-studied weight quan
16
+
17
+ ![](images/c8db393869c237be8c2d59e8226db1629489aee66b746ce1a8714204d70f22e2.jpg)
18
+ Figure 1: Definition of per-token and per-channel quantization. $X \in \mathbb{R}^{l_{\mathrm{prompt}} \times d}$ is key/value cache where $l_{\mathrm{prompt}}$ is the number of tokens and $d$ is the number of channels. $z_{X}$ is the zero-point, $s_{X}$ is the scaling factor.
19
+
20
+ tization (Lin et al., 2023; Xiao et al., 2023a; Zhao et al., 2024), to the best of our knowledge, only a few studies applied the vanilla 4bit round-to-nearest quantization to KV cache (Sheng et al., 2023; Zhang et al., 2023; Zhao et al., 2024) due to the streaming nature of KV cache or other complications. There is a lack of in-depth studies that explore the element distribution of KV cache to understand the hardness and limitation of KV cache quantization. To fill the gap, we study the element distribution of KV cache. Our analysis suggests:
21
+
22
+ - For the key cache, there are a few fixed channels whose magnitudes are very large, which is consistent with previous finding (Lin et al., 2023; Xiao et al., 2023a). Thus, as shown in Figure 1 right, key cache should be quantized per-channel, i.e., group elements along the channel dimension and quantize them together. In this way, it can confine the error to each individual channel, without impacting the other normal channels.
23
+ - For the value cache, there is no obvious outlier pattern. Although value cache has no obvious outlier pattern, we experimentally show that it can only be quantized per-token because it is used to calculate the attention output, which is essentially a value cache mixer. As shown in Figure 1 left, the per-token quantization can confine the error inside each individual token and ensure that the quantization of one token does not adversely impact the others.
24
+
25
+ Based on the above insights, we propose KIVI, a plug-and-play extreme low-bit KV cache quantization method. KIVI quantizes key cache per-channel and quantizes value cache per-token. The per-token value cache quantization aligns well with the streaming nature of auto-regressive inference, allowing newly quantized tensors to be directly appended to the existing quantized value cache by token dimension. However, for per-channel key cache quantization, the quantization process spans different tokens, which cannot be directly implemented in this streaming setting. Since the
26
+
27
+ number of tokens in key cache can be arbitrary, our key idea is to split key cache into two parts. The first part is the grouped key cache, which contains several groups of tokens and each group has a certain number of tokens. The second part is the residual key cache, which does not have a sufficient number of tokens to form a complete group. Similarly, we split value cache into the grouped and residual parts to maintain the accuracy. We only apply group-wise quantization to the grouped key cache and value cache, while the residual key cache and value cache are kept in full precision. The grouped and residual parts can be combined using tiled matrix multiplication when computing attention scores. Our contributions are summarized as follows:
28
+
29
+ - Extensive analysis regarding the outlier patterns and quantization error of KV cache in commonly-used LLMs. Our observations suggest that key cache should be quantized per-channel and value cache should be quantized per-token. We also explain in depth why these caches require different quantization approaches.
30
+ - A new plug-and-play 2bit KV cache quantization algorithm without any fine-tuning, KIVI, with hardware-friendly implementation. We conduct an extensive evaluation for KIVI with Llama (Llama2), Mistral, and Falcon on popular generation tasks. KIVI can efficiently compress KV cache to 2bit and bring $2.6 \times$ peak memory usage reduction for Llama2-7B, with little to no accuracy drop. With our efficient system implementation, this memory reduction, in return, enables up to $4 \times$ larger batch size and brings $2.35 \times \sim 3.47 \times$ throughput.
31
+
32
+ # 2. Background: Attention Inference-Time Workflow
33
+
34
+ The LLM attention inference-time workflow involves two phases: i) the prefetch phase, where the input prompt is used to generate KV cache for each transformer layer of LLMs; and ii) the decoding phase, where the model uses and updates KV cache to generate the next token, one at a time.
35
+
36
+ Prefill Phase. Let $X \in \mathbb{R}^{b \times l_{\text{prompt}} \times d}$ be the input tensor, where $b$ is the batch size, $l_{\text{prompt}}$ is the length of the input prompt, and $d$ is the model hidden size. For convenience, we ignore the layer index here. The key, value tensors can be computed by
37
+
38
+ $$
39
+ \boldsymbol {X} _ {K} = \boldsymbol {X} \boldsymbol {W} _ {K}, \boldsymbol {X} _ {V} = \boldsymbol {X} \boldsymbol {W} _ {V},
40
+ $$
41
+
42
+ where $W_{K}, W_{V} \in \mathbb{R}^{d \times d}$ are the key and value layer weight, respectively. After obtaining $X_{K}$ and $X_{V}$ , they are cached in the memory for the ease of decoding.
43
+
44
+ Decoding Phase. Let $t \in \mathbb{R}^{b \times 1 \times d}$ be the current input token embedding. Let $t_K = tW_K$ and $t_V = tW_V$ be the key and value layer output, respectively. We first update KV cache:
45
+
46
+ $$
47
+ \boldsymbol {X} _ {K} \leftarrow \operatorname {C o n c a t} \left(\boldsymbol {X} _ {K}, \boldsymbol {t} _ {K}\right),
48
+ $$
49
+
50
+ $$
51
+ \boldsymbol {X} _ {V} \leftarrow \operatorname {C o n c a t} \left(\boldsymbol {X} _ {V}, \boldsymbol {t} _ {V}\right),
52
+ $$
53
+
54
+ then calculate the attention output as:
55
+
56
+ $$
57
+ \boldsymbol {t} _ {Q} = \boldsymbol {t} \boldsymbol {W} _ {Q},
58
+ $$
59
+
60
+ $$
61
+ \boldsymbol {A} = \operatorname {S o f t m a x} \left(\boldsymbol {t} _ {Q} \boldsymbol {X} _ {K} ^ {\top}\right),
62
+ $$
63
+
64
+ $$
65
+ \boldsymbol {t} _ {O} = \boldsymbol {A} \boldsymbol {X} _ {V}, \tag {1}
66
+ $$
67
+
68
+ where $W_{Q}$ is the weight matrix of the query layer. For ease of illustration, we ignore the attention output layer and the other parts of the inference workflow.
69
+
70
+ Memory and Speed Analysis. The above process is repeated until a special token indicating the sentence's conclusion is reached. Let $l_{\mathrm{gen}}$ be the number of generated tokens. From the above analysis, the shape of KV cache is $b \times (l_{\mathrm{prompt}} + l_{\mathrm{gen}}) \times d$ . To get a sense of the scale, consider the OPT-175B model with a batch size $b$ 512, a prompt length $l_{\mathrm{prompt}}$ 512, and an output length $l_{\mathrm{gen}}$ 32. The KV cache requires 1.2TB, which is 3.8 times the model weights (Sheng et al., 2023). Besides the memory, the inference speed is also decided by the KV cache size. The GPU needs to load KV cache from GPU main memory to GPU SRAM once for every token generated during which the computational core of the chip is essentially idle (Pope et al., 2023; Kwon et al., 2023).
71
+
72
+ # 3. Methodology
73
+
74
+ In scenarios with long contexts or batched inferences, the memory and speed bottlenecks are storing and loading KV cache. The most simple and effective way to alleviate this problem is to reduce the total bytes occupied by KV cache, specifically, quantization. Following this motivation, we first evaluate the performance of the existing quantization method in Section 3.1. Our observations suggest that key and value cache should be quantized along different dimensions. We analyze the rationale behind this observation in Section 3.2. Then based on the analysis, we propose KIVI, a new KV cache quantization method along with its streaming data structure, detailed in Section 3.3.
75
+
76
+ # 3.1. Preliminary Study of KV Cache Quantization
77
+
78
+ As we analyzed in Section 2, KV cache functions as a streaming data structure, where the new tensor arrives sequentially. Thus, optimization-based methods like GPTQ (Frantar et al., 2022) are unsuitable for quantizing KV cache due to the overhead. To the best of our knowledge, the
79
+
80
+ Table 1: The results of simulated KV cache group-wise quantization with various configurations. The group size is set as 32. $\mathbb{C}$ stands for per-channel quantization and $\mathbb{T}$ stands for per-token quantization. Please check the whole evaluation in Table 3.
81
+
82
+ <table><tr><td>Llama-2-13B</td><td>CoQA</td><td>TruthfulQA</td></tr><tr><td>16bit</td><td>66.37</td><td>29.53</td></tr><tr><td>4bit (K - T, V - T)</td><td>66.48</td><td>29.51</td></tr><tr><td>2bit (K - T, V - T)</td><td>52.93</td><td>24.98</td></tr><tr><td>2bit (K - C, V - C)</td><td>2.88</td><td>0.74</td></tr><tr><td>2bit (K - T, V - C)</td><td>2.80</td><td>0.26</td></tr><tr><td>2bit (K - C, V - T)</td><td>63.53</td><td>28.60</td></tr></table>
83
+
84
+ most flexible way for quantizing KV cache is the round-to-nearest quantization. The $B$ -bit integer quantization-dequantization process can be expressed as:
85
+
86
+ $$
87
+ Q (\boldsymbol {X}) = \left\lfloor \frac {\boldsymbol {X} - z _ {X}}{s _ {X}} \right\rceil , \quad \boldsymbol {X} ^ {\prime} = Q (\boldsymbol {X}) \cdot s _ {X} + z _ {X},
88
+ $$
89
+
90
+ where $z_{X} = \min X$ is the zero-point, $s_{X} = (\max X - \min X) / (2^{B} - 1)$ is the scaling factor, and $\lfloor \cdot \rceil$ is the rounding operation. Here we ignore the batch size for ease of understanding. As shown in Figure 1, $X$ is quantized along either the token or channel dimension group-wisely.
91
+
92
+ Considering the streaming nature of KV cache, previous studies often apply per-token quantization to both key and value cache since the newly quantized KV cache can be naively added to the existing quantized one along the token dimension (Sheng et al., 2023). While per-channel quantization is non-trivial, we have designed a padding method to implement per-channel quantization to explore its effect on both key and value cache.
93
+
94
+ Setting. In Table 1, we show the results of fake KV cache group-wise quantization with different configurations on the Llama-2-13B model for the CoQA and TruthfulQA tasks. We use a group size of 32 for all configurations. Here fake quantization means we simulate the quantization process by first quantizing KV cache into lower precision and then dequantizing it in the attention layer. For per-channel quantization, if the number of tokens is not divided evenly into groups, we add zero-padding to ensure it can be grouped perfectly. In this way, we ensure that all tokens in KV cache are quantized for a fair comparison. The detailed experimental setting can be found in Section 4.1. Specifically, we observe that:
95
+
96
+ OB 1. When using the commonly used per-token quantization to both key and value caches, INT4 precision can maintain accuracy. However, reducing it to INT2 results in a notable accuracy drop.
97
+
98
+ OB 2. When value cache is quantized per-channel, the accuracy significantly worsens regardless of how key cache
99
+
100
+ ![](images/5964e9c36bb7d2eefc4ddad34245632f31941a3dd51110d9091ef21eef1bbca3.jpg)
101
+ Llama-2-13B Layer 16
102
+ Head 0 Key Cache
103
+
104
+ ![](images/2067871987ce30bf5e06653b43f1a593b31126a3c5b529a9afaba7eaf770a1a3.jpg)
105
+ Llama-2-13B Layer 16
106
+ Head 0 Value Cache
107
+
108
+ ![](images/db358606b84710de97bad0fa00770e909377e613afafb9da5bb7dcaf83cc432d.jpg)
109
+ Llama-2-13B Layer 31 Head 0 Key Cache
110
+
111
+ ![](images/fc6a1235fa8b88cac60ec799bfda423fd336c5e837dfac759b86948f05a52bda.jpg)
112
+ Llama-2-13B Layer 31 Head 0 Value Cache
113
+
114
+ ![](images/c998fa711988d0edfa1a7b5f2ccd868bff9960e0d0d707f5f18ed83024b03655.jpg)
115
+ Falcon-7B Layer 16
116
+ Head 0 Key Cache
117
+
118
+ ![](images/6f4bdb304208b9f1786715eecb72de682d145ad0d7afa83271efcf7ab45f92b0.jpg)
119
+ Falcon-7B Layer 16 Head 0 Value Cache
120
+
121
+ ![](images/fa9bd0618aa1454dfbb4603c7e05f9a58beefb050896dc7faa1262acadcee697.jpg)
122
+ Falcon-7B Layer 20
123
+ Head 0 Key Cache
124
+
125
+ ![](images/113a02159cf4629335ee4fe90d68e8487fc2322aa8b8334df3b1289c3fb0ce3f.jpg)
126
+ Falcon-7B Layer 20
127
+ Head 0 Value Cache
128
+ Figure 2: Magnitude of key and value cache for Llama-2-13B and Falcon-7B. We observe (1) for key cache, there are a few channels whose magnitudes are very large. (2) for value cache, there is no obvious outlier pattern.
129
+
130
+ is quantized.
131
+
132
+ OB 3. When using a lower numerical precision such as INT2, the most accurate approach is to quantize key cache per-channel and value cache per-token.
133
+
134
+ # 3.2. Why Key and Value Cache Should Quantize Along Different Dimensions?
135
+
136
+ In Table 1, we observe that quantizing key cache per-channel and value cache per-token to 2bit results in a very small accuracy drop. Here we analyze why this configuration delivers better accuracy. In Figure 2 we visualize the original KV cache distribution at different layers. We observe that in key cache, some fixed channels exhibit very large magnitudes, whereas in value cache, there is no significant pattern for outliers.
137
+
138
+ Analysis of Key Cache. The above observation for key cache aligns with previous findings that certain fixed columns in activations exhibit larger outliers (Dettmers et al., 2022; Lin et al., 2023). The persistence of outliers within each channel means that per-channel quantization can confine the quantization error to each individual channel without impacting the other normal channels. Thus, Figure 2 explains why key cache should be quantized per-channel. In Table 2 we show key cache relative reconstruction error
139
+
140
+ $\| \frac{\pmb{X}_K - \pmb{X}_K'}{\pmb{X}_K}\| _F$ , along with the relative attention score error $\| \frac{\pmb{A} - \pmb{A}'}{\pmb{A}}\| _F$ where $A^{\prime} = \mathrm{Softmax}(t_{Q}\pmb{X}_{K}^{\prime \top})$ . We observe that the per-token quantization can lead to almost $5\times$ larger attention score error than per-channel quantization, which is consistent with Figure 2.
141
+
142
+ Table 2: The relative error statistics averaged over all layers and all heads
143
+
144
+ <table><tr><td>Llama-2-13B</td><td>K Per-Token</td><td>K Per-Channel</td></tr><tr><td>Avg. ||X_K-X&#x27;_K|_F</td><td>13.67</td><td>4.55</td></tr><tr><td>Avg. ||A-A&#x27;/A|_F</td><td>47.0</td><td>9.6</td></tr><tr><td>Attention sparsity</td><td colspan="2">84.3%</td></tr></table>
145
+
146
+ <table><tr><td></td><td>V Per-Token</td><td>V Per-Channel</td></tr><tr><td>Avg. ||Xv-X&#x27;v/V|F</td><td>4.57</td><td>3.73</td></tr><tr><td>Avg. Δ</td><td>3.55</td><td>49.89</td></tr></table>
147
+
148
+ Analysis of Value Cache. Unlike key cache, value cache does not show the channel-wise outlier pattern. Furthermore, Figure 2 alone cannot explain OB2, which indicates value cache should only be quantized per-token. This is because Figure 2 implies that errors should be comparable for both per-token and per-channel quantization, given the absence
149
+
150
+ ![](images/4fa791fb493a3fb009a1ee38c04b0d080397c81ffdfca5bc3f23eb343a48aacf.jpg)
151
+ Figure 3: The overview of KIVI algorithm. For ease of illustration, we omit the value cache and attention output parts. The detailed pseudo-code is provided in Algorithm 1. Here “Q_Matmul” is the mix-precision matrix multiplication which fuses the dequantization with matrix multiplication at the tiling level.
152
+
153
+ of a clear pattern. As shown in Equation (1), value cache is used to calculate the attention output $t_{O}$ . Instead of analyzing the quantization error of value cache $X_{V}$ , in Table 2 we analyze the relative error $\Delta = \| \frac{AX_V - AX_V'}{AX_V}\| _F$ with different quantization configurations. Surprisingly, we observe that the per-token quantization error is almost $15\times$ smaller than per-channel quantization, which explains why OB2 happens. The intuition behind this observation stems from the attention sparsity. Equation (1) can be written as:
154
+
155
+ $$
156
+ \left[ \boldsymbol {A} \boldsymbol {X} _ {V} \right] _ {i *} = \sum_ {j = 1} ^ {l _ {\text {p r o m p t}}} \boldsymbol {A} _ {i j} \left[ \boldsymbol {X} _ {V} \right] _ {j *}, \tag {2}
157
+ $$
158
+
159
+ where $[X_V]_{j*}$ is the $j$ -th row of $X_V$ . From Equation (2), the attention output is the weighted summation of value cache across various tokens, with the weights being the attention scores. Since the attention score is highly sparse (Tian et al., 2023), the output is just the combination of value caches of a few important tokens. The per-token quantization can confine the error to each individual token. Thus, quantizing other tokens does not affect the accuracy of important tokens. Consequently, per-token quantization leads to a much smaller relative error $\Delta$ .
160
+
161
+ # 3.3. KIVI: Algorithm and System Support
162
+
163
+ Algorithm. As we previously analyzed, key cache should be quantized per-channel and value cache should be quantized per-token. Recall that key and value cache of newly generated tokens arrive sequentially. From the implementation perspective, per-token quantization aligns well with streaming settings, allowing newly quantized tensors to be directly appended to the existing quantized value cache by token dimension. However, for per-channel quantization, the quantization process spans across different tokens, which cannot be directly implemented in the streaming setting. As shown in Figure 3, our key idea to solve this problem is to group key cache every $G$ tokens and quantize them separately. Because the number of tokens in $X_{K}$ can be arbitrary, we split $X_{K}$ into two parts, namely, the grouped part
164
+
165
+ $\mathbf{X}_{K_g} = \mathbf{X}_K[:l - r]$ and residual part $\mathbf{X}_{K_r} = \mathbf{X}_K[l - r:],$ where $l$ is the number of tokens inside the current key cache $\mathbf{X}_K,r$ is the number of residual tokens, where $l - r$ can be divisible by $G$
166
+
167
+ Since $X_{K_g}$ can be evenly divided into $(l - r) / G$ groups, we only store $Q(X_{K_g})$ with group-wise quantization, while $X_{K_r}$ is kept in full precision. During the decoding process, each newly arrived key cache $t_K$ is added to $X_{K_r}$ and once $X_{K_r}$ reaches $R$ tokens, which is a hyperparameter - residual length, we quantize and concatenate it with the previously quantized $Q(X_{K_G})$ . Then we reset $X_{K_r}$ to an empty tensor. We note that $R$ should be divisible by $G$ . With tiled matrix multiplication, the raw attention logits is then calculated as:
168
+
169
+ $$
170
+ \boldsymbol {A} _ {g} = t _ {Q} Q \left(\boldsymbol {X} _ {K _ {g}} ^ {\top}\right),
171
+ $$
172
+
173
+ $$
174
+ \boldsymbol {X} _ {K _ {r}} = \operatorname {C o n c a t} \left(\left[ \boldsymbol {X} _ {K _ {r}}, \boldsymbol {t} _ {K} \right]\right),
175
+ $$
176
+
177
+ $$
178
+ \boldsymbol {A} _ {r} = \boldsymbol {t} _ {Q} \boldsymbol {X} _ {K _ {r}} ^ {\top},
179
+ $$
180
+
181
+ $$
182
+ \boldsymbol {A} = \operatorname {C o n c a t} \left(\left[ \boldsymbol {A} _ {g}, \boldsymbol {A} _ {r} \right]\right). \tag {3}
183
+ $$
184
+
185
+ For value cache, similar to key cache, we also split it into two parts and keep the most recent value cache in full precision, namely, $X_{V_g}$ and $X_{V_r}$ . Specifically, we maintain a queue and each newly arrived value cache is pushed into the queue. Once the queue reaches the predefined residual length $R$ , the most outdated value cache is popped. Then the popped value cache is quantized per-token and concatenated with the previously quantized value cache along the token dimension.
186
+
187
+ As shown in Figure 3, we also emphasize that during the prefill phase, the exact key and value tensors are passed to the next layers, although only the quantized KV cache is retained in memory. The whole algorithm can be found in Appendix A Algorithm 1.
188
+
189
+ Analysis. In KIVI, the grouped key cache $X_{K_g}$ and value cache $X_{V_g}$ is quantized, while the residual key cache $X_{K_r}$ and value cache $X_{V_r}$ is kept in full precision. By design,
190
+
191
+ there are at most $R$ tokens inside $X_{K_r}$ or $X_{V_r}$ . In practice, we set $R \leq 128$ and the sequence length $l_{\mathrm{prompt}} + l_{\mathrm{gen}}$ is often much longer than $R$ . Thus the memory overhead from $X_{K_r}$ and $X_{V_r}$ is negligible when considering the benefit from extreme low-bit quantization, especially for the long context scenarios. Also, since the newly arrived key and value tensors are added to $X_{K_r}$ and $X_{V_r}$ in full precision, KIVI maintains a full precision KV cache sliding window for the local relevant tokens. This window size is expected to be $\frac{R}{2}$ for key cache, and $R$ for value cache. Later in the experiment section, we show that this full precision sliding window is crucial for obtaining desirable performance on hard tasks, such as GSM8K.
192
+
193
+ System Support. We provide a hardware-friendly implementation for running KIVI on GPUs. To minimize the overhead, we have fused the dequantization process with matrix multiplication, e.g., Q_MatMul in Figure 3, using CUDA. We also implement the group-wise quantization kernel in Triton. Our method is fully compatible with weight-only quantization.
194
+
195
+ # 4. Experiments
196
+
197
+ # 4.1. Settings
198
+
199
+ Models. We evaluate KIVI using three popular model families: Llama/Llama-2 (Touvron et al., 2023a,b)), Falcon (Penedo et al., 2023) and Mistral (Jiang et al., 2023). Llama and Mistral model is based on multi-head attention, while Falcon is based on multi-query attention (Shazeer, 2019). We use the Hugging Face Transformers codebase and implement the KIVI algorithm upon it. Following previous work (Sheng et al., 2023), the group size $G$ in Algorithm 1 for quantization is set as 32 across all experiments, the residual length $R$ for key and value cache is set to 128.
200
+
201
+ Tasks. As we analyzed in Section 2, the KV cache size grows larger with a longer context. Thus, we evaluate KIVI under the normal context length and long context setting, respectively. Specifically, we adopt generation tasks from LM-Eval (Gao et al., 2021) for normal context length evaluation and LongBench (Bai et al., 2023) for long context evaluation, respectively<sup>1</sup>. For LM-eval, we adopt CoQA (Exact match accuracy), TruthfulQA (BLEU score), and GSM8K (Exact match accuracy). For LongBench, we chose tasks from four subgroups. Specifically, Qasper (F1 score) is a Single-Document QA task; QMSum (ROUGE score) and MultiNews (ROUGE score) are Summarization tasks;
202
+
203
+ TREC (classification score), TriviaQA (F1 score), and SAM-Sum (ROUGE score) are Few-shot Learning tasks; and LCC (similarity score) and RepoBench-P (similarity score) is Code Completion task. The maximum sequence length in LongBench was set to 8192 for the Mistral model and 4096 for other models.
204
+
205
+ # 4.2. Accuracy and Efficiency Analysis
206
+
207
+ # 4.2.1. COMPARISON BETWEEN DIFFERENT QUANTIZATION CONFIGURATIONS
208
+
209
+ We first utilize the fake quantization to demonstrate the effectiveness of our asymmetric quantization, namely, quantizing key cache per-channel and value cache per-token. Here fake quantization is exactly the same as in Table 1. The results are shown in Table 3. We observe that "2bit (K per-channel, V per-token)" consistently achieves the best results compared to all other configurations. This is consistent with our previous analysis. We also note that for hard generation tasks such as GSM8K, the fake "2bit (K per-channel, V per-token)" quantization results are significantly worse than the full precision counterparts. However, for KIVI in Table 3, we observe that the accuracy drop is only around $2\%$ for GSM8K across different models. As we analyzed in Section 3.3, the difference between fake "2bit (K per-channel, V per-token)" quantization and KIVI is that KIVI maintains a full precision key and value cache sliding window for the local relevant tokens. This sliding window is crucial to maintaining accuracy for hard generation tasks such as mathematical reasoning.
210
+
211
+ # 4.2.2. ACCURACY COMPARISON ON GENERATION TASKS
212
+
213
+ LM-Eval Results. We benchmark KIVI on CoQA, TruthfulQA, and GSM8K tasks using LM-Eval framework. All dataset parameters were set to default. We compare the standard 16bit configuration with our KIVI compression techniques across Llama-2-7B, Llama-2-13B, Falcon-7B, and Mistral-7B. As shown in Table 3, we observe that for the Llama and Mistral model, KIVI only has up to $2\%$ accuracy drop despite the KV cache being stored in 2bit. For instance, in the Llama-2-7B model, the transition from 16bit to 2bit only slightly decreases accuracy. Similar trends are observed in other Llama-family models. Since Falcon-7B adopts multi-query attention and only has one head for KV cache, it is already highly compressed compared to Llama-based models. Thus, in Table 3, 4bit KIVI is needed to maintain the accuracy, while 2bit KIVI may have a large accuracy drop in this case.
214
+
215
+ LongBench Results. The performance of KIVI over various models in the LongBench dataset is summarised in Table 4. We apply KIVI over Llama2-7B, Llama2-13B, Llama2-
216
+
217
+ Table 3: Performance comparison between 16bit, 4-bit pentoken quantization, four fake 2bit KV cache quantization similar to those in Table 1, KIVI-2 (2bit) / KIVI-4 (4bit) across various models. We emphasize that unlike KIVI, which preserves a small portion of full precision key cache $\mathbf{X}_{K_r}$ and value cache $\mathbf{X}_{V_r}$ , all tokens in fake KV cache quantization are quantized for a fair comparison. $\mathbb{C}$ stands for per-channel quantization and $\mathbb{T}$ stands for per-token quantization.
218
+
219
+ <table><tr><td>Model</td><td></td><td>CoQA</td><td>TruthfulQA</td><td>GSM8K</td></tr><tr><td rowspan="8">Llama-2-7B</td><td>16bit</td><td>63.88</td><td>30.76</td><td>13.50</td></tr><tr><td>4bit (K - T, V - T)</td><td>64.82</td><td>29.85</td><td>12.28</td></tr><tr><td>2bit (K - C, V - T)</td><td>59.08</td><td>33.10</td><td>5.76</td></tr><tr><td>2bit (K - T, V - T)</td><td>39.88</td><td>18.29</td><td>0.83</td></tr><tr><td>2bit (K - C, V - C)</td><td>3.60</td><td>0.27</td><td>0.00</td></tr><tr><td>2bit (K - T, V - C)</td><td>1.30</td><td>0.49</td><td>0.08</td></tr><tr><td>KIVI-4</td><td>63.78</td><td>30.80</td><td>13.80</td></tr><tr><td>KIVI-2</td><td>63.05</td><td>33.95</td><td>12.74</td></tr><tr><td rowspan="8">Llama-2-13B</td><td>16bit</td><td>66.37</td><td>29.53</td><td>22.67</td></tr><tr><td>4bit (K - T, V - T)</td><td>66.73</td><td>29.14</td><td>20.92</td></tr><tr><td>2bit (K - C, V - T)</td><td>63.53</td><td>28.60</td><td>12.21</td></tr><tr><td>2bit (K - T, V - T)</td><td>52.93</td><td>24.98</td><td>4.55</td></tr><tr><td>2bit (K - C, V - C)</td><td>2.88</td><td>0.74</td><td>0.00</td></tr><tr><td>2bit (K - T, V - C)</td><td>2.80</td><td>0.26</td><td>0.08</td></tr><tr><td>KIVI-4</td><td>66.38</td><td>29.49</td><td>23.65</td></tr><tr><td>KIVI-2</td><td>66.23</td><td>29.84</td><td>20.77</td></tr><tr><td rowspan="8">Falcon-7B</td><td>16bit</td><td>59.83</td><td>23.20</td><td>4.55</td></tr><tr><td>4bit (K - T, V - T)</td><td>58.53</td><td>22.94</td><td>3.26</td></tr><tr><td>2bit (K - C, V - T)</td><td>43.93</td><td>20.82</td><td>1.29</td></tr><tr><td>2bit (K - T, V - T)</td><td>25.72</td><td>0.91</td><td>0.53</td></tr><tr><td>2bit (K - C, V - C)</td><td>41.95</td><td>17.11</td><td>1.52</td></tr><tr><td>2bit (K - T, V - C)</td><td>19.53</td><td>0.94</td><td>0.15</td></tr><tr><td>KIVI-4</td><td>59.67</td><td>22.58</td><td>4.47</td></tr><tr><td>KIVI-2</td><td>57.48</td><td>24.98</td><td>3.41</td></tr><tr><td rowspan="8">Mistral-7B</td><td>16bit</td><td>67.40</td><td>30.45</td><td>38.36</td></tr><tr><td>4bit (K - T, V - T)</td><td>67.80</td><td>29.83</td><td>36.85</td></tr><tr><td>2bit (K - C, V - T)</td><td>61.65</td><td>29.64</td><td>26.46</td></tr><tr><td>2bit (K - T, V - T)</td><td>54.55</td><td>25.86</td><td>5.00</td></tr><tr><td>2bit (K - C, V - C)</td><td>24.40</td><td>24.86</td><td>2.27</td></tr><tr><td>2bit (K - T, V - C)</td><td>10.73</td><td>19.12</td><td>0.99</td></tr><tr><td>KIVI-4</td><td>66.95</td><td>30.49</td><td>37.30</td></tr><tr><td>KIVI-2</td><td>66.35</td><td>32.17</td><td>36.01</td></tr></table>
220
+
221
+ 7B-Chat, Llama2-13B-Chat, Falcon-7B and Mistral-7B. Table 4 suggests that KIVI is an effective method for KV cache compression with minimal impact on accuracy across various hard long context generation tasks. We also present additional results using Mistral-7B-v0.2 and LongChat-7B-v1.5 on LongBench, which can be found in Table 8 and Table 9, respectively.
222
+
223
+ # 4.2.3. ABLATION
224
+
225
+ In this section, we benchmark KIVI on GSM8K, one of the hardest generation tasks, to show the effect of hyperparameters group size $G$ and residual length $R$ on the model performance. For full results of KIVI with a residual length of 32, please refer to Appendix B.
226
+
227
+ ![](images/a4bede7aeed2fd43682a6ee9a10b3bc87482a2ed8c4466780a118c60101a7638.jpg)
228
+
229
+ ![](images/0f6d1c78dab71d173df268013d7d78384803c2a0fa53d32e7c778746c8d000b3.jpg)
230
+ Figure 4: Memory usage and throughput comparison between 2bit KIVI and 16bit baseline. KIVI can achieve higher throughput by enabling a larger batch size.
231
+
232
+ The effect of group size. We fix the residual length at 128 and vary the group sizes to 32, 64, and 128. From Table 5, we observe that group sizes 32 and 64 yield similar results, whereas the performance significantly decreases when the group size reaches 128. Note the zero-point and the scaling factor mentioned in Section 3.1 are calculated according to this group size; where the choice of group size will greatly impact the KV cache compression effect under a long input.
233
+
234
+ The effect of residual length. We fix the group size at 32 and vary the residual length across 32, 64, 96, and 128. As shown in Table 5, there is no consistent pattern between residual lengths and model accuracy. Namely, while a residual length of 128 achieves good results, 32 and 96 yield similar outcomes, but a residual length of 64 results in the worst performance. We emphasize that while we observe no significance among residual lengths of $\{32, 96, 128\}$ , having a reasonably large residual length is important; as it brings much performance boosts on hard tasks like GSM8K, again as shown in Table 5.
235
+
236
+ # 4.2.4. EFFICIENCY COMPARISON
237
+
238
+ To evaluate the wall-clock time efficiency of KIVI, following vLLM (Kwon et al., 2023), we synthesize workloads based on ShareGPT (sha, 2023), which contain input and output texts of real LLM services. On average, the data set has an input prompt length $l_{\mathrm{prompt}}$ of 161 and an output length $l_{\mathrm{gen}}$ of 338 (Kwon et al., 2023). We increase the batch
239
+
240
+ Table 4: Performance evaluation of KIVI on various models across a range of benchmarks in LongBench. We highlight the average performance of our method. More similar results on Mistral-7B-v0.2 and LongChat-7b-v1.5 can be found in Table 8 and Table 9
241
+
242
+ <table><tr><td>Model</td><td></td><td>Qasper</td><td>QMSum</td><td>MultiNews</td><td>TREC</td><td>TriviaQA</td><td>SAMSum</td><td>LCC</td><td>RepoBench-P</td><td>Average</td></tr><tr><td rowspan="3">Llama2-7B</td><td>16bit</td><td>9.52</td><td>21.28</td><td>3.51</td><td>66</td><td>87.72</td><td>41.69</td><td>66.66</td><td>59.82</td><td>44.52</td></tr><tr><td>KIVI-4</td><td>9.28</td><td>21.42</td><td>3.88</td><td>66</td><td>87.72</td><td>41.82</td><td>66.8</td><td>59.83</td><td>44.59</td></tr><tr><td>KIVI-2</td><td>9.31</td><td>20.5</td><td>1.14</td><td>66</td><td>87.42</td><td>42.71</td><td>66.88</td><td>60.23</td><td>44.27</td></tr><tr><td rowspan="3">Llama2-13B</td><td>16bit</td><td>9.32</td><td>21.38</td><td>3.71</td><td>70</td><td>87.87</td><td>43.55</td><td>66.61</td><td>56.42</td><td>44.85</td></tr><tr><td>KIVI-4</td><td>9.16</td><td>20.86</td><td>3.21</td><td>69</td><td>86.97</td><td>44.26</td><td>65.3</td><td>57.08</td><td>44.48</td></tr><tr><td>KIVI-2</td><td>8.58</td><td>20.69</td><td>6.19</td><td>69.5</td><td>87.78</td><td>44.3</td><td>65.08</td><td>55.46</td><td>44.69</td></tr><tr><td rowspan="3">Llama2-7B-Chat</td><td>16bit</td><td>19.65</td><td>20.54</td><td>26.36</td><td>63</td><td>84.28</td><td>41.12</td><td>59.75</td><td>52.93</td><td>45.95</td></tr><tr><td>KIVI-4</td><td>19.62</td><td>20.7</td><td>25.49</td><td>63</td><td>84.13</td><td>40.87</td><td>59.27</td><td>53.56</td><td>45.83</td></tr><tr><td>KIVI-2</td><td>19.32</td><td>20.46</td><td>25.48</td><td>63</td><td>84.84</td><td>40.6</td><td>58.71</td><td>52.97</td><td>45.67</td></tr><tr><td rowspan="3">Llama2-13B-Chat</td><td>16bit</td><td>24.18</td><td>20.37</td><td>25.69</td><td>67.5</td><td>86.9</td><td>42.18</td><td>50.23</td><td>50.64</td><td>45.96</td></tr><tr><td>KIVI-4</td><td>23</td><td>20.36</td><td>26.06</td><td>67.5</td><td>87.2</td><td>42.04</td><td>52.55</td><td>52.77</td><td>46.44</td></tr><tr><td>KIVI-2</td><td>23.59</td><td>20.76</td><td>25.25</td><td>67.5</td><td>87.17</td><td>41.56</td><td>49.93</td><td>48.45</td><td>45.52</td></tr><tr><td rowspan="3">Falcon-7B</td><td>16bit</td><td>1.48</td><td>2.35</td><td>11.09</td><td>13</td><td>5.84</td><td>2.44</td><td>23.86</td><td>9.69</td><td>8.71</td></tr><tr><td>KIVI-4</td><td>1.04</td><td>2.41</td><td>11.98</td><td>13</td><td>5.84</td><td>2.36</td><td>23.72</td><td>9.92</td><td>8.78</td></tr><tr><td>KIVI-2</td><td>1.98</td><td>3.61</td><td>6.78</td><td>10</td><td>6.24</td><td>2.73</td><td>22.18</td><td>10.12</td><td>7.95</td></tr><tr><td rowspan="3">Mistral-7B</td><td>16bit</td><td>8.12</td><td>19.98</td><td>19.99</td><td>67.5</td><td>89.8</td><td>41.69</td><td>66.59</td><td>58.99</td><td>46.58</td></tr><tr><td>KIVI-4</td><td>7.89</td><td>20.06</td><td>20.58</td><td>67.5</td><td>89.8</td><td>41.56</td><td>66.45</td><td>58.62</td><td>46.56</td></tr><tr><td>KIVI-2</td><td>6.92</td><td>19.71</td><td>17.92</td><td>66.5</td><td>89.63</td><td>41.66</td><td>65.52</td><td>58.99</td><td>45.85</td></tr></table>
243
+
244
+ Table 5: Ablation study of KIVI by changing group size $G$ and residual length $R$ .
245
+
246
+ <table><tr><td>Model</td><td>Group Size</td><td>GSM8K</td></tr><tr><td rowspan="3">Llama2-13B</td><td>32</td><td>20.77</td></tr><tr><td>64</td><td>21.00</td></tr><tr><td>128</td><td>17.29</td></tr><tr><td>Model</td><td>Residual Length</td><td>GSM8K</td></tr><tr><td rowspan="4">Llama2-13B</td><td>32</td><td>20.62</td></tr><tr><td>64</td><td>19.86</td></tr><tr><td>96</td><td>20.55</td></tr><tr><td>128</td><td>20.77</td></tr></table>
247
+
248
+ size until out of memory and report the peak memory usage and throughput between KIVI (with residual length 32 and 128) and FP16 baseline for the Llama-2-7B model. The hardware here is a single NVIDIA A100 GPU (80GB).
249
+
250
+ As shown in Figure 4, with similar maximum memory usage, KIVI enables up to $4 \times$ larger batch size and gives $2.35 \times \sim 3.47 \times$ larger throughput. This throughput number can grow larger with longer context length and output length. We also note that this speed-up can be greatly increased if we further fuse the KV cache quantization process with previous operations. We leave it as one of future work.
251
+
252
+ # 5. Related Work
253
+
254
+ Many machine learning system work have been proposed to scale up LLM training and inference process (Pope
255
+
256
+ et al., 2023; Wang et al., 2023; 2022). Among them, quantization techniques have been widely applied (Frantar et al., 2022; Lin et al., 2023; Kim et al., 2023; Xu et al., 2023). A main branch of LLM quantization is weight-only quantization, which involves the quantization of model weights to lower precision. For instance, AWQ (Lin et al., 2023) cleverly quantizes model weights to INT4 and INT3 using an activation-aware manner. GPTQ (Frantar et al., 2022) utilizes approximate second-order information to quantize model weights both accurately and efficiently. SqueezeLLM (Kim et al., 2023) adopts the concept of sensitivity-based non-uniform quantization along with Dense-and-Sparse decomposition. This line of work is orthogonal to ours, as they can be combined together.
257
+
258
+ SmoothQuant (Xiao et al., 2023a) is a post-training quantization method that is more closely related to our work. This method uses equivalent transformations to balance the quantization complexity for both activation and weight, making the activation easier to quantize. SmoothQuant can compress KV cache to 8bit with minor performance loss. However, it faces a significant accuracy drop when scaled down to 4bit or less (Zhao et al., 2024). FlexGen adopts 4-bit per-token quantization for both key and value cache.
259
+
260
+ One important recipe of KIVI is the per-channel quantization scheme designed base on observation made in Section 3.2 and Figure 2. ATOM (Zhao et al., 2024) also identifies that the Key cache exhibits more outliers compared to the Value cache. KIVI provides further extensive analysis and leverages this observation to implement per-channel
261
+
262
+ quantization. A similar observation and approach have been independently discovered and developed in the concurrent work KVQuant (Hooper et al., 2024).
263
+
264
+ vLLM (Kwon et al., 2023) and S3 (Jin et al., 2023) are system-level works, which include memory management through the use of PagedAttention or memory usage prediction. They can lower the memory requirements of KV cache and simultaneously increase model throughput. This research direction is orthogonal to our work, since system-level optimizations can also be applied upon our algorithm.
265
+
266
+ Several other works also consider compressing KV cache by evicting tokens. H2O (Zhang et al., 2023) retains only a small portion of tokens that contribute significantly to the attention scores. Similarly, Scissorhands (Liu et al., 2024) exploit the persistence of the importance hypothesis in KV cache sparsification. StreamingLLM (Xiao et al., 2023b) is based on the observation of "attention sink" and maintains only a few initial tokens to preserve performance. Unlike these works, our KIVI retains all input tokens and compresses them into lower precision. This line of work is orthogonal to ours, as they also can be combined together.
267
+
268
+ # 6. Conclusion and Future Work
269
+
270
+ In this paper, we systematically analyze KV cache element distribution in popular LLMs. We conclude that key cache should be quantized per-channel and value cache should be quantized per token. Based on these observations, we propose KIVI, a plug-and-play 2bit KV cache quantization algorithm without the need for any tuning. In real LLM workload, KIVI allows up to $4 \times$ larger batch sizes and $3.47 \times$ throughput. In the future, we will further optimize the implementation to reduce the overhead of quantization process during the prefetch and decoding phase.
271
+
272
+ # Acknowledgments
273
+
274
+ The authors thank the anonymous reviewers for their helpful comments. Dr. Beidi Chen is supported by a research gift from Moffett.AI. Dr. Vladimir Braverman is partially supported by the Ministry of Trade, Industry and Energy (MOTIE) and Korea Institute for Advancement of Technology (KIAT) through the International Cooperative R&D program, the Naval Research (ONR) grant N00014-23-1-2737, and NSF CNS 2333887 award. Dr. Xia Hu is supported by NSF grants NSF IIS-2224843. The views and conclusions contained in this paper are those of the authors and should not be interpreted as representing any funding agencies.
275
+
276
+ # Impact Statement
277
+
278
+ This paper presents work whose goal is to advance the field of Machine Learning. There are many potential societal
279
+
280
+ consequences of our work, none which we feel must be specifically highlighted here.
281
+
282
+ # References
283
+
284
+ ShareGPT Team. https://sharegpt.com/, 2023.
285
+ Joshua Ainslie, James Lee-Thorp, Michiel de Jong, Yury Zemlyanskiy, Federico Lebrón, and Sumit Sanghai. Gqa: Training generalized multi-query transformer models from multi-head checkpoints. arXiv preprint arXiv:2305.13245, 2023.
286
+ Yushi Bai, Xin Lv, Jiajie Zhang, Hongchang Lyu, Jiankai Tang, Zhidian Huang, Zhengxiao Du, Xiao Liu, Aohan Zeng, Lei Hou, Yuxiao Dong, Jie Tang, and Juanzi Li. Longbench: A bilingual, multitask benchmark for long context understanding. arXiv preprint arXiv:2308.14508, 2023.
287
+ Tom Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared D Kaplan, Prafulla Dhariwal, Arvind Neelakantan, Pranav Shyam, Girish Sastry, Amanda Askell, et al. Language models are few-shot learners. Advances in neural information processing systems, 33:1877-1901, 2020.
288
+ Tim Dettmers, Mike Lewis, Younes Belkada, and Luke Zettlemoyer. Llm. int8(): 8-bit matrix multiplication for transformers at scale. arXiv preprint arXiv:2208.07339, 2022.
289
+ Elias Frantar, Saleh Ashkboos, Torsten Hoefler, and Dan Alistarh. Gptq: Accurate post-training quantization for generative pre-trained transformers. arXiv preprint arXiv:2210.17323, 2022.
290
+ Leo Gao, Jonathan Tow, Stella Biderman, Sid Black, Anthony DiPofi, Charles Foster, Laurence Golding, Jeffrey Hsu, Kyle McDonell, Niklas Muennighoff, et al. A framework for few-shot language model evaluation. Version v0. 0.1. Sept, page 8, 2021.
291
+ Coleman Hooper, Sehoon Kim, Hiva Mohammadzadeh, Michael W Mahoney, Yakun Sophia Shao, Kurt Keutzer, and Amir Gholami. Kvquant: Towards 10 million context length llm inference with kv cache quantization. arXiv preprint arXiv:2401.18079, 2024.
292
+ Albert Q Jiang, Alexandre Sablayrolles, Arthur Mensch, Chris Bamford, Devendra Singh Chaplot, Diego de las Casas, Florian Bressand, Gianna Lengyel, Guillaume Lample, Lucile Saulnier, et al. Mistral 7b. arXiv preprint arXiv:2310.06825, 2023.
293
+ Yunho Jin, Chun-Feng Wu, David Brooks, and Gu-Yeon Wei. S3: Increasing gpu utilization during generative inference for higher throughput. arXiv preprint arXiv:2306.06000, 2023.
294
+
295
+ Sehoon Kim, Coleman Hooper, Amir Gholami, Zhen Dong, Xiuyu Li, Sheng Shen, Michael W Mahoney, and Kurt Keutzer. Squeezeellm: Dense-and-sparse quantization. arXiv preprint arXiv:2306.07629, 2023.
296
+ Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph Gonzalez, Hao Zhang, and Ion Stoica. Efficient memory management for large language model serving with pagedattention. In Proceedings of the 29th Symposium on Operating Systems Principles, pages 611-626, 2023.
297
+ Ji Lin, Jiaming Tang, Haotian Tang, Shang Yang, Xingyu Dang, and Song Han. Awq: Activation-aware weight quantization for llm compression and acceleration. arXiv preprint arXiv:2306.00978, 2023.
298
+ Zichang Liu, Aditya Desai, Fangshuo Liao, Weitao Wang, Victor Xie, Zhaozhuo Xu, Anastasios Kyrillidis, and Anshumali Shrivastava. Scissorhands: Exploiting the persistence of importance hypothesis for llm kv cache compression at test time. Advances in Neural Information Processing Systems, 36, 2024.
299
+ Guilherme Penedo, Quentin Malartic, Daniel Hesslow, Ruxandra Cojocaru, Alessandro Cappelli, Hamza Alobeidli, Baptiste Pannier, Ebtesam Almazrouei, and Julien Launay. The refinedweb dataset for falcon llm: outperforming curated corpora with web data, and web data only. arXiv preprint arXiv:2306.01116, 2023.
300
+ Reiner Pope, Sholto Douglas, Aakanksha Chowdhery, Jacob Devlin, James Bradbury, Jonathan Heek, Kefan Xiao, Shivani Agrawal, and Jeff Dean. Efficiently scaling transformer inference. Proceedings of Machine Learning and Systems, 5, 2023.
301
+ Noam Shazeer. Fast transformer decoding: One write-head is all you need. arXiv preprint arXiv:1911.02150, 2019.
302
+ Ying Sheng, Lianmin Zheng, Binhang Yuan, Zhuohan Li, Max Ryabinin, Beidi Chen, Percy Liang, Christopher Ré, Ion Stoica, and Ce Zhang. Flexgen: High-throughput generative inference of large language models with a singlegpu. In International Conference on Machine Learning, pages 31094-31116. PMLR, 2023.
303
+ Ross Taylor, Marcin Kardas, Guillem Cucurull, Thomas Scialom, Anthony Hartshorn, Elvis Saravia, Andrew Poulton, Viktor Kerkez, and Robert Stojnic. Galactica: A large language model for science. arXiv preprint arXiv:2211.09085, 2022.
304
+ Yuandong Tian, Yiping Wang, Beidi Chen, and Simon Du. Scan and snap: Understanding training dynamics and token composition in 1-layer transformer. arXiv preprint arXiv:2305.16380, 2023.
305
+
306
+ Hugo Touvron, Thibaut Lavril, Gautier Izacard, Xavier Martinet, Marie-Anne Lachaux, Timothee Lacroix, Baptiste Rozière, Naman Goyal, Eric Hambro, Faisal Azhar, et al. Llama: Open and efficient foundation language models. arXiv preprint arXiv:2302.13971, 2023a.
307
+ Hugo Touvron, Louis Martin, Kevin Stone, Peter Albert, Amjad Almahairi, Yasmine Babaei, Nikolay Bashlykov, Soumya Batra, Prajjwal Bhargava, Shruti Bhosale, et al. Llama 2: Open foundation and fine-tuned chat models. arXiv preprint arXiv:2307.09288, 2023b.
308
+ Zhuang Wang, Zhaozhuo Xu, Xinyu Wu, Anshumali Shrivastava, and TS Eugene Ng. *Dragonn: Distributed randomized approximate gradients of neural networks*. In International Conference on Machine Learning, pages 23274-23291. PMLR, 2022.
309
+ Zhuang Wang, Zhen Jia, Shuai Zheng, Zhen Zhang, Xinwei Fu, T. S. Eugene Ng, and Yida Wang. Gemini: Fast failure recovery in distributed training with in-memory checkpoints. In Proceedings of the 29th Symposium on Operating Systems Principles, 2023.
310
+ Guangxuan Xiao, Ji Lin, Mickael Seznec, Hao Wu, Julien Demouth, and Song Han. Smoothquant: Accurate and efficient post-training quantization for large language models. In International Conference on Machine Learning, pages 38087-38099. PMLR, 2023a.
311
+ Guangxuan Xiao, Yuandong Tian, Beidi Chen, Song Han, and Mike Lewis. Efficient streaming language models with attention sinks. arXiv preprint arXiv:2309.17453, 2023b.
312
+ Zhaozhuo Xu, Zirui Liu, Beidi Chen, Yuxin Tang, Jue Wang, Kaixiong Zhou, Xia Hu, and Anshumali Shrivastava. Compress, then prompt: Improving accuracy-efficiency trade-off of llm inference with transferable prompt. arXiv preprint arXiv:2305.11186, 2023.
313
+ Jiayi Yuan, Ruixiang Tang, Xiaogian Jiang, and Xia Hu. Large language models for healthcare data augmentation: An example on patient-trial matching. In AMIA Annual Symposium Proceedings, volume 2023, page 1324. American Medical Informatics Association, 2023.
314
+ Zhenyu Zhang, Ying Sheng, Tianyi Zhou, Tianlong Chen, Lianmin Zheng, Ruisi Cai, Zhao Song, Yuandong Tian, Christopher Ré, Clark Barrett, et al. H _2 o: Heavy-hitter oracle for efficient generative inference of large language models. arXiv preprint arXiv:2306.14048, 2023.
315
+ Yilong Zhao, Chien-Yu Lin, Kan Zhu, Zihao Ye, Lequn Chen, Size Zheng, Luis Ceze, Arvind Krishnamurthy, Tianqi Chen, and Baris Kasikci. Atom: Low-bit quantization for efficient and accurate llm serving. Proceedings of Machine Learning and Systems, 6:196-209, 2024.
316
+
317
+ # A. Detailed Implementations
318
+
319
+ In this section, we present the algorithm for KIVI as discussed in Section 3.3. Specifically, we provide the pseudocode for KIVI when calculating the attention output in the prefetch and decoding phases.
320
+
321
+ Algorithm 1: The KIVI Prefix & Decoding Algorithm
322
+ ```txt
323
+ parameter: group size $G$ ,residual length $R$
324
+ procedure Prefill: Input: $\pmb {X}\in \mathbb{R}^{l_{\mathrm{prompt}}\times d}$ $\begin{array}{rl} & {\pmb {X}_K = \pmb {X}\pmb {W}_K,\pmb {X}_V = \pmb {X}\pmb {W}_V}\\ & {\pmb {X}_{V_g} = \pmb {X}_V[:l_{\mathrm{prompt}} - R],\pmb {X}_{V_r} = \pmb {X}_V[l_{\mathrm{prompt}} - R:]}\\ & {Q(\pmb {X}_{V_g})\leftarrow \mathrm{GroupQuant}(\pmb {X}_{V_g},\mathrm{dim} = \mathrm{token},\mathrm{numGroup} = d / / }\\ & {Q(\pmb {X}_{K_g}),\pmb {X}_{K_r}\leftarrow \mathrm{KeyQuant}(\pmb {X}_K)}\\ & {\mathrm{KV~cache}\leftarrow Q(\pmb {X}_{K_g}),\pmb {X}_{K_r},Q(\pmb {X}_{V_g}),\pmb {X}_{V_r}}\\ & {\mathrm{return} \pmb {X}_K,\pmb {X}_V} \end{array}$
325
+ ```
326
+
327
+ end
328
+ ```julia
329
+ procedure Decoding:
330
+ Input: KV cache, $t \in \mathbb{R}^{1 \times d}$ $t_{Q} = tW_{Q}, t_{K} = tW_{K}, t_{V} = tW_{V}$ $Q(\boldsymbol{X}_{K_{g}}), \boldsymbol{X}_{K_{r}}, Q(\boldsymbol{X}_{V_{g}}), \boldsymbol{X}_{V_{r}} \gets \mathrm{KV~cache}$ $\boldsymbol{X}_{K_{r}} \gets \mathrm{Concat}([\boldsymbol{X}_{K_{r}}, t_{K}], \dim=token)$ $\boldsymbol{X}_{V_{r}} \gets \mathrm{Concat}([\boldsymbol{X}_{V_{r}}, t_{V}], \dim=token)$
331
+ if len( $X_{K_{r}}$ ) = R then
332
+ $Q(\boldsymbol{X}_{K_{r}}), -\leftarrow \mathrm{KeyQuant}(\boldsymbol{X}_{K_{r}})$ $Q(\boldsymbol{X}_{K_{g}}) \gets \mathrm{Concat}([Q(\boldsymbol{X}_{K_{g}}), Q(\boldsymbol{X}_{K_{r}})], \dim=token)$ $\boldsymbol{X}_{K_{r}} \gets \mathrm{empty~tensor}.$
333
+ end
334
+ if len( $X_{V_{r}}$ ) > R then
335
+ $Q(\boldsymbol{X}_{V_{r}^{\prime}}) \gets \mathrm{GroupQuant}(\boldsymbol{X}_{V_{r}}[: -R], \dim=token, \mathrm{numGroup} = d // G)$ $Q(\boldsymbol{X}_{V_{g}}) \gets \mathrm{Concat}([Q(\boldsymbol{X}_{V_{g}}), Q(\boldsymbol{X}_{V_{r}^{\prime}})], \dim=token)$ $\boldsymbol{X}_{V_{r}} \gets \boldsymbol{X}_{V_{r}}[-R:]$
336
+ end
337
+ A ← Concat([tQ(Q(\boldsymbol{X}_{K_{g}})^{\top}, tQ\boldsymbol{X}_{K_{r}}^{\top}], \dim=token)
338
+ A_g = Softmax(A)[-R], A_r = Softmax(A)[-R:]
339
+ tO ← A_gQ(\boldsymbol{X}_{V_{g}}) + A_r\boldsymbol{X}_{V_{r}}
340
+ KV cache ← Q(\boldsymbol{X}_{K_{g}}, \boldsymbol{X}_{K_{r}}, Q(\boldsymbol{X}_{V_{g}}), \boldsymbol{X}_{V_{r}})
341
+ return tO
342
+ end
343
+ function KeyQuant(\boldsymbol{X}_k \in \mathbb{R}^{l \times d}):
344
+ r = l%R,
345
+ X_K_g = X_K[: l-r], X_K_r = X_K[l-r:]
346
+ Q(\boldsymbol{X}_{K_g}) ← GroupQuant(X_K_g, dim=channel, numGroup=l // G)
347
+ return Q(\boldsymbol{X}_{K_g}), X_K_r
348
+ end
349
+ ```
350
+
351
+ # B. More Experimental Results
352
+
353
+ In our efficiency evaluation, we observe that with a residual length of 32, KIVI achieves a significantly higher memory compression rate, which in turn leads to increased throughput. Additionally, our ablation study reveals that changing the residual length from 128 to 32 does not result in a substantial performance gap. We demonstrate KIVI with a residual length of 32 across all benchmark datasets. As shown in Tables 6 and 7, KIVI with a residual length of 32 also delivers performance comparable to that of the 16-bit full model.
354
+
355
+ We also present additional results using Mistral-7B-v0.2 and LongChat-7B-v1.5 on LongBench, which can be found in Table 8 and Table 9, respectively.
356
+
357
+ Table 6: Performance comparison between 16bit, KIVI-2 (2bit) / KIVI-4 (4bit) with residual length 128 and 32 across various models. R32 stands for residual length 32.
358
+
359
+ <table><tr><td>Model</td><td></td><td>CoQA</td><td>TruthfulQA</td><td>GSM8K</td></tr><tr><td rowspan="3">Llama-2-7B</td><td>16bit</td><td>63.88</td><td>30.76</td><td>13.50</td></tr><tr><td>KIVI-2 R128</td><td>63.05</td><td>33.95</td><td>12.74</td></tr><tr><td>KIVI-2 R32</td><td>62.85</td><td>33.01</td><td>13.57</td></tr><tr><td rowspan="3">Llama-2-13B</td><td>16bit</td><td>66.37</td><td>29.53</td><td>22.67</td></tr><tr><td>KIVI-2 R128</td><td>66.23</td><td>29.84</td><td>20.77</td></tr><tr><td>KIVI-2 R32</td><td>66.57</td><td>29.35</td><td>20.62</td></tr><tr><td rowspan="5">Falcon-7B</td><td>16bit</td><td>59.83</td><td>23.20</td><td>4.55</td></tr><tr><td>KIVI-4 R128</td><td>59.67</td><td>22.58</td><td>4.47</td></tr><tr><td>KIVI-4 R32</td><td>59.73</td><td>22.96</td><td>3.94</td></tr><tr><td>KIVI-2 R128</td><td>57.48</td><td>24.98</td><td>3.41</td></tr><tr><td>KIVI-2 R32</td><td>57.50</td><td>25.70</td><td>2.20</td></tr><tr><td rowspan="3">Mistral-7B</td><td>16bit</td><td>67.40</td><td>30.45</td><td>38.36</td></tr><tr><td>KIVI-2 R128</td><td>66.35</td><td>32.17</td><td>36.01</td></tr><tr><td>KIVI-2 R32</td><td>65.90</td><td>31.21</td><td>34.34</td></tr></table>
360
+
361
+ Table 7: Performance evaluation of KIVI with residual length 128 and 32 on various models across a range of benchmarks in LongBench. $R32$ stands for residual length 32.
362
+
363
+ <table><tr><td>Model</td><td></td><td>Qasper</td><td>QMSum</td><td>MultiNews</td><td>TREC</td><td>TriviaQA</td><td>SAMSum</td><td>LCC</td><td>RepoBench-P</td><td>Average</td></tr><tr><td rowspan="3">Llama2-7B</td><td>16bit</td><td>9.52</td><td>21.28</td><td>3.51</td><td>66</td><td>87.72</td><td>41.69</td><td>66.66</td><td>59.82</td><td>44.52</td></tr><tr><td>KIVI-2 R128</td><td>9.31</td><td>20.5</td><td>1.14</td><td>66</td><td>87.42</td><td>42.71</td><td>66.88</td><td>60.23</td><td>44.27</td></tr><tr><td>KIVI-2 R32</td><td>9.26</td><td>20.53</td><td>0.97</td><td>66</td><td>87.42</td><td>42.61</td><td>66.22</td><td>59.67</td><td>44.08</td></tr><tr><td rowspan="3">Llama2-13B</td><td>16bit</td><td>9.32</td><td>21.38</td><td>3.71</td><td>70</td><td>87.87</td><td>43.55</td><td>66.61</td><td>56.42</td><td>44.85</td></tr><tr><td>KIVI-2 R128</td><td>8.58</td><td>20.69</td><td>6.19</td><td>69.5</td><td>87.78</td><td>44.3</td><td>65.08</td><td>55.46</td><td>44.69</td></tr><tr><td>KIVI-2 R32</td><td>8.38</td><td>20.74</td><td>7.01</td><td>69.5</td><td>87.78</td><td>44.43</td><td>64.89</td><td>55.31</td><td>44.75</td></tr><tr><td rowspan="3">Llama2-7B-Chat</td><td>16bit</td><td>19.65</td><td>20.54</td><td>26.36</td><td>63</td><td>84.28</td><td>41.12</td><td>59.75</td><td>52.93</td><td>45.95</td></tr><tr><td>KIVI-2 R128</td><td>19.32</td><td>20.46</td><td>25.48</td><td>63</td><td>84.84</td><td>40.6</td><td>58.71</td><td>52.97</td><td>45.67</td></tr><tr><td>KIVI-2 R32</td><td>19.1</td><td>20.08</td><td>25.33</td><td>63</td><td>85.04</td><td>39.8</td><td>57.91</td><td>52.38</td><td>45.33</td></tr><tr><td rowspan="3">Llama2-13B-Chat</td><td>16bit</td><td>24.18</td><td>20.37</td><td>25.69</td><td>67.5</td><td>86.9</td><td>42.18</td><td>50.23</td><td>50.64</td><td>45.96</td></tr><tr><td>KIVI-2 R128</td><td>23.59</td><td>20.76</td><td>25.25</td><td>67.5</td><td>87.17</td><td>41.56</td><td>49.93</td><td>48.45</td><td>45.52</td></tr><tr><td>KIVI-2 R32</td><td>23.56</td><td>20.9</td><td>25.45</td><td>67.5</td><td>87.42</td><td>41.4</td><td>48.93</td><td>48.81</td><td>45.49</td></tr><tr><td rowspan="5">Falcon-7B</td><td>16bit</td><td>1.48</td><td>2.35</td><td>11.09</td><td>13</td><td>5.84</td><td>2.44</td><td>23.86</td><td>9.69</td><td>8.71</td></tr><tr><td>KIVI-4 R128</td><td>1.04</td><td>2.41</td><td>11.98</td><td>13</td><td>5.84</td><td>2.36</td><td>23.72</td><td>9.92</td><td>8.78</td></tr><tr><td>KIVI-4 R32</td><td>1.03</td><td>2.45</td><td>11.99</td><td>13.5</td><td>5.84</td><td>2.46</td><td>23.88</td><td>9.95</td><td>8.88</td></tr><tr><td>KIVI-2 R128</td><td>1.98</td><td>3.61</td><td>6.78</td><td>10</td><td>6.24</td><td>2.73</td><td>22.18</td><td>10.12</td><td>7.95</td></tr><tr><td>KIVI-2 R32</td><td>2.28</td><td>3.23</td><td>6.73</td><td>10</td><td>6.31</td><td>2.88</td><td>22.71</td><td>10.45</td><td>8.07</td></tr><tr><td rowspan="3">Mistral-7B</td><td>16bit</td><td>8.12</td><td>19.98</td><td>19.99</td><td>67.5</td><td>89.8</td><td>41.69</td><td>66.59</td><td>58.99</td><td>46.58</td></tr><tr><td>KIVI-2 R128</td><td>6.92</td><td>19.71</td><td>17.92</td><td>66.5</td><td>89.63</td><td>41.66</td><td>65.52</td><td>58.99</td><td>45.85</td></tr><tr><td>KIVI-2 R32</td><td>6.84</td><td>19.81</td><td>17.2</td><td>66.5</td><td>89.63</td><td>42.82</td><td>65.13</td><td>58.06</td><td>45.74</td></tr></table>
364
+
365
+ Table 8: The results of LongChat-7B-v1.5-32K with KIVI on LongBench. The model has 32K context length. We use a 32 group size and 128 residual length for both KIVI-2 and KIVI-4. The baseline is of full precision.
366
+
367
+ <table><tr><td></td><td>NarrativeQA</td><td>Qasper</td><td>MultiFieldQA</td><td>HotpotQA</td><td>MuSiQue</td><td>2WikiMQA</td><td>GovReport</td><td>QMSum</td></tr><tr><td>Baseline</td><td>20.65</td><td>29.42</td><td>43.15</td><td>33.05</td><td>14.66</td><td>24.14</td><td>30.85</td><td>22.84</td></tr><tr><td>w./ KIVI-2</td><td>20.79</td><td>28.69</td><td>41.02</td><td>32.91</td><td>13.82</td><td>23.00</td><td>30.47</td><td>22.59</td></tr><tr><td>w./ KIVI-4</td><td>20.49</td><td>28.90</td><td>43.24</td><td>33.07</td><td>14.66</td><td>24.86</td><td>31.40</td><td>22.84</td></tr><tr><td></td><td>MultiNews</td><td>LCC</td><td>RepoBench-P</td><td>TriviaQA</td><td>SAMSum</td><td>TRec</td><td>PR</td><td>Avg</td></tr><tr><td>Baseline</td><td>26.55</td><td>54.83</td><td>58.94</td><td>83.99</td><td>40.75</td><td>66.50</td><td>30.50</td><td>38.72</td></tr><tr><td>w./ KIVI-2</td><td>26.28</td><td>54.11</td><td>57.62</td><td>83.19</td><td>41.28</td><td>66.50</td><td>32.25</td><td>38.30</td></tr><tr><td>w./ KIVI-4</td><td>26.52</td><td>54.06</td><td>58.77</td><td>83.88</td><td>40.62</td><td>67.00</td><td>31.50</td><td>38.79</td></tr></table>
368
+
369
+ Table 9: The results of Mistral-7B-Instruct-v0.2 with KIVI on LongBench. The model has 32K context length and applies group query attention, which uses 8 heads for KV Cache instead of the full 32 heads. We use a 32 group size and 128 residual length for both KIVI-2 and KIVI-4. The baseline is of full precision.
370
+
371
+ <table><tr><td></td><td>NarrativeQA</td><td>Qasper</td><td>MultiFieldQA</td><td>HotpotQA</td><td>MuSiQue</td><td>2WikiMQA</td><td>GovReport</td><td>QMSum</td></tr><tr><td>Baseline</td><td>21.02</td><td>29.41</td><td>47.13</td><td>36.53</td><td>19.13</td><td>21.76</td><td>32.59</td><td>23.99</td></tr><tr><td>w./ KIVI-2</td><td>20.61</td><td>28.73</td><td>44.88</td><td>35.47</td><td>17.95</td><td>20.68</td><td>32.55</td><td>23.65</td></tr><tr><td>w./ KIVI-4</td><td>20.97</td><td>29.41</td><td>46.52</td><td>36.25</td><td>19.53</td><td>21.66</td><td>32.97</td><td>24.06</td></tr><tr><td></td><td>MultiNews</td><td>LCC</td><td>RepoBench-P</td><td>TriviaQA</td><td>SAMSum</td><td>TRec</td><td>PR</td><td>Avg</td></tr><tr><td>Baseline</td><td>27.09</td><td>53.49</td><td>51.40</td><td>86.23</td><td>43.04</td><td>71.00</td><td>89.33</td><td>43.54</td></tr><tr><td>w./ KIVI-2</td><td>26.54</td><td>53.03</td><td>51.16</td><td>86.00</td><td>43.34</td><td>71.00</td><td>80.83</td><td>42.43</td></tr><tr><td>w./ KIVI-4</td><td>26.89</td><td>53.33</td><td>51.41</td><td>86.23</td><td>43.34</td><td>71.00</td><td>89.42</td><td>43.53</td></tr></table>
2024/KIVI_ A Tuning-Free Asymmetric 2bit Quantization for KV Cache/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f85b1784a8c2540bffef8cf9a0b2b1bc882de4decd9835796495838df5ab6d52
3
+ size 868742
2024/KIVI_ A Tuning-Free Asymmetric 2bit Quantization for KV Cache/layout.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/KV-Runahead_ Scalable Causal LLM Inference by Parallel Key-Value Cache Generation/7aa03393-2876-47f2-bf79-bac44a783b1a_content_list.json ADDED
@@ -0,0 +1,2211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [
2
+ {
3
+ "type": "text",
4
+ "text": "KV-Runahead: Scalable Causal LLM Inference by Parallel Key-Value Cache Generation",
5
+ "text_level": 1,
6
+ "bbox": [
7
+ 230,
8
+ 109,
9
+ 743,
10
+ 156
11
+ ],
12
+ "page_idx": 0
13
+ },
14
+ {
15
+ "type": "text",
16
+ "text": "Minsk Cho<sup>1</sup> Mohammad Rastegari<sup>2</sup> Devang Naik<sup>1</sup>",
17
+ "bbox": [
18
+ 292,
19
+ 199,
20
+ 671,
21
+ 215
22
+ ],
23
+ "page_idx": 0
24
+ },
25
+ {
26
+ "type": "text",
27
+ "text": "Abstract",
28
+ "text_level": 1,
29
+ "bbox": [
30
+ 241,
31
+ 242,
32
+ 320,
33
+ 258
34
+ ],
35
+ "page_idx": 0
36
+ },
37
+ {
38
+ "type": "text",
39
+ "text": "Large Language Model or LLM inference has two phases, the prompt (or prefill) phase to output the first token and the extension (or decoding) phase to the generate subsequent tokens. In this work, we propose an efficient parallelization scheme, KV-Runahead to accelerate the prompt phase. The key observation is that the extension phase generates tokens faster than the prompt phase because of key-value cache (KV-cache). Hence, KV-Runahead parallelizes the prompt phase by orchestrating multiple processes to populate the KV-cache and minimizes the time-to-first-token (TTFT). Dual-purposing the KV-cache scheme has two main benefits. First, since KV-cache is designed to leverage the causal attention map, we minimize computation and computation automatically. Second, since it already exists for the extension phase, KV-Runahead is easy to implement. We further propose context-level load-balancing to handle uneven KV-cache generation (due to the causal attention) and to optimize TTFT. Compared with an existing parallelization scheme such as tensor or sequential parallelization where keys and values are locally generated and exchanged via all-gather collectives, our experimental results demonstrate that KV-Runahead can offer over $1.4 \\times$ and $1.6 \\times$ speedups for Llama 7B and Falcon 7B respectively.",
40
+ "bbox": [
41
+ 117,
42
+ 265,
43
+ 444,
44
+ 690
45
+ ],
46
+ "page_idx": 0
47
+ },
48
+ {
49
+ "type": "text",
50
+ "text": "1. Introduction",
51
+ "text_level": 1,
52
+ "bbox": [
53
+ 86,
54
+ 717,
55
+ 217,
56
+ 732
57
+ ],
58
+ "page_idx": 0
59
+ },
60
+ {
61
+ "type": "text",
62
+ "text": "Large language models or LLMs, and especially Generative Pre-trained Transformer (GPT) models have shown excellent performance on many complex language tasks (Ouyang et al., 2022; Zhang et al., 2022a). However, the decoder architecture and autoregression execution in LLMs pose",
63
+ "bbox": [
64
+ 84,
65
+ 743,
66
+ 475,
67
+ 820
68
+ ],
69
+ "page_idx": 0
70
+ },
71
+ {
72
+ "type": "text",
73
+ "text": "<sup>1</sup>Apple. USA <sup>2</sup>Meta. USA (the work done while being with Apple). Correspondence to: Minsik Cho <minsik@apple.com>.",
74
+ "bbox": [
75
+ 84,
76
+ 827,
77
+ 473,
78
+ 856
79
+ ],
80
+ "page_idx": 0
81
+ },
82
+ {
83
+ "type": "text",
84
+ "text": "Proceedings of the $41^{st}$ International Conference on Machine Learning, Vienna, Austria. PMLR 235, 2024. Copyright 2024 by the author(s).",
85
+ "bbox": [
86
+ 84,
87
+ 864,
88
+ 473,
89
+ 905
90
+ ],
91
+ "page_idx": 0
92
+ },
93
+ {
94
+ "type": "text",
95
+ "text": "two challenges for efficient inferences: a) Time-to-first-token or TTFT: consuming potentially a long user context and generate the first token b) Time Per Output Token or TPOT: generating the subsequent tokens fast (Liu et al., 2023a). The second challenge is known to be a memory-bound problem, and a large body of research has been done (Pope et al., 2022), including sparsification, quantization, or weight clustering (Frantar et al., 2023; Lin et al., 2023; Cho et al., 2023; Liu et al., 2023b) or speculative decoding (Leviathan et al., 2023; Chen et al., 2023). But, the first challenge for a long user context is largely a compute-bound problem (Liu et al., 2023a; NVidia-LLM, 2023) and critical for favorable user experience with retrieval augmentation (Ram et al., 2023), in-context learning (Dong et al., 2023), summarization (Zhang et al., 2023b), story generation (Zhang et al., 2023a), and so on.",
96
+ "bbox": [
97
+ 495,
98
+ 243,
99
+ 888,
100
+ 484
101
+ ],
102
+ "page_idx": 0
103
+ },
104
+ {
105
+ "type": "text",
106
+ "text": "Since TTFT for a long context is compute-bound, one solution is to use more computing power in the form of parallelization. The current SOTA in LLM parallelization includes tensor and sequential parallelization (Patel et al., 2023; Li et al., 2023; Korthikanti et al., 2022; NVidia-LLM, 2023) where the key and value computations are distributed over multiple processes and subsequently exchanged, aiming to compute the attention map perfectly in parallel. The methods above are generic enough to drive LLM inference (Vaswani et al., 2017), but not specialized enough for scalable LLM inference, as the causality in attention is not fully leveraged, resulting in up to $2 \\times$ overhead in terms of both computation and communication over the ideal case.",
107
+ "bbox": [
108
+ 495,
109
+ 492,
110
+ 888,
111
+ 690
112
+ ],
113
+ "page_idx": 0
114
+ },
115
+ {
116
+ "type": "text",
117
+ "text": "Therefore, we propose a novel yet effective parallelization technique tailed for LLM inference, KV-Runahead to minimize TTFT. By re-purposing the key-value cache or KV-cache (NVidia-LLM, 2023) mechanism (which exists anyway for subsequent token generation), our proposed KV-Runahead uses other processes to populate KV-cache for the last process with context-level load-balancing. Since KV-cache assumes causal attention computation, KV-Runahead reduces the computation and communication costs and offers lower TTFT over the existing methods. Further, KV-Runahead requires minimal engineering costs, as it simply makes the KV-cache interface dual-purposed. In detail, our contributions are the following:",
118
+ "bbox": [
119
+ 495,
120
+ 696,
121
+ 888,
122
+ 893
123
+ ],
124
+ "page_idx": 0
125
+ },
126
+ {
127
+ "type": "page_number",
128
+ "text": "1",
129
+ "bbox": [
130
+ 480,
131
+ 922,
132
+ 491,
133
+ 934
134
+ ],
135
+ "page_idx": 0
136
+ },
137
+ {
138
+ "type": "image",
139
+ "img_path": "images/1c9c56702671c0bcd6ad34ca7dc4f0aa4d7924119287e6019a7d9bcd04947f01.jpg",
140
+ "image_caption": [
141
+ "(a) LLM inference consists of two phases: the prompt phase for the first token and the extension phase for the next tokens."
142
+ ],
143
+ "image_footnote": [],
144
+ "bbox": [
145
+ 96,
146
+ 89,
147
+ 496,
148
+ 183
149
+ ],
150
+ "page_idx": 1
151
+ },
152
+ {
153
+ "type": "image",
154
+ "img_path": "images/8fdd2ab0739e1c6821799f1bbd6148dee3142229b751f248f259d6bfa6c98dc3.jpg",
155
+ "image_caption": [
156
+ "(b) Causal attention computation of one layer on one process: the upper triangle of $QK^{T}$ will be masked out with $-\\infty$ .",
157
+ "Figure 1. LLM inference begins with the prompt phase to generate the KV-cache and the first token which drive the extension phase as in (a). Inside each layer of the LLM as in (b), a causal attention map $(QK^T)$ is built to compute the attention $A$ from query, value, and key $s$ $(Q,K,V)$ . Computing attention thus has $O(C^{2})$ complexity where $C$ is the user context."
158
+ ],
159
+ "image_footnote": [],
160
+ "bbox": [
161
+ 513,
162
+ 88,
163
+ 870,
164
+ 181
165
+ ],
166
+ "page_idx": 1
167
+ },
168
+ {
169
+ "type": "list",
170
+ "sub_type": "text",
171
+ "list_items": [
172
+ "- We demonstrate that KV-cache scheme can be dual-purposed to parallelize LLM inference for low TTF. Since the KV-cache is built on the causal decoder and gets populated in parallel, KV-Runahead can offer considerable compute and communication savings over tensor/sequential parallelization.",
173
+ "- We show that using KV-cache for parallelization enables asynchronous communication. Thus, KV-Runahead replaces global synchronization with point-to-point asynchronous communication, and provides robustness against network bandwidth fluctuation.",
174
+ "- We highlight that context-level partitioning can load-balance parallel LLM inference. Asymmetric computations and communication rise from KV-cache and its dependency chain across parallel processes. Yet, we can mitigate the negative effects on TTFT with the proposed context-level load-balancing.",
175
+ "- We propose that hierarchical grid search for efficient context-partitioning. Such search results contribute to a lookup table from which a TTFT-minimizing partitioning can be interpolated for various context lengths."
176
+ ],
177
+ "bbox": [
178
+ 104,
179
+ 279,
180
+ 475,
181
+ 642
182
+ ],
183
+ "page_idx": 1
184
+ },
185
+ {
186
+ "type": "text",
187
+ "text": "2. Related Works",
188
+ "text_level": 1,
189
+ "bbox": [
190
+ 84,
191
+ 660,
192
+ 235,
193
+ 676
194
+ ],
195
+ "page_idx": 1
196
+ },
197
+ {
198
+ "type": "text",
199
+ "text": "LLM Inference: Generative LLM inference consists of two steps as in Fig. 1 (Patel et al., 2023). Once the user context is received, all the input tokens are consumed to generate the first token, which is called the prompt phase. At the same time, the computed key and value embeddings are saved as KV-cache (Park et al., 2020; Liu et al., 2023a) and fed to all subsequent token generations to expedite the extension phase. Accordingly, KV-cache grows as more tokens are generated, because the next token generation needs to attend to all previous tokens, including the user context. While the critical metric for the extension phase is time-per-output-token or TPOT, the prompt phase needs to deliver the first token fast which is measured as time-to-first-token or TTFT.",
200
+ "bbox": [
201
+ 84,
202
+ 686,
203
+ 475,
204
+ 883
205
+ ],
206
+ "page_idx": 1
207
+ },
208
+ {
209
+ "type": "text",
210
+ "text": "TTFT Optimization: Minimizing TTFT, especially for",
211
+ "bbox": [
212
+ 84,
213
+ 890,
214
+ 475,
215
+ 906
216
+ ],
217
+ "page_idx": 1
218
+ },
219
+ {
220
+ "type": "text",
221
+ "text": "long context requires two efforts: efficient KV-cache management and fast attention map computation. PagedAttention (Kwon et al., 2023) facilitates the exchange of data including KV-cache between different memory subsystems to handle long contexts. Infinite-LLM (Lin et al., 2024) suggests distributed KV-cache management system at the cloud scale to adaptively handle extremely long context lengths. CacheGen (Liu et al., 2023a) proposes compressing KV-cache for pre-computed contexts to lower TTFT. SplitWise (Patel et al., 2023) proposes to use two different platforms, one with high computing capacity for the prompt phase and the other with low computing capacity for the extension phase by transferring the LLM states, including KV-cache from the first to the second platforms.",
222
+ "bbox": [
223
+ 495,
224
+ 279,
225
+ 888,
226
+ 491
227
+ ],
228
+ "page_idx": 1
229
+ },
230
+ {
231
+ "type": "text",
232
+ "text": "LLM Inference Parallelization: Since TTFT optimization is compute-bound, one can employ parallel DNN inference. Pipeline parallelism shards the layers of a model across multiple processes, splitting the model into several stages or layers (Huang et al., 2019; Narayanan et al., 2021a; Agrawal et al., 2023). Tensor Parallelism is one of the popular parallel methods from (HuggingFace-TensorParallelism; Shoeybi et al., 2020; Narayanan et al., 2021b) where a large matrix multiplication is scattered and then the partial output matrices are gathered, and is known to be superior to pipeline parallelism (Patel et al., 2023). Sequence parallelization (NVidia-LLM, 2023; Li et al., 2023) is a novel",
233
+ "bbox": [
234
+ 495,
235
+ 497,
236
+ 888,
237
+ 679
238
+ ],
239
+ "page_idx": 1
240
+ },
241
+ {
242
+ "type": "image",
243
+ "img_path": "images/eb6faf768734182651973c5ef3d59729abc2c6c9873968c143f272af50ef65db.jpg",
244
+ "image_caption": [
245
+ "(a) 1 process (b) 2 processes (c) 4 processes (d) $p$ processes",
246
+ "Figure 2. $QK^{T}$ computation coverage using BLAS matrix-matrix multiplication: by linking each context partition to KV-cache, we can closely approximate the lower triangular part and minimize unnecessary dot products. Note the upper triangular part of the attention will be masked out to enforce causality."
247
+ ],
248
+ "image_footnote": [],
249
+ "bbox": [
250
+ 496,
251
+ 710,
252
+ 888,
253
+ 803
254
+ ],
255
+ "page_idx": 1
256
+ },
257
+ {
258
+ "type": "header",
259
+ "text": "KV-Runahead: Scalable Causal LLM Inference by Parallel Key-Value Cache Generation",
260
+ "bbox": [
261
+ 205,
262
+ 56,
263
+ 767,
264
+ 71
265
+ ],
266
+ "page_idx": 1
267
+ },
268
+ {
269
+ "type": "page_number",
270
+ "text": "2",
271
+ "bbox": [
272
+ 480,
273
+ 922,
274
+ 491,
275
+ 934
276
+ ],
277
+ "page_idx": 1
278
+ },
279
+ {
280
+ "type": "image",
281
+ "img_path": "images/2702a909fd555e205c5fe23cabc56a6607e5814cad968c1a0c4a15d72aaf522c.jpg",
282
+ "image_caption": [
283
+ "(a) Tensor+Sequence Parallel Inference: With even context partitioning, each process will perform all-gather over $K, V$ . All computations in the layers are symmetric and globally synchronized, and the user context can be evenly partitioned. (See Fig. 4)."
284
+ ],
285
+ "image_footnote": [],
286
+ "bbox": [
287
+ 94,
288
+ 89,
289
+ 472,
290
+ 184
291
+ ],
292
+ "page_idx": 2
293
+ },
294
+ {
295
+ "type": "image",
296
+ "img_path": "images/fd27845e34afdf18c6c69c6df0ac032f172682374baced3707b13392f2cc2fde.jpg",
297
+ "image_caption": [
298
+ "(b) KV-Runahead Inference: Since the later processes wait for the KV-cache to be ready, the layers will asynchronously communicate, and the user context is unevenly partitioned (for loadbalancing) to minimize TTFT. (See Fig. 5).",
299
+ "Figure 3. Comparing the existing tensor+sequence parallel scheme with the proposed KV-Runahead for parallel LLM inference."
300
+ ],
301
+ "image_footnote": [],
302
+ "bbox": [
303
+ 501,
304
+ 90,
305
+ 880,
306
+ 184
307
+ ],
308
+ "page_idx": 2
309
+ },
310
+ {
311
+ "type": "text",
312
+ "text": "data parallel algorithm (by evenly partitioning the input sequences over multiple processes) coupled with a distributed ring attention algorithm. By deploying the ring topology over all the devices, each process exchanges the key and value embedding with neighbors and builds a full attention map locally.",
313
+ "bbox": [
314
+ 84,
315
+ 268,
316
+ 475,
317
+ 358
318
+ ],
319
+ "page_idx": 2
320
+ },
321
+ {
322
+ "type": "text",
323
+ "text": "Both tensor and sequence parallelizations in LLM are mathematically similar in a sense that a) one of two matrices (i.e., either activations or parameters) in multiplication will be sharded over multiple devices, b) both require collective communication to merge the partial outcomes. Hence, both are popular for parallel LLM inference (Korthikanti et al., 2022), yet not specialized enough for causal attention, leading to excessive computation and communication overheads.",
324
+ "bbox": [
325
+ 84,
326
+ 366,
327
+ 477,
328
+ 501
329
+ ],
330
+ "page_idx": 2
331
+ },
332
+ {
333
+ "type": "text",
334
+ "text": "3. Causal LLM Scalability and Motivation",
335
+ "text_level": 1,
336
+ "bbox": [
337
+ 84,
338
+ 521,
339
+ 444,
340
+ 539
341
+ ],
342
+ "page_idx": 2
343
+ },
344
+ {
345
+ "type": "text",
346
+ "text": "In this section, we will discuss the lower bound of the scalability of a causal attention-based LLM for a sufficiently long user context $C$ over parallel $p$ processes. Assume that the user context $C$ is partitioned into $C = \\{c_0, c_1, c_2, \\dots, c_{p-1}\\}$ for $p$ processes, and each process is exclusively mapped to one compute fabric (e.g., GPU). The minimum compute over $p$ to generate the first token, $TTFT(p)$ with perfect load-balancing is as follows:",
347
+ "bbox": [
348
+ 84,
349
+ 547,
350
+ 475,
351
+ 667
352
+ ],
353
+ "page_idx": 2
354
+ },
355
+ {
356
+ "type": "equation",
357
+ "text": "\n$$\n\\begin{array}{l} T T F T (p) \\geq \\alpha \\left[ \\frac {\\frac {1}{2} C ^ {2} + \\frac {1}{2} \\left(\\sum_ {0} ^ {p - 1} c _ {i} ^ {2}\\right)}{p} \\right] (1) \\\\ \\geq \\alpha \\left[ \\frac {\\frac {1}{2} C ^ {2} + \\frac {1}{2} p (\\frac {C}{p}) ^ {2}}{p} \\right] \\\\ = \\alpha \\left[ \\frac {C ^ {2}}{2} (\\frac {1}{p} + \\frac {1}{p ^ {2}}) \\right] \\\\ = \\frac {T T F T (1)}{2} \\left(\\frac {1}{p} + \\frac {1}{p ^ {2}}\\right) (2) \\\\ = \\mathbf {T T F T} ^ {*} (p) (3) \\\\ \\end{array}\n$$\n",
358
+ "text_format": "latex",
359
+ "bbox": [
360
+ 148,
361
+ 676,
362
+ 473,
363
+ 849
364
+ ],
365
+ "page_idx": 2
366
+ },
367
+ {
368
+ "type": "text",
369
+ "text": "where $\\alpha$ is a fitting coefficient such that $TTFT(1) = \\alpha C^2$ (single process performance) (Dao et al., 2022), and $\\mathbf{TFT}^{*}(\\mathfrak{p})$ is the lower bound of TTFT over $p$ . The signifi",
370
+ "bbox": [
371
+ 84,
372
+ 859,
373
+ 477,
374
+ 906
375
+ ],
376
+ "page_idx": 2
377
+ },
378
+ {
379
+ "type": "text",
380
+ "text": "cance of $\\mathbf{T}\\mathbf{T}\\mathbf{F}\\mathbf{T}^{*}(p)$ is that for a very long user context, there exists super-linear scalability (i.e., more than $2\\times$ speedup with 2 processes) with causal LLM in the ideal setup, such as perfect load-balancing, zero communication costs, and so on. Please see the super-linear scalability of KV-Runahead reported in Fig. 8 (d).",
381
+ "bbox": [
382
+ 496,
383
+ 268,
384
+ 885,
385
+ 358
386
+ ],
387
+ "page_idx": 2
388
+ },
389
+ {
390
+ "type": "text",
391
+ "text": "Fig. 2 visualizes the concepts behind Eq. (1) which essentially divides an attention map, $QK^{T}(C,C)$ in the shaded regions over $p$ processes. We need to practically compute multiple rectangle regions using matrix-matrix multiplication and mask out the upper triangle part (which is how most LLMs are implemented). Therefore, with more partitions, we can eliminate the wasted computation. Other equally good partitioning setups (i.e., using vertical rectangles to approximate the lower triangle) could exist, but the one in Fig. 2 (d) is LLM-friendly: easy to generate at the context level, and exactly aligned with KV-cache.",
392
+ "bbox": [
393
+ 496,
394
+ 366,
395
+ 887,
396
+ 532
397
+ ],
398
+ "page_idx": 2
399
+ },
400
+ {
401
+ "type": "text",
402
+ "text": "Hence, we can intuitively map the partitions in Fig. 2 (d) to $p$ processes, which can be implemented by dual-purposing the already-existing KV-cache interface with minor efforts, leading to the motivation behind KV-Runahead. Also, as seen in Fig. 2 (d), each process will suffer from varying computation load, thus one may not effectively minimize TTFT. Yet, optimizing $c_{i}$ alone may lead to global over-computation. Hence, we perform context-level partitioning for load-balancing and minimal TTFT in KV-Runahead.",
403
+ "bbox": [
404
+ 495,
405
+ 539,
406
+ 888,
407
+ 676
408
+ ],
409
+ "page_idx": 2
410
+ },
411
+ {
412
+ "type": "text",
413
+ "text": "4. KV-Runahead Overview",
414
+ "text_level": 1,
415
+ "bbox": [
416
+ 496,
417
+ 695,
418
+ 728,
419
+ 710
420
+ ],
421
+ "page_idx": 2
422
+ },
423
+ {
424
+ "type": "text",
425
+ "text": "In Fig. 3, the proposed KV-Runahead is illustrated and compared against Tensor/sequence parallel inference (or TSP), which characterizes both tensor parallelism (Shoeybi et al., 2020; Narayanan et al., 2021b) and sequence parallelization (Li et al., 2023). As in Fig. 3 (b), KV-Runahead starts with uneven context partitioning for load-balancing. The existing TSP parallelizes the forward computation itself, but KV-Runahead achieves parallel inference by utilizing multiple processes to populate KV-caches for the last process. Therefore, unlike TSP where computation is symmetric and evenly distributed (thus no need to balance out context partitioning), KV-Runahead needs good context partitioning",
426
+ "bbox": [
427
+ 495,
428
+ 720,
429
+ 888,
430
+ 902
431
+ ],
432
+ "page_idx": 2
433
+ },
434
+ {
435
+ "type": "header",
436
+ "text": "KV-Runahead: Scalable Causal LLM Inference by Parallel Key-Value Cache Generation",
437
+ "bbox": [
438
+ 205,
439
+ 56,
440
+ 767,
441
+ 71
442
+ ],
443
+ "page_idx": 2
444
+ },
445
+ {
446
+ "type": "page_number",
447
+ "text": "3",
448
+ "bbox": [
449
+ 480,
450
+ 922,
451
+ 491,
452
+ 934
453
+ ],
454
+ "page_idx": 2
455
+ },
456
+ {
457
+ "type": "image",
458
+ "img_path": "images/cb3f7f361a6728d091f45ebcf16c3cdc8dad7f6b75fa4b2054a23748b76d08e5.jpg",
459
+ "image_caption": [],
460
+ "image_footnote": [],
461
+ "bbox": [
462
+ 125,
463
+ 90,
464
+ 480,
465
+ 178
466
+ ],
467
+ "page_idx": 3
468
+ },
469
+ {
470
+ "type": "image",
471
+ "img_path": "images/82ee586c5969f078018643976514767e3d25fd7ef30a7b6ede13e7390a0e3b66.jpg",
472
+ "image_caption": [],
473
+ "image_footnote": [],
474
+ "bbox": [
475
+ 125,
476
+ 195,
477
+ 478,
478
+ 286
479
+ ],
480
+ "page_idx": 3
481
+ },
482
+ {
483
+ "type": "image",
484
+ "img_path": "images/e6fd5c2a17b619bf2a2dd61fbd41446eb378122c29a33a098f0e099c7a50ae0f.jpg",
485
+ "image_caption": [
486
+ "(a) $Q, K, V$ are computed for the evenly partitioned context."
487
+ ],
488
+ "image_footnote": [],
489
+ "bbox": [
490
+ 125,
491
+ 301,
492
+ 478,
493
+ 390
494
+ ],
495
+ "page_idx": 3
496
+ },
497
+ {
498
+ "type": "image",
499
+ "img_path": "images/70397634352c4e8718132434b5b5fa2016891a73336ea199c9742ab45576dab6.jpg",
500
+ "image_caption": [
501
+ "all-gather K"
502
+ ],
503
+ "image_footnote": [],
504
+ "bbox": [
505
+ 516,
506
+ 90,
507
+ 846,
508
+ 175
509
+ ],
510
+ "page_idx": 3
511
+ },
512
+ {
513
+ "type": "image",
514
+ "img_path": "images/e8fd7a20df9989657dcd46b813e2b36b0eb7b61b1fe5442ed278d21c7298149c.jpg",
515
+ "image_caption": [
516
+ "all-gather K"
517
+ ],
518
+ "image_footnote": [],
519
+ "bbox": [
520
+ 516,
521
+ 196,
522
+ 846,
523
+ 282
524
+ ],
525
+ "page_idx": 3
526
+ },
527
+ {
528
+ "type": "image",
529
+ "img_path": "images/0637c50cb98803aa291679cb232a0396df1cb959f7bdb6c0bfe1c235f51c99d2.jpg",
530
+ "image_caption": [
531
+ "(b) $K,V$ are exchanged by all-gather to mimic Fig. 1 (b)."
532
+ ],
533
+ "image_footnote": [],
534
+ "bbox": [
535
+ 517,
536
+ 304,
537
+ 846,
538
+ 390
539
+ ],
540
+ "page_idx": 3
541
+ },
542
+ {
543
+ "type": "image",
544
+ "img_path": "images/904d9239433dc855585a22efff7c26056dd51fd4f40e59d26b826e9e4ab9a19e.jpg",
545
+ "image_caption": [
546
+ "Figure 4. Tensor/sequence parallel inference over 3 processes $p_{\\{0,1,2\\}}$ within a layer to compute attention map $(QK^T)$ and final attention $A$ : Each process will compute the equal amount of $(Q,K,V)$ in (a), and then globally share $(K,V)$ using all-gather collectives to compute the equally sized partial $QK^T$ (i.e., 27 dot-products needed on each) and partial $A$ . Such all-gather operations require global synchronization, and incur the traffic for 36 $(K,V)$ entries (i.e., the number of blue rows in $(K,V)$ )."
547
+ ],
548
+ "image_footnote": [],
549
+ "bbox": [
550
+ 124,
551
+ 489,
552
+ 475,
553
+ 578
554
+ ],
555
+ "page_idx": 3
556
+ },
557
+ {
558
+ "type": "image",
559
+ "img_path": "images/f097000cfcc71ed79c5f9f87a404953352c67099180decafdecc62ec8131778f.jpg",
560
+ "image_caption": [],
561
+ "image_footnote": [],
562
+ "bbox": [
563
+ 124,
564
+ 595,
565
+ 475,
566
+ 683
567
+ ],
568
+ "page_idx": 3
569
+ },
570
+ {
571
+ "type": "image",
572
+ "img_path": "images/313f97c685e10615375d7ee0386bd6ee2867a0439ad3c2c97e6c80edd95ed314.jpg",
573
+ "image_caption": [
574
+ "(a) $Q, K, V$ are computed for the uneven partitioning.",
575
+ "Figure 5. KV-Runahead execution over 3 processes $p_{\\{0,1,2\\}}$ within a layer to compute attention map $(QK^T)$ and final attention $A$ : Each process will compute different amounts of $(Q,K,V)$ in (a), and the maximum amount for $QK^T$ is 21 dot-products on $p_1$ (in contrast to 27 from Fig. 4 (b)). The locally computed $(K,V)$ are passed down to the following processes as KV-cache using point-2-point one-way send (i.e., $p_0 \\to p_1 \\to p_2$ ). Our communication is much cheaper than global all-gather in Fig. 4 (b), as the traffic incurred in KV-Runahead is 22 (i.e., the number of blue rows in $(K,V)$ ), which is much lower than 36 from Fig. 4."
576
+ ],
577
+ "image_footnote": [],
578
+ "bbox": [
579
+ 124,
580
+ 702,
581
+ 475,
582
+ 789
583
+ ],
584
+ "page_idx": 3
585
+ },
586
+ {
587
+ "type": "image",
588
+ "img_path": "images/8d6d4f00951b78c1217d30e8d60caf2176f77a62e1c67739a6baf26b42d4647b.jpg",
589
+ "image_caption": [
590
+ "send K[0:3]"
591
+ ],
592
+ "image_footnote": [],
593
+ "bbox": [
594
+ 514,
595
+ 489,
596
+ 846,
597
+ 575
598
+ ],
599
+ "page_idx": 3
600
+ },
601
+ {
602
+ "type": "image",
603
+ "img_path": "images/7592f060c5116a225ad6e7ec9e1ca576ab8f72cab72fca63532c739b3cb0640c.jpg",
604
+ "image_caption": [
605
+ "send K[0:6]"
606
+ ],
607
+ "image_footnote": [],
608
+ "bbox": [
609
+ 514,
610
+ 598,
611
+ 844,
612
+ 681
613
+ ],
614
+ "page_idx": 3
615
+ },
616
+ {
617
+ "type": "image",
618
+ "img_path": "images/89565517b0310538b63cf784a51e0295d004de7ac7fe8e127ec48c099e6cd97b.jpg",
619
+ "image_caption": [
620
+ "(b) KV-caches are handed down from $p_i$ to $p_{i+1}$ by send."
621
+ ],
622
+ "image_footnote": [],
623
+ "bbox": [
624
+ 514,
625
+ 703,
626
+ 844,
627
+ 789
628
+ ],
629
+ "page_idx": 3
630
+ },
631
+ {
632
+ "type": "header",
633
+ "text": "KV-Runahead: Scalable Causal LLM Inference by Parallel Key-Value Cache Generation",
634
+ "bbox": [
635
+ 205,
636
+ 56,
637
+ 766,
638
+ 70
639
+ ],
640
+ "page_idx": 3
641
+ },
642
+ {
643
+ "type": "page_number",
644
+ "text": "4",
645
+ "bbox": [
646
+ 480,
647
+ 922,
648
+ 491,
649
+ 934
650
+ ],
651
+ "page_idx": 3
652
+ },
653
+ {
654
+ "type": "text",
655
+ "text": "to balance out the KV-cache amount from each compute process and to minimize TTFT.",
656
+ "bbox": [
657
+ 84,
658
+ 85,
659
+ 475,
660
+ 116
661
+ ],
662
+ "page_idx": 4
663
+ },
664
+ {
665
+ "type": "text",
666
+ "text": "Once partitioning is complete, each process will run each layer, conditioning on the KV-cache from its precedent process. In detail, the current process must wait for the required KV-cache to arrive from the precedent (i.e., notice the layer misalignment in Fig. 3 (b)), forming a dependency chain via local peer-to-peer communication rather than global synchronization via all-gather (Thakur et al., 2005).",
667
+ "bbox": [
668
+ 84,
669
+ 122,
670
+ 473,
671
+ 229
672
+ ],
673
+ "page_idx": 4
674
+ },
675
+ {
676
+ "type": "text",
677
+ "text": "We will first elaborate on how KV-Runahead works inside each layer in terms of compute/communication saving in Section 4.1, and then discuss the context partitioning for load-balancing in KV-Runahead in Section 4.2. Finally, Section 4.3 briefly discuss implementing KV-Runahead.",
678
+ "bbox": [
679
+ 84,
680
+ 234,
681
+ 475,
682
+ 311
683
+ ],
684
+ "page_idx": 4
685
+ },
686
+ {
687
+ "type": "text",
688
+ "text": "4.1. Forward Execution",
689
+ "text_level": 1,
690
+ "bbox": [
691
+ 84,
692
+ 328,
693
+ 254,
694
+ 342
695
+ ],
696
+ "page_idx": 4
697
+ },
698
+ {
699
+ "type": "text",
700
+ "text": "The causal attention computation on a single process is shown in Fig. 1 (b), which is to be parallelized in this section. For a given context, once $(Q,K,V)$ are computed, $QK^T$ or attention map is computed for $A$ . Although only the lower triangular part of $QK^T$ is needed due to the causality, the entire $QK^T$ is commonly computed via dense matrix-matrix multiplication first, then a mask is added in general (HuggingFace-Transformers), because no good mapping to BLAS-L3 exists or writing a custom kernel is expensive (NVidia-cuBLAS).",
701
+ "bbox": [
702
+ 84,
703
+ 351,
704
+ 475,
705
+ 502
706
+ ],
707
+ "page_idx": 4
708
+ },
709
+ {
710
+ "type": "text",
711
+ "text": "One SOTA way to enable parallel inference for LLM (e.g., GPT-3, Llama, and BLOOM), would be to utilize tensor and sequence parallelizations (Li et al., 2023; Patel et al., 2023; Shoeybi et al., 2020; Korthikanti et al., 2022), Tensor/sequence parallelization or TSP in Fig. 4 where the focus is on parallelizing the single process behavior from Fig. 1 (b). In TSP, for a given evenly partitioned context, $(Q, K, V)$ are independently computed on each process as in Fig. 4 (a). Then, the collective operation all-gather is performed to exchange $K$ and $V$ to all processes so that $Q K^T$ can be evenly distributed as shown in Fig. 4 (b). Although TSP faithfully follows the single process case in Fig. 1 (b), it does not take advantage of the causality in LLM inference.",
712
+ "bbox": [
713
+ 84,
714
+ 508,
715
+ 475,
716
+ 705
717
+ ],
718
+ "page_idx": 4
719
+ },
720
+ {
721
+ "type": "text",
722
+ "text": "In our KV-Runahead, we start with a given yet unevenly partitioned context, and $(Q,K,V)$ are independently computed on each process as in Fig. 5 (a). Thus, each process computes a different number of entries in $(Q,K,V)$ . Then, KV-Runahead simply populates the KV-cache from each process and hands over to the next process in chain, mimicking the extension phase in Fig. 1 (a). As a result, only the last process will have the full $(K,V)$ , but still each process can output the $A$ in the same shape as $Q$ , driving the next layer. Since KV-cache itself is built upon the causality, KV-Runahead can automatically minimize the computation of the upper triangle and reduce the number of dot-products for",
723
+ "bbox": [
724
+ 84,
725
+ 713,
726
+ 475,
727
+ 893
728
+ ],
729
+ "page_idx": 4
730
+ },
731
+ {
732
+ "type": "text",
733
+ "text": "$QK^T$ . For example, 27 dot-products are needed on all the processes in TSP as in Fig. 4 (b), but KV-Runahead requires 21 (max out of $\\{p_0:16,p_1:21,p_2:18\\}$ ) as in Fig. 5 (b). This also highlights the motivation behind uneven context partitioning to minimize the largest $QK^T$ computation.",
734
+ "bbox": [
735
+ 496,
736
+ 84,
737
+ 885,
738
+ 161
739
+ ],
740
+ "page_idx": 4
741
+ },
742
+ {
743
+ "type": "text",
744
+ "text": "KV-Runahead also removes the global synchronization points and reduces the total traffic volume exchanged among processes. All-gather operations in Fig. 4 (b) force all the processes to stop and secure the full $(K,V)$ (Thakur et al., 2005), while KV-Runahead shares only the local KV-cache with the next process via point-to-point send operations. As a result, TSP in Fig. 4 (a) requires to share $36(K,V)$ entries to get to the state in Fig. 4 (b), but KV-Runahead only needs 22 to transit to Fig. 5 (b). Such a dependency chain from KV-cache introduces a longer wait time for the later processes, but KV-Runahead can outperform TSP even with such overheads.",
745
+ "bbox": [
746
+ 496,
747
+ 167,
748
+ 885,
749
+ 348
750
+ ],
751
+ "page_idx": 4
752
+ },
753
+ {
754
+ "type": "text",
755
+ "text": "In theory, with a sufficient number of parallel processes and a sufficiently long user context (i.e., $QK^T$ dominates the runtime), KV-Runahead can offer up to $2 \\times$ speed up over TSP, because both total $QK^T$ computation and network traffic among processes in KV-Runahead are half of those in TSP. It could be possible to handcraft a custom/expensive BLAS kernel for TSP to avoid over-computation. Even with a tailored custom kernel, however, the communication involved in TSP remains suboptimal as it still uses Allgather to exchange (K, V) The proposed KV-Runahead avoids both over-computation and wasted network traffic seamlessly, by dual-purposing the LLM-specific KV-cache scheme (which already exists for the extension phase).",
756
+ "bbox": [
757
+ 496,
758
+ 356,
759
+ 885,
760
+ 551
761
+ ],
762
+ "page_idx": 4
763
+ },
764
+ {
765
+ "type": "text",
766
+ "text": "Additionally, the same computational savings achieved with the custom GPU kernel, can also be applied to KVR. From Fig 5 (b), we can still see some wasted computation. Hence, a custom kernel would save such waste to further enhance the performance of KVR. Yet, the benefit from a custom kernel would diminish with more GPUs in parallel, as the nature of KV-cache allows our technique to approximate the unmasked lower triangle more accurately with more processes, as illustrated in Figure 2 (b) and (d).",
767
+ "bbox": [
768
+ 496,
769
+ 560,
770
+ 885,
771
+ 696
772
+ ],
773
+ "page_idx": 4
774
+ },
775
+ {
776
+ "type": "text",
777
+ "text": "For simplicity, assume that a user context $C$ is even partitioned for KV-Runahead and TSP over $p$ processes. Then, the total TSP traffic $\\mathbf{Net}_{tsp}$ can be written as follows:",
778
+ "bbox": [
779
+ 496,
780
+ 704,
781
+ 885,
782
+ 750
783
+ ],
784
+ "page_idx": 4
785
+ },
786
+ {
787
+ "type": "equation",
788
+ "text": "\n$$\n\\begin{array}{l} \\mathbf {N e t} _ {t s p} (C, p) = p (p - 1) \\frac {C}{p} (4) \\\\ = (p - 1) C (5) \\\\ \\end{array}\n$$\n",
789
+ "text_format": "latex",
790
+ "bbox": [
791
+ 598,
792
+ 786,
793
+ 885,
794
+ 837
795
+ ],
796
+ "page_idx": 4
797
+ },
798
+ {
799
+ "type": "text",
800
+ "text": "which is essentially the total number of $(K,V)$ entries from other processes. The total KV-Runahead traffic $\\mathbf{Net}_{kvr}$ is",
801
+ "bbox": [
802
+ 496,
803
+ 875,
804
+ 885,
805
+ 905
806
+ ],
807
+ "page_idx": 4
808
+ },
809
+ {
810
+ "type": "header",
811
+ "text": "KV-Runahead: Scalable Causal LLM Inference by Parallel Key-Value Cache Generation",
812
+ "bbox": [
813
+ 205,
814
+ 56,
815
+ 767,
816
+ 70
817
+ ],
818
+ "page_idx": 4
819
+ },
820
+ {
821
+ "type": "page_number",
822
+ "text": "5",
823
+ "bbox": [
824
+ 480,
825
+ 922,
826
+ 491,
827
+ 934
828
+ ],
829
+ "page_idx": 4
830
+ },
831
+ {
832
+ "type": "text",
833
+ "text": "the sum of the total KV-cache put into the network.",
834
+ "bbox": [
835
+ 84,
836
+ 85,
837
+ 424,
838
+ 99
839
+ ],
840
+ "page_idx": 5
841
+ },
842
+ {
843
+ "type": "equation",
844
+ "text": "\n$$\n\\begin{array}{l} \\mathbf {N e t} _ {k v r} (C, p) = \\frac {C}{p} + \\frac {2 C}{p} + \\frac {3 C}{p} + \\dots (6) \\\\ = \\sum_ {i = 1} ^ {p - 1} \\frac {i C}{p} = \\frac {(p - 1)}{2} C (7) \\\\ \\end{array}\n$$\n",
845
+ "text_format": "latex",
846
+ "bbox": [
847
+ 151,
848
+ 108,
849
+ 475,
850
+ 185
851
+ ],
852
+ "page_idx": 5
853
+ },
854
+ {
855
+ "type": "text",
856
+ "text": "The $2 \\times$ reduction is over the total computation and network traffic, not for each individual process. Therefore, it is critical to perform load-balancing to maximize the gain over TSP and minimize TTFT, and KV-Runahead accomplishes it by context-level load-balancing in Section 4.2.",
857
+ "bbox": [
858
+ 84,
859
+ 203,
860
+ 475,
861
+ 277
862
+ ],
863
+ "page_idx": 5
864
+ },
865
+ {
866
+ "type": "text",
867
+ "text": "4.2. Context-Level Load-Balancing",
868
+ "text_level": 1,
869
+ "bbox": [
870
+ 84,
871
+ 295,
872
+ 334,
873
+ 310
874
+ ],
875
+ "page_idx": 5
876
+ },
877
+ {
878
+ "type": "text",
879
+ "text": "As discussed in Section 3, KV-Runahead needs loadbalancing for low TTFT. We propose running off-line search for the best partitioning, and then store the results in a partitioning lookup table. For example, we pre-compute the optimal partitioning of user contexts at various lengths for a given number of processes off-line by measuring TTFT on the target hardware, and then contribute the search results to a lookup table. During inference, we can predict the best partitioning by interpolating the two nearest known entries in the lookup table. For the example of $10\\mathrm{k}$ prompt, we can interpolate from the known partitioning configurations from $8\\mathrm{k}$ and $12\\mathrm{k}$ in the lookup table.",
880
+ "bbox": [
881
+ 84,
882
+ 318,
883
+ 475,
884
+ 500
885
+ ],
886
+ "page_idx": 5
887
+ },
888
+ {
889
+ "type": "text",
890
+ "text": "Finding the best partitioning configuration for a given user context, although one-time off-line overhead, can be expensive. Hence, we propose a hierarchical grid search for acceleration. From the nature of KV-Runahead, it is straightforward to see that finding the TTFT-optimal partitioning has two conflicting objectives.",
891
+ "bbox": [
892
+ 84,
893
+ 507,
894
+ 475,
895
+ 598
896
+ ],
897
+ "page_idx": 5
898
+ },
899
+ {
900
+ "type": "list",
901
+ "sub_type": "text",
902
+ "list_items": [
903
+ "- The partitions for the earlier processes must be small, otherwise the later processes will wait too long for the earlier ones to populate KV-caches and send them over.",
904
+ "- The partitions for the later processes need to be small, otherwise the later processes will the bottleneck in generating the first token."
905
+ ],
906
+ "bbox": [
907
+ 104,
908
+ 607,
909
+ 475,
910
+ 708
911
+ ],
912
+ "page_idx": 5
913
+ },
914
+ {
915
+ "type": "text",
916
+ "text": "For two processes, we can use a binary search to find out the best partitioning. Fig. 6 (a) shows how TTFT changes as we grow the partition for the $p_0$ for a 16k context where the partitioning is $C[0,8192 + \\delta_1,16384]$ . As $\\delta_1$ grows, it bottoms at the partition of [0, 9728, 16384] (i.e., $\\delta_1 = 1536$ , thus $p_0$ takes C[0:9728] and $p_1$ takes in C[9728:16384]).",
917
+ "bbox": [
918
+ 84,
919
+ 715,
920
+ 475,
921
+ 808
922
+ ],
923
+ "page_idx": 5
924
+ },
925
+ {
926
+ "type": "text",
927
+ "text": "By generalizing the binary search into a hierarchical grid search for multiple processes (Zhang et al., 2022b), we can find a high-quality partitioning fast for a given user context length. Figs. 6 (b-d) depict the proposed search process for a user context length of 96 over 4 processes, which is to find the optimal $(\\delta_1,\\delta_2)$ for the partitioning of",
928
+ "bbox": [
929
+ 84,
930
+ 814,
931
+ 475,
932
+ 906
933
+ ],
934
+ "page_idx": 5
935
+ },
936
+ {
937
+ "type": "image",
938
+ "img_path": "images/0de08b41056e6ff2140d2b216b707d87618a0b70327ca08685a7d88167957551.jpg",
939
+ "image_caption": [
940
+ "(a) 2 partitions"
941
+ ],
942
+ "image_footnote": [],
943
+ "bbox": [
944
+ 496,
945
+ 87,
946
+ 594,
947
+ 165
948
+ ],
949
+ "page_idx": 5
950
+ },
951
+ {
952
+ "type": "image",
953
+ "img_path": "images/5332defd6dee6d7c3d9103059dfdbb4437bf5b4f0b6f559db055e5ead44f3364.jpg",
954
+ "image_caption": [
955
+ "(b) stride 8"
956
+ ],
957
+ "image_footnote": [],
958
+ "bbox": [
959
+ 596,
960
+ 89,
961
+ 691,
962
+ 164
963
+ ],
964
+ "page_idx": 5
965
+ },
966
+ {
967
+ "type": "image",
968
+ "img_path": "images/9fb56257d5b491d6110b5f21162f9ba421fb67f48dbc686cf450e28d7c9b95f5.jpg",
969
+ "image_caption": [
970
+ "(c) stride 4",
971
+ "Figure 6. Finding two partitions can be done quickly by binary search as shown in (a) where $\\delta_{1}$ is the variable for additional context the $p_0$ . We can extend such binary search into hierarchical grid search for multiple processes as in (b, c, d) for the example of $C[0,32 + \\delta_1,64 + \\delta_2,96]$ ."
972
+ ],
973
+ "image_footnote": [],
974
+ "bbox": [
975
+ 692,
976
+ 89,
977
+ 789,
978
+ 164
979
+ ],
980
+ "page_idx": 5
981
+ },
982
+ {
983
+ "type": "image",
984
+ "img_path": "images/7ea9e4bc0a65600d1c0e60be23257dcaf9279d5006121ea3e04eec79d56c56ef.jpg",
985
+ "image_caption": [
986
+ "(d) stride 2"
987
+ ],
988
+ "image_footnote": [],
989
+ "bbox": [
990
+ 790,
991
+ 90,
992
+ 887,
993
+ 164
994
+ ],
995
+ "page_idx": 5
996
+ },
997
+ {
998
+ "type": "image",
999
+ "img_path": "images/b4d6be5306d88e9f59b44aeb35d38004093fb8e0dc494d5d634cf98bd3ace16f.jpg",
1000
+ "image_caption": [
1001
+ "(a) Without KV-Runahead.",
1002
+ "Figure 7. KV-Runahead can be easily implemented in LLM with existing KV-cache support (e.g., most of public LLMs) by simply inserting recv/send operations (in the blue boxes). Note that $M$ is the causality mask."
1003
+ ],
1004
+ "image_footnote": [],
1005
+ "bbox": [
1006
+ 511,
1007
+ 297,
1008
+ 676,
1009
+ 532
1010
+ ],
1011
+ "page_idx": 5
1012
+ },
1013
+ {
1014
+ "type": "image",
1015
+ "img_path": "images/9f3f32ee6357aca91f4ca3ef766fddba6a6884bec8cb0541e4d4c534b17514f9.jpg",
1016
+ "image_caption": [
1017
+ "(b) With KV-Runahead."
1018
+ ],
1019
+ "image_footnote": [],
1020
+ "bbox": [
1021
+ 705,
1022
+ 297,
1023
+ 870,
1024
+ 532
1025
+ ],
1026
+ "page_idx": 5
1027
+ },
1028
+ {
1029
+ "type": "text",
1030
+ "text": "$C[0,32 + \\delta_1,64 + \\delta_2,96]$ . In the first level, we set the search stride as 8 and measure the TTFTs on each grid. Once we find the best performing $(\\delta_{1},\\delta_{2})$ pair, we limit the search to the gray grid and reduce the search stride to 4 to perform another scan as in Fig. 6 (c). We repeat the same process recursively until the minimum stride is applied, leading to the final search as in Fig. 6 (d). The best partitioning is then [0, 28, 70, 96] and marked as a red dot in Fig. 6 (b).",
1031
+ "bbox": [
1032
+ 496,
1033
+ 656,
1034
+ 885,
1035
+ 777
1036
+ ],
1037
+ "page_idx": 5
1038
+ },
1039
+ {
1040
+ "type": "text",
1041
+ "text": "A comprehensive partitioning lookup table will enable efficient partitioning as in Fig. 3 (b) for effective load-balancing. For a given user context, we will interpolate and predict the best partitioning from two closest entries. Therefore, having a dense and large table would be advantageous at the cost of one-time search overhead. Our results also show that even at the $4\\mathrm{k}$ intervals between entries, the predicted partitioning can yield excellent TTFT (see Fig. 10).",
1042
+ "bbox": [
1043
+ 495,
1044
+ 784,
1045
+ 887,
1046
+ 906
1047
+ ],
1048
+ "page_idx": 5
1049
+ },
1050
+ {
1051
+ "type": "header",
1052
+ "text": "KV-Runahead: Scalable Causal LLM Inference by Parallel Key-Value Cache Generation",
1053
+ "bbox": [
1054
+ 205,
1055
+ 56,
1056
+ 766,
1057
+ 70
1058
+ ],
1059
+ "page_idx": 5
1060
+ },
1061
+ {
1062
+ "type": "page_number",
1063
+ "text": "6",
1064
+ "bbox": [
1065
+ 480,
1066
+ 922,
1067
+ 491,
1068
+ 934
1069
+ ],
1070
+ "page_idx": 5
1071
+ },
1072
+ {
1073
+ "type": "image",
1074
+ "img_path": "images/07aea3d394ce8c110a91f95fec8c3355b5651c80f1e8ca6abe1c694eda4d946a.jpg",
1075
+ "image_caption": [
1076
+ "(a) TSP hits out-of-memory error for 16k."
1077
+ ],
1078
+ "image_footnote": [],
1079
+ "bbox": [
1080
+ 84,
1081
+ 88,
1082
+ 352,
1083
+ 224
1084
+ ],
1085
+ "page_idx": 6
1086
+ },
1087
+ {
1088
+ "type": "image",
1089
+ "img_path": "images/ab70d739615ff66c545f35060cbe27990f2386e4a2977e1d0f1b9d1ded548556.jpg",
1090
+ "image_caption": [
1091
+ "(b) KVR-S is $1.42 \\times$ faster for 12k than TSP.(c) KVR-S is $1.41 \\times$ faster for 16k than TSP."
1092
+ ],
1093
+ "image_footnote": [],
1094
+ "bbox": [
1095
+ 354,
1096
+ 88,
1097
+ 614,
1098
+ 224
1099
+ ],
1100
+ "page_idx": 6
1101
+ },
1102
+ {
1103
+ "type": "image",
1104
+ "img_path": "images/d6772f906ca5e41cc386d2daa03322a98775a2ab4120cc6d7c3ef4ce14bc697e.jpg",
1105
+ "image_caption": [],
1106
+ "image_footnote": [],
1107
+ "bbox": [
1108
+ 619,
1109
+ 88,
1110
+ 885,
1111
+ 224
1112
+ ],
1113
+ "page_idx": 6
1114
+ },
1115
+ {
1116
+ "type": "image",
1117
+ "img_path": "images/76433181f1d66247415ce2e7008f4565182bc440c7288913684f1832379b5066.jpg",
1118
+ "image_caption": [
1119
+ "(d) KVR-S shows the best scalability."
1120
+ ],
1121
+ "image_footnote": [],
1122
+ "bbox": [
1123
+ 84,
1124
+ 257,
1125
+ 352,
1126
+ 393
1127
+ ],
1128
+ "page_idx": 6
1129
+ },
1130
+ {
1131
+ "type": "image",
1132
+ "img_path": "images/fdc231f08c4f6ce0386da6829e51cdce33255fd509c2e6fc779f96c62faa02b5.jpg",
1133
+ "image_caption": [
1134
+ "(e) KVR-S is $1.79 \\times$ faster for 8k than TSP."
1135
+ ],
1136
+ "image_footnote": [],
1137
+ "bbox": [
1138
+ 354,
1139
+ 257,
1140
+ 617,
1141
+ 393
1142
+ ],
1143
+ "page_idx": 6
1144
+ },
1145
+ {
1146
+ "type": "image",
1147
+ "img_path": "images/b0139926865ec99bed687c648b126f71e6227a08587b784184880ae527263436.jpg",
1148
+ "image_caption": [
1149
+ "(f) KVR-S is $1.57 \\times$ faster for 16k than TSP."
1150
+ ],
1151
+ "image_footnote": [],
1152
+ "bbox": [
1153
+ 620,
1154
+ 257,
1155
+ 887,
1156
+ 393
1157
+ ],
1158
+ "page_idx": 6
1159
+ },
1160
+ {
1161
+ "type": "image",
1162
+ "img_path": "images/d7f4d8473f743c715fd648b3f723b4a216d397f3a8cd44453764d3ac39ca84f4.jpg",
1163
+ "image_caption": [
1164
+ "Figure 8. Llama 7B: while KVR-E already outperforms TSP in all the test cases, KVR-S further accelerates by $1.42 \\times$ over TSP as in (a-c) with 300GB/s network. The speedups from KVR-E and KVR-S are even higher with 10GB/s network as in (e, f): $1.55 \\times$ (4 GPUs and 8k) and $1.79 \\times$ (4 GPUs and 12k) over TSP, respectively. KVR-S is the closest to the scalability lower bounds as in (d)."
1165
+ ],
1166
+ "image_footnote": [],
1167
+ "bbox": [
1168
+ 84,
1169
+ 488,
1170
+ 352,
1171
+ 625
1172
+ ],
1173
+ "page_idx": 6
1174
+ },
1175
+ {
1176
+ "type": "image",
1177
+ "img_path": "images/32a0cbccf81cb12234489805c44770c2d53de2554c539ce593f13751a36fe403.jpg",
1178
+ "image_caption": [
1179
+ "(a) KVR-S is $1.26 \\times$ faster for 4k than TSP.",
1180
+ "(b) KVR-S is $1.46 \\times$ faster for 8k than TSP.",
1181
+ "(c) KVR-S is $1.63 \\times$ faster for 8k than TSP.",
1182
+ "Figure 9. Falcon 7B: KVR-S offers up to $1.63 \\times$ speedup over TSP. Since 4k context length is relatively short, the benefit from KVR-E is canceled out by the overhead from KV-cache waiting time and unbalanced attention compute as in (b-c). However, with load-balancing, KVR-S delivers $1.37 \\times$ and $1.47 \\times$ speedup over TSP with 4 and 8 GPUs, respectively, which emphasizes the context-level load-balancing."
1183
+ ],
1184
+ "image_footnote": [],
1185
+ "bbox": [
1186
+ 352,
1187
+ 488,
1188
+ 620,
1189
+ 626
1190
+ ],
1191
+ "page_idx": 6
1192
+ },
1193
+ {
1194
+ "type": "image",
1195
+ "img_path": "images/7ea6c260c79a31180ceb2ed3ae08dd5de0fa8e95c413af060218d979590a5adb.jpg",
1196
+ "image_caption": [],
1197
+ "image_footnote": [],
1198
+ "bbox": [
1199
+ 622,
1200
+ 488,
1201
+ 887,
1202
+ 626
1203
+ ],
1204
+ "page_idx": 6
1205
+ },
1206
+ {
1207
+ "type": "text",
1208
+ "text": "4.3. Implementation",
1209
+ "text_level": 1,
1210
+ "bbox": [
1211
+ 84,
1212
+ 719,
1213
+ 230,
1214
+ 734
1215
+ ],
1216
+ "page_idx": 6
1217
+ },
1218
+ {
1219
+ "type": "text",
1220
+ "text": "Since KV-Runahead dual-purposes the KV-cache interface, which exists in most LLM implementations for faster subsequent token generations during the extension phase in Fig. 1 (a) (HuggingFace-Transformers), KV-Runahead is easy to implement. Fig. 7 shows the pseudocode/computational graph without and with KV-Runahead. Note that KV-cache is already in the input argument to the attention block. The only additions are two parts in the blue boxes: a) overwrite the KV-cache by receiving it from $p_{i - 1}$ before concatenating it with the local $(K,V)$ , and b) forward the",
1221
+ "bbox": [
1222
+ 83,
1223
+ 742,
1224
+ 475,
1225
+ 893
1226
+ ],
1227
+ "page_idx": 6
1228
+ },
1229
+ {
1230
+ "type": "text",
1231
+ "text": "updated KV-cache to $p_{i+1}$ right after concatenation. We can make both recv and send asynchronous calls by overlapping with qkv proj and softmax respectively, thanks to the nature of point-to-point connections. More details on the implementation and examples can be found in Appendix 5.",
1232
+ "bbox": [
1233
+ 495,
1234
+ 719,
1235
+ 885,
1236
+ 796
1237
+ ],
1238
+ "page_idx": 6
1239
+ },
1240
+ {
1241
+ "type": "text",
1242
+ "text": "Both TSP and KV-Runahead require to have tensors in the contiguous memory space for efficient network communication, which is then about KV-cache for KV-Runahead: if KV-cache is physically fragmented, costly extra memory copy will be necessary. Therefore, the KV-cache management such as vLLM (Kwon et al., 2023; vLLM) needs to",
1243
+ "bbox": [
1244
+ 495,
1245
+ 801,
1246
+ 888,
1247
+ 893
1248
+ ],
1249
+ "page_idx": 6
1250
+ },
1251
+ {
1252
+ "type": "header",
1253
+ "text": "KV-Runahead: Scalable Causal LLM Inference by Parallel Key-Value Cache Generation",
1254
+ "bbox": [
1255
+ 205,
1256
+ 56,
1257
+ 767,
1258
+ 70
1259
+ ],
1260
+ "page_idx": 6
1261
+ },
1262
+ {
1263
+ "type": "page_number",
1264
+ "text": "7",
1265
+ "bbox": [
1266
+ 480,
1267
+ 922,
1268
+ 491,
1269
+ 934
1270
+ ],
1271
+ "page_idx": 6
1272
+ },
1273
+ {
1274
+ "type": "image",
1275
+ "img_path": "images/e3e673831299e5ae770cdfe88bec20141eeb18641255606507e85aa8c2c11904.jpg",
1276
+ "image_caption": [
1277
+ "(a) The partitioning breakdowns found by hierarchical grid search for KVR-S in Figs. 8 (a-c)."
1278
+ ],
1279
+ "image_footnote": [],
1280
+ "bbox": [
1281
+ 89,
1282
+ 87,
1283
+ 362,
1284
+ 236
1285
+ ],
1286
+ "page_idx": 7
1287
+ },
1288
+ {
1289
+ "type": "image",
1290
+ "img_path": "images/c04ce678a16b1d56a8d6b9c4d58b3b931cfd9ee009ada2561beabf91e87912bd.jpg",
1291
+ "image_caption": [
1292
+ "(b) KVR-P with predicted partitions is only $1.1\\%$ worse than KVR-S."
1293
+ ],
1294
+ "image_footnote": [],
1295
+ "bbox": [
1296
+ 374,
1297
+ 98,
1298
+ 633,
1299
+ 231
1300
+ ],
1301
+ "page_idx": 7
1302
+ },
1303
+ {
1304
+ "type": "image",
1305
+ "img_path": "images/411919f2bba7836bc003317e1c0dbe5a42d46e339fdc0426f3793683c9f01f81.jpg",
1306
+ "image_caption": [
1307
+ "(c) KVR-P with predicted partitions is only $1.3\\%$ worse than KVR-S.",
1308
+ "Figure 10. KVR-P with predicted partitions for $10\\mathrm{k}$ and $12\\mathrm{k}$ contexts interpolated from the searched breakdowns for Figs. 8 (a-c) has negligible TTFT degradations from KVR-S, supporting the fact that the proposed lookup method for context partitioning is effective."
1309
+ ],
1310
+ "image_footnote": [],
1311
+ "bbox": [
1312
+ 640,
1313
+ 99,
1314
+ 898,
1315
+ 233
1316
+ ],
1317
+ "page_idx": 7
1318
+ },
1319
+ {
1320
+ "type": "text",
1321
+ "text": "support contiguous physical memory allocation during the prompt phase to work seamlessly with KV-Runahead.",
1322
+ "bbox": [
1323
+ 84,
1324
+ 319,
1325
+ 473,
1326
+ 349
1327
+ ],
1328
+ "page_idx": 7
1329
+ },
1330
+ {
1331
+ "type": "text",
1332
+ "text": "5. Experimental Results",
1333
+ "text_level": 1,
1334
+ "bbox": [
1335
+ 84,
1336
+ 369,
1337
+ 290,
1338
+ 386
1339
+ ],
1340
+ "page_idx": 7
1341
+ },
1342
+ {
1343
+ "type": "text",
1344
+ "text": "We used PyTorch 2.0 (Paszke et al., 2019) and NCCL 2.14 to enable KV-Runahead in Huggingface LLaMA 7B and Falcon 7B (Touvron et al., 2023; Almazrouei et al., 2023). All our experiments were done on a single node with $8 \\times$ NVidia A100 GPUs, and under high (300GB/s) and low (10GB/s) bandwidth setups. Note that we turned off the high-speed CUDA-direct link (NVidia-NCCL, 2023) to configure the low bandwidth environments.",
1345
+ "bbox": [
1346
+ 84,
1347
+ 395,
1348
+ 475,
1349
+ 515
1350
+ ],
1351
+ "page_idx": 7
1352
+ },
1353
+ {
1354
+ "type": "text",
1355
+ "text": "We used FP16 for the inference. We compared KV-Runahead with Tensor/Sequence Parallelization (TSP) (Li et al., 2023; Shoeybi et al., 2020; Patel et al., 2023). Note that KV-Runahead is applicable to any LLM with causal attention and does not alter any task accuracy. For ablation, we created a few variants of KVR as below.",
1356
+ "bbox": [
1357
+ 84,
1358
+ 523,
1359
+ 475,
1360
+ 613
1361
+ ],
1362
+ "page_idx": 7
1363
+ },
1364
+ {
1365
+ "type": "text",
1366
+ "text": "KVR-E with even context partitioning \nKVR-S with searched context partitioning \nKVR-P with predicted/interpolated context partitioning",
1367
+ "bbox": [
1368
+ 91,
1369
+ 625,
1370
+ 470,
1371
+ 672
1372
+ ],
1373
+ "page_idx": 7
1374
+ },
1375
+ {
1376
+ "type": "text",
1377
+ "text": "Acceleration: Our results are presented in Figs. 8 and 9 with multiple context lengths and GPU counts. From Figs. 8 (a-c), we can see KVR-S (even KVR-E) consistently outperforms TSP. And, KVR-S can deliver larger speed up (over $40\\%$ ) with longer contexts and more GPUs, and the speedup gain is even higher on low bandwidth (10GB/s) network as in (e, f). Also, note that TSP hit the out-of-memory error for 16k contexts on 2 GPUs, apparently consuming more memory. Fig. 9 shows the similar results with 8k context lengths, but speedups are observed only with KVR-S for 4k context. Fig. 8 (d) compares the scalability of TSP, KVR-E, and KVR-S against two lower bounds: $\\mathrm{TTFT}(p)$ is the same as KVR-S without any communication (so practical lower bound), and $\\mathrm{TTFT}^* (p)$ is from Eq. (3) (so theoretical lower bound), which leads to the following observations:",
1378
+ "bbox": [
1379
+ 84,
1380
+ 679,
1381
+ 477,
1382
+ 905
1383
+ ],
1384
+ "page_idx": 7
1385
+ },
1386
+ {
1387
+ "type": "list",
1388
+ "sub_type": "text",
1389
+ "list_items": [
1390
+ "- $\\mathbf{TTFT}^*(p)$ is very tight to $\\mathbf{TTFT}(p)$ , until the non-parallelizable parts become dominant, like on 8 GPUs.",
1391
+ "- KVR-S gets much closer than TSP to TTF $(p)$ .",
1392
+ "- KVR-S is up to $17\\%$ away from $\\mathbf{T}\\mathbf{T}\\mathbf{F}\\mathbf{T}(p)$ in our tests."
1393
+ ],
1394
+ "bbox": [
1395
+ 514,
1396
+ 319,
1397
+ 887,
1398
+ 406
1399
+ ],
1400
+ "page_idx": 7
1401
+ },
1402
+ {
1403
+ "type": "text",
1404
+ "text": "More results with other smaller/bigger LLMs and shorter/longer contexts are available in Appendix A.",
1405
+ "bbox": [
1406
+ 496,
1407
+ 422,
1408
+ 887,
1409
+ 453
1410
+ ],
1411
+ "page_idx": 7
1412
+ },
1413
+ {
1414
+ "type": "text",
1415
+ "text": "Context-level Partitioning: Fig. 10 (a) discloses the searched context partitioning for the cases in Figs. 8 (a-c). In general, we can see the earlier processes need to consume more contexts, and the later ones consume less, which implies that the wait time for the later processes is less of a concern for the configuration. We can use these breakdowns to build a partitioning lookup table, and linearly interpolate the partitionings for $10\\mathrm{k}$ and $14\\mathrm{k}$ contexts. For example, we can interpolate from the breakdowns of $8\\mathrm{k}$ and $12\\mathrm{k}$ to get the predicted partitioning for $10\\mathrm{k}$ on 4 GPUs, which results in $[0.350, 0.255, 0.210, 0.185]$ in terms of ratio. And, it can be done similarly for $12\\mathrm{k}$ user contexts as well on 4 and 8 GPUs. According to our results in Figs. 10 (b, c), even with $4\\mathrm{k}$ intervals, KVR-P with predicted partitioning from interpolation is within $1.3\\%$ of the KVR-S cases with the searched partition configurations and still outperforms TSP.",
1416
+ "bbox": [
1417
+ 495,
1418
+ 460,
1419
+ 888,
1420
+ 702
1421
+ ],
1422
+ "page_idx": 7
1423
+ },
1424
+ {
1425
+ "type": "text",
1426
+ "text": "Point-to-point communication: To understand the benefit of point-to-point asynchronous communication of KVR over the all-gather operation in TSP, we added a noisy sidecar to generate the bidirectional network traffic between a random pair of adjacent GPUs (i.e., simulating dynamically changing non-uniform network bandwidth), averaged out multiple TTFTs for the 8k, 12k, and 16k context lengths, and then reported the results in Fig 11. We found that KVR is much more robust against non-uniform bandwidth among processes: while TSP degraded the TTFTs over $10\\%$ on average due to non-uniform effective bandwidth, KVR has up to $3.7\\%$ impact on TTFT, clearly demonstrating the benefits of the communication mechanism in KV-Runahead. Also,",
1427
+ "bbox": [
1428
+ 495,
1429
+ 709,
1430
+ 888,
1431
+ 904
1432
+ ],
1433
+ "page_idx": 7
1434
+ },
1435
+ {
1436
+ "type": "header",
1437
+ "text": "KV-Runahead: Scalable Causal LLM Inference by Parallel Key-Value Cache Generation",
1438
+ "bbox": [
1439
+ 205,
1440
+ 56,
1441
+ 767,
1442
+ 70
1443
+ ],
1444
+ "page_idx": 7
1445
+ },
1446
+ {
1447
+ "type": "page_number",
1448
+ "text": "8",
1449
+ "bbox": [
1450
+ 480,
1451
+ 922,
1452
+ 491,
1453
+ 934
1454
+ ],
1455
+ "page_idx": 7
1456
+ },
1457
+ {
1458
+ "type": "image",
1459
+ "img_path": "images/a655b0454f5687fea96986e87718bc026c6958de49facadb39e48215ad14f9d8.jpg",
1460
+ "image_caption": [
1461
+ "(a) On a noisy network, KVR-S outperforms TSP even more $(42.2\\%$ vs. $43.4\\%)$ than the quiet case in Fig. 8 (b)."
1462
+ ],
1463
+ "image_footnote": [],
1464
+ "bbox": [
1465
+ 91,
1466
+ 88,
1467
+ 354,
1468
+ 223
1469
+ ],
1470
+ "page_idx": 8
1471
+ },
1472
+ {
1473
+ "type": "image",
1474
+ "img_path": "images/cc52b591cd386a22439a119a93437f8a89f584c5ebbaef3fed9d93d7dd7f04a4.jpg",
1475
+ "image_caption": [
1476
+ "Figure 11. On a noisy high bandwidth network, KVR-S still outperforms TSP by even wider margin than the case in Figs. 8 (b, c), and shows high tolerance against the other noisy traffics. Yet, in terms of absolute tolerance, KVR-E appears to be the best."
1477
+ ],
1478
+ "image_footnote": [],
1479
+ "bbox": [
1480
+ 366,
1481
+ 88,
1482
+ 625,
1483
+ 220
1484
+ ],
1485
+ "page_idx": 8
1486
+ },
1487
+ {
1488
+ "type": "image",
1489
+ "img_path": "images/aa37e7fa8f3d3dc157ea85989bdbce856cb5cb0ff00fea645665514cf2af5ed8.jpg",
1490
+ "image_caption": [
1491
+ "(b) On a noisy network, KVR-S outperforms TSP even more (41.1% vs. 45.8%) than the quiet case in Fig. 8 (c).",
1492
+ "(c) In terms of the TTFT overhead, TSP is most affected (up to $11.8\\%$ ), and KVR-E is least influenced (up to $2.7\\%$ )."
1493
+ ],
1494
+ "image_footnote": [],
1495
+ "bbox": [
1496
+ 640,
1497
+ 88,
1498
+ 897,
1499
+ 220
1500
+ ],
1501
+ "page_idx": 8
1502
+ },
1503
+ {
1504
+ "type": "text",
1505
+ "text": "KVR-S is tuned to the quiet environment, but still outperforms TSP thanks to the point-to-point communication.",
1506
+ "bbox": [
1507
+ 84,
1508
+ 318,
1509
+ 478,
1510
+ 349
1511
+ ],
1512
+ "page_idx": 8
1513
+ },
1514
+ {
1515
+ "type": "text",
1516
+ "text": "6. Conclusion",
1517
+ "text_level": 1,
1518
+ "bbox": [
1519
+ 84,
1520
+ 369,
1521
+ 205,
1522
+ 383
1523
+ ],
1524
+ "page_idx": 8
1525
+ },
1526
+ {
1527
+ "type": "text",
1528
+ "text": "In this work, we propose an efficient parallel LLM inference technique, KV-Runahead, to minimize the time-to-first-token. With the proposed techniques, we observed over $60\\%$ speedup in the first token generation over the existing parallelization schemes and higher robustness against a non-uniform bandwidth environment.",
1529
+ "bbox": [
1530
+ 84,
1531
+ 393,
1532
+ 475,
1533
+ 484
1534
+ ],
1535
+ "page_idx": 8
1536
+ },
1537
+ {
1538
+ "type": "text",
1539
+ "text": "Impact Statement",
1540
+ "text_level": 1,
1541
+ "bbox": [
1542
+ 86,
1543
+ 505,
1544
+ 240,
1545
+ 522
1546
+ ],
1547
+ "page_idx": 8
1548
+ },
1549
+ {
1550
+ "type": "text",
1551
+ "text": "This paper presents work whose goal is to advance the field of Machine Learning. There are many potential societal consequences of our work, none which we feel must be specifically highlighted here.",
1552
+ "bbox": [
1553
+ 84,
1554
+ 530,
1555
+ 475,
1556
+ 590
1557
+ ],
1558
+ "page_idx": 8
1559
+ },
1560
+ {
1561
+ "type": "text",
1562
+ "text": "References",
1563
+ "text_level": 1,
1564
+ "bbox": [
1565
+ 86,
1566
+ 609,
1567
+ 183,
1568
+ 626
1569
+ ],
1570
+ "page_idx": 8
1571
+ },
1572
+ {
1573
+ "type": "list",
1574
+ "sub_type": "ref_text",
1575
+ "list_items": [
1576
+ "Agrawal, A., Panwar, A., Mohan, J., Kwatra, N., Gulavani, B. S., and Ramjee, R. Sarathi: Efficient llm inference by piggybacking decodes with chunked prefixes, 2023.",
1577
+ "Ainslie, J., Lee-Thorp, J., de Jong, M., Zemlyanskiy, Y., Lebrón, F., and Sanghai, S. Gqa: Training generalized multi-query transformer models from multi-head checkpoints, 2023.",
1578
+ "Almazrouei, E., Alobeidli, H., Alshamsi, A., Cappelli, A., Cojocaru, R., Debbah, M., Goffinet, E., Heslow, D., Lau-nay, J., Malartic, Q., Noune, B., Pannier, B., and Penedo, G. Falcon-40B: an open large language model with state-of-the-art performance. 2023.",
1579
+ "Chen, C., Borgeaud, S., Irving, G., Lespiau, J.-B., Sifre, L., and Jumper, J. Accelerating large language model decoding with speculative sampling, 2023."
1580
+ ],
1581
+ "bbox": [
1582
+ 86,
1583
+ 633,
1584
+ 475,
1585
+ 905
1586
+ ],
1587
+ "page_idx": 8
1588
+ },
1589
+ {
1590
+ "type": "list",
1591
+ "sub_type": "ref_text",
1592
+ "list_items": [
1593
+ "Cho, M., Vahid, K. A., Fu, Q., Adya, S., Mundo, C. C. D., Rastegari, M., Naik, D., and Zatloukal, P. edkm: An efficient and accurate train-time weight clustering for large language models. 2023.",
1594
+ "Dao, T., Fu, D. Y., Ermon, S., Rudra, A., and Ré, C. Flashattention: Fast and memory-efficient exact attention with io-awareness. Advances in Neural Information Processing Systems, 2022.",
1595
+ "Dong, Q., Li, L., Dai, D., Zheng, C., Wu, Z., Chang, B., Sun, X., Xu, J., Li, L., and Sui, Z. A survey on in-context learning, 2023.",
1596
+ "Frantar, E., Ashkboos, S., Hoefler, T., and Alistarh, D. GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformers. In arXiv, 2023.",
1597
+ "Huang, Y., Cheng, Y., Bapna, A., First, O., Chen, M. X., Chen, D., Lee, H., Ngiam, J., Le, Q. V., Wu, Y., and Chen, Z. Gpipe: Efficient training of giant neural networks using pipeline parallelism. In Advances in Neural Information Processing Systems, 2019.",
1598
+ "HuggingFace-TensorParallelism. https://huggingface.co/docs/transformers/v4.15.0/parallelism#tensor-parallelism.",
1599
+ "HuggingFace-Transformers. https://huggingface.co/docs/transformers/main_classess/output.",
1600
+ "Korthikanti, V., Casper, J., Lym, S., McAfee, L., Andersch, M., Shoeybi, M., and Catanzaro, B. Reducing activation recomputation in large transformer models, 2022.",
1601
+ "Kwon, W., Li, Z., Zhuang, S., Sheng, Y., Zheng, L., Yu, C. H., Gonzalez, J. E., Zhang, H., and Stoica, I. Efficient memory management for large language model serving with pagedattention, 2023."
1602
+ ],
1603
+ "bbox": [
1604
+ 498,
1605
+ 318,
1606
+ 888,
1607
+ 905
1608
+ ],
1609
+ "page_idx": 8
1610
+ },
1611
+ {
1612
+ "type": "header",
1613
+ "text": "KV-Runahead: Scalable Causal LLM Inference by Parallel Key-Value Cache Generation",
1614
+ "bbox": [
1615
+ 205,
1616
+ 56,
1617
+ 767,
1618
+ 70
1619
+ ],
1620
+ "page_idx": 8
1621
+ },
1622
+ {
1623
+ "type": "page_number",
1624
+ "text": "9",
1625
+ "bbox": [
1626
+ 480,
1627
+ 922,
1628
+ 491,
1629
+ 934
1630
+ ],
1631
+ "page_idx": 8
1632
+ },
1633
+ {
1634
+ "type": "list",
1635
+ "sub_type": "ref_text",
1636
+ "list_items": [
1637
+ "Leviathan, Y., Kalman, M., and Matias, Y. Fast inference from transformers via speculative decoding. In International Conference on Machine Learning, 2023.",
1638
+ "Li, S., Xue, F., Baranwal, C., Li, Y., and You, Y. Sequence parallelism: Long sequence training from system perspective. In Association for Computational Linguistics (ACL), 2023.",
1639
+ "Lin, B., Peng, T., Zhang, C., Sun, M., Li, L., Zhao, H., Xiao, W., Xu, Q., Qiu, X., Li, S., Ji, Z., Li, Y., and Lin, W. Infinite-llm: Efficient llm service for long context with distattention and distributed kvcache, 2024.",
1640
+ "Lin, J., Tang, J., Tang, H., Yang, S., Dang, X., and Han, S. AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration. arXiv, 2023.",
1641
+ "Liu, Y., Li, H., Du, K., Yao, J., Cheng, Y., Huang, Y., Lu, S., Maire, M., Hoffmann, H., Holtzman, A., Ananthanarayanan, G., and Jiang, J. Cachegen: Fast context loading for language model applications, 2023a.",
1642
+ "Liu, Z., Oguz, B., Zhao, C., Chang, E., Stock, P., Mehdad, Y., Shi, Y., Krishnamoorthi, R., and Chandra, V. LLM-QAT: Data-Free Quantization Aware Training for Large Language Models. arXiv, 2023b.",
1643
+ "Narayanan, D., Phanishayee, A., Shi, K., Chen, X., and Zaharia, M. Memory-efficient pipeline-parallel dnn training. In International Conference on Machine Learning, 2021a.",
1644
+ "Narayanan, D., Shoeybi, M., Casper, J., LeGresley, P., Patwary, M., Korthikanti, V. A., Vainbrand, D., Kashinkunti, P., Bernauer, J., Catanzaro, B., Phanishayee, A., and Zaharia, M. Efficient large-scale language model training ongpu clusters using megatron-lm, 2021b.",
1645
+ "NVidia-cuBLAS. https://docs.nvidia.com/cuda/cublas/.",
1646
+ "NVidia-LLM. https:// developer.nvidia.com/blog/ mastering-llm-techniques-inference_ optimization, 2023.",
1647
+ "NVidia-NCCL. https://docs.nvidia.com/deeplearning/nccl/user-guide/docs/environment, 2023.",
1648
+ "Ouyang, L., Wu, J., Jiang, X., Almeida, D., Wainwright, C. L., Mishkin, P., Zhang, C., Agarwal, S., Slama, K., Ray, A., Schulman, J., Hilton, J., Kelton, F., Miller, L., Simens, M., Askell, A., Welinder, P., Christiano, P., Leike, J., and Lowe, R. Training language models to follow instructions with human feedback. In Advances in Neural Information Processing Systems, 2022."
1649
+ ],
1650
+ "bbox": [
1651
+ 86,
1652
+ 84,
1653
+ 475,
1654
+ 905
1655
+ ],
1656
+ "page_idx": 9
1657
+ },
1658
+ {
1659
+ "type": "list",
1660
+ "sub_type": "ref_text",
1661
+ "list_items": [
1662
+ "Park, J., Yoon, H., Ahn, D., Choi, J., and Kim, J. OPTIMUS: optimized matrix multiplication structure for transformer neural network accelerator. In Dhillon, I. S., Papailiopoulos, D. S., and Sze, V. (eds.), Proceedings of Machine Learning and Systems (MLSys), 2020.",
1663
+ "Paszke, A., Gross, S., Massa, F., Lerer, A., Bradbury, J., Chanan, G., Killeen, T., Lin, Z., Gimelshein, N., Antiga, L., Desmaison, A., Kopf, A., Yang, E., DeVito, Z., Raison, M., Tejani, A., Chilamkurthy, S., Steiner, B., Fang, L., Bai, J., and Chintala, S. Pytorch: An imperative style, high-performance deep learning library. Advances in Neural Information Processing Systems, 2019.",
1664
+ "Patel, P., Choukse, E., Zhang, C., Iñigo Goiri, Shah, A., Maleki, S., and Bianchini, R. Splitwise: Efficient generative llm inference using phase splitting, 2023.",
1665
+ "Pope, R., Douglas, S., Chowdhery, A., Devlin, J., Bradbury, J., Levskaya, A., Heek, J., Xiao, K., Agrawal, S., and Dean, J. Efficiently scaling transformer inference, 2022.",
1666
+ "Ram, O., Levine, Y., Dalmedigos, I., Muhlgay, D., Shashua, A., Leyton-Brown, K., and Shoham, Y. In-context retrieval-augmented language models, 2023.",
1667
+ "Shoeybi, M., Patwary, M., Puri, R., LeGresley, P., Casper, J., and Catanzaro, B. Megatron-lm: Training multi-billion parameter language models using model parallelism, 2020.",
1668
+ "Thakur, R., Rabenseifner, R., and Gropp, W. Optimization of collective communication operations in MPICH. The International Journal of High Performance Computing Applications, 19(1):49-66, 2005.",
1669
+ "Touvron, H., Lavril, T., Izacard, G., Martinet, X., Lachaux, M.-A., Lacroix, T., Roziere, B., Goyal, N., Hambro, E., Azhar, F., Rodriguez, A., Joulin, A., Grave, E., and Lample, G. Llama: Open and efficient foundation language models. In arXiv, 2023.",
1670
+ "Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, L. u., and Polosukhin, I. Attention is all you need. In Advances in Neural Information Processing Systems, 2017.",
1671
+ "vLLM. https://docs.vllm.ai/en/latest/.",
1672
+ "Zhang, H., Song, H., Li, S., Zhou, M., and Song, D. A survey of controllable text generation using transformer-based pre-trained language models, 2023a.",
1673
+ "Zhang, S., Roller, S., Goyal, N., Artetxe, M., Chen, M., Chen, S., Dewan, C., Diab, M., Li, X., Lin, X. V., Mihaylov, T., Ott, M., Shleifer, S., Shuster, K., Simig, D., Koura, P. S., Sridhar, A., Wang, T., and Zettlemoyer, L. Opt: Open pre-trained transformer language models. In arXiv, 2022a."
1674
+ ],
1675
+ "bbox": [
1676
+ 500,
1677
+ 84,
1678
+ 885,
1679
+ 904
1680
+ ],
1681
+ "page_idx": 9
1682
+ },
1683
+ {
1684
+ "type": "header",
1685
+ "text": "KV-Runahead: Scalable Causal LLM Inference by Parallel Key-Value Cache Generation",
1686
+ "bbox": [
1687
+ 205,
1688
+ 56,
1689
+ 767,
1690
+ 70
1691
+ ],
1692
+ "page_idx": 9
1693
+ },
1694
+ {
1695
+ "type": "page_number",
1696
+ "text": "10",
1697
+ "bbox": [
1698
+ 477,
1699
+ 922,
1700
+ 495,
1701
+ 934
1702
+ ],
1703
+ "page_idx": 9
1704
+ },
1705
+ {
1706
+ "type": "list",
1707
+ "sub_type": "ref_text",
1708
+ "list_items": [
1709
+ "Zhang, T., Ladhak, F., Durmus, E., Liang, P., McKeown, K., and Hashimoto, T. B. Benchmarking large language models for news summarization, 2023b.",
1710
+ "Zhang, Y., Liu, W., Wang, X., and Shaheer, M. A. A novel hierarchical hyper-parameter search algorithm based on greedy strategy for wind turbine fault diagnosis. Expert Systems with Applications, 202:117473, 2022b."
1711
+ ],
1712
+ "bbox": [
1713
+ 86,
1714
+ 84,
1715
+ 475,
1716
+ 200
1717
+ ],
1718
+ "page_idx": 10
1719
+ },
1720
+ {
1721
+ "type": "header",
1722
+ "text": "KV-Runahead: Scalable Causal LLM Inference by Parallel Key-Value Cache Generation",
1723
+ "bbox": [
1724
+ 205,
1725
+ 56,
1726
+ 767,
1727
+ 70
1728
+ ],
1729
+ "page_idx": 10
1730
+ },
1731
+ {
1732
+ "type": "page_number",
1733
+ "text": "11",
1734
+ "bbox": [
1735
+ 477,
1736
+ 922,
1737
+ 493,
1738
+ 934
1739
+ ],
1740
+ "page_idx": 10
1741
+ },
1742
+ {
1743
+ "type": "table",
1744
+ "img_path": "images/1f32f3261d0a4c2aa331dd1c22edaab4b9c75ae0c39ffdb1ae93ae73318c0266.jpg",
1745
+ "table_caption": [],
1746
+ "table_footnote": [],
1747
+ "table_body": "<table><tr><td rowspan=\"3\">Network</td><td rowspan=\"3\">Context Length</td><td colspan=\"3\">4 GPUs</td><td colspan=\"3\">8 GPUs</td></tr><tr><td colspan=\"3\">Method</td><td colspan=\"3\">Method</td></tr><tr><td>TSP</td><td>KVR-S</td><td>SpeedUp×</td><td>TSP</td><td>KVR-S</td><td>SpeedUp×</td></tr><tr><td rowspan=\"6\">Llama 7B</td><td>1k</td><td>0.107</td><td>0.097</td><td>1.11</td><td>0.117</td><td>0.098</td><td>1.19</td></tr><tr><td>2k</td><td>0.111</td><td>0.100</td><td>1.11</td><td>0.117</td><td>0.103</td><td>1.14</td></tr><tr><td>4k</td><td>0.20</td><td>0.17</td><td>1.17</td><td>0.12</td><td>0.11</td><td>1.14</td></tr><tr><td>8k</td><td>0.54</td><td>0.41</td><td>1.30</td><td>0.30</td><td>0.22</td><td>1.36</td></tr><tr><td>12k</td><td>1.06</td><td>0.76</td><td>1.39</td><td>0.57</td><td>0.41</td><td>1.37</td></tr><tr><td>16k</td><td>1.76</td><td>1.24</td><td>1.42</td><td>0.92</td><td>0.65</td><td>1.41</td></tr><tr><td rowspan=\"6\">Llama 13B</td><td>1k</td><td>0.140</td><td>0.126</td><td>1.12</td><td>0.150</td><td>0.129</td><td>1.16</td></tr><tr><td>2k</td><td>0.143</td><td>0.131</td><td>1.09</td><td>0.153</td><td>0.131</td><td>1.17</td></tr><tr><td>4k</td><td>0.32</td><td>0.29</td><td>1.12</td><td>0.19</td><td>0.16</td><td>1.17</td></tr><tr><td>8k</td><td>0.87</td><td>0.68</td><td>1.27</td><td>0.49</td><td>0.36</td><td>1.35</td></tr><tr><td>12k</td><td>1.71</td><td>1.25</td><td>1.36</td><td>0.91</td><td>0.66</td><td>1.37</td></tr><tr><td>16k</td><td>2.89</td><td>2.05</td><td>1.41</td><td>1.46</td><td>1.05</td><td>1.39</td></tr><tr><td rowspan=\"2\">Llama 30B</td><td>1k</td><td>0.21</td><td>0.20</td><td>1.08</td><td>0.23</td><td>0.19</td><td>1.19</td></tr><tr><td>2k</td><td>0.28</td><td>0.26</td><td>1.06</td><td>0.24</td><td>0.20</td><td>1.19</td></tr><tr><td rowspan=\"4\">Falcon 1B</td><td>1k</td><td>0.073</td><td>0.061</td><td>1.18</td><td>0.081</td><td>0.066</td><td>1.23</td></tr><tr><td>2k</td><td>0.067</td><td>0.060</td><td>1.12</td><td>0.079</td><td>0.065</td><td>1.23</td></tr><tr><td>4k</td><td>0.09</td><td>0.07</td><td>1.26</td><td>0.08</td><td>0.06</td><td>1.21</td></tr><tr><td>8k</td><td>0.25</td><td>0.19</td><td>1.28</td><td>0.15</td><td>0.10</td><td>1.58</td></tr><tr><td rowspan=\"4\">Falcon 7B</td><td>1k</td><td>0.107</td><td>0.095</td><td>1.12</td><td>0.119</td><td>0.096</td><td>1.24</td></tr><tr><td>2k</td><td>0.117</td><td>0.103</td><td>1.13</td><td>0.118</td><td>0.099</td><td>1.20</td></tr><tr><td>4k</td><td>0.28</td><td>0.21</td><td>1.30</td><td>0.18</td><td>0.12</td><td>1.47</td></tr><tr><td>8k</td><td>0.78</td><td>0.54</td><td>1.46</td><td>0.47</td><td>0.29</td><td>1.63</td></tr></table>",
1748
+ "bbox": [
1749
+ 184,
1750
+ 80,
1751
+ 787,
1752
+ 465
1753
+ ],
1754
+ "page_idx": 11
1755
+ },
1756
+ {
1757
+ "type": "text",
1758
+ "text": "Table 1. Top-1 accuracy with ImageNet1k: KV-Runahead outperforms other schemes with various pruning rates.",
1759
+ "bbox": [
1760
+ 148,
1761
+ 481,
1762
+ 823,
1763
+ 494
1764
+ ],
1765
+ "page_idx": 11
1766
+ },
1767
+ {
1768
+ "type": "text",
1769
+ "text": "A. Additional Experiments",
1770
+ "text_level": 1,
1771
+ "bbox": [
1772
+ 84,
1773
+ 518,
1774
+ 316,
1775
+ 535
1776
+ ],
1777
+ "page_idx": 11
1778
+ },
1779
+ {
1780
+ "type": "text",
1781
+ "text": "In this section, we present additional results with a wider range of LLMs using both long and short contexts to confirm that KV-Runahead will generalize well across a broader spectrum of LLMs. We experimented with Falcon 1B, Llama 13B, and Llama 30B, (in addition to Llama 7B and Falcon-7B from Section 5) and summarize the results in Table 1 where we can observe the followings:",
1782
+ "bbox": [
1783
+ 84,
1784
+ 544,
1785
+ 887,
1786
+ 604
1787
+ ],
1788
+ "page_idx": 11
1789
+ },
1790
+ {
1791
+ "type": "list",
1792
+ "sub_type": "text",
1793
+ "list_items": [
1794
+ "- KVR-S consistently outperforms TSP for all cases across 4 and 8 GPUs over high bandwidth network.",
1795
+ "- The speedup from KVR-S is less with shorter inputs (as attention is less bottlenecked)."
1796
+ ],
1797
+ "bbox": [
1798
+ 102,
1799
+ 613,
1800
+ 795,
1801
+ 652
1802
+ ],
1803
+ "page_idx": 11
1804
+ },
1805
+ {
1806
+ "type": "text",
1807
+ "text": "Also, we tested Llama 7B with Multi-Query-Attention (MQA) and Group-Query-Attention (GQA) (Ainslie et al., 2023) over high bandwidth network and report the results in Table 2. MQA and GQA (Ainslie et al., 2023) are techniques to share keys and values among queries so that the attention part can be computationally more efficient. Accordingly, $(K,V)$ projection computation costs will be reduced for TSP and KVR, benefiting both. In detail, TSP has lower communication costs as it has a fewer K and V matrices to all_gather, and KVR will have lower communication costs with MQA or GQA, as it leads a smaller $(K,V)$ cache.",
1808
+ "bbox": [
1809
+ 84,
1810
+ 671,
1811
+ 887,
1812
+ 762
1813
+ ],
1814
+ "page_idx": 11
1815
+ },
1816
+ {
1817
+ "type": "text",
1818
+ "text": "Compared with Multi-Head-Attention cases from Fig. 8 (b-c), overall GQA8 and MQA reduce the TTFT universally. For example, the speedup is as large as $1.22\\mathrm{x}$ with MQA. KVR demonstrates marginally better speedup gains over TSP with GQA8 and MQA than with MHA. For the example of 8GPU and 16k context, the speedup over TSP was $1.41\\mathrm{x}$ with MHA (see Fig. 8 (c)), but it becomes $1.48\\mathrm{x}$ with MQA and $1.46\\mathrm{x}$ with GQA.",
1819
+ "bbox": [
1820
+ 84,
1821
+ 768,
1822
+ 887,
1823
+ 830
1824
+ ],
1825
+ "page_idx": 11
1826
+ },
1827
+ {
1828
+ "type": "text",
1829
+ "text": "B. Parallel Inference Benefits",
1830
+ "text_level": 1,
1831
+ "bbox": [
1832
+ 84,
1833
+ 849,
1834
+ 334,
1835
+ 864
1836
+ ],
1837
+ "page_idx": 11
1838
+ },
1839
+ {
1840
+ "type": "text",
1841
+ "text": "The benefit of parallel LLM inference depends on the input context size (which determines the parallelization gain) and the network bandwidth (which determines the parallelization cost). To understand when KVR (i.e., parallel LLM inference in",
1842
+ "bbox": [
1843
+ 84,
1844
+ 875,
1845
+ 885,
1846
+ 906
1847
+ ],
1848
+ "page_idx": 11
1849
+ },
1850
+ {
1851
+ "type": "header",
1852
+ "text": "KV-Runahead: Scalable Causal LLM Inference by Parallel Key-Value Cache Generation",
1853
+ "bbox": [
1854
+ 205,
1855
+ 56,
1856
+ 767,
1857
+ 70
1858
+ ],
1859
+ "page_idx": 11
1860
+ },
1861
+ {
1862
+ "type": "page_number",
1863
+ "text": "12",
1864
+ "bbox": [
1865
+ 477,
1866
+ 922,
1867
+ 495,
1868
+ 934
1869
+ ],
1870
+ "page_idx": 11
1871
+ },
1872
+ {
1873
+ "type": "table",
1874
+ "img_path": "images/6d4106867e50fc98179ff93838029bbd606daf346dce872ac0f8acadaa455ca5.jpg",
1875
+ "table_caption": [],
1876
+ "table_footnote": [],
1877
+ "table_body": "<table><tr><td rowspan=\"3\">Network</td><td rowspan=\"3\">Context Length</td><td colspan=\"3\">4 GPUs</td><td colspan=\"3\">8 GPUs</td></tr><tr><td colspan=\"3\">Method</td><td colspan=\"3\">Method</td></tr><tr><td>TSP</td><td>KVR-S</td><td>SpeedUp×</td><td>TSP</td><td>KVR-S</td><td>SpeedUp×</td></tr><tr><td rowspan=\"6\">Llama 7BMQA</td><td>1k</td><td>0.109</td><td>0.102</td><td>1.07</td><td>0.117</td><td>0.101</td><td>1.17</td></tr><tr><td>2k</td><td>0.107</td><td>0.102</td><td>1.05</td><td>0.120</td><td>0.101</td><td>1.18</td></tr><tr><td>4k</td><td>0.18</td><td>0.14</td><td>1.23</td><td>0.12</td><td>0.10</td><td>1.18</td></tr><tr><td>8k</td><td>0.49</td><td>0.37</td><td>1.33</td><td>0.26</td><td>0.18</td><td>1.44</td></tr><tr><td>12k</td><td>0.98</td><td>0.70</td><td>1.41</td><td>0.51</td><td>0.35</td><td>1.45</td></tr><tr><td>16k</td><td>1.65</td><td>1.16</td><td>1.43</td><td>0.84</td><td>0.57</td><td>1.48</td></tr><tr><td rowspan=\"6\">Llama 7BGQA8</td><td>1k</td><td>0.112</td><td>0.102</td><td>1.10</td><td>0.119</td><td>0.101</td><td>1.18</td></tr><tr><td>2k</td><td>0.113</td><td>0.102</td><td>1.12</td><td>0.118</td><td>0.103</td><td>1.15</td></tr><tr><td>4k</td><td>0.18</td><td>0.15</td><td>1.20</td><td>0.12</td><td>0.11</td><td>1.15</td></tr><tr><td>8k</td><td>0.50</td><td>0.38</td><td>1.32</td><td>0.27</td><td>0.19</td><td>1.42</td></tr><tr><td>12k</td><td>1.00</td><td>0.72</td><td>1.39</td><td>0.52</td><td>0.36</td><td>1.42</td></tr><tr><td>16k</td><td>1.67</td><td>1.16</td><td>1.44</td><td>0.86</td><td>0.59</td><td>1.46</td></tr></table>",
1878
+ "bbox": [
1879
+ 189,
1880
+ 80,
1881
+ 782,
1882
+ 313
1883
+ ],
1884
+ "page_idx": 12
1885
+ },
1886
+ {
1887
+ "type": "table",
1888
+ "img_path": "images/f60502dddbaca9384813f6b0e3be39f87590fd4cd8b5d73fd53049a99f2ce798.jpg",
1889
+ "table_caption": [
1890
+ "Table 2. Top-1 accuracy with ImageNet1k: KV-Runahead outperforms other schemes with various pruning rates."
1891
+ ],
1892
+ "table_footnote": [],
1893
+ "table_body": "<table><tr><td>Context</td><td>base</td><td colspan=\"2\">10GB/s</td><td colspan=\"2\">1GB/s</td></tr><tr><td>Length</td><td>1 GPU</td><td>2 GPU</td><td>4 GPU</td><td>2 GPU</td><td>4 GPU</td></tr><tr><td>1k</td><td>0.10</td><td>0.10</td><td>0.10</td><td>0.11</td><td>0.19</td></tr><tr><td>2k</td><td>0.24</td><td>0.16</td><td>0.19</td><td>0.21</td><td>0.35</td></tr><tr><td>4k</td><td>0.65</td><td>0.38</td><td>0.36</td><td>0.84</td><td>0.93</td></tr><tr><td>8k</td><td>1.95</td><td>0.99</td><td>0.72</td><td>1.31</td><td>2.06</td></tr><tr><td>12k</td><td>3.95</td><td>1.82</td><td>1.15</td><td>2.28</td><td>2.30</td></tr></table>",
1894
+ "bbox": [
1895
+ 287,
1896
+ 354,
1897
+ 683,
1898
+ 465
1899
+ ],
1900
+ "page_idx": 12
1901
+ },
1902
+ {
1903
+ "type": "table",
1904
+ "img_path": "images/fdaf967d81c097b708b7a4e2c5de5138638711180f2fa4c45e33242e225adbfc.jpg",
1905
+ "table_caption": [
1906
+ "Table 3. Top-1 accuracy with ImageNet1k: KV-Runahead outperforms other schemes with various pruning rates."
1907
+ ],
1908
+ "table_footnote": [],
1909
+ "table_body": "<table><tr><td>method</td><td>rank/gpu</td><td>partition</td><td>size</td></tr><tr><td rowspan=\"4\">TSP</td><td>0</td><td rowspan=\"4\">Antibiotics are a type of medication used to treat bacterial infections</td><td>3</td></tr><tr><td>1</td><td>3</td></tr><tr><td>2</td><td>3</td></tr><tr><td>3</td><td>2</td></tr><tr><td rowspan=\"4\">KVR</td><td>0</td><td rowspan=\"4\">Antibiotics are a type of medication used to treat bacterial infections</td><td>5</td></tr><tr><td>1</td><td>3</td></tr><tr><td>2</td><td>2</td></tr><tr><td>3</td><td>1</td></tr></table>",
1910
+ "bbox": [
1911
+ 300,
1912
+ 507,
1913
+ 671,
1914
+ 648
1915
+ ],
1916
+ "page_idx": 12
1917
+ },
1918
+ {
1919
+ "type": "text",
1920
+ "text": "Table 4. Partitioning examples for Table 5.",
1921
+ "bbox": [
1922
+ 359,
1923
+ 664,
1924
+ 612,
1925
+ 678
1926
+ ],
1927
+ "page_idx": 12
1928
+ },
1929
+ {
1930
+ "type": "text",
1931
+ "text": "general) does help or does not, we experimented with Llama 7B on a low-bandwidth setup (10GB/s) and a poor-bandwidth setup (1GB/s) and report the TTFT for each case in Table 3. The bold numbers are when it is beneficial to have multi-GPU inference over single-GPU inference in terms of TTFT. One can observe the followings:",
1932
+ "bbox": [
1933
+ 84,
1934
+ 703,
1935
+ 885,
1936
+ 750
1937
+ ],
1938
+ "page_idx": 12
1939
+ },
1940
+ {
1941
+ "type": "list",
1942
+ "sub_type": "text",
1943
+ "list_items": [
1944
+ "- Parallel inference is helpful only when the bandwidth is good enough OR the input context is long enough. For example, the bold numbers which indicate when it is beneficial to have multi-GPU inference over single-GPU inference in terms of TTFT form a lower triangle in the table.",
1945
+ "- Even for parallel inference, when the bandwidth is not high enough, using more GPUs is not always helping. For the example of 2K input and 10GB/s, TTFT is 0.16sec with 2GPUs, but it gets worse into 0.19sec with 4GPUs. Such a degradation is more pronounced with 1GB/s network."
1946
+ ],
1947
+ "bbox": [
1948
+ 102,
1949
+ 757,
1950
+ 887,
1951
+ 858
1952
+ ],
1953
+ "page_idx": 12
1954
+ },
1955
+ {
1956
+ "type": "text",
1957
+ "text": "All above imply that for a given the infrastructure bandwidth, the optimal system for LLM inference can be determined based on the input size distribution of the target application. A user request needs to dynamically be assigned to a system",
1958
+ "bbox": [
1959
+ 84,
1960
+ 875,
1961
+ 887,
1962
+ 906
1963
+ ],
1964
+ "page_idx": 12
1965
+ },
1966
+ {
1967
+ "type": "header",
1968
+ "text": "KV-Runahead: Scalable Causal LLM Inference by Parallel Key-Value Cache Generation",
1969
+ "bbox": [
1970
+ 205,
1971
+ 56,
1972
+ 767,
1973
+ 70
1974
+ ],
1975
+ "page_idx": 12
1976
+ },
1977
+ {
1978
+ "type": "page_number",
1979
+ "text": "13",
1980
+ "bbox": [
1981
+ 477,
1982
+ 922,
1983
+ 495,
1984
+ 934
1985
+ ],
1986
+ "page_idx": 12
1987
+ },
1988
+ {
1989
+ "type": "text",
1990
+ "text": "input = ‘Antibiotics are a type of medication used to treat bacterial infections’",
1991
+ "bbox": [
1992
+ 84,
1993
+ 88,
1994
+ 883,
1995
+ 107
1996
+ ],
1997
+ "page_idx": 13
1998
+ },
1999
+ {
2000
+ "type": "code",
2001
+ "sub_type": "code",
2002
+ "code_caption": [],
2003
+ "code_body": "if method $= =$ 'tsp': context $=$ even_context_partitioning(input,rank,world_size) elif method $= =$ 'kvr': context $=$ kva_context_partitioning(input,rank,world_size) else: context $=$ input",
2004
+ "guess_lang": "txt",
2005
+ "bbox": [
2006
+ 86,
2007
+ 119,
2008
+ 715,
2009
+ 213
2010
+ ],
2011
+ "page_idx": 13
2012
+ },
2013
+ {
2014
+ "type": "text",
2015
+ "text": "def forward(context, mask, rank, world_size, method, KV_cache=None):",
2016
+ "bbox": [
2017
+ 86,
2018
+ 224,
2019
+ 754,
2020
+ 242
2021
+ ],
2022
+ "page_idx": 13
2023
+ },
2024
+ {
2025
+ "type": "code",
2026
+ "sub_type": "code",
2027
+ "code_caption": [],
2028
+ "code_body": "if method $= =$ kvr' and rank $>0$ KV_cache $\\equiv$ net_recv (rank-1) \nif method $= =$ 'tsp': Q $\\equiv$ q.protoj(context) local_K $\\equiv$ k.protoj(context) local_V $\\equiv$ v.protoj(context) K, V $\\equiv$ net_all_gather(local_K,local_V) \nelse: #kvr,base Q $\\equiv$ q.protoj(context) K $\\equiv$ k.protoj(context) V $\\equiv$ v.protoj(context)",
2029
+ "guess_lang": "txt",
2030
+ "bbox": [
2031
+ 125,
2032
+ 255,
2033
+ 550,
2034
+ 440
2035
+ ],
2036
+ "page_idx": 13
2037
+ },
2038
+ {
2039
+ "type": "code",
2040
+ "sub_type": "code",
2041
+ "code_caption": [],
2042
+ "code_body": "if KV_cache: $\\mathrm{K} = \\mathrm{cat(KV\\_cache[0],K)}$ $\\mathrm{V} = \\mathrm{cat(KV\\_cache[1],V)}$",
2043
+ "guess_lang": "txt",
2044
+ "bbox": [
2045
+ 125,
2046
+ 452,
2047
+ 392,
2048
+ 500
2049
+ ],
2050
+ "page_idx": 13
2051
+ },
2052
+ {
2053
+ "type": "code",
2054
+ "sub_type": "code",
2055
+ "code_caption": [],
2056
+ "code_body": "KV_cache $=$ stack(K,V) \nif method $\\equiv =$ kvr' and rank $<$ world_size-1: net_send(KV_cache,rank+1) \nattnweights $=$ softmax(matmul(Q,K.T)+mask) \nattn_output $=$ matmul(atanweights,V) \nattn_output $=$ oProj(atan_output) \nreturn atan_output,KV_cache",
2057
+ "guess_lang": "c",
2058
+ "bbox": [
2059
+ 125,
2060
+ 512,
2061
+ 578,
2062
+ 664
2063
+ ],
2064
+ "page_idx": 13
2065
+ },
2066
+ {
2067
+ "type": "text",
2068
+ "text": "Table 5. Simplified Pseudo Code with KV-Runahead Integration",
2069
+ "bbox": [
2070
+ 294,
2071
+ 684,
2072
+ 678,
2073
+ 698
2074
+ ],
2075
+ "page_idx": 13
2076
+ },
2077
+ {
2078
+ "type": "text",
2079
+ "text": "with the right number of GPUs based on the optimization metric (i.e., cost, latency, utilization, and so on).",
2080
+ "bbox": [
2081
+ 84,
2082
+ 724,
2083
+ 781,
2084
+ 739
2085
+ ],
2086
+ "page_idx": 13
2087
+ },
2088
+ {
2089
+ "type": "text",
2090
+ "text": "C. Pseudo Code and Example",
2091
+ "text_level": 1,
2092
+ "bbox": [
2093
+ 84,
2094
+ 758,
2095
+ 339,
2096
+ 777
2097
+ ],
2098
+ "page_idx": 13
2099
+ },
2100
+ {
2101
+ "type": "text",
2102
+ "text": "Table 5 shows the simplified pseudo code for KV-Runahead integration into an existing transformer implementation, which also contrasts it with TSP. Table 4 illustrates one plausible partitioning with TSP and KVR for the example in Table 5, underscoring its difference from TSP.",
2103
+ "bbox": [
2104
+ 84,
2105
+ 784,
2106
+ 888,
2107
+ 830
2108
+ ],
2109
+ "page_idx": 13
2110
+ },
2111
+ {
2112
+ "type": "text",
2113
+ "text": "D. Lookup Table Generation Overhead",
2114
+ "text_level": 1,
2115
+ "bbox": [
2116
+ 84,
2117
+ 849,
2118
+ 418,
2119
+ 867
2120
+ ],
2121
+ "page_idx": 13
2122
+ },
2123
+ {
2124
+ "type": "text",
2125
+ "text": "We analytically derive the cost to precompute a partitioning lookup table (which is a one-time job). Let us assume that there are $N$ GPUs and a $C$ context with size, and we will pick a stride size at each level such that there are 5 values to check for",
2126
+ "bbox": [
2127
+ 84,
2128
+ 875,
2129
+ 888,
2130
+ 906
2131
+ ],
2132
+ "page_idx": 13
2133
+ },
2134
+ {
2135
+ "type": "header",
2136
+ "text": "KV-Runahead: Scalable Causal LLM Inference by Parallel Key-Value Cache Generation",
2137
+ "bbox": [
2138
+ 205,
2139
+ 56,
2140
+ 766,
2141
+ 70
2142
+ ],
2143
+ "page_idx": 13
2144
+ },
2145
+ {
2146
+ "type": "page_number",
2147
+ "text": "14",
2148
+ "bbox": [
2149
+ 477,
2150
+ 922,
2151
+ 495,
2152
+ 934
2153
+ ],
2154
+ "page_idx": 13
2155
+ },
2156
+ {
2157
+ "type": "text",
2158
+ "text": "each as shown in Figure 6. Let the time taken for each forward pass to measure TTFT be $T$ .",
2159
+ "bbox": [
2160
+ 84,
2161
+ 85,
2162
+ 687,
2163
+ 99
2164
+ ],
2165
+ "page_idx": 14
2166
+ },
2167
+ {
2168
+ "type": "text",
2169
+ "text": "At each level, there are $(N - 1)^{5}$ combinations to evaluate. Once the best combination is picked, we can zoom in and repeat the evaluation for $log_{5-1}C$ levels. Therefore, the time taken to precompute the lookup table will be $T(N - 1)^{5}\\log_{5-1}C$ .",
2170
+ "bbox": [
2171
+ 84,
2172
+ 107,
2173
+ 883,
2174
+ 137
2175
+ ],
2176
+ "page_idx": 14
2177
+ },
2178
+ {
2179
+ "type": "text",
2180
+ "text": "For instance, if we assume $T = 1$ sec, $N = 8$ , and $C = 16k$ for the case in Fig. 8 (c), it would take approximately 33 hours for an entry. Moreover, each entry can be searched for in parallel, if more GPUs are available. In practice, after a few entries, we can seed the search from the interpolated context partitioning with limited scopes for the expedition.",
2181
+ "bbox": [
2182
+ 84,
2183
+ 145,
2184
+ 883,
2185
+ 191
2186
+ ],
2187
+ "page_idx": 14
2188
+ },
2189
+ {
2190
+ "type": "header",
2191
+ "text": "KV-Runahead: Scalable Causal LLM Inference by Parallel Key-Value Cache Generation",
2192
+ "bbox": [
2193
+ 205,
2194
+ 56,
2195
+ 766,
2196
+ 70
2197
+ ],
2198
+ "page_idx": 14
2199
+ },
2200
+ {
2201
+ "type": "page_number",
2202
+ "text": "15",
2203
+ "bbox": [
2204
+ 477,
2205
+ 922,
2206
+ 495,
2207
+ 934
2208
+ ],
2209
+ "page_idx": 14
2210
+ }
2211
+ ]
2024/KV-Runahead_ Scalable Causal LLM Inference by Parallel Key-Value Cache Generation/7aa03393-2876-47f2-bf79-bac44a783b1a_model.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/KV-Runahead_ Scalable Causal LLM Inference by Parallel Key-Value Cache Generation/7aa03393-2876-47f2-bf79-bac44a783b1a_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f2ca14e4f3f1872b601362ab28b101e30d828fd8605c86102d3118f0d9aae7b4
3
+ size 6174889
2024/KV-Runahead_ Scalable Causal LLM Inference by Parallel Key-Value Cache Generation/full.md ADDED
@@ -0,0 +1,406 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # KV-Runahead: Scalable Causal LLM Inference by Parallel Key-Value Cache Generation
2
+
3
+ Minsk Cho<sup>1</sup> Mohammad Rastegari<sup>2</sup> Devang Naik<sup>1</sup>
4
+
5
+ # Abstract
6
+
7
+ Large Language Model or LLM inference has two phases, the prompt (or prefill) phase to output the first token and the extension (or decoding) phase to the generate subsequent tokens. In this work, we propose an efficient parallelization scheme, KV-Runahead to accelerate the prompt phase. The key observation is that the extension phase generates tokens faster than the prompt phase because of key-value cache (KV-cache). Hence, KV-Runahead parallelizes the prompt phase by orchestrating multiple processes to populate the KV-cache and minimizes the time-to-first-token (TTFT). Dual-purposing the KV-cache scheme has two main benefits. First, since KV-cache is designed to leverage the causal attention map, we minimize computation and computation automatically. Second, since it already exists for the extension phase, KV-Runahead is easy to implement. We further propose context-level load-balancing to handle uneven KV-cache generation (due to the causal attention) and to optimize TTFT. Compared with an existing parallelization scheme such as tensor or sequential parallelization where keys and values are locally generated and exchanged via all-gather collectives, our experimental results demonstrate that KV-Runahead can offer over $1.4 \times$ and $1.6 \times$ speedups for Llama 7B and Falcon 7B respectively.
8
+
9
+ # 1. Introduction
10
+
11
+ Large language models or LLMs, and especially Generative Pre-trained Transformer (GPT) models have shown excellent performance on many complex language tasks (Ouyang et al., 2022; Zhang et al., 2022a). However, the decoder architecture and autoregression execution in LLMs pose
12
+
13
+ <sup>1</sup>Apple. USA <sup>2</sup>Meta. USA (the work done while being with Apple). Correspondence to: Minsik Cho <minsik@apple.com>.
14
+
15
+ Proceedings of the $41^{st}$ International Conference on Machine Learning, Vienna, Austria. PMLR 235, 2024. Copyright 2024 by the author(s).
16
+
17
+ two challenges for efficient inferences: a) Time-to-first-token or TTFT: consuming potentially a long user context and generate the first token b) Time Per Output Token or TPOT: generating the subsequent tokens fast (Liu et al., 2023a). The second challenge is known to be a memory-bound problem, and a large body of research has been done (Pope et al., 2022), including sparsification, quantization, or weight clustering (Frantar et al., 2023; Lin et al., 2023; Cho et al., 2023; Liu et al., 2023b) or speculative decoding (Leviathan et al., 2023; Chen et al., 2023). But, the first challenge for a long user context is largely a compute-bound problem (Liu et al., 2023a; NVidia-LLM, 2023) and critical for favorable user experience with retrieval augmentation (Ram et al., 2023), in-context learning (Dong et al., 2023), summarization (Zhang et al., 2023b), story generation (Zhang et al., 2023a), and so on.
18
+
19
+ Since TTFT for a long context is compute-bound, one solution is to use more computing power in the form of parallelization. The current SOTA in LLM parallelization includes tensor and sequential parallelization (Patel et al., 2023; Li et al., 2023; Korthikanti et al., 2022; NVidia-LLM, 2023) where the key and value computations are distributed over multiple processes and subsequently exchanged, aiming to compute the attention map perfectly in parallel. The methods above are generic enough to drive LLM inference (Vaswani et al., 2017), but not specialized enough for scalable LLM inference, as the causality in attention is not fully leveraged, resulting in up to $2 \times$ overhead in terms of both computation and communication over the ideal case.
20
+
21
+ Therefore, we propose a novel yet effective parallelization technique tailed for LLM inference, KV-Runahead to minimize TTFT. By re-purposing the key-value cache or KV-cache (NVidia-LLM, 2023) mechanism (which exists anyway for subsequent token generation), our proposed KV-Runahead uses other processes to populate KV-cache for the last process with context-level load-balancing. Since KV-cache assumes causal attention computation, KV-Runahead reduces the computation and communication costs and offers lower TTFT over the existing methods. Further, KV-Runahead requires minimal engineering costs, as it simply makes the KV-cache interface dual-purposed. In detail, our contributions are the following:
22
+
23
+ ![](images/1c9c56702671c0bcd6ad34ca7dc4f0aa4d7924119287e6019a7d9bcd04947f01.jpg)
24
+ (a) LLM inference consists of two phases: the prompt phase for the first token and the extension phase for the next tokens.
25
+
26
+ ![](images/8fdd2ab0739e1c6821799f1bbd6148dee3142229b751f248f259d6bfa6c98dc3.jpg)
27
+ (b) Causal attention computation of one layer on one process: the upper triangle of $QK^{T}$ will be masked out with $-\infty$ .
28
+ Figure 1. LLM inference begins with the prompt phase to generate the KV-cache and the first token which drive the extension phase as in (a). Inside each layer of the LLM as in (b), a causal attention map $(QK^T)$ is built to compute the attention $A$ from query, value, and key $s$ $(Q,K,V)$ . Computing attention thus has $O(C^{2})$ complexity where $C$ is the user context.
29
+
30
+ - We demonstrate that KV-cache scheme can be dual-purposed to parallelize LLM inference for low TTF. Since the KV-cache is built on the causal decoder and gets populated in parallel, KV-Runahead can offer considerable compute and communication savings over tensor/sequential parallelization.
31
+ - We show that using KV-cache for parallelization enables asynchronous communication. Thus, KV-Runahead replaces global synchronization with point-to-point asynchronous communication, and provides robustness against network bandwidth fluctuation.
32
+ - We highlight that context-level partitioning can load-balance parallel LLM inference. Asymmetric computations and communication rise from KV-cache and its dependency chain across parallel processes. Yet, we can mitigate the negative effects on TTFT with the proposed context-level load-balancing.
33
+ - We propose that hierarchical grid search for efficient context-partitioning. Such search results contribute to a lookup table from which a TTFT-minimizing partitioning can be interpolated for various context lengths.
34
+
35
+ # 2. Related Works
36
+
37
+ LLM Inference: Generative LLM inference consists of two steps as in Fig. 1 (Patel et al., 2023). Once the user context is received, all the input tokens are consumed to generate the first token, which is called the prompt phase. At the same time, the computed key and value embeddings are saved as KV-cache (Park et al., 2020; Liu et al., 2023a) and fed to all subsequent token generations to expedite the extension phase. Accordingly, KV-cache grows as more tokens are generated, because the next token generation needs to attend to all previous tokens, including the user context. While the critical metric for the extension phase is time-per-output-token or TPOT, the prompt phase needs to deliver the first token fast which is measured as time-to-first-token or TTFT.
38
+
39
+ TTFT Optimization: Minimizing TTFT, especially for
40
+
41
+ long context requires two efforts: efficient KV-cache management and fast attention map computation. PagedAttention (Kwon et al., 2023) facilitates the exchange of data including KV-cache between different memory subsystems to handle long contexts. Infinite-LLM (Lin et al., 2024) suggests distributed KV-cache management system at the cloud scale to adaptively handle extremely long context lengths. CacheGen (Liu et al., 2023a) proposes compressing KV-cache for pre-computed contexts to lower TTFT. SplitWise (Patel et al., 2023) proposes to use two different platforms, one with high computing capacity for the prompt phase and the other with low computing capacity for the extension phase by transferring the LLM states, including KV-cache from the first to the second platforms.
42
+
43
+ LLM Inference Parallelization: Since TTFT optimization is compute-bound, one can employ parallel DNN inference. Pipeline parallelism shards the layers of a model across multiple processes, splitting the model into several stages or layers (Huang et al., 2019; Narayanan et al., 2021a; Agrawal et al., 2023). Tensor Parallelism is one of the popular parallel methods from (HuggingFace-TensorParallelism; Shoeybi et al., 2020; Narayanan et al., 2021b) where a large matrix multiplication is scattered and then the partial output matrices are gathered, and is known to be superior to pipeline parallelism (Patel et al., 2023). Sequence parallelization (NVidia-LLM, 2023; Li et al., 2023) is a novel
44
+
45
+ ![](images/eb6faf768734182651973c5ef3d59729abc2c6c9873968c143f272af50ef65db.jpg)
46
+ (a) 1 process (b) 2 processes (c) 4 processes (d) $p$ processes
47
+ Figure 2. $QK^{T}$ computation coverage using BLAS matrix-matrix multiplication: by linking each context partition to KV-cache, we can closely approximate the lower triangular part and minimize unnecessary dot products. Note the upper triangular part of the attention will be masked out to enforce causality.
48
+
49
+ ![](images/2702a909fd555e205c5fe23cabc56a6607e5814cad968c1a0c4a15d72aaf522c.jpg)
50
+ (a) Tensor+Sequence Parallel Inference: With even context partitioning, each process will perform all-gather over $K, V$ . All computations in the layers are symmetric and globally synchronized, and the user context can be evenly partitioned. (See Fig. 4).
51
+
52
+ ![](images/fd27845e34afdf18c6c69c6df0ac032f172682374baced3707b13392f2cc2fde.jpg)
53
+ (b) KV-Runahead Inference: Since the later processes wait for the KV-cache to be ready, the layers will asynchronously communicate, and the user context is unevenly partitioned (for loadbalancing) to minimize TTFT. (See Fig. 5).
54
+ Figure 3. Comparing the existing tensor+sequence parallel scheme with the proposed KV-Runahead for parallel LLM inference.
55
+
56
+ data parallel algorithm (by evenly partitioning the input sequences over multiple processes) coupled with a distributed ring attention algorithm. By deploying the ring topology over all the devices, each process exchanges the key and value embedding with neighbors and builds a full attention map locally.
57
+
58
+ Both tensor and sequence parallelizations in LLM are mathematically similar in a sense that a) one of two matrices (i.e., either activations or parameters) in multiplication will be sharded over multiple devices, b) both require collective communication to merge the partial outcomes. Hence, both are popular for parallel LLM inference (Korthikanti et al., 2022), yet not specialized enough for causal attention, leading to excessive computation and communication overheads.
59
+
60
+ # 3. Causal LLM Scalability and Motivation
61
+
62
+ In this section, we will discuss the lower bound of the scalability of a causal attention-based LLM for a sufficiently long user context $C$ over parallel $p$ processes. Assume that the user context $C$ is partitioned into $C = \{c_0, c_1, c_2, \dots, c_{p-1}\}$ for $p$ processes, and each process is exclusively mapped to one compute fabric (e.g., GPU). The minimum compute over $p$ to generate the first token, $TTFT(p)$ with perfect load-balancing is as follows:
63
+
64
+ $$
65
+ \begin{array}{l} T T F T (p) \geq \alpha \left[ \frac {\frac {1}{2} C ^ {2} + \frac {1}{2} \left(\sum_ {0} ^ {p - 1} c _ {i} ^ {2}\right)}{p} \right] (1) \\ \geq \alpha \left[ \frac {\frac {1}{2} C ^ {2} + \frac {1}{2} p (\frac {C}{p}) ^ {2}}{p} \right] \\ = \alpha \left[ \frac {C ^ {2}}{2} (\frac {1}{p} + \frac {1}{p ^ {2}}) \right] \\ = \frac {T T F T (1)}{2} \left(\frac {1}{p} + \frac {1}{p ^ {2}}\right) (2) \\ = \mathbf {T T F T} ^ {*} (p) (3) \\ \end{array}
66
+ $$
67
+
68
+ where $\alpha$ is a fitting coefficient such that $TTFT(1) = \alpha C^2$ (single process performance) (Dao et al., 2022), and $\mathbf{TFT}^{*}(\mathfrak{p})$ is the lower bound of TTFT over $p$ . The signifi
69
+
70
+ cance of $\mathbf{T}\mathbf{T}\mathbf{F}\mathbf{T}^{*}(p)$ is that for a very long user context, there exists super-linear scalability (i.e., more than $2\times$ speedup with 2 processes) with causal LLM in the ideal setup, such as perfect load-balancing, zero communication costs, and so on. Please see the super-linear scalability of KV-Runahead reported in Fig. 8 (d).
71
+
72
+ Fig. 2 visualizes the concepts behind Eq. (1) which essentially divides an attention map, $QK^{T}(C,C)$ in the shaded regions over $p$ processes. We need to practically compute multiple rectangle regions using matrix-matrix multiplication and mask out the upper triangle part (which is how most LLMs are implemented). Therefore, with more partitions, we can eliminate the wasted computation. Other equally good partitioning setups (i.e., using vertical rectangles to approximate the lower triangle) could exist, but the one in Fig. 2 (d) is LLM-friendly: easy to generate at the context level, and exactly aligned with KV-cache.
73
+
74
+ Hence, we can intuitively map the partitions in Fig. 2 (d) to $p$ processes, which can be implemented by dual-purposing the already-existing KV-cache interface with minor efforts, leading to the motivation behind KV-Runahead. Also, as seen in Fig. 2 (d), each process will suffer from varying computation load, thus one may not effectively minimize TTFT. Yet, optimizing $c_{i}$ alone may lead to global over-computation. Hence, we perform context-level partitioning for load-balancing and minimal TTFT in KV-Runahead.
75
+
76
+ # 4. KV-Runahead Overview
77
+
78
+ In Fig. 3, the proposed KV-Runahead is illustrated and compared against Tensor/sequence parallel inference (or TSP), which characterizes both tensor parallelism (Shoeybi et al., 2020; Narayanan et al., 2021b) and sequence parallelization (Li et al., 2023). As in Fig. 3 (b), KV-Runahead starts with uneven context partitioning for load-balancing. The existing TSP parallelizes the forward computation itself, but KV-Runahead achieves parallel inference by utilizing multiple processes to populate KV-caches for the last process. Therefore, unlike TSP where computation is symmetric and evenly distributed (thus no need to balance out context partitioning), KV-Runahead needs good context partitioning
79
+
80
+ ![](images/cb3f7f361a6728d091f45ebcf16c3cdc8dad7f6b75fa4b2054a23748b76d08e5.jpg)
81
+
82
+ ![](images/82ee586c5969f078018643976514767e3d25fd7ef30a7b6ede13e7390a0e3b66.jpg)
83
+
84
+ ![](images/e6fd5c2a17b619bf2a2dd61fbd41446eb378122c29a33a098f0e099c7a50ae0f.jpg)
85
+ (a) $Q, K, V$ are computed for the evenly partitioned context.
86
+
87
+ ![](images/70397634352c4e8718132434b5b5fa2016891a73336ea199c9742ab45576dab6.jpg)
88
+ all-gather K
89
+
90
+ ![](images/e8fd7a20df9989657dcd46b813e2b36b0eb7b61b1fe5442ed278d21c7298149c.jpg)
91
+ all-gather K
92
+
93
+ ![](images/0637c50cb98803aa291679cb232a0396df1cb959f7bdb6c0bfe1c235f51c99d2.jpg)
94
+ (b) $K,V$ are exchanged by all-gather to mimic Fig. 1 (b).
95
+
96
+ ![](images/904d9239433dc855585a22efff7c26056dd51fd4f40e59d26b826e9e4ab9a19e.jpg)
97
+ Figure 4. Tensor/sequence parallel inference over 3 processes $p_{\{0,1,2\}}$ within a layer to compute attention map $(QK^T)$ and final attention $A$ : Each process will compute the equal amount of $(Q,K,V)$ in (a), and then globally share $(K,V)$ using all-gather collectives to compute the equally sized partial $QK^T$ (i.e., 27 dot-products needed on each) and partial $A$ . Such all-gather operations require global synchronization, and incur the traffic for 36 $(K,V)$ entries (i.e., the number of blue rows in $(K,V)$ ).
98
+
99
+ ![](images/f097000cfcc71ed79c5f9f87a404953352c67099180decafdecc62ec8131778f.jpg)
100
+
101
+ ![](images/313f97c685e10615375d7ee0386bd6ee2867a0439ad3c2c97e6c80edd95ed314.jpg)
102
+ (a) $Q, K, V$ are computed for the uneven partitioning.
103
+ Figure 5. KV-Runahead execution over 3 processes $p_{\{0,1,2\}}$ within a layer to compute attention map $(QK^T)$ and final attention $A$ : Each process will compute different amounts of $(Q,K,V)$ in (a), and the maximum amount for $QK^T$ is 21 dot-products on $p_1$ (in contrast to 27 from Fig. 4 (b)). The locally computed $(K,V)$ are passed down to the following processes as KV-cache using point-2-point one-way send (i.e., $p_0 \to p_1 \to p_2$ ). Our communication is much cheaper than global all-gather in Fig. 4 (b), as the traffic incurred in KV-Runahead is 22 (i.e., the number of blue rows in $(K,V)$ ), which is much lower than 36 from Fig. 4.
104
+
105
+ ![](images/8d6d4f00951b78c1217d30e8d60caf2176f77a62e1c67739a6baf26b42d4647b.jpg)
106
+ send K[0:3]
107
+
108
+ ![](images/7592f060c5116a225ad6e7ec9e1ca576ab8f72cab72fca63532c739b3cb0640c.jpg)
109
+ send K[0:6]
110
+
111
+ ![](images/89565517b0310538b63cf784a51e0295d004de7ac7fe8e127ec48c099e6cd97b.jpg)
112
+ (b) KV-caches are handed down from $p_i$ to $p_{i+1}$ by send.
113
+
114
+ to balance out the KV-cache amount from each compute process and to minimize TTFT.
115
+
116
+ Once partitioning is complete, each process will run each layer, conditioning on the KV-cache from its precedent process. In detail, the current process must wait for the required KV-cache to arrive from the precedent (i.e., notice the layer misalignment in Fig. 3 (b)), forming a dependency chain via local peer-to-peer communication rather than global synchronization via all-gather (Thakur et al., 2005).
117
+
118
+ We will first elaborate on how KV-Runahead works inside each layer in terms of compute/communication saving in Section 4.1, and then discuss the context partitioning for load-balancing in KV-Runahead in Section 4.2. Finally, Section 4.3 briefly discuss implementing KV-Runahead.
119
+
120
+ # 4.1. Forward Execution
121
+
122
+ The causal attention computation on a single process is shown in Fig. 1 (b), which is to be parallelized in this section. For a given context, once $(Q,K,V)$ are computed, $QK^T$ or attention map is computed for $A$ . Although only the lower triangular part of $QK^T$ is needed due to the causality, the entire $QK^T$ is commonly computed via dense matrix-matrix multiplication first, then a mask is added in general (HuggingFace-Transformers), because no good mapping to BLAS-L3 exists or writing a custom kernel is expensive (NVidia-cuBLAS).
123
+
124
+ One SOTA way to enable parallel inference for LLM (e.g., GPT-3, Llama, and BLOOM), would be to utilize tensor and sequence parallelizations (Li et al., 2023; Patel et al., 2023; Shoeybi et al., 2020; Korthikanti et al., 2022), Tensor/sequence parallelization or TSP in Fig. 4 where the focus is on parallelizing the single process behavior from Fig. 1 (b). In TSP, for a given evenly partitioned context, $(Q, K, V)$ are independently computed on each process as in Fig. 4 (a). Then, the collective operation all-gather is performed to exchange $K$ and $V$ to all processes so that $Q K^T$ can be evenly distributed as shown in Fig. 4 (b). Although TSP faithfully follows the single process case in Fig. 1 (b), it does not take advantage of the causality in LLM inference.
125
+
126
+ In our KV-Runahead, we start with a given yet unevenly partitioned context, and $(Q,K,V)$ are independently computed on each process as in Fig. 5 (a). Thus, each process computes a different number of entries in $(Q,K,V)$ . Then, KV-Runahead simply populates the KV-cache from each process and hands over to the next process in chain, mimicking the extension phase in Fig. 1 (a). As a result, only the last process will have the full $(K,V)$ , but still each process can output the $A$ in the same shape as $Q$ , driving the next layer. Since KV-cache itself is built upon the causality, KV-Runahead can automatically minimize the computation of the upper triangle and reduce the number of dot-products for
127
+
128
+ $QK^T$ . For example, 27 dot-products are needed on all the processes in TSP as in Fig. 4 (b), but KV-Runahead requires 21 (max out of $\{p_0:16,p_1:21,p_2:18\}$ ) as in Fig. 5 (b). This also highlights the motivation behind uneven context partitioning to minimize the largest $QK^T$ computation.
129
+
130
+ KV-Runahead also removes the global synchronization points and reduces the total traffic volume exchanged among processes. All-gather operations in Fig. 4 (b) force all the processes to stop and secure the full $(K,V)$ (Thakur et al., 2005), while KV-Runahead shares only the local KV-cache with the next process via point-to-point send operations. As a result, TSP in Fig. 4 (a) requires to share $36(K,V)$ entries to get to the state in Fig. 4 (b), but KV-Runahead only needs 22 to transit to Fig. 5 (b). Such a dependency chain from KV-cache introduces a longer wait time for the later processes, but KV-Runahead can outperform TSP even with such overheads.
131
+
132
+ In theory, with a sufficient number of parallel processes and a sufficiently long user context (i.e., $QK^T$ dominates the runtime), KV-Runahead can offer up to $2 \times$ speed up over TSP, because both total $QK^T$ computation and network traffic among processes in KV-Runahead are half of those in TSP. It could be possible to handcraft a custom/expensive BLAS kernel for TSP to avoid over-computation. Even with a tailored custom kernel, however, the communication involved in TSP remains suboptimal as it still uses Allgather to exchange (K, V) The proposed KV-Runahead avoids both over-computation and wasted network traffic seamlessly, by dual-purposing the LLM-specific KV-cache scheme (which already exists for the extension phase).
133
+
134
+ Additionally, the same computational savings achieved with the custom GPU kernel, can also be applied to KVR. From Fig 5 (b), we can still see some wasted computation. Hence, a custom kernel would save such waste to further enhance the performance of KVR. Yet, the benefit from a custom kernel would diminish with more GPUs in parallel, as the nature of KV-cache allows our technique to approximate the unmasked lower triangle more accurately with more processes, as illustrated in Figure 2 (b) and (d).
135
+
136
+ For simplicity, assume that a user context $C$ is even partitioned for KV-Runahead and TSP over $p$ processes. Then, the total TSP traffic $\mathbf{Net}_{tsp}$ can be written as follows:
137
+
138
+ $$
139
+ \begin{array}{l} \mathbf {N e t} _ {t s p} (C, p) = p (p - 1) \frac {C}{p} (4) \\ = (p - 1) C (5) \\ \end{array}
140
+ $$
141
+
142
+ which is essentially the total number of $(K,V)$ entries from other processes. The total KV-Runahead traffic $\mathbf{Net}_{kvr}$ is
143
+
144
+ the sum of the total KV-cache put into the network.
145
+
146
+ $$
147
+ \begin{array}{l} \mathbf {N e t} _ {k v r} (C, p) = \frac {C}{p} + \frac {2 C}{p} + \frac {3 C}{p} + \dots (6) \\ = \sum_ {i = 1} ^ {p - 1} \frac {i C}{p} = \frac {(p - 1)}{2} C (7) \\ \end{array}
148
+ $$
149
+
150
+ The $2 \times$ reduction is over the total computation and network traffic, not for each individual process. Therefore, it is critical to perform load-balancing to maximize the gain over TSP and minimize TTFT, and KV-Runahead accomplishes it by context-level load-balancing in Section 4.2.
151
+
152
+ # 4.2. Context-Level Load-Balancing
153
+
154
+ As discussed in Section 3, KV-Runahead needs loadbalancing for low TTFT. We propose running off-line search for the best partitioning, and then store the results in a partitioning lookup table. For example, we pre-compute the optimal partitioning of user contexts at various lengths for a given number of processes off-line by measuring TTFT on the target hardware, and then contribute the search results to a lookup table. During inference, we can predict the best partitioning by interpolating the two nearest known entries in the lookup table. For the example of $10\mathrm{k}$ prompt, we can interpolate from the known partitioning configurations from $8\mathrm{k}$ and $12\mathrm{k}$ in the lookup table.
155
+
156
+ Finding the best partitioning configuration for a given user context, although one-time off-line overhead, can be expensive. Hence, we propose a hierarchical grid search for acceleration. From the nature of KV-Runahead, it is straightforward to see that finding the TTFT-optimal partitioning has two conflicting objectives.
157
+
158
+ - The partitions for the earlier processes must be small, otherwise the later processes will wait too long for the earlier ones to populate KV-caches and send them over.
159
+ - The partitions for the later processes need to be small, otherwise the later processes will the bottleneck in generating the first token.
160
+
161
+ For two processes, we can use a binary search to find out the best partitioning. Fig. 6 (a) shows how TTFT changes as we grow the partition for the $p_0$ for a 16k context where the partitioning is $C[0,8192 + \delta_1,16384]$ . As $\delta_1$ grows, it bottoms at the partition of [0, 9728, 16384] (i.e., $\delta_1 = 1536$ , thus $p_0$ takes C[0:9728] and $p_1$ takes in C[9728:16384]).
162
+
163
+ By generalizing the binary search into a hierarchical grid search for multiple processes (Zhang et al., 2022b), we can find a high-quality partitioning fast for a given user context length. Figs. 6 (b-d) depict the proposed search process for a user context length of 96 over 4 processes, which is to find the optimal $(\delta_1,\delta_2)$ for the partitioning of
164
+
165
+ ![](images/0de08b41056e6ff2140d2b216b707d87618a0b70327ca08685a7d88167957551.jpg)
166
+ (a) 2 partitions
167
+
168
+ ![](images/5332defd6dee6d7c3d9103059dfdbb4437bf5b4f0b6f559db055e5ead44f3364.jpg)
169
+ (b) stride 8
170
+
171
+ ![](images/9fb56257d5b491d6110b5f21162f9ba421fb67f48dbc686cf450e28d7c9b95f5.jpg)
172
+ (c) stride 4
173
+ Figure 6. Finding two partitions can be done quickly by binary search as shown in (a) where $\delta_{1}$ is the variable for additional context the $p_0$ . We can extend such binary search into hierarchical grid search for multiple processes as in (b, c, d) for the example of $C[0,32 + \delta_1,64 + \delta_2,96]$ .
174
+
175
+ ![](images/7ea9e4bc0a65600d1c0e60be23257dcaf9279d5006121ea3e04eec79d56c56ef.jpg)
176
+ (d) stride 2
177
+
178
+ ![](images/b4d6be5306d88e9f59b44aeb35d38004093fb8e0dc494d5d634cf98bd3ace16f.jpg)
179
+ (a) Without KV-Runahead.
180
+ Figure 7. KV-Runahead can be easily implemented in LLM with existing KV-cache support (e.g., most of public LLMs) by simply inserting recv/send operations (in the blue boxes). Note that $M$ is the causality mask.
181
+
182
+ ![](images/9f3f32ee6357aca91f4ca3ef766fddba6a6884bec8cb0541e4d4c534b17514f9.jpg)
183
+ (b) With KV-Runahead.
184
+
185
+ $C[0,32 + \delta_1,64 + \delta_2,96]$ . In the first level, we set the search stride as 8 and measure the TTFTs on each grid. Once we find the best performing $(\delta_{1},\delta_{2})$ pair, we limit the search to the gray grid and reduce the search stride to 4 to perform another scan as in Fig. 6 (c). We repeat the same process recursively until the minimum stride is applied, leading to the final search as in Fig. 6 (d). The best partitioning is then [0, 28, 70, 96] and marked as a red dot in Fig. 6 (b).
186
+
187
+ A comprehensive partitioning lookup table will enable efficient partitioning as in Fig. 3 (b) for effective load-balancing. For a given user context, we will interpolate and predict the best partitioning from two closest entries. Therefore, having a dense and large table would be advantageous at the cost of one-time search overhead. Our results also show that even at the $4\mathrm{k}$ intervals between entries, the predicted partitioning can yield excellent TTFT (see Fig. 10).
188
+
189
+ ![](images/07aea3d394ce8c110a91f95fec8c3355b5651c80f1e8ca6abe1c694eda4d946a.jpg)
190
+ (a) TSP hits out-of-memory error for 16k.
191
+
192
+ ![](images/ab70d739615ff66c545f35060cbe27990f2386e4a2977e1d0f1b9d1ded548556.jpg)
193
+ (b) KVR-S is $1.42 \times$ faster for 12k than TSP.(c) KVR-S is $1.41 \times$ faster for 16k than TSP.
194
+
195
+ ![](images/d6772f906ca5e41cc386d2daa03322a98775a2ab4120cc6d7c3ef4ce14bc697e.jpg)
196
+
197
+ ![](images/76433181f1d66247415ce2e7008f4565182bc440c7288913684f1832379b5066.jpg)
198
+ (d) KVR-S shows the best scalability.
199
+
200
+ ![](images/fdc231f08c4f6ce0386da6829e51cdce33255fd509c2e6fc779f96c62faa02b5.jpg)
201
+ (e) KVR-S is $1.79 \times$ faster for 8k than TSP.
202
+
203
+ ![](images/b0139926865ec99bed687c648b126f71e6227a08587b784184880ae527263436.jpg)
204
+ (f) KVR-S is $1.57 \times$ faster for 16k than TSP.
205
+
206
+ ![](images/d7f4d8473f743c715fd648b3f723b4a216d397f3a8cd44453764d3ac39ca84f4.jpg)
207
+ Figure 8. Llama 7B: while KVR-E already outperforms TSP in all the test cases, KVR-S further accelerates by $1.42 \times$ over TSP as in (a-c) with 300GB/s network. The speedups from KVR-E and KVR-S are even higher with 10GB/s network as in (e, f): $1.55 \times$ (4 GPUs and 8k) and $1.79 \times$ (4 GPUs and 12k) over TSP, respectively. KVR-S is the closest to the scalability lower bounds as in (d).
208
+
209
+ ![](images/32a0cbccf81cb12234489805c44770c2d53de2554c539ce593f13751a36fe403.jpg)
210
+ (a) KVR-S is $1.26 \times$ faster for 4k than TSP.
211
+ (b) KVR-S is $1.46 \times$ faster for 8k than TSP.
212
+ (c) KVR-S is $1.63 \times$ faster for 8k than TSP.
213
+ Figure 9. Falcon 7B: KVR-S offers up to $1.63 \times$ speedup over TSP. Since 4k context length is relatively short, the benefit from KVR-E is canceled out by the overhead from KV-cache waiting time and unbalanced attention compute as in (b-c). However, with load-balancing, KVR-S delivers $1.37 \times$ and $1.47 \times$ speedup over TSP with 4 and 8 GPUs, respectively, which emphasizes the context-level load-balancing.
214
+
215
+ ![](images/7ea6c260c79a31180ceb2ed3ae08dd5de0fa8e95c413af060218d979590a5adb.jpg)
216
+
217
+ # 4.3. Implementation
218
+
219
+ Since KV-Runahead dual-purposes the KV-cache interface, which exists in most LLM implementations for faster subsequent token generations during the extension phase in Fig. 1 (a) (HuggingFace-Transformers), KV-Runahead is easy to implement. Fig. 7 shows the pseudocode/computational graph without and with KV-Runahead. Note that KV-cache is already in the input argument to the attention block. The only additions are two parts in the blue boxes: a) overwrite the KV-cache by receiving it from $p_{i - 1}$ before concatenating it with the local $(K,V)$ , and b) forward the
220
+
221
+ updated KV-cache to $p_{i+1}$ right after concatenation. We can make both recv and send asynchronous calls by overlapping with qkv proj and softmax respectively, thanks to the nature of point-to-point connections. More details on the implementation and examples can be found in Appendix 5.
222
+
223
+ Both TSP and KV-Runahead require to have tensors in the contiguous memory space for efficient network communication, which is then about KV-cache for KV-Runahead: if KV-cache is physically fragmented, costly extra memory copy will be necessary. Therefore, the KV-cache management such as vLLM (Kwon et al., 2023; vLLM) needs to
224
+
225
+ ![](images/e3e673831299e5ae770cdfe88bec20141eeb18641255606507e85aa8c2c11904.jpg)
226
+ (a) The partitioning breakdowns found by hierarchical grid search for KVR-S in Figs. 8 (a-c).
227
+
228
+ ![](images/c04ce678a16b1d56a8d6b9c4d58b3b931cfd9ee009ada2561beabf91e87912bd.jpg)
229
+ (b) KVR-P with predicted partitions is only $1.1\%$ worse than KVR-S.
230
+
231
+ ![](images/411919f2bba7836bc003317e1c0dbe5a42d46e339fdc0426f3793683c9f01f81.jpg)
232
+ (c) KVR-P with predicted partitions is only $1.3\%$ worse than KVR-S.
233
+ Figure 10. KVR-P with predicted partitions for $10\mathrm{k}$ and $12\mathrm{k}$ contexts interpolated from the searched breakdowns for Figs. 8 (a-c) has negligible TTFT degradations from KVR-S, supporting the fact that the proposed lookup method for context partitioning is effective.
234
+
235
+ support contiguous physical memory allocation during the prompt phase to work seamlessly with KV-Runahead.
236
+
237
+ # 5. Experimental Results
238
+
239
+ We used PyTorch 2.0 (Paszke et al., 2019) and NCCL 2.14 to enable KV-Runahead in Huggingface LLaMA 7B and Falcon 7B (Touvron et al., 2023; Almazrouei et al., 2023). All our experiments were done on a single node with $8 \times$ NVidia A100 GPUs, and under high (300GB/s) and low (10GB/s) bandwidth setups. Note that we turned off the high-speed CUDA-direct link (NVidia-NCCL, 2023) to configure the low bandwidth environments.
240
+
241
+ We used FP16 for the inference. We compared KV-Runahead with Tensor/Sequence Parallelization (TSP) (Li et al., 2023; Shoeybi et al., 2020; Patel et al., 2023). Note that KV-Runahead is applicable to any LLM with causal attention and does not alter any task accuracy. For ablation, we created a few variants of KVR as below.
242
+
243
+ KVR-E with even context partitioning
244
+ KVR-S with searched context partitioning
245
+ KVR-P with predicted/interpolated context partitioning
246
+
247
+ Acceleration: Our results are presented in Figs. 8 and 9 with multiple context lengths and GPU counts. From Figs. 8 (a-c), we can see KVR-S (even KVR-E) consistently outperforms TSP. And, KVR-S can deliver larger speed up (over $40\%$ ) with longer contexts and more GPUs, and the speedup gain is even higher on low bandwidth (10GB/s) network as in (e, f). Also, note that TSP hit the out-of-memory error for 16k contexts on 2 GPUs, apparently consuming more memory. Fig. 9 shows the similar results with 8k context lengths, but speedups are observed only with KVR-S for 4k context. Fig. 8 (d) compares the scalability of TSP, KVR-E, and KVR-S against two lower bounds: $\mathrm{TTFT}(p)$ is the same as KVR-S without any communication (so practical lower bound), and $\mathrm{TTFT}^* (p)$ is from Eq. (3) (so theoretical lower bound), which leads to the following observations:
248
+
249
+ - $\mathbf{TTFT}^*(p)$ is very tight to $\mathbf{TTFT}(p)$ , until the non-parallelizable parts become dominant, like on 8 GPUs.
250
+ - KVR-S gets much closer than TSP to TTF $(p)$ .
251
+ - KVR-S is up to $17\%$ away from $\mathbf{T}\mathbf{T}\mathbf{F}\mathbf{T}(p)$ in our tests.
252
+
253
+ More results with other smaller/bigger LLMs and shorter/longer contexts are available in Appendix A.
254
+
255
+ Context-level Partitioning: Fig. 10 (a) discloses the searched context partitioning for the cases in Figs. 8 (a-c). In general, we can see the earlier processes need to consume more contexts, and the later ones consume less, which implies that the wait time for the later processes is less of a concern for the configuration. We can use these breakdowns to build a partitioning lookup table, and linearly interpolate the partitionings for $10\mathrm{k}$ and $14\mathrm{k}$ contexts. For example, we can interpolate from the breakdowns of $8\mathrm{k}$ and $12\mathrm{k}$ to get the predicted partitioning for $10\mathrm{k}$ on 4 GPUs, which results in $[0.350, 0.255, 0.210, 0.185]$ in terms of ratio. And, it can be done similarly for $12\mathrm{k}$ user contexts as well on 4 and 8 GPUs. According to our results in Figs. 10 (b, c), even with $4\mathrm{k}$ intervals, KVR-P with predicted partitioning from interpolation is within $1.3\%$ of the KVR-S cases with the searched partition configurations and still outperforms TSP.
256
+
257
+ Point-to-point communication: To understand the benefit of point-to-point asynchronous communication of KVR over the all-gather operation in TSP, we added a noisy sidecar to generate the bidirectional network traffic between a random pair of adjacent GPUs (i.e., simulating dynamically changing non-uniform network bandwidth), averaged out multiple TTFTs for the 8k, 12k, and 16k context lengths, and then reported the results in Fig 11. We found that KVR is much more robust against non-uniform bandwidth among processes: while TSP degraded the TTFTs over $10\%$ on average due to non-uniform effective bandwidth, KVR has up to $3.7\%$ impact on TTFT, clearly demonstrating the benefits of the communication mechanism in KV-Runahead. Also,
258
+
259
+ ![](images/a655b0454f5687fea96986e87718bc026c6958de49facadb39e48215ad14f9d8.jpg)
260
+ (a) On a noisy network, KVR-S outperforms TSP even more $(42.2\%$ vs. $43.4\%)$ than the quiet case in Fig. 8 (b).
261
+
262
+ ![](images/cc52b591cd386a22439a119a93437f8a89f584c5ebbaef3fed9d93d7dd7f04a4.jpg)
263
+ Figure 11. On a noisy high bandwidth network, KVR-S still outperforms TSP by even wider margin than the case in Figs. 8 (b, c), and shows high tolerance against the other noisy traffics. Yet, in terms of absolute tolerance, KVR-E appears to be the best.
264
+
265
+ ![](images/aa37e7fa8f3d3dc157ea85989bdbce856cb5cb0ff00fea645665514cf2af5ed8.jpg)
266
+ (b) On a noisy network, KVR-S outperforms TSP even more (41.1% vs. 45.8%) than the quiet case in Fig. 8 (c).
267
+ (c) In terms of the TTFT overhead, TSP is most affected (up to $11.8\%$ ), and KVR-E is least influenced (up to $2.7\%$ ).
268
+
269
+ KVR-S is tuned to the quiet environment, but still outperforms TSP thanks to the point-to-point communication.
270
+
271
+ # 6. Conclusion
272
+
273
+ In this work, we propose an efficient parallel LLM inference technique, KV-Runahead, to minimize the time-to-first-token. With the proposed techniques, we observed over $60\%$ speedup in the first token generation over the existing parallelization schemes and higher robustness against a non-uniform bandwidth environment.
274
+
275
+ # Impact Statement
276
+
277
+ This paper presents work whose goal is to advance the field of Machine Learning. There are many potential societal consequences of our work, none which we feel must be specifically highlighted here.
278
+
279
+ # References
280
+
281
+ Agrawal, A., Panwar, A., Mohan, J., Kwatra, N., Gulavani, B. S., and Ramjee, R. Sarathi: Efficient llm inference by piggybacking decodes with chunked prefixes, 2023.
282
+ Ainslie, J., Lee-Thorp, J., de Jong, M., Zemlyanskiy, Y., Lebrón, F., and Sanghai, S. Gqa: Training generalized multi-query transformer models from multi-head checkpoints, 2023.
283
+ Almazrouei, E., Alobeidli, H., Alshamsi, A., Cappelli, A., Cojocaru, R., Debbah, M., Goffinet, E., Heslow, D., Lau-nay, J., Malartic, Q., Noune, B., Pannier, B., and Penedo, G. Falcon-40B: an open large language model with state-of-the-art performance. 2023.
284
+ Chen, C., Borgeaud, S., Irving, G., Lespiau, J.-B., Sifre, L., and Jumper, J. Accelerating large language model decoding with speculative sampling, 2023.
285
+
286
+ Cho, M., Vahid, K. A., Fu, Q., Adya, S., Mundo, C. C. D., Rastegari, M., Naik, D., and Zatloukal, P. edkm: An efficient and accurate train-time weight clustering for large language models. 2023.
287
+ Dao, T., Fu, D. Y., Ermon, S., Rudra, A., and Ré, C. Flashattention: Fast and memory-efficient exact attention with io-awareness. Advances in Neural Information Processing Systems, 2022.
288
+ Dong, Q., Li, L., Dai, D., Zheng, C., Wu, Z., Chang, B., Sun, X., Xu, J., Li, L., and Sui, Z. A survey on in-context learning, 2023.
289
+ Frantar, E., Ashkboos, S., Hoefler, T., and Alistarh, D. GPTQ: Accurate Post-Training Quantization for Generative Pre-trained Transformers. In arXiv, 2023.
290
+ Huang, Y., Cheng, Y., Bapna, A., First, O., Chen, M. X., Chen, D., Lee, H., Ngiam, J., Le, Q. V., Wu, Y., and Chen, Z. Gpipe: Efficient training of giant neural networks using pipeline parallelism. In Advances in Neural Information Processing Systems, 2019.
291
+ HuggingFace-TensorParallelism. https://huggingface.co/docs/transformers/v4.15.0/parallelism#tensor-parallelism.
292
+ HuggingFace-Transformers. https://huggingface.co/docs/transformers/main_classess/output.
293
+ Korthikanti, V., Casper, J., Lym, S., McAfee, L., Andersch, M., Shoeybi, M., and Catanzaro, B. Reducing activation recomputation in large transformer models, 2022.
294
+ Kwon, W., Li, Z., Zhuang, S., Sheng, Y., Zheng, L., Yu, C. H., Gonzalez, J. E., Zhang, H., and Stoica, I. Efficient memory management for large language model serving with pagedattention, 2023.
295
+
296
+ Leviathan, Y., Kalman, M., and Matias, Y. Fast inference from transformers via speculative decoding. In International Conference on Machine Learning, 2023.
297
+ Li, S., Xue, F., Baranwal, C., Li, Y., and You, Y. Sequence parallelism: Long sequence training from system perspective. In Association for Computational Linguistics (ACL), 2023.
298
+ Lin, B., Peng, T., Zhang, C., Sun, M., Li, L., Zhao, H., Xiao, W., Xu, Q., Qiu, X., Li, S., Ji, Z., Li, Y., and Lin, W. Infinite-llm: Efficient llm service for long context with distattention and distributed kvcache, 2024.
299
+ Lin, J., Tang, J., Tang, H., Yang, S., Dang, X., and Han, S. AWQ: Activation-aware Weight Quantization for LLM Compression and Acceleration. arXiv, 2023.
300
+ Liu, Y., Li, H., Du, K., Yao, J., Cheng, Y., Huang, Y., Lu, S., Maire, M., Hoffmann, H., Holtzman, A., Ananthanarayanan, G., and Jiang, J. Cachegen: Fast context loading for language model applications, 2023a.
301
+ Liu, Z., Oguz, B., Zhao, C., Chang, E., Stock, P., Mehdad, Y., Shi, Y., Krishnamoorthi, R., and Chandra, V. LLM-QAT: Data-Free Quantization Aware Training for Large Language Models. arXiv, 2023b.
302
+ Narayanan, D., Phanishayee, A., Shi, K., Chen, X., and Zaharia, M. Memory-efficient pipeline-parallel dnn training. In International Conference on Machine Learning, 2021a.
303
+ Narayanan, D., Shoeybi, M., Casper, J., LeGresley, P., Patwary, M., Korthikanti, V. A., Vainbrand, D., Kashinkunti, P., Bernauer, J., Catanzaro, B., Phanishayee, A., and Zaharia, M. Efficient large-scale language model training ongpu clusters using megatron-lm, 2021b.
304
+ NVidia-cuBLAS. https://docs.nvidia.com/cuda/cublas/.
305
+ NVidia-LLM. https:// developer.nvidia.com/blog/ mastering-llm-techniques-inference_ optimization, 2023.
306
+ NVidia-NCCL. https://docs.nvidia.com/deeplearning/nccl/user-guide/docs/environment, 2023.
307
+ Ouyang, L., Wu, J., Jiang, X., Almeida, D., Wainwright, C. L., Mishkin, P., Zhang, C., Agarwal, S., Slama, K., Ray, A., Schulman, J., Hilton, J., Kelton, F., Miller, L., Simens, M., Askell, A., Welinder, P., Christiano, P., Leike, J., and Lowe, R. Training language models to follow instructions with human feedback. In Advances in Neural Information Processing Systems, 2022.
308
+
309
+ Park, J., Yoon, H., Ahn, D., Choi, J., and Kim, J. OPTIMUS: optimized matrix multiplication structure for transformer neural network accelerator. In Dhillon, I. S., Papailiopoulos, D. S., and Sze, V. (eds.), Proceedings of Machine Learning and Systems (MLSys), 2020.
310
+ Paszke, A., Gross, S., Massa, F., Lerer, A., Bradbury, J., Chanan, G., Killeen, T., Lin, Z., Gimelshein, N., Antiga, L., Desmaison, A., Kopf, A., Yang, E., DeVito, Z., Raison, M., Tejani, A., Chilamkurthy, S., Steiner, B., Fang, L., Bai, J., and Chintala, S. Pytorch: An imperative style, high-performance deep learning library. Advances in Neural Information Processing Systems, 2019.
311
+ Patel, P., Choukse, E., Zhang, C., Iñigo Goiri, Shah, A., Maleki, S., and Bianchini, R. Splitwise: Efficient generative llm inference using phase splitting, 2023.
312
+ Pope, R., Douglas, S., Chowdhery, A., Devlin, J., Bradbury, J., Levskaya, A., Heek, J., Xiao, K., Agrawal, S., and Dean, J. Efficiently scaling transformer inference, 2022.
313
+ Ram, O., Levine, Y., Dalmedigos, I., Muhlgay, D., Shashua, A., Leyton-Brown, K., and Shoham, Y. In-context retrieval-augmented language models, 2023.
314
+ Shoeybi, M., Patwary, M., Puri, R., LeGresley, P., Casper, J., and Catanzaro, B. Megatron-lm: Training multi-billion parameter language models using model parallelism, 2020.
315
+ Thakur, R., Rabenseifner, R., and Gropp, W. Optimization of collective communication operations in MPICH. The International Journal of High Performance Computing Applications, 19(1):49-66, 2005.
316
+ Touvron, H., Lavril, T., Izacard, G., Martinet, X., Lachaux, M.-A., Lacroix, T., Roziere, B., Goyal, N., Hambro, E., Azhar, F., Rodriguez, A., Joulin, A., Grave, E., and Lample, G. Llama: Open and efficient foundation language models. In arXiv, 2023.
317
+ Vaswani, A., Shazeer, N., Parmar, N., Uszkoreit, J., Jones, L., Gomez, A. N., Kaiser, L. u., and Polosukhin, I. Attention is all you need. In Advances in Neural Information Processing Systems, 2017.
318
+ vLLM. https://docs.vllm.ai/en/latest/.
319
+ Zhang, H., Song, H., Li, S., Zhou, M., and Song, D. A survey of controllable text generation using transformer-based pre-trained language models, 2023a.
320
+ Zhang, S., Roller, S., Goyal, N., Artetxe, M., Chen, M., Chen, S., Dewan, C., Diab, M., Li, X., Lin, X. V., Mihaylov, T., Ott, M., Shleifer, S., Shuster, K., Simig, D., Koura, P. S., Sridhar, A., Wang, T., and Zettlemoyer, L. Opt: Open pre-trained transformer language models. In arXiv, 2022a.
321
+
322
+ Zhang, T., Ladhak, F., Durmus, E., Liang, P., McKeown, K., and Hashimoto, T. B. Benchmarking large language models for news summarization, 2023b.
323
+ Zhang, Y., Liu, W., Wang, X., and Shaheer, M. A. A novel hierarchical hyper-parameter search algorithm based on greedy strategy for wind turbine fault diagnosis. Expert Systems with Applications, 202:117473, 2022b.
324
+
325
+ <table><tr><td rowspan="3">Network</td><td rowspan="3">Context Length</td><td colspan="3">4 GPUs</td><td colspan="3">8 GPUs</td></tr><tr><td colspan="3">Method</td><td colspan="3">Method</td></tr><tr><td>TSP</td><td>KVR-S</td><td>SpeedUp×</td><td>TSP</td><td>KVR-S</td><td>SpeedUp×</td></tr><tr><td rowspan="6">Llama 7B</td><td>1k</td><td>0.107</td><td>0.097</td><td>1.11</td><td>0.117</td><td>0.098</td><td>1.19</td></tr><tr><td>2k</td><td>0.111</td><td>0.100</td><td>1.11</td><td>0.117</td><td>0.103</td><td>1.14</td></tr><tr><td>4k</td><td>0.20</td><td>0.17</td><td>1.17</td><td>0.12</td><td>0.11</td><td>1.14</td></tr><tr><td>8k</td><td>0.54</td><td>0.41</td><td>1.30</td><td>0.30</td><td>0.22</td><td>1.36</td></tr><tr><td>12k</td><td>1.06</td><td>0.76</td><td>1.39</td><td>0.57</td><td>0.41</td><td>1.37</td></tr><tr><td>16k</td><td>1.76</td><td>1.24</td><td>1.42</td><td>0.92</td><td>0.65</td><td>1.41</td></tr><tr><td rowspan="6">Llama 13B</td><td>1k</td><td>0.140</td><td>0.126</td><td>1.12</td><td>0.150</td><td>0.129</td><td>1.16</td></tr><tr><td>2k</td><td>0.143</td><td>0.131</td><td>1.09</td><td>0.153</td><td>0.131</td><td>1.17</td></tr><tr><td>4k</td><td>0.32</td><td>0.29</td><td>1.12</td><td>0.19</td><td>0.16</td><td>1.17</td></tr><tr><td>8k</td><td>0.87</td><td>0.68</td><td>1.27</td><td>0.49</td><td>0.36</td><td>1.35</td></tr><tr><td>12k</td><td>1.71</td><td>1.25</td><td>1.36</td><td>0.91</td><td>0.66</td><td>1.37</td></tr><tr><td>16k</td><td>2.89</td><td>2.05</td><td>1.41</td><td>1.46</td><td>1.05</td><td>1.39</td></tr><tr><td rowspan="2">Llama 30B</td><td>1k</td><td>0.21</td><td>0.20</td><td>1.08</td><td>0.23</td><td>0.19</td><td>1.19</td></tr><tr><td>2k</td><td>0.28</td><td>0.26</td><td>1.06</td><td>0.24</td><td>0.20</td><td>1.19</td></tr><tr><td rowspan="4">Falcon 1B</td><td>1k</td><td>0.073</td><td>0.061</td><td>1.18</td><td>0.081</td><td>0.066</td><td>1.23</td></tr><tr><td>2k</td><td>0.067</td><td>0.060</td><td>1.12</td><td>0.079</td><td>0.065</td><td>1.23</td></tr><tr><td>4k</td><td>0.09</td><td>0.07</td><td>1.26</td><td>0.08</td><td>0.06</td><td>1.21</td></tr><tr><td>8k</td><td>0.25</td><td>0.19</td><td>1.28</td><td>0.15</td><td>0.10</td><td>1.58</td></tr><tr><td rowspan="4">Falcon 7B</td><td>1k</td><td>0.107</td><td>0.095</td><td>1.12</td><td>0.119</td><td>0.096</td><td>1.24</td></tr><tr><td>2k</td><td>0.117</td><td>0.103</td><td>1.13</td><td>0.118</td><td>0.099</td><td>1.20</td></tr><tr><td>4k</td><td>0.28</td><td>0.21</td><td>1.30</td><td>0.18</td><td>0.12</td><td>1.47</td></tr><tr><td>8k</td><td>0.78</td><td>0.54</td><td>1.46</td><td>0.47</td><td>0.29</td><td>1.63</td></tr></table>
326
+
327
+ Table 1. Top-1 accuracy with ImageNet1k: KV-Runahead outperforms other schemes with various pruning rates.
328
+
329
+ # A. Additional Experiments
330
+
331
+ In this section, we present additional results with a wider range of LLMs using both long and short contexts to confirm that KV-Runahead will generalize well across a broader spectrum of LLMs. We experimented with Falcon 1B, Llama 13B, and Llama 30B, (in addition to Llama 7B and Falcon-7B from Section 5) and summarize the results in Table 1 where we can observe the followings:
332
+
333
+ - KVR-S consistently outperforms TSP for all cases across 4 and 8 GPUs over high bandwidth network.
334
+ - The speedup from KVR-S is less with shorter inputs (as attention is less bottlenecked).
335
+
336
+ Also, we tested Llama 7B with Multi-Query-Attention (MQA) and Group-Query-Attention (GQA) (Ainslie et al., 2023) over high bandwidth network and report the results in Table 2. MQA and GQA (Ainslie et al., 2023) are techniques to share keys and values among queries so that the attention part can be computationally more efficient. Accordingly, $(K,V)$ projection computation costs will be reduced for TSP and KVR, benefiting both. In detail, TSP has lower communication costs as it has a fewer K and V matrices to all_gather, and KVR will have lower communication costs with MQA or GQA, as it leads a smaller $(K,V)$ cache.
337
+
338
+ Compared with Multi-Head-Attention cases from Fig. 8 (b-c), overall GQA8 and MQA reduce the TTFT universally. For example, the speedup is as large as $1.22\mathrm{x}$ with MQA. KVR demonstrates marginally better speedup gains over TSP with GQA8 and MQA than with MHA. For the example of 8GPU and 16k context, the speedup over TSP was $1.41\mathrm{x}$ with MHA (see Fig. 8 (c)), but it becomes $1.48\mathrm{x}$ with MQA and $1.46\mathrm{x}$ with GQA.
339
+
340
+ # B. Parallel Inference Benefits
341
+
342
+ The benefit of parallel LLM inference depends on the input context size (which determines the parallelization gain) and the network bandwidth (which determines the parallelization cost). To understand when KVR (i.e., parallel LLM inference in
343
+
344
+ <table><tr><td rowspan="3">Network</td><td rowspan="3">Context Length</td><td colspan="3">4 GPUs</td><td colspan="3">8 GPUs</td></tr><tr><td colspan="3">Method</td><td colspan="3">Method</td></tr><tr><td>TSP</td><td>KVR-S</td><td>SpeedUp×</td><td>TSP</td><td>KVR-S</td><td>SpeedUp×</td></tr><tr><td rowspan="6">Llama 7BMQA</td><td>1k</td><td>0.109</td><td>0.102</td><td>1.07</td><td>0.117</td><td>0.101</td><td>1.17</td></tr><tr><td>2k</td><td>0.107</td><td>0.102</td><td>1.05</td><td>0.120</td><td>0.101</td><td>1.18</td></tr><tr><td>4k</td><td>0.18</td><td>0.14</td><td>1.23</td><td>0.12</td><td>0.10</td><td>1.18</td></tr><tr><td>8k</td><td>0.49</td><td>0.37</td><td>1.33</td><td>0.26</td><td>0.18</td><td>1.44</td></tr><tr><td>12k</td><td>0.98</td><td>0.70</td><td>1.41</td><td>0.51</td><td>0.35</td><td>1.45</td></tr><tr><td>16k</td><td>1.65</td><td>1.16</td><td>1.43</td><td>0.84</td><td>0.57</td><td>1.48</td></tr><tr><td rowspan="6">Llama 7BGQA8</td><td>1k</td><td>0.112</td><td>0.102</td><td>1.10</td><td>0.119</td><td>0.101</td><td>1.18</td></tr><tr><td>2k</td><td>0.113</td><td>0.102</td><td>1.12</td><td>0.118</td><td>0.103</td><td>1.15</td></tr><tr><td>4k</td><td>0.18</td><td>0.15</td><td>1.20</td><td>0.12</td><td>0.11</td><td>1.15</td></tr><tr><td>8k</td><td>0.50</td><td>0.38</td><td>1.32</td><td>0.27</td><td>0.19</td><td>1.42</td></tr><tr><td>12k</td><td>1.00</td><td>0.72</td><td>1.39</td><td>0.52</td><td>0.36</td><td>1.42</td></tr><tr><td>16k</td><td>1.67</td><td>1.16</td><td>1.44</td><td>0.86</td><td>0.59</td><td>1.46</td></tr></table>
345
+
346
+ Table 2. Top-1 accuracy with ImageNet1k: KV-Runahead outperforms other schemes with various pruning rates.
347
+
348
+ <table><tr><td>Context</td><td>base</td><td colspan="2">10GB/s</td><td colspan="2">1GB/s</td></tr><tr><td>Length</td><td>1 GPU</td><td>2 GPU</td><td>4 GPU</td><td>2 GPU</td><td>4 GPU</td></tr><tr><td>1k</td><td>0.10</td><td>0.10</td><td>0.10</td><td>0.11</td><td>0.19</td></tr><tr><td>2k</td><td>0.24</td><td>0.16</td><td>0.19</td><td>0.21</td><td>0.35</td></tr><tr><td>4k</td><td>0.65</td><td>0.38</td><td>0.36</td><td>0.84</td><td>0.93</td></tr><tr><td>8k</td><td>1.95</td><td>0.99</td><td>0.72</td><td>1.31</td><td>2.06</td></tr><tr><td>12k</td><td>3.95</td><td>1.82</td><td>1.15</td><td>2.28</td><td>2.30</td></tr></table>
349
+
350
+ Table 3. Top-1 accuracy with ImageNet1k: KV-Runahead outperforms other schemes with various pruning rates.
351
+
352
+ <table><tr><td>method</td><td>rank/gpu</td><td>partition</td><td>size</td></tr><tr><td rowspan="4">TSP</td><td>0</td><td rowspan="4">Antibiotics are a type of medication used to treat bacterial infections</td><td>3</td></tr><tr><td>1</td><td>3</td></tr><tr><td>2</td><td>3</td></tr><tr><td>3</td><td>2</td></tr><tr><td rowspan="4">KVR</td><td>0</td><td rowspan="4">Antibiotics are a type of medication used to treat bacterial infections</td><td>5</td></tr><tr><td>1</td><td>3</td></tr><tr><td>2</td><td>2</td></tr><tr><td>3</td><td>1</td></tr></table>
353
+
354
+ Table 4. Partitioning examples for Table 5.
355
+
356
+ general) does help or does not, we experimented with Llama 7B on a low-bandwidth setup (10GB/s) and a poor-bandwidth setup (1GB/s) and report the TTFT for each case in Table 3. The bold numbers are when it is beneficial to have multi-GPU inference over single-GPU inference in terms of TTFT. One can observe the followings:
357
+
358
+ - Parallel inference is helpful only when the bandwidth is good enough OR the input context is long enough. For example, the bold numbers which indicate when it is beneficial to have multi-GPU inference over single-GPU inference in terms of TTFT form a lower triangle in the table.
359
+ - Even for parallel inference, when the bandwidth is not high enough, using more GPUs is not always helping. For the example of 2K input and 10GB/s, TTFT is 0.16sec with 2GPUs, but it gets worse into 0.19sec with 4GPUs. Such a degradation is more pronounced with 1GB/s network.
360
+
361
+ All above imply that for a given the infrastructure bandwidth, the optimal system for LLM inference can be determined based on the input size distribution of the target application. A user request needs to dynamically be assigned to a system
362
+
363
+ input = ‘Antibiotics are a type of medication used to treat bacterial infections’
364
+
365
+ ```txt
366
+ if method $= =$ 'tsp': context $=$ even_context_partitioning(input,rank,world_size) elif method $= =$ 'kvr': context $=$ kva_context_partitioning(input,rank,world_size) else: context $=$ input
367
+ ```
368
+
369
+ def forward(context, mask, rank, world_size, method, KV_cache=None):
370
+
371
+ ```txt
372
+ if method $= =$ kvr' and rank $>0$ KV_cache $\equiv$ net_recv (rank-1)
373
+ if method $= =$ 'tsp': Q $\equiv$ q.protoj(context) local_K $\equiv$ k.protoj(context) local_V $\equiv$ v.protoj(context) K, V $\equiv$ net_all_gather(local_K,local_V)
374
+ else: #kvr,base Q $\equiv$ q.protoj(context) K $\equiv$ k.protoj(context) V $\equiv$ v.protoj(context)
375
+ ```
376
+
377
+ ```txt
378
+ if KV_cache: $\mathrm{K} = \mathrm{cat(KV\_cache[0],K)}$ $\mathrm{V} = \mathrm{cat(KV\_cache[1],V)}$
379
+ ```
380
+
381
+ ```c
382
+ KV_cache $=$ stack(K,V)
383
+ if method $\equiv =$ kvr' and rank $<$ world_size-1: net_send(KV_cache,rank+1)
384
+ attnweights $=$ softmax(matmul(Q,K.T)+mask)
385
+ attn_output $=$ matmul(atanweights,V)
386
+ attn_output $=$ oProj(atan_output)
387
+ return atan_output,KV_cache
388
+ ```
389
+
390
+ Table 5. Simplified Pseudo Code with KV-Runahead Integration
391
+
392
+ with the right number of GPUs based on the optimization metric (i.e., cost, latency, utilization, and so on).
393
+
394
+ # C. Pseudo Code and Example
395
+
396
+ Table 5 shows the simplified pseudo code for KV-Runahead integration into an existing transformer implementation, which also contrasts it with TSP. Table 4 illustrates one plausible partitioning with TSP and KVR for the example in Table 5, underscoring its difference from TSP.
397
+
398
+ # D. Lookup Table Generation Overhead
399
+
400
+ We analytically derive the cost to precompute a partitioning lookup table (which is a one-time job). Let us assume that there are $N$ GPUs and a $C$ context with size, and we will pick a stride size at each level such that there are 5 values to check for
401
+
402
+ each as shown in Figure 6. Let the time taken for each forward pass to measure TTFT be $T$ .
403
+
404
+ At each level, there are $(N - 1)^{5}$ combinations to evaluate. Once the best combination is picked, we can zoom in and repeat the evaluation for $log_{5-1}C$ levels. Therefore, the time taken to precompute the lookup table will be $T(N - 1)^{5}\log_{5-1}C$ .
405
+
406
+ For instance, if we assume $T = 1$ sec, $N = 8$ , and $C = 16k$ for the case in Fig. 8 (c), it would take approximately 33 hours for an entry. Moreover, each entry can be searched for in parallel, if more GPUs are available. In practice, after a few entries, we can seed the search from the interpolated context partitioning with limited scopes for the expedition.
2024/KV-Runahead_ Scalable Causal LLM Inference by Parallel Key-Value Cache Generation/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ee9d5f1d336c418693cb6e89992bd213499908ad16512c1418894898d8525a96
3
+ size 934151
2024/KV-Runahead_ Scalable Causal LLM Inference by Parallel Key-Value Cache Generation/layout.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/Keep the Momentum_ Conservation Laws beyond Euclidean Gradient Flows/0f5417c5-1d82-4164-a466-68fd918679dd_content_list.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/Keep the Momentum_ Conservation Laws beyond Euclidean Gradient Flows/0f5417c5-1d82-4164-a466-68fd918679dd_model.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/Keep the Momentum_ Conservation Laws beyond Euclidean Gradient Flows/0f5417c5-1d82-4164-a466-68fd918679dd_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:89578af61c359d0def82728068821cdb9635ec6a4f2a63b476ae3ccf5f7ff1a6
3
+ size 859328
2024/Keep the Momentum_ Conservation Laws beyond Euclidean Gradient Flows/full.md ADDED
The diff for this file is too large to render. See raw diff
 
2024/Keep the Momentum_ Conservation Laws beyond Euclidean Gradient Flows/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fa96321944792400a5164fbb15f096e827089cc3fb55d269986ada8556e6c414
3
+ size 1234866
2024/Keep the Momentum_ Conservation Laws beyond Euclidean Gradient Flows/layout.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/Kepler codebook/ff7aa711-f0cd-4fe1-9c46-7fb24d4e745b_content_list.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/Kepler codebook/ff7aa711-f0cd-4fe1-9c46-7fb24d4e745b_model.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/Kepler codebook/ff7aa711-f0cd-4fe1-9c46-7fb24d4e745b_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:261715271b1405ccb93b54b7c6cc8d4b394c32a5d36913ca195c1d559c552d4d
3
+ size 7418832
2024/Kepler codebook/full.md ADDED
@@ -0,0 +1,544 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Junrong Lian $^{*1}$ Ziyue Dong $^{*2}$ Pengxu Wei $^{1}$ Wei Ke $^{2}$ Chang Liu $^{3}$ Qixiang Ye $^{4}$ Xiangyang Ji $^{3}$ Liang Lin $^{15}$
2
+
3
+ # Abstract
4
+
5
+ A codebook designed for learning discrete distributions in latent space has demonstrated state-of-the-art results on generation tasks. This inspires us to explore what distribution of codebook is better. Following the spirit of Kepler's Conjecture, we cast the codebook training as solving the sphere packing problem and derive a Kepler codebook with a compact and structured distribution to obtain a codebook for image representations. Furthermore, we implement the Kepler codebook training by simply employing this derived distribution as regularization and using the codebook partition method. We conduct extensive experiments to evaluate our trained codebook for image reconstruction and generation on natural and human face datasets, respectively, achieving significant performance improvement. Besides, our Kepler codebook has demonstrated superior performance when evaluated across datasets and even for reconstructing images with different resolutions. Codes and pre-trained weights are available at https://github.com/banianrong/KeplerCodebook.
6
+
7
+ # 1. Introduction
8
+
9
+ Vector quantization (VQ) (Gray, 1984) is a foundational algorithm in the field of machine learning, extensively utilized in deep learning for various domains including audio (Baevski et al., 2019; Wang et al., 2021; Wu et al., 2020), language (Roy & Grangier, 2019; Chen et al., 2023) and vision tasks (Van Den Oord et al., 2017; Razavi et al., 2019; Esser et al., 2021). Among these, its application in image generation/synthesis has been particularly notable in recent years, especially with the prevalence of pre-quantizing images into discrete latent variables and modeling them autoregressively, e.g., VQVAE (Van Den Oord et al., 2017), DALL-E (Ramesh et al., 2021a), VQGAN (Esser et al., 2021), and ViT-VQGAN (Yu et al., 2021). Those approaches follow a two-stage generation routine, including a codebook learning by image quantization for image reconstruction in the first stage and vector-quantized image modeling based on the learned codebook for image generation in the second stage.
10
+
11
+ Nevertheless, codebook learning always bears the brunt
12
+
13
+ (a) Initialization
14
+ ![](images/3972b094f1e01f1decfac89d43902b848411705233040b41e56b7c07bc00abe8.jpg)
15
+ Figure 1. Codebook distribution. Tokens are denoted by dots. The codebook is initialized with uniform distribution (a). After training, VAGAN and Reg-VQ maintain unordered in (b) and (c), impairing their performance in reconstructing and generating images. Our Kepler codebook with an ordered and compact distribution (d).
16
+
17
+ ![](images/9d5a8c20a847d503c79724dfb1d6073583751ad751ca7429da04911ac15fde41.jpg)
18
+ (b) VQGAN
19
+
20
+ ![](images/7e8d5f684a66d0147a016ffcc1e4fa61114d60b82844f5e3d8ebc95e59fbe9cd.jpg)
21
+ (c) Reg-VQ
22
+
23
+ ![](images/2f26d39ad0b7ce05fa15aa95de4e330b4d412f0f224bc273b7c8ff59945fcd29.jpg)
24
+ (d) Ours
25
+
26
+ of codebook collapse (Yu et al., 2021; Zhang et al., 2023; Ramesh et al., 2021a), indicating that a large portion of tokens in a learned codebook have not been fully used with a rather low codebook usage $^{1}$ (Yu et al., 2021; Zhang et al., 2023), e.g., $35.9\%$ for VQGAN, shown in Fig. 2. This raises an issue: for a learned codebook, its low codebook usage is bad for image reconstruction. Subsequently, several methods have been proposed to address this issue. One effective method is the application of Gumbel-Softmax (Jang et al., 2016; Ramesh et al., 2021b), which employs stochastic quantization by random sampling to select a token from a predicted token distribution. Reg-VQ (Zhang et al., 2023) uses a stochastic mask regularization to balance VQGAN and Gumbel-VQ quantization method. However, this apparent improvement in codebook usage is affected by stochastic quantization, which essentially leads to unreliable training with limited quality of reconstructed images and generalization of image representation. This raises another issue: higher codebook usage does not promise an excellent reconstruction capability. For instance, in Fig. 2, Reg-VQ has a higher codebook usage, but its active frequency variance $^{2}$ , is
27
+
28
+ $^{*}$ Equal contribution $^{1}$ School of Computer Science and Engineering, Sun Yat-sen University, Guangzhou, China $^{2}$ School of Software Engineering, Xi'an Jiaotong University, Xi'an, China $^{3}$ Department of Automation, Tsinghua University, Beijing, China $^{4}$ School of Electronic, Electrical and Communication Engineering, University of Chinese Academy of Sciences, Beijing, China $^{5}$ Peng Cheng Laboratory, Shenzhen, China. Correspondence to: Pengxu Wei <weipx3@mail.sysu.edu.cn>.
29
+
30
+ Proceedings of the $41^{st}$ International Conference on Machine Learning, Vienna, Austria. PMLR 235, 2024. Copyright 2024 by the author(s).
31
+
32
+ 1. "Codebook usage" means the percentage of how many tokens in a codebook are used for image reconstruction.
33
+ 2. Active frequency variance measures the difference indicator
34
+
35
+ ![](images/04dc2d9e5f37e24639c68a13bb614881c90583208e2d3628d7f994a23065a0b3.jpg)
36
+ Figure 2. The codebook usage, active frequency variance, and active rate statistics of tokens for different models trained on ADE20K. Those models are trained with the same epochs for statistic comparison. VQGAN focuses on a very limited number of tokens that have been trained many times with a high active rate, and thus it has a low codebook usage (35.9%) and high active frequency variance. Even though Reg-VQ has a high codebook usage (87.6%) and declines the active frequency variance, it still exhibits a training bias to some tokens trained many times, but some tokens have not trained. Instead, our Kepler codebook tends to a balanced training for each token; thus it significantly improves the codebook usage to 100% and remarkably declines the active frequency variance.
37
+
38
+ ![](images/f4b343b3c4d3116576004aa2ef982590c46b6e2055e7949406666698c932df1a.jpg)
39
+
40
+ ![](images/2ab9ecb4436b1f0db7417e92cbe767aa7771c9e1574146b6c12d52c542e6d626.jpg)
41
+
42
+ ![](images/f8c6e952f1fcbfea7eb3312e87e7b83f94f5e19a26e311aae39afd420abfad0f.jpg)
43
+ Figure 3. The active tokens are highlighted for image reconstruction in the whole token embedding space (t-SNE). One dot denotes one token in a trained codebook. Take one image for example: for reconstructing an image in a street scene, active tokens are in yellow; not-used (i.e., dead) tokens are in gray. VQGAN and Reg-VQ utilize a rather smaller part of tokens than our method to reconstruct images. Thus, they possibly fail to exploit the VQ representations to produce more image details effectively, and thus the quality of their reconstructed images is negatively influenced.
44
+
45
+ also large, indicating that their tokens are not well-balanced for training. Thus, a small part of tokens are used to reconstruct images, and its reconstructed images present limited texture details and even obvious artifacts, as shown in Fig. 3. This possibly causes a limited codebook generalization, extending it to other datasets.
46
+
47
+ The above problems are relevant to the distribution of the codebook, as shown in Fig. 1. In VQGAN, during early training, only the tokens closest to the feature will be activated. As the update progresses, this small subset of tokens gradually drifts from the center of the initial distribution, leading to low usage, distorted structure, and many wrong details. Reg-VQ regularizes the training process with a uniform distribution to make all tokens be used uniformly. Despite most tokens being activated, Reg-VQ still favors certain tokens to an extreme, potentially leading to high active frequency variance, obvious artifacts (e.g., duplicate wall textures), and limited codebook generalization. In Fig. 3, the codebook distributions of both VQGAN and Reg-VQ show a disordered pattern. This implies that certain tokens used in almost every reconstruction may represent multiple different features, leading to artifacts and inaccurate details in reconstruction.
48
+
49
+ To address the aforementioned issues, we propose developing a compact and structured codebook for improving discrete representation. This approach draws inspiration from Kepler's Conjecture, suggesting that codebook training can be likened to solving a sphere packing problem. Building on two key preconditions, we argue that the compact and structured distribution can be effectively modeled
50
+
51
+ by the Irwin-Hall distribution (Hall, 1927). This is a probability distribution for a random variable defined as the sum of many independent random variables, each having a uniform distribution. Using Irwin-Hall distribution as the ideal prior, we apply it to regularize the codebook's posterior distribution via KL divergence. Based on the preconditions, we further argue that the distribution of each dimension within the codebook follows the independent and identically distributed (i.i.d.) distribution. Consequently, we group the encoder tokens, called codebook partition, to simplify the complex dense distribution. This allows the codebook to better capture the distribution, thus improving the ability of reconstruction and generalization. Moreover, we conduct reconstruction and generation experiments on the ADE20K and CelebA-HQ datasets and obtain superior performance. We additionally perform cross-domain experiments on three other datasets to validate our model's generalization and downstream super-resolution based on the latent diffusion model on DRealSR dataset.
52
+
53
+ In a nutshell, our contributions are summarized below:
54
+
55
+ - Following the spirit of Kepler's Conjecture, we propose to combine codebook training with solving the sphere packing problem. We introduce the Kepler codebook, which features a compact and structured distribution, to achieve enhanced discrete representation.
56
+
57
+ - We employ the derived Irwin-Hall distribution to regularize the codebook optimization process and propose a codebook partitioning method to reduce the codebook distribution's complexity. These two strategies effectively restructure the codebook distribution, improving the codebook usage and decreasing the active frequency variance with balanced codebook training.
58
+ - Comprehensive experiments have demonstrated the superiority of our method in reconstruction, generation, cross-domain reconstruction, and downstream superresolution tasks.
59
+
60
+ # 2. Related Work
61
+
62
+ # 2.1. Tokenized Image Synthesis
63
+
64
+ Many prevailing approaches for learning discrete representations employ VQ-based methodologies, typically following a two-step training procedure. The first step trains a well-structured codebook, considered as a discrete representation. In the second step, networks are trained to predict token indices to approximate this discrete space. VQ-VAE (Van Den Oord et al., 2017) initially demonstrated strong generation capabilities with PixelCNN (Van Den Oord et al., 2016), while VQGAN (Esser et al., 2021) later excelled at synthesizing high-resolution images using auto-regressive transformers. ViT-VQGAN (Yu et al., 2021) improved the tokenization phase by introducing a VIT-based (Dosovitskiy et al., 2020) encoder-decoder setup. RQ-VAE (Lee et al., 2022) made the code sequence more manageable by encoding images as discrete stack sequences. DQ-VAE (Huang et al., 2023) generated images progressively by assigning varying code lengths to different parts of the image. HQ-VAE (You et al., 2022) used a two-tiered discrete coding approach with differing spatial resolutions. In contrast to adding complexity to network architectures, our work concentrates on refining the codebook itself. We aim to heighten reconstruction quality by optimizing codebook usage and attaining a more condensed distribution.
65
+
66
+ # 2.2. Codebook Usage Optimization
67
+
68
+ There have been several methods to improve codebook usage by various ideas. VQGAN (Van Den Oord et al., 2017; Esser et al., 2021) with narrow interval codebook initialization and without regularization often leaves many tokens untrained throughout the training process, resulting in their usage falling below $40\%$ . In ViT-VQGAN (Yu et al., 2021), factorized codes and L2-norm are used to enhance codebook usage. Reg-VQ (Zhang et al., 2023) combines deterministic and stochastic quantization to activate tokens via Gumbel sampling. Additionally, HVQ-VAE (Williams et al., 2020) and Jukebox (Dhariwal et al., 2020) implement codebook reset strategies, randomly re-initializing unused
69
+
70
+ or low-used codebook tokens. Building upon the concept, CVQ-VAE (Zheng & Vedaldi, 2023) further refines the approach by clustering anchors online to unoptimized tokens, thereby waking up inactive tokens. However, these methods do not answer what a good codebook distribution looks like. Following the spirit of Kepler's Conjecture, we propose a solution involving a compact and ordered distribution to tackle these challenges effectively.
71
+
72
+ # 3. Kepler Codebook
73
+
74
+ As outlined in Sec. 1, two primary concerns on codebook training pose significant challenges: 1) a learned codebook often exhibits low codebook usage, which is detrimental to image reconstruction; 2) even a higher codebook usage does not necessarily guarantee superior reconstruction capability. Those two issues would result in low-quality image reconstruction and limited codebook generalization. Thus, it is essential to investigate the characteristics of an effective codebook and the optimal methods to train such a codebook. In our study, we attempt to address this question by deriving the structure and distribution of the codebook for its training.
75
+
76
+ # 3.1. Codebook Training is Kepler's Conjecture
77
+
78
+ Learning discrete representations is closely related to a codebook for vector quantization. Assuming the representation space is bounded, 1) a good codebook with $N$ tokens is expected, whose space spanned by all tokens is as large as possible; 2) the distance between each token is relatively far apart, resulting in a relatively balanced probability of each token being trained.
79
+
80
+ With both preconditions, we will derive the distribution or structure of the codebook. In particular, to ensure as identical training as possible for each token, it can be cast as a problem of codebook token packing, inspired by Kepler's Conjecture (Kepler, 1966), which was proposed to exploit the problem of the sphere packing problem. Thus, we specifically establish our strategy of codebook training, following two principles of Kepler's Conjecture (Hales, 1998).
81
+
82
+ Formally, a codebook is denoted as $\mathcal{Z} = \{z_k\}_{k=1}^K \subset \mathbb{R}^{n_z}$ , consisting of $K$ tokens in $n_z$ dimensions. For an image $x \in \mathbb{R}^{H \times W \times 3}$ , it is represented by a set of codebook entries $z_q \in \mathbb{R}^{h \times w \times n_z}$ , where $(h, w) = (H/f, W/f)$ , and $f$ is the down-sampling factor. In line with the VQGAN model, the codebook is learned via a convolutional model comprised of an encoder $E$ and a decoder $D$ . During training, a given image $x$ is approximated into $\hat{x} = D(z_q)$ for image reconstruction. This process is subject to two preconditions aforementioned, which are elaborated as follows.
83
+
84
+ 1) Making the space spanned by all the tokens as large
85
+
86
+ as possible, indicating that a token $z_{q} \in \mathbb{R}^{h \times w \times n_{z}}$ in the codebook should cover continuous latent space $\hat{z}_{q} = E(x) \in \mathbb{R}^{h \times w \times n_{z}}$ as extensively as possible. $|\hat{z}|$ is the size of the continuous latent space $\hat{z}_{q}$ .
87
+
88
+ 2) Making the distance between each token in the codebook relatively far, indicating maximizing the minimum of $d_{i}$ , i.e., $\max_{d_i} \min_{i} d_i$ . $d_{i}$ is the minimum distance between the $i$ -th token and all the other tokens.
89
+
90
+ Lemma 1. Considering that a token vector $z_{k}$ is in the rational number field, according to the countability of rational numbers (Sagan, 1991), there exists a set of basis vector (a.k.a., basis matrix) $B$ that satisfies $z_{k} = Bm$ , where the $n_{z}$ -dimensional vector $m$ denotes integral coefficients.
91
+
92
+ Based on Lemma 1, we reformulate the codebook $\mathcal{Z}$ by a basis matrix $B = \{b_k\}_{k=1}^{n_z} \subset \mathbb{R}^{n_z}$ , where $b_k$ is a basis vector. That is, each token vector can be represented by this basis matrix $B$ . The spanned space of $z_k$ can be regarded as an $n_z$ -dimensional sphere with the radius $r_k$ and then its volume is in direct proportion to $r_k^{n_z}$ (its coefficient is constant for all the tokens and thus is ignored for simplicity in the following sections). The space of each token has no overlap. Accordingly, the whole volume of the spanned space by all the tokens is constrained to $|\hat{z}|$ , namely, $\sum_{i=1}^{K} r_i^{n_z} \leq |\hat{z}|$ . Then, based on the two preconditions, our objective of codebook training can be formally formulated as follows,
93
+
94
+ $$
95
+ \left\{ \begin{array}{c} a r g \max \min _ {i} d _ {i}, \\ s. t. \sum_ {i = 1} ^ {K} r _ {i} ^ {n _ {z}} \leq | \hat {z} |, \end{array} \right. \tag {1}
96
+ $$
97
+
98
+ Remark 1. In Equ. 1, the objective optimization for codebook training essentially follows the spirit of Kepler's Conjecture (Kepler, 1966), which indicates a problem of the closest packing of spheres to achieve the maximum packing density of spheres in $n_z$ -dimensional space.
99
+
100
+ Remark 2. With the Lagrange multiplier technique, the optimal objective is achieved when $d_{1} = d_{2} = \ldots = d_{K}$ under the condition of the spheres of two adjacent tokens being tangent. The detailed proof is given in Appendix A.1.
101
+
102
+ In this fashion, an optimally trained codebook exhibits a tight and structured distribution. Compared to the loose disorder of merely narrowing the upper and lower bounds of the initial uniform distribution in VQGAN and the disorder of Gaussian distribution initialization in Reg-VQ, this compactness is conducive to improving the usage of the codebook. At the same time, the orderliness makes the probability of each token being trained more balanced, reducing the active frequency variance.
103
+
104
+ ![](images/192947e78aa605c3391cdd1efd618546accb8b962a1706080e8b18355fa124a4.jpg)
105
+ (a) Token Space
106
+ Figure 4. (a) The distance between two tokens. The grey area represents the token space, which can be approximately measured by the number of fundamental domains it occupies. (b)-(c) Visualization for a two-dimensional solution for Equ. 1. A dark black point represents a token and the grey area represents the corresponding spanned space of each token. (b) illustrates a feasible solution, where the space of all tokens is small and the minimum distance between some tokens is close. This does not meet two of our preconditions. (c) illustrates the optimal solution, where each token is relatively far and the space of all tokens is large. This presents the compact and ordered properties.
107
+
108
+ ![](images/e1e1cb520b3b6bf2b60544bc94d25b46db596c40ecd694661adb58aaf7f67172.jpg)
109
+ (b)Feasible Solution
110
+
111
+ ![](images/1daa302c632b240ba513064dc0b660289e2578bc776aa09cc02bbb9633440c9b.jpg)
112
+ (c) Optimal Solution
113
+
114
+ # 3.2. Hexagonal Distribution for Codebook
115
+
116
+ Based on the analyses in Sec. 3.1, training a good codebook problem is regarded as the sphere packing problem in Kepler's Conjecture. The sphere packing problem considers different distributions of equal spheres in the space. Its target is to maximize the packing density of packing spheres (Hales, 1998; Bernal, 1959). This just indicates that an optimal codebook has tokens with identical distances to the nearest token, but does not suggest the specific distribution of the codebook. In this part, we will explore this issue based on Kepler's Conjecture.
117
+
118
+ Remark 3. In Lemma 1, $z_{k} = Bm$ with integral items of $m$ also follows the definition of integer lattice<sup>3</sup> (Maehara, 2018), and $m$ indicates the locations in the integer lattice. Thus, we derive the codebook distribution in the integer lattice.
119
+
120
+ Specifically, in Kepler's Conjecture, the packing density is the ratio between the volume of spheres and the volume of total space. Similarly, we denote the codebook (token) density as $\eta$ , measuring the ratio between the token space and the fundamental domain (Beardon, 1983) in the integer lattice. Thus, training a good codebook equals maximizing $\eta$ . $\eta$ is defined as
121
+
122
+ $$
123
+ \eta = \frac {\pi^ {\frac {n _ {z}}{2}}}{\Gamma \left(\frac {n _ {z}}{2} + 1\right)} \cdot \frac {\sum_ {i = 1} ^ {K} r _ {i} ^ {n _ {z}}}{K \det (B)} \tag {2}
124
+ $$
125
+
126
+ where $\operatorname{det}(B)$ is the volume of a fundamental domain of $B$ . However, this is an NP-hard problem, and it's intractable to optimize this objective directly. In our work, we relax the
127
+
128
+ ![](images/96663668b0904a298d74c2b4f69400944718a4b7afb9f8669d7f33c2a3e8e237.jpg)
129
+ (a)
130
+
131
+ ![](images/5dd73027ac694ed16a70e055828f91757de8ee3590d61ec1d5a532a8b6be6e0e.jpg)
132
+ (b)
133
+ Figure 5. Kepler codebook in the 2D (a) and 3D (b) space.
134
+
135
+ original problem to maximize $\eta$ with a constraint that the angle between any two basis vectors in $B$ is equal. Specifically, we can build the codebook structure $B$ as follows:
136
+
137
+ $$
138
+ \left\{ \begin{array}{l l} b _ {1} = (1, 0, 0, \dots , 0), \| b _ {i} \| = 1 & (i) \\ b _ {i} \cdot b _ {i - 1} = \cos \theta & (i i) \\ b _ {i, j} = b _ {i - 1, j} (1 \leq j \leq i - 2, i \geq 3) & (i i i) \end{array} \right. \tag {3}
139
+ $$
140
+
141
+ where $b_{i,j}$ is the $j$ -th element in basis vector $b_i$ , $\theta$ is the angle between two basis vectors. Rule (i) presents the initial condition and the constraint for the unit vector. Rule (ii) measures the distance between two vectors. Rule (iii) indicates starting from the $i$ -th $(i \geq 3)$ basis vector, the elements in its first $(i - 2)$ -rows must be equal to the $(i - 1)$ -th vector, to ensure that the angle between it and the previous vectors remains constant. For example, the previous third vectors of $B$ are $b_1 = (1,0,0,\dots ,0), b_2 = (\frac{1}{2},\frac{\sqrt{3}}{2},0,\dots ,0), b_3 = (\frac{1}{2},\frac{\sqrt{3}}{6},\frac{\sqrt{6}}{12},\dots ,0).$
142
+
143
+ Derived from the given codebook structure in Equ. 3, the optimization of the codebook density $\eta$ becomes the following form:
144
+
145
+ $$
146
+ \underset {\theta} {\arg \max } q ^ {n} (\theta) / \det (B), \tag {4}
147
+ $$
148
+
149
+ where $q(\theta)$ means the maximum radium of sphere in the fundamental domain (Beardon, 1983) of $B$ .
150
+
151
+ Lemma 2: When $\theta = 60^{\circ}$ , the maximum codebook density is attained. The proof is provided in the Appendix.2.
152
+
153
+ Remark 4: Based on Lemma 2, one conclusion has been drawn that the codebook structure or distribution in two-dimensional space is hexagonal. This derived codebook with the hexagonal structure or distribution is named the Kepler codebook. Fig. 5 illustrates examples of the derived structures in 2D/3D.
154
+
155
+ For a token, $z_{k} = Bm$ , $m \in \mathbb{Z}^{n_z}$ , and the $i$ -th element is calculated as $z_{ki} = \sum_{j=1}^{n_z} b_{ij} m_j$ , where for each dimension of $m$ , it can be approximated to follow $m_j \sim U$ , $i \in [1, n_z]$ . That is, the $i$ -th dimension of one token is approximately equivalent to the sum of $n_z$ independent uniform distributions since the basis matrix $B$ can be rotated that none entries in $B$ are zero, which is mathematically regarded as a Irwin-Hall distribution (Hall, 1927),
156
+
157
+ $$
158
+ z _ {k i} \sim U ^ {n _ {z}} (0, 1), \tag {5}
159
+ $$
160
+
161
+ where $U^{n_z}$ represents the sum of $n_z$ independent uniform
162
+
163
+ distributions. On one hand, every dimension $z_{ki}$ of each token follows an $n_z$ -dimensional Irwin-Hall distribution as depicted in Equ. 5. On the other hand, if the distribution of each codebook token entry is $n_z$ -dimensional Irwin-Hall distribution, it will reach the previous target where making the space of all tokens larger and the distance between each token relatively further. Meanwhile, it also means the tokens in the codebook are compact and ordered, while the compact property will bring the high codebook usage potential and the ordered property will balance the train times of each token to solve the problem proposed in the title and finally improve the quality of image in both reconstruction and generalization task.
164
+
165
+ # 4. Kepler Codebook Training
166
+
167
+ # 4.1. Irwin-Hall Distribution Regularization
168
+
169
+ In Sec. 3.2, we conclude that each dimension of every token conforms to independent and identical $n_z$ -dimensional Irwin-Hall distribution. Thus, we follow the principle of the Kepler codebook and propose an Irwin-Hall Distribution (IHD) regularization to constrain the training of the codebook. Specifically, we take the distribution of Kepler codebook as prior for codebook training. The prior distribution $P_{\mathrm{prior}} = U^{n_z}(0,1) = [p_1,p_2,\dots,p_k]$ , where $p_i$ is a vector sampled from $n_z$ -dimensional Irwin-Hall distribution, is utilized to regularize the vector quantization. The posterior distribution can be approximated $P_{\mathrm{post}} = [z_1,z_2,\dots,z_K]$ . Accordingly, our Irwin-Hall distribution regularization is calculated by the distance between the prior and the predicted codebook distribution, to constrain the codebook training. It aims to facilitate the model to learn a compact codebook space with ordered token distribution to improve codebook usage and balance the training for each token. With the Kullback-Leibler (KL) divergence as the distance measure, it is defined as follows,
170
+
171
+ $$
172
+ \mathcal {L} _ {\mathrm {I H D}} = \mathrm {K L} \left(P _ {\text {p o s t}}, P _ {\text {p r i o r}}\right) = - \sum_ {i = 1} ^ {K} p _ {i} \log \frac {z _ {i}}{p _ {i}}. \tag {6}
173
+ $$
174
+
175
+ # 4.2. Codebook Partition
176
+
177
+ Due to the curse of dimensionality, the token distribution in the codebook becomes sparse, which can lead to inaccurate probability distribution estimation and then make it hard to calculate accurately the KL divergence in Equ. 6. Thus, we aim to obtain a lower-dimensional codebook distribution to reduce training complexity, by partitioning the encoder output and then quantifying the elements within each partition. This partitioning strategy is supported by the conclusion that every dimension of tokens conforms to Equ. 5 in an independent identical distribution. Precisely, we can shuffle the encoder output $\hat{z}_q$ to low dimension $\hat{z}_q / d$ , where $d$ is the number of partitions in the quantization process, and then unshuffle to $z_q$ for decoder to reconstruct the image.
178
+
179
+ Table 1. Quantitative comparison of image reconstruction and generation tasks with VQGAN (Esser et al., 2021), Reg-VQ (Zhang et al., 2023), FSQ (Mentzer et al., 2023) on the ADE20K and CelebA-HQ datasets. The notation [R] and [G] indicate whether the metric is for image reconstruction or generation.
180
+
181
+ <table><tr><td rowspan="2">Method</td><td colspan="3">ADE20K</td><td colspan="3">CelebA-HQ</td></tr><tr><td>PSNR[R]↑</td><td>rFID[R]↓</td><td>FID[G]↓</td><td>PSNR[R]↑</td><td>rFID[R]↓</td><td>FID[G]↓</td></tr><tr><td>VQ-VAE</td><td>19.95</td><td>49.21</td><td>60.29</td><td>23.39</td><td>28.38</td><td>39.57</td></tr><tr><td>VQGAN</td><td>18.89</td><td>28.17</td><td>38.53</td><td>22.44</td><td>12.74</td><td>17.42</td></tr><tr><td>Reg-VQ</td><td>18.44</td><td>23.69</td><td>34.47</td><td>22.05</td><td>10.09</td><td>15.34</td></tr><tr><td>FSQ</td><td>20.31</td><td>18.30</td><td>35.03</td><td>-</td><td>-</td><td>-</td></tr><tr><td>Ours</td><td>21.34</td><td>16.87</td><td>33.84</td><td>24.85</td><td>8.59</td><td>14.96</td></tr></table>
182
+
183
+ Table 2. Ablation study for our proposed method on ADE20K. The codebook partition number is $d = 4$ . $n_z$ is the codebook dimension. The codebook vector number $K$ is set as 1024 in all experiments.
184
+
185
+ <table><tr><td>Method</td><td>d</td><td>nz</td><td>rFID↓</td><td>usage↑</td></tr><tr><td>Baseline (VQGAN)</td><td>1</td><td>256</td><td>28.17</td><td>35%</td></tr><tr><td>+ IHD</td><td>1</td><td>256</td><td>26.28</td><td>40%</td></tr><tr><td>+ Partition</td><td>4</td><td>64</td><td>19.34</td><td>100%</td></tr><tr><td>+ IHD&amp;Partition (Ours)</td><td>4</td><td>64</td><td>16.87</td><td>100%</td></tr></table>
186
+
187
+ For its implementation, VQ-GAN flattens the encoder output $\hat{z}_q$ to $hw \times n_z$ for quantization, while we reshape it to $hwd \times n_z / d$ . Correspondingly, the dimension of the codebook $n_z$ reduces to $n_z / d$ to mitigate the effects of the curse of dimensionality. After quantization, the flattened $z_q$ is reshaped back to $h \times w \times n_z$ . This ensures 0 dimension consistency in the network between the output of encoder and the input of decoder, aligning with VQGAN. Similarly, this strategy can also be used in the dimension $hw$ , by flattening $hw$ to $d \times hw / d$ during the quantization process and reshaping it back to $hw$ after quantization.
188
+
189
+ # 5. Experiments
190
+
191
+ # 5.1. Experimental Settings
192
+
193
+ Datasets. For empirical comparison with existing methods, we conduct the codebook training on ADE20K (Zhou et al., 2017) and CelebA-HQ (Liu et al., 2015) datasets, respectively, in two tasks of image reconstruction and semantic image synthesis. The evaluation results are reported on the validation sets of these two datasets, respectively. To further demonstrate the generalization capabilities of our method, we extend our evaluation to cross-domain datasets, namely training on the ADE20K dataset and testing on another three datasets, MS-COCO (Lin et al., 2014), LS-DIR (Li et al., 2023), and DIV2K (Timofte et al., 2017). Additionally, we undertake a downstream application of the learned codebooks to the image super-resolution task. Specifically, we train the latent diffusion model (Rombach
194
+
195
+ et al., 2022) on a large real-world image super-resolution dataset DRealSR (Wei et al., 2020), whose autoencoder is replaced by our models trained on the ImageNet dataset.
196
+
197
+ Implementation details. Our model follows the similar architecture of VQGAN (Esser et al., 2021), which compresses $256 \times 256$ images into $16 \times 16$ tokens (where $f = 16$ ). We utilize the proposed Irwin-Hall distribution regularization for the reconstruction training to optimize the codebook, which has a $K \times n_z / d$ size. We set $d = 4$ in all experiments. All the experiments are conducted on 8 NVIDIA Tesla A100-40G GPUs. The model optimization is performed using the AdamW optimizer (Loshchilov & Hutter, 2017) with parameters $\beta_{1} = 0.9$ and $\beta_{2} = 0.95$ , and a base learning rate of $4.5 \times 10^{-6}$ . The batch size is 96 for the reconstruction and 64 for the generation. Detailed efficiency analyses can be found in the Appendix.
198
+
199
+ Metrics. In the image reconstruction and semantic image synthesis tasks, following VQGAN, we use FID (Heusel et al., 2017) and PSNR for comparison. For cross-domain evaluation and downstream application, we adopt PSNR, SSIM, LPIPS, and FID to evaluate the model's capabilities from various aspects.
200
+
201
+ # 5.2. Quantitative Evaluation
202
+
203
+ For the image reconstruction task, the experiments are conducted on the ADE20K and CelebA-HQ datasets, respectively. The comparative results are detailed in Tab. 1. It is noteworthy that our model outperforms VQ-VAE (Van Den Oord et al., 2017), VQGAN (Esser et al., 2021), and Reg-VQ (Zhang et al., 2023) by 1.39, 2.45, 2.9 dB in PSNR and by 32.34, 11.3, 6.82 in rFID on ADE20K, respectively. On CelebA-HQ, compared to VQ-VAE, VQGAN, and Reg-VQ, there is a 1.46, 2.41, 2.8 dB improvement in PSNR and 19.79, 4.15, 1.5 performance gains in rFID. Besides, the comparison with the state-of-the-art method, FSQ, In comparison with FSQ (Mentzer et al., 2023) trained from scratch on ADE20K using its official codes, our method outperforms FSQ by 1.03 dB in PSNR and 1.43 in rFID. These significant performance improvements demonstrate that our model performs better than existing works, i.e., VQ-VAE, VQGAN and Reg-VQ, on two different datasets. One main difference between our method and those existing works is the introduction of IHD regulation for the codebook training. Thus, these improvements can be attributed to the consideration of the codebook distribution, which is vital for effectively reconstructing image details and reducing artifacts.
204
+
205
+ For the semantic image synthesis task, the experimental results on ADE20K and CelebA-HQ datasets are provided in Tab. 1. Our model also achieves a remarkable improvement on these two different datasets. For example, in comparison with VQ-VAE, VQGAN, and Reg-VQ, our model
206
+
207
+ ![](images/c30f4b2565051e3d0c2759fdfa13cd8b1b9349b562bc22dfae52227c8d09fc5d.jpg)
208
+ Figure 6. Reconstruction results on ADE20K and CelebA-HQ from different models.
209
+
210
+ ![](images/646b2afa7ea32f7286d1c17c75599110f4b8d0549f0330ac2d36c7a722b406ae.jpg)
211
+ Figure 7. Semantic segmentation synthesis on ADE20K and CelebA-HQ. The semantic segmentation map in the first column is the condition for generation.
212
+
213
+ ![](images/9021048afc1b53be85b51a4f63bd6ac67202cb11cee6544adad40e800a9fc7a3.jpg)
214
+ Figure 8. Ablation study on the effect of codebook dimension $n_z$ on ADE20K. In our method, $n_z = 256$ means no codebook partition technique is utilized, $n_z = 128$ means 2 partitions, and $n_z = 64$ means 4 partitions, and so on. For VQGAN, the codebook dimension is reduced directly. The codebook vector number $K$ is set as 1024 in all experiments.
215
+
216
+ outperforms them by 26.45, 4.69, and 1.19 in FID on the ADE20K dataset. It indicates that our Kepler codebook with a compact and ordered distribution is beneficial in producing conditional images for the autoregressive model.
217
+
218
+ # 5.3. Qualitative Evaluation
219
+
220
+ We present a comparison of reconstruction visualizations for the ADE20K and CelebA-HQ datasets, as illustrated in Fig. 6. Our model demonstrates superior performance in image reconstruction. For instance, our model reproduces the shape of the haystack more accurately, and the woman's
221
+
222
+ ![](images/9777f8091592c50132121da64b2ef17ed047e1f952562bc2078f00d3cc6559a1.jpg)
223
+ Figure 9. Cross-domain experiment. All models are trained on the ADE20K dataset and tested on (a) MS-COCO, (b) LSDIR, and (c) DIV2K.
224
+
225
+ eyes and lips are more faithful. Compared with VQGAN and Reg-VQ, our model preserves details and structure without distortions. Fig. 7 shows the results generated by each model using the same semantic segmentation map. Our model produces images corresponding to the semantic map while retaining reasonable details in natural scenes, indoor
226
+
227
+ ![](images/a3dffd85f990e4fee8390cba387906f59c619366734016bc8fa2b93f6506323c.jpg)
228
+
229
+ ![](images/fd7938b6a49f6c3532600c092cf87cc151984afd37e358a30c0ef3ea4bdfc3e3.jpg)
230
+
231
+ ![](images/deb2c25f857a2163d4363f00ee45183a0f6362324e4548fd0c95c818dd8e180d.jpg)
232
+ Figure 10. Multi-resolution cross-domain evaluation on DIV2K validation set. We train the three models on ADE20K with $256 \times 256$ resolution and test them on five different resolutions from low to high on the DIV2K dataset.
233
+
234
+ ![](images/db5da9c8f39991d7497d9d2928d478efe5cb5f830166570d67147ee7a63926a3.jpg)
235
+
236
+ Table 3. Quantitative reconstruction and SR comparison on ImageNet and DRealSR validation sets.
237
+
238
+ <table><tr><td>Method</td><td>Task</td><td>Dataset</td><td>PSNR↑</td><td>SSIM↑</td><td>LPIPS↓</td><td>rFID/FID↓</td></tr><tr><td>LDM</td><td rowspan="2">Rec.</td><td rowspan="2">ImageNet</td><td>27.48</td><td>0.826</td><td>0.024</td><td>0.42</td></tr><tr><td>Ours</td><td>28.00</td><td>0.837</td><td>0.019</td><td>0.33</td></tr><tr><td>LDM</td><td rowspan="2">SR</td><td rowspan="2">DRealSR</td><td>24.86</td><td>0.715</td><td>0.080</td><td>35.66</td></tr><tr><td>Ours</td><td>26.15</td><td>0.750</td><td>0.065</td><td>26.11</td></tr></table>
239
+
240
+ scenes, and faces.
241
+
242
+ # 5.4. Ablation Study and Evaluation
243
+
244
+ IHD regularization & Codebook partition. The ablation study on those two strategies is provided in Tab. 2. With the proposed IHD regularization based on the baseline model VQGAN, the performance of both rFID and codebook usage is improved. With the codebook partition, there is an improvement of about $31\%$ in rFID, and the usage rate is directly increased from $35\%$ to $100\%$ . When both strategies are used, our model makes an improvement of $40\%$ in rFID compared to VQGAN and the usage rate is still $100\%$ . Since the dimension of tokens in codebook is so high that it is difficult to compute the KL divergence accurately in Equ. 6, only using IHD regularization improves performance slightly. With the codebook partition, though there is a remarkable improvement, it cannot confirm the well-ordered property of codebook distribution. Thus the collaboration of the codebook partition to lower the dimension of tokens and the IHD regularization to confirm the well-ordered property of the distribution, our model improves the image reconstruction by an even larger margin.
245
+
246
+ Codebook dimension. The use of the codebook partition technique naturally alters the dimensionality of the code-
247
+
248
+ book. To explore the effect on the quality of image reconstruction when only reducing the dimension but no partition performed, we conduct a set of ablation experiments. As shown in Fig. 8, when the token number $K$ remains unchanged, the quality of image reconstruction gradually deteriorates and the codebook usage decreases as the dimension decreases. In contrast, our model achieves a significant improvement in image reconstruction quality and codebook utilization as the dimension decreases (which implies a corresponding increase in the partition number $n_z$ ). This implies that there is a fundamental difference between codebook partition and dimensionality reduction.
249
+
250
+ Balance evaluation of codebook distribution. To fully verify our method, we measure the balance of the codebook distribution before and after training. The distribution balance implies that the number of other tokens within the neighborhood of each token is roughly equal, avoiding situations where certain tokens have disproportionately many or few neighboring tokens within their hollow neighborhoods. Based on this principle, we set a radius for the hollow neighborhoods and evaluate the balance of the distribution by calculating the variance of the number of other tokens within each token's hollow neighborhood. If the variance is large, it suggests that some tokens in the distribution are either overly dense or sparse, whereas a small variance indicates a relatively even distribution among the tokens.
251
+
252
+ Specifically, in Tab. 4, the parameter $d_{rank}$ represents that we select the $d_{rank}$ -th distance as the hollow neighborhood radius when arranging all the distances between any two tokens in the codebook in ascending order. We present evaluation results on the ADE20K dataset with a codebook dimensionality $K = 1024$ . As shown in Tab. 4, during the early stages of training, all models exhibit varying degrees of imbalance in their distribution states. However, after applying our optimized training strategy, we observe a significant decrease in the variance values, with an average reduction approximately twice that of the initial state. In contrast, other models show minimal improvement in their distribution balance after training, still closely resembling their initial distribution states. Notably, regardless of the $d_{rank}$ value chosen, our method consistently reduces the variance to about half that achieved by alternative methods, further substantiating the superior performance of our model in improving the balance of distributions.
253
+
254
+ # 5.5. Cross-Domain Evaluation
255
+
256
+ The generalization performance of VQGAN, Reg-VQ, and our model is examined by training them on ADE20K and testing on MS-COCO, LSDIR, and DIV2K, respectively. Specifically, these models are trained on ADE20K with a resolution of $256 \times 256$ and tested on the other three datasets. As shown in Fig. 9, our model produces impressive visual
257
+
258
+ Table 4. Balance evaluation of the codebook distribution trained on the ADE20K dataset. The variance of the number of other tokens within each token's hollow neighborhood, explained in Sec.5.4, is employed to measure the balance degree.
259
+
260
+ <table><tr><td rowspan="2">drank</td><td colspan="3">2048</td><td colspan="3">5120</td><td colspan="3">10240</td><td colspan="3">20480</td></tr><tr><td>VQGAN</td><td>Reg-VQ</td><td>Ours</td><td>VQGAN</td><td>Reg-VQ</td><td>Ours</td><td>VQGAN</td><td>Reg-VQ</td><td>Ours</td><td>VQGAN</td><td>Reg-VQ</td><td>Ours</td></tr><tr><td>Variance(Before training)</td><td>54.2</td><td>66.3</td><td>54.1</td><td>248.6</td><td>286</td><td>252.3</td><td>765.2</td><td>837.5</td><td>768.1</td><td>2269.3</td><td>2377.4</td><td>2241.9</td></tr><tr><td>Variance(After training)</td><td>50.6</td><td>67.3</td><td>23.5</td><td>242.6</td><td>282.4</td><td>113.7</td><td>798.7</td><td>837.7</td><td>410.1</td><td>2635.3</td><td>2398.5</td><td>1505.6</td></tr></table>
261
+
262
+ ![](images/5080ec5eeb98d09abe5c1760fb17a7cc87264904d74bea0ea459579ae59c6284.jpg)
263
+ Figure 11. Multi-resolution cross-domain visualization on DIV2K validation set with five resolutions from high to low. Notably, the models are trained on ADE20K with $256 \times 256$ resolution. Please zoom in for a better view.
264
+
265
+ ![](images/27dcc5a382110d42ca9c5ad099b15111163cba4fb4fd75cb46c6391b44cb2f48.jpg)
266
+ Figure 12. Evaluation on the super-resolution task on the DRealSR dataset.
267
+
268
+ results. This demonstrates the accuracy of our codebook in modeling discrete representations and the ability to generalize to cross-domain images while still achieving accurate reconstruction compared to other models. Furthermore, we conduct a multi-resolution cross-domain experiment on the DIV2K dataset, using trained models on ADE20K. As shown in Fig. 10, our model achieves superior results on the four metrics. The visualization for five resolution images is shown in Fig. 11. Additional visualization results and detailed metrics can be found in the Appendix.
269
+
270
+ # 5.6. Downstream Application: Super-Resolution
271
+
272
+ We present a downstream application to image superresolution (SR). We first train our model as an autoencoder from scratch on the ImageNet dataset, employing the same downsample factor $(f = 4)$ and codebook configurations (VQ, $K = 8192$ , $n_z = 3$ ) with the autoencoder in Latent Diffusion Model (LDM) (Rombach et al., 2022). We then
273
+
274
+ apply our model to the LDM to train an SR model on the DRealSR dataset. All configurations are consistent with the SR tasks in LDM. The quantitative result for reconstruction and SR is shown in Tab. 3 and the qualitative result for SR is shown in Fig. 12. Our model has significant advantages for both the reconstruction and SR tasks, especially in terms of rFID/FID enhancement, indicating that Kepler Codebook is also beneficial for enhancing downstream tasks. Additional visualization results can be found in the Appendix.
275
+
276
+ # 6. Conclusion
277
+
278
+ In this paper, we make a theoretical and technical attempt to explore the codebook to address the typical codebook collapse and ensure full training of codebook tokens for high codebook usage. The codebook distribution is formulated and derived in conjunction with Kepler's Conjecture in a principle way. To constrain the distribution of tokens, the derived Irwin-Hall distribution regularization for Kepler codebook training is conducted together with a codebook partition strategy to improve codebook usage. Extensive experiments have been conducted to evaluate our trained codebook for image reconstruction and generation on natural and human face datasets, respectively, demonstrating a remarkable performance in these tasks. Moreover, the proposed Kepler codebook has been further evaluated across datasets and even for reconstructing images with different resolutions, demonstrating a promising codebook generalization. Our main contributions, including the mathematical derivation of the codebook distribution from Kepler's Conjecture perspective and the proposed Kepler codebook together with its training manner, are expected to be useful for further insightful research.
279
+
280
+ # Acknowledgements
281
+
282
+ This work is supported in part by National Natural Science Foundation of China (NSFC) under Grant No.62376292, 62376209, U21A20470, 62325605, China Postdoctoral Science Foundation under Grant No. 2023M731964, Guangzhou Science and Technology Program (No.2024A04J6365), and Guangdong Province Key Laboratory of Information Security Technology.
283
+
284
+ # Impact Statement
285
+
286
+ Our work aims to explore the problem of codebook collapse for its training and learn discrete representations with vector quantization. The trained codebook is a precondition for generative models and is the base for visual content generation. The main contribution is casting codebook training as the densest sphere packing and providing a principle solution to derive a compact and structured codebook distribution, which presents a promising potential to extend to the learning visual representation. Ethical considerations are crucial, as generative models can be misused to create misleading content. This paper highlights the significance of responsible use of technology to ensure that technological advancements benefit our society.
287
+
288
+ # References
289
+
290
+ Baevski, A., Schneider, S., and Auli, M. vq-wav2vec: Self-supervised learning of discrete speech representations. arXiv preprint arXiv:1910.05453, 2019.
291
+ Beardon, A. F. Fundamental Domains, pp. 204-252. Springer New York, New York, NY, 1983.
292
+ Bernal, J. D. A Geometrical Approach to the Structure Of Liquids., 183(4655):141-147, 1959.
293
+ Chen, Y., Yuan, J., Tian, Y., Geng, S., Li, X., Zhou, D., Metaxas, D. N., and Yang, H. Revisiting multimodal representation in contrastive learning: from patch and token embeddings to finite discrete tokens. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 15095-15104, 2023.
294
+ Dhariwal, P., Jun, H., Payne, C., Kim, J. W., Radford, A., and Sutskever, I. Jukebox: A generative model for music, 2020.
295
+ Dosovitskiy, A., Beyer, L., Kolesnikov, A., Weissenborn, D., Zhai, X., Unterthiner, T., Dehghani, M., Minderer, M., Heigold, G., Gelly, S., et al. An image is worth 16x16 words: Transformers for image recognition at scale. arXiv preprint arXiv:2010.11929, 2020.
296
+ Esser, P., Rombach, R., and Ommer, B. Taming transformers for high-resolution image synthesis. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 12873-12883, 2021.
297
+ Gray, R. Vector quantization. IEEE Assp Magazine, 1(2): 4-29, 1984.
298
+ Hales, T. C. An overview of the Kepler conjecture. arXiv Mathematics e-prints, 1998.
299
+ Hall, P. The distribution of means for samples of size $n$ drawn from a population in which the variate takes values
300
+
301
+ between 0 and 1, all such values being equally probable. Biometrika, pp. 240-245, 1927.
302
+ Heusel, M., Ramsauer, H., Unterthiner, T., Nessler, B., and Hochreiter, S. Gans trained by a two time-scale update rule converge to a local nash equilibrium. In Proceedings of Advances in Neural Information Processing Systems, 2017.
303
+ Huang, M., Mao, Z., Chen, Z., and Zhang, Y. Towards accurate image coding: Improved autoregressive image generation with dynamic vector quantization. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 22596-22605, 2023.
304
+ Jang, E., Gu, S., and Poole, B. Categorical reparameterization with gumbel-softmax. arXiv preprint arXiv:1611.01144, 2016.
305
+ Kepler, J. The Six-Cornered Snowflake. The Six-Cornered Snowflake, 1966.
306
+ Lee, D., Kim, C., Kim, S., Cho, M., and Han, W.-S. Autoregressive image generation using residual quantization. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 11523-11532, 2022.
307
+ Li, Y., Zhang, K., Liang, J., Cao, J., Liu, C., Gong, R., Zhang, Y., Tang, H., Liu, Y., Demandolx, D., Ranjan, R., Timofte, R., and Van Gool, L. Lsdir: A large scale dataset for image restoration. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops, pp. 1775-1787, 2023.
308
+ Lin, T.-Y., Maire, M., Belongie, S., Hays, J., Perona, P., Ramanan, D., Dollár, P., and Zitnick, C. L. Microsoft coco: Common objects in context. In Proceedings of European Conference on Computer Vision, pp. 740-755, 2014.
309
+ Liu, Z., Luo, P., Wang, X., and Tang, X. Deep learning face attributes in the wild. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 3730-3738, 2015.
310
+ Loshchilov, I. and Hutter, F. Decoupled weight decay regularization. arXiv preprint arXiv:1711.05101, 2017.
311
+ Maehara, Hiroshi Martini, H. Elementary geometry on the integer lattice. Aequationes mathematicae, 92(4), 2018.
312
+ Mentzer, F., Minnen, D., Agustsson, E., and Tschannen, M. Finite scalar quantization: Vq-vae made simple. arXiv preprint arXiv:2309.15505, 2023.
313
+ Ramesh, A., Pavlov, M., Goh, G., Gray, S., Voss, C., Radford, A., Chen, M., and Sutskever, I. Zero-shot text-to-image generation. In Proceedings of International Conference on Machine Learning, pp. 8821-8831, 2021a.
314
+
315
+ Ramesh, A., Pavlov, M., Goh, G., Gray, S., Voss, C., Radford, A., Chen, M., and Sutskever, I. Zero-shot text-to-image generation. In Proceedings of International Conference on Machine Learning, pp. 8821-8831, 2021b.
316
+ Razavi, A., Van den Oord, A., and Vinyals, O. Generating diverse high-fidelity images with vq-vae-2. Advances in neural information processing systems, 32, 2019.
317
+ Rombach, R., Blattmann, A., Lorenz, D., Esser, P., and Ommer, B. High-resolution image synthesis with latent diffusion models. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 10684-10695, 2022.
318
+ Roy, A. and Grangier, D. Unsupervised paraphrasing without translation. In Proceedings of the Annual Meeting of the Association for Computational Linguistics, pp. 6033-6039, 2019.
319
+ Sagan, H. Some reflections on the emergence of spacefilling curves: the way it could have happened and should have happened, but did not happen. Journal of the Franklin Institute, 328(4):419-430, 1991. ISSN 0016-0032.
320
+ Timofte, R., Agustsson, E., Gool, L. V., Yang, M.-H., and Zhang, L. Ntire 2017 challenge on single image superresolution: Methods and results. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops, pp. 1110-1121, 2017.
321
+ Van Den Oord, A., Kalchbrenner, N., and Kavukcuoglu, K. Pixel recurrent neural networks. In Proceedings of International Conference on Machine Learning, pp. 1747-1756, 2016.
322
+ Van Den Oord, A., Vinyals, O., et al. Neural discrete representation learning. In Proceedings of Advances in Neural Information Processing Systems, 2017.
323
+ Wang, D., Deng, L., Yeung, Y. T., Chen, X., Liu, X., and Meng, H. Vqmivc: Vector quantization and mutual information-based unsupervised speech representation disentanglement for one-shot voice conversion. arXiv preprint arXiv:2106.10132, 2021.
324
+ Wei, P., Xie, Z., Lu, H., Zhan, Z., Ye, Q., Zuo, W., and Lin, L. Component divide-and-conquer for real-world image super-resolution. In Proceedings of European Conference on Computer Vision, pp. 101-117, 2020.
325
+ Williams, W., Ringer, S., Ash, T., MacLeod, D., Dougherty, J., and Hughes, J. Hierarchical quantized autoencoders. In Larochelle, H., Ranzato, M., Hadsell, R., Balcan, M., and Lin, H. (eds.), Advances in Neural Information Processing Systems, pp. 4524-4535, 2020.
326
+
327
+ Wu, D.-Y., Chen, Y.-H., and Lee, H.-Y. Vqvc+: One-shot voice conversion by vector quantization and u-net architecture. arXiv preprint arXiv:2006.04154, 2020.
328
+ You, T., Kim, S., Kim, C., Lee, D., and Han, B. Locally hierarchical auto-regressive modeling for image generation. In Proceedings of Advances in Neural Information Processing Systems, pp. 16360-16372, 2022.
329
+ Yu, J., Li, X., Koh, J. Y., Zhang, H., Pang, R., Qin, J., Ku, A., Xu, Y., Baldridge, J., and Wu, Y. Vector-quantized image modeling with improved vqgan. arXiv preprint arXiv:2110.04627, 2021.
330
+ Zhang, J., Zhan, F., Theobalt, C., and Lu, S. Regularized vector quantization for tokenized image synthesis. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 18467-18476, 2023.
331
+ Zheng, C. and Vedaldi, A. Online clustered codebook. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 22798-22807, 2023.
332
+ Zhou, B., Zhao, H., Puig, X., Fidler, S., Barriuso, A., and Torralba, A. Scene parsing through ade20k dataset. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pp. 633-641, 2017.
333
+
334
+ # A. Proof Details
335
+
336
+ # A.1. Codebook Training is Kepler's Conjecture Proof Details
337
+
338
+ To ensure the establishment of a representative feature space, two essential conditions are posited. Under the assumption that the representation space is bounded (a reasonable consideration for deterministic data within a given training set), the conditions are delineated as follows:
339
+
340
+ 1) A well-constructed codebook comprising $N$ tokens is requisite, with the space spanned by all tokens maximizing its expansiveness. 2) The distance between each token should be relatively large, leading to a relatively uniform probability distribution for the training of each token.
341
+
342
+ Further more, according to the first precondition, the space of each token is contact instead of separation to get larger spanned space. According to the based model VQGAN, it usually use the nearest neighbour encoding resulting the spanned space of any two tokens will contact in their midpoint. Thus we can get the relation between $r_i$ and $d_i$ of $i$ -th token that $2r_i = d_i$ . In other words, the constrained condition can be transformed into $g(d_1, d_2, \dots, d_K) = \sum_{i=1}^{K} d_i^{n_z} \leq |\hat{z}| / 2^{n_z}$ . Formally, these conditions can be expressed as follows:
343
+
344
+ $$
345
+ \left\{ \begin{array}{c} a r g \max f \left(d _ {1}, d _ {2}, \dots , d _ {K}\right) \\ s. t. g \left(d _ {1}, d _ {2}, \dots , d _ {K}\right) = \sum_ {i = 1} ^ {K} d _ {i} ^ {n _ {z}} \leq | \hat {z} | / 2 ^ {n _ {z}} \end{array} \right. \tag {7}
346
+ $$
347
+
348
+ where $d_{i}$ is the minimum distance between the $i$ -th token and all the other tokens, $K$ is the number of tokens in codebook, $n_z$ is the dimension of the token and $|\hat{z}|$ is the space of $\hat{z} = E(x)$ . Since $f(d_1, d_2, \dots, d_K) \doteq \min(d_1, d_2, \dots, d_K)$ , we may infer that $d_1$ represents the minimum distance within $d_1, d_2, \dots, d_K$ . Consequently, we can reformulate Equation 7 into an equivalent expression as follows:
349
+
350
+ $$
351
+ \left\{ \begin{array}{c} \arg \min - d _ {1} \\ s. t. \quad g _ {1} \left(d _ {1}, d _ {2}, \dots , d _ {K}\right) = g \left(d _ {1}, d _ {2}, \dots , d _ {K}\right) - | \hat {z} | / 2 ^ {n _ {z}} \leq 0 \\ \quad g _ {2} \left(d _ {1}, d _ {2}, \dots , d _ {K}\right) = d _ {1} - d _ {2} \leq 0 \\ \quad g _ {3} \left(d _ {1}, d _ {2}, \dots , d _ {K}\right) = d _ {1} - d _ {3} \leq 0 \\ \quad \vdots \\ \quad g _ {K} \left(d _ {1}, d _ {2}, \dots , d _ {K}\right) = d _ {K} - d _ {2} \leq 0 \end{array} \right. \tag {8}
352
+ $$
353
+
354
+ It is apparent that the set $G$ becomes nonlinear when $G = \{\nabla g_{i}(\pmb{d}^{*}) : i = 1,2,\dots,K\}$ serves as the optimal solution for Equ. 8. Initially, we compute each $\nabla g_{i}(\pmb{d}^{*})$ as outlined below:
355
+
356
+ $$
357
+ \begin{array}{l} \nabla g _ {1} \left(\boldsymbol {d} ^ {*}\right) = \left(\frac {\partial g _ {1}}{\partial d _ {1}}, \frac {\partial g _ {1}}{\partial d _ {2}}, \dots , \frac {\partial g _ {1}}{\partial d _ {K}}\right) = \left(n _ {z} d _ {1} ^ {n _ {z} - 1}, n _ {z} d _ {2} ^ {n _ {z} - 1}, \dots , n _ {z} d _ {K} ^ {n _ {z} - 1}\right) \\ \nabla g _ {2} (\pmb {d} ^ {*}) = (\frac {\partial g _ {1}}{\partial d _ {1}}, \frac {\partial g _ {1}}{\partial d _ {2}}, \dots , \frac {\partial g _ {1}}{\partial d _ {K}}) = (1, - 1, 0, 0, \dots , 0) \\ \nabla g _ {3} (\pmb {d} ^ {*}) = (\frac {\partial g _ {1}}{\partial d _ {1}}, \frac {\partial g _ {1}}{\partial d _ {2}}, \dots , \frac {\partial g _ {1}}{\partial d _ {\kappa}}) = (1, 0, - 1, 0, \dots , 0) \\ \nabla g _ {4} (\boldsymbol {d} ^ {*}) = \left(\frac {\partial g _ {1}}{\partial d _ {1}}, \frac {\partial g _ {1}}{\partial d _ {2}}, \dots , \frac {\partial g _ {1}}{\partial d _ {K}}\right) = (1, 0, 0, - 1, \dots , 0) \tag {9} \\ \begin{array}{c} \bullet \\ \vdots \\ \bullet \\ \bullet \end{array} \\ \end{array}
358
+ $$
359
+
360
+ $$
361
+ \nabla g _ {K} (\boldsymbol {d} ^ {*}) = \left(\frac {\partial g _ {1}}{\partial d _ {1}}, \frac {\partial g _ {1}}{\partial d _ {2}}, \dots , \frac {\partial g _ {1}}{\partial d _ {K}}\right) = (1, 0, 0, 0, \dots , - 1)
362
+ $$
363
+
364
+ It is evident that $\nabla g_{i}(\pmb{d}^{*})$ is linearly independent for $2\leq i\leq K$ . Simultaneously, considering that the distance between any two tokens is greater than zero ( $d_1,d_2,\dots,d_K > 0$ ), a linear combination of $\nabla g_{2}(\pmb{d}^{*}),\nabla g_{3}(\pmb{d}^{*}),\dots,\nabla g_{K}(\pmb{d}^{*})$ cannot represent $\nabla g_{1}(\pmb{d}^{*})$ . Consequently, Equ. 8 adheres to the regularity conditions.
365
+
366
+ We consider using the Lagrange Multiplier Method to solve the problem. We transform Equ. 8 into the Lagrange function as follows:
367
+
368
+ $$
369
+ L (\boldsymbol {d}, \mu_ {1}, \mu_ {2}, \dots , \mu_ {K}) = - d _ {1} + \sum_ {i = 1} ^ {K} \mu_ {i} g _ {i} (\boldsymbol {d}) \tag {10}
370
+ $$
371
+
372
+ where $\pmb{d}$ represents $(d_{1}, d_{2}, \dots, d_{K})$ and $\mu_{i}$ is the Lagrange Multiplier. Using the KKT conditions, potential optimal solutions can be found:
373
+
374
+ $$
375
+ \left\{ \begin{array}{l l} \nabla_ {\boldsymbol {d}} L = 0 & \\ \mu_ {i} g _ {i} (\boldsymbol {d}) = 0 & i = 1, 2, \dots , K \\ \mu_ {i} \geq 0 & i = 1, 2, \dots , K \\ g _ {i} (\boldsymbol {d}) \leq 0 & i = 1, 2, \dots , K \end{array} \right. \tag {11}
376
+ $$
377
+
378
+ One such optimal solution is:
379
+
380
+ $$
381
+ \left\{ \begin{array}{l} d _ {1} = d _ {2} = \dots = d _ {K} \\ g _ {1} (\boldsymbol {d}) = 0 \end{array} \right. \tag {12}
382
+ $$
383
+
384
+ The expression corresponding to Equ. 12 maximizes the space occupied by all tokens when the distances $d_{i}$ of each token are equal within the constraint space. Simultaneously, this expression is analogous to Kepler's Conjecture, which seeks to determine the maximum density of sphere packing.
385
+
386
+ # A.2. Hexagonal Distribution is Good for Codebook Proof Details
387
+
388
+ To demonstrate the existence of the basis matrix $B$ when $\theta \leq 90^\circ$ in any dimension, consider $B = (\vec{b_1},\vec{b_2},\dots,\vec{b_{n_z}})$ . It is evident that the matrix $B^T B$ is semi-positive definite, indicating that $x^{T}B^{T}Bx\geq 0$ . For $x = (1,1,\ldots ,1)$ , the following expression can be derived:
389
+
390
+ $$
391
+ x ^ {T} B ^ {T} B x = \sum_ {i j} b _ {i} ^ {T} b _ {j} = \sum_ {i \neq j} b _ {i} ^ {T} b _ {j} + n _ {z} \geq 0 \tag {13}
392
+ $$
393
+
394
+ The following form can be derived from Equ. 13:
395
+
396
+ $$
397
+ n _ {z} \left(n _ {z} - 1\right) \max _ {i \neq j} \left(\overrightarrow {b _ {i}} \cdot \overrightarrow {b _ {j}}\right) \geq \sum_ {i \neq j} b _ {i} ^ {T} b _ {j} \geq - n _ {z} \tag {14}
398
+ $$
399
+
400
+ Consequently, we can draw the conclusion from Equ. 14:
401
+
402
+ $$
403
+ \max _ {i \neq j} (\overrightarrow {b _ {i}} \cdot \overrightarrow {b _ {j}}) \geq - \frac {1}{n - 1} \tag {15}
404
+ $$
405
+
406
+ Given that both $b_{i}$ and $b_{j}$ are unit vectors, it follows that $\cos(\theta) \geq -\frac{1}{n_z - 1}$ in $n_z$ -dimensional space. To elaborate further, the range of angles between basis vectors in $B$ is $0 \leq \theta \leq \arccos\left(-\frac{1}{n - 1}\right)$ in $n_z$ dimensions, implying that the basis matrix can be constructed using the method outlined in the paper. As the dimension $n_z$ approaches infinity, the range of angles $\theta$ approximates the interval from 0 to 90 degrees. Exploiting this property of angle range in sufficiently high dimensions and the associated symmetry, we maximize the following expression within the angle range from 0 to 90 degrees:
407
+
408
+ $$
409
+ \max _ {\theta} \frac {q ^ {n} (\theta)}{\det (B)} \tag {16}
410
+ $$
411
+
412
+ Before addressing Equ. 16, let us elucidate the choice of $q(\theta)$ . Without loss of generality, the basis matrix $B$ can be constructed in the following manner:
413
+
414
+ $$
415
+ \left\{ \begin{array}{l} b _ {1} = (1, 0, 0, \dots , 0), \| b _ {i} \| = 1 \\ b _ {i} \cdot b _ {i - 1} = \cos \theta \\ b _ {i, j} = b _ {i - 1, j} (1 \leq j \leq i - 2, i \geq 3) \end{array} \right. \tag {17}
416
+ $$
417
+
418
+ Here, the angles between and basis vectors in $B$ are $\theta$ . Moreover, the basis matrix $B$ is a nonnegative matrix. Then $q(\theta)$ can be described as follows:
419
+
420
+ $$
421
+ q (\theta) = \min _ {\boldsymbol {\alpha} \neq \boldsymbol {\beta}} \| B \boldsymbol {\alpha} - B \boldsymbol {\beta} \| \tag {18}
422
+ $$
423
+
424
+ Here, $\alpha$ and $\beta$ belong to $\{0,1\}^{n_z}$ . Given that the basis matrix $B$ is a nonnegative matrix, the possible values for $\alpha$ and $\beta$ are constrained to
425
+
426
+ $$
427
+ \{(0, 0, \dots , 0), (1, 0, \dots , 0), (0, 1, \dots , 0), \dots , (0, 0, \dots , 1) \}
428
+ $$
429
+
430
+ In other words, if $\alpha = (1, 1, 0, \dots, 0)$ and $\beta = (0, 0, 0, \dots, 1)$ , the distance between $B\alpha$ and $B\beta$ is greater than when $\alpha = (1, 0, 0, \dots, 0)$ and $\beta = (0, 0, 0, \dots, 1)$ . Meanwhile, Equ. 18 can be accurately transformed into the following form:
431
+
432
+ $$
433
+ q (\theta) = \min \left(1, \min _ {i \neq j} \| b _ {i} - b _ {j} \|\right) \tag {19}
434
+ $$
435
+
436
+ where the value 1 represents the distance between $\alpha = (0,0,\dots,0)$ and $\beta$ . And $b_{i}$ represents $B\alpha$ where only i-th entry in $\alpha$ is 1, other entries are zero. It's easy to find that $\| b_{i} - b_{i + 1}\| = \| b_{i} - b_{j}\|$ , $j = i + 1, i + 2, \ldots, K$ . Therefore, Equ. 19 can be transformed to the following form.
437
+
438
+ $$
439
+ q (\theta) = \min \left(1, \min _ {i} \| b _ {i} - b _ {i + 1} \|\right) \tag {20}
440
+ $$
441
+
442
+ In order to calculate $\| b_{i} - b_{i + 1}\|$ , here we first derive the relationship between adjacent diagonal elements in the basis matrix $B$ . The relationship between $b_{i}$ and $b_{i + 1}$ can be derived from Equ. 17 as follows.
443
+
444
+ $$
445
+ \left\{ \begin{array}{l} b _ {i} \cdot b _ {i + 1} = \cos \theta \\ \| b _ {i} \| = \| b _ {i + 1} \| = 1 \end{array} \right. \tag {21}
446
+ $$
447
+
448
+ From Equ. 21, we can get the relationship between $b_{ii}$ and $b_{i+1i+1}$ as follows.
449
+
450
+ $$
451
+ b _ {i + 1 i + 1} ^ {2} = 2 (1 - \cos \theta) - \frac {\left(1 - \cos \theta\right) ^ {2}}{b _ {i i} ^ {2}} \tag {22}
452
+ $$
453
+
454
+ While for the relationship between $b_{ii}$ and $b_{i+1}$ is $b_{i+1} = \frac{b_{ii}^2 - 1 + \cos\theta}{b_{ii}}$ , thus, $\| b_i - b_{i+1} \|$ can be calculated as follows.
455
+
456
+ $$
457
+ \begin{array}{l} \left\| b _ {i} - b _ {i + 1} \right\| = \left(\left(b _ {i i} - b _ {i + 1 i}\right) ^ {2} + b _ {i + 1 i + 1} ^ {2}\right) ^ {\frac {1}{2}} \\ = \left(\left(b _ {i i} - b _ {i i} + \frac {1 - \cos \theta}{b _ {i i}}\right) ^ {2} + 2 (1 - \cos \theta) - \frac {(1 - \cos \theta) ^ {2}}{b _ {i i} ^ {2}}\right) ^ {\frac {1}{2}} \tag {23} \\ = (2 (1 - \cos \theta)) ^ {\frac {1}{2}} \\ = 2 \sin {\frac {\theta}{2}} \\ \end{array}
458
+ $$
459
+
460
+ It follows that $q(\theta) = \min(1, 2\sin \frac{\theta}{2})$ . When $\theta > 60^\circ$ , it is evident that $q(\theta) = \frac{1}{2}$ , and $\prod_{i=1}^{k} b_{i,i}$ increases. This indicates that the result for $\theta = 60^\circ$ cannot be surpassed if $\theta > 60^\circ$ in Equation 16. Therefore, we can narrow down the range of angles under consideration to $0 \leq \theta \leq 60^\circ$ .
461
+
462
+ To simplify the discussion, let us use the following symbols to represent the optimization target in Equ. 16:
463
+
464
+ $$
465
+ h (n, \theta) = \frac {\left(2 \sin \frac {\theta}{2}\right) ^ {n}}{\prod_ {i = 1} ^ {n} b _ {i i}} \tag {24}
466
+ $$
467
+
468
+ For the 2-dimensional case, Equ. 24 takes the following form:
469
+
470
+ $$
471
+ h (2, \theta) = \frac {2 \sin \left(\frac {\theta}{2}\right)}{\sin \theta} = \frac {1}{\cos \left(\frac {\theta}{2}\right)} \tag {25}
472
+ $$
473
+
474
+ Clearly, when the angle $\theta$ equals 60 degrees, $h(2,\theta)$ attains its maximum.
475
+
476
+ Similarly, we can demonstrate that for $n = 3$ , $\frac{2\sin(\frac{\theta}{2})}{b_{22}}$ also achieves its maximum at $\theta = 60^\circ$ . This implies that at an angle of 60 degrees, $h(3,\theta)$ reaches its maximum because both $h(2,\theta)$ and $\frac{2\sin(\frac{\theta}{2})}{b_{22}}$ attain their maxima at $\theta = 60^\circ$ .
477
+
478
+ Assuming that $n = 2,3,\ldots ,k$ supports the conclusion that $\frac{\sin(\frac{\theta}{2})}{b_{nn}}$ reaches its maximum at $\theta = 60^{\circ}$ , then when $n = k + 1$ we can draw the following conclusions:
479
+
480
+ $$
481
+ \begin{array}{l} \frac {\sin \left(\frac {\theta}{2}\right)}{b _ {k + 1 k + 1}} = \frac {\sin \left(\frac {\theta}{2}\right)}{\sqrt {2 (1 - \cos \theta) - \frac {(1 - \cos \theta) ^ {2}}{b _ {k k} ^ {2}}}} \\ = \frac {\sin \left(\frac {\theta}{2}\right)}{\sqrt {4 \sin^ {2} \left(\frac {\theta}{2}\right) - \frac {4 \sin^ {4} \left(\frac {\theta}{2}\right)}{b _ {k k} ^ {2}}}} \tag {26} \\ = \frac {1}{2} (1 - \frac {\sin^ {2} (\frac {\theta}{2})}{b _ {k k} ^ {2}}) ^ {- 1} \\ \end{array}
482
+ $$
483
+
484
+ In the above assumption, we deduce that when $\theta = 60^\circ$ , $\frac{\sin(\frac{\theta}{2})}{b_{kk}}$ is the largest. Thus, when $\theta = 60^\circ$ , $\frac{\sin(\frac{\theta}{2})}{b_{k+1k+1}}$ reaches its maximum. More to specifically, that implies that $h(k+1,\theta)$ is the largest at $\theta = 60^\circ$ .
485
+
486
+ To sum up, when $\theta = 60^{\circ}$ , the maximum codebook density $h(n_z,\theta)$ is attained.
487
+
488
+ # B. Further Evaluation for Codebook Partition
489
+
490
+ We conclude that each entry in the codebook follows an independent identical distribution. Consequently, we employ the codebook partition to enhance the image quality in the reconstruction and generalization processes. Specifically, this implies that there can be multiple variations of the codebook partition method. As described in the following Table 5, reshaping the model's encoder output $\hat{z}_q$ from $hwn_z$ to $hwd \times n_z / d$ or from $n_zhw$ to $d \times n_zhw / d$ contributes to improving the image quality.
491
+
492
+ Table 5. Ours reshapes encoder output $\hat{z}_q$ from $hwn_z$ to $hwd \times n_z / d$ where $d$ means the number of partitions. Ours(w/o permute) is reshapes encoder output $\hat{z}_q$ from $n_zhw$ to $d \times n_zhw / d$ . It shows better reconstruction image quality in both reshape methods which further proves each entry in codebook is an independent identical distribution, thus it can be used in any reshape methods in the quantized process.
493
+
494
+ <table><tr><td>Model</td><td>PSNR↑</td><td>rFID↓</td></tr><tr><td>Reg-VQ</td><td>18.44</td><td>23.69</td></tr><tr><td>Ours(w/o permute)</td><td>20.31</td><td>20.43</td></tr><tr><td>Ours</td><td>21.71</td><td>16.39</td></tr></table>
495
+
496
+ # C. Efficiency analysis
497
+
498
+ The main modifications of our method to the baseline are a KL regularization-based loss and the codebook partition which both bring negligible computations. A comparison in terms of the parameters can be found in Tab. 6.
499
+
500
+ With almost the same parameter size and FLOPS, VQGAN, Reg-VQ, and Ours require almost the same training hours, as shown in Tab. 7.
501
+
502
+ Table 6. The efficiency analysis comparison on ADE20K.
503
+
504
+ <table><tr><td>Model</td><td>#Param</td><td>FLOPS</td></tr><tr><td>VQGAN</td><td>376.4M</td><td>264.1G</td></tr><tr><td>Reg-VQ</td><td>376.1M</td><td>264.2G</td></tr><tr><td>Ours</td><td>377.2M</td><td>264.3G</td></tr></table>
505
+
506
+ Table 7. The details about batch, epoch and training time set in the training process.
507
+
508
+ <table><tr><td>Task</td><td>Dataset</td><td>Batch</td><td>Epoch</td><td>Training time</td></tr><tr><td>Reconstruction</td><td>ADE20K</td><td>96</td><td>100</td><td>14h</td></tr><tr><td>Reconstruction</td><td>Celeb-HQ</td><td>96</td><td>100</td><td>14h</td></tr><tr><td>Generation</td><td>ADE20K</td><td>64</td><td>50</td><td>18h</td></tr><tr><td>Generation</td><td>Celeb-HQ</td><td>64</td><td>50</td><td>18h</td></tr></table>
509
+
510
+ # D. More Visualization Results
511
+
512
+ # D.1. More reconstruction and generation results
513
+
514
+ We provide additional reconstruction and semantic segmentation synthesis results on ADE20K and CelebA-HQ datasets in Fig.13, Fig.14 and Fig.15, respectively.
515
+
516
+ # D.2. More cross-domain results
517
+
518
+ We provide additional cross-domain visualization comparison on MS-COCO LSDIR and DIV2K datasets in Fig.16, along with multi-resolution results for DIV2K in Fig.17. More detailed metrics are shown in Tab. 8. In the comparison of cross-domain datasets with identical resolution, our model outperforms others in reconstructing various elements such as animals, architecture, text, landscapes, etc. When comparing cross-domain multi-resolution reconstruction, our model demonstrates a more favorable visualization effect compared to the other two models. These results highlight the potential of the Kepler codebook distribution in cross-domain and multi-resolution. The tight and ordered properties of Kepler codebook distribution improve the ability to capture more details for codebook tokens.
519
+
520
+ # D.3. More super-resolution results
521
+
522
+ We additionally provide downstream super-resolution visualization comparison on DRealSR validation set in Fig. 18. Whether faced with text, buildings, or natural scenes, our models accurately reproduce GT, whereas LDM suffers from significant color aberration, producing artifacts and false details.
523
+
524
+ ![](images/1312f02ab16e3a012465adbacddc2027940576e3168329ab10ecd5a65dd393d7.jpg)
525
+ Figure 13. Additional reconstruction results on ADE20K dataset.
526
+
527
+ Table 8. Multi-resolution cross-domain results on DIV2K validation dataset. We train the three models on ADE20K with ${256} \times {256}$ resolution and test them on five different resolutions from low to high.
528
+
529
+ <table><tr><td>Resolution</td><td>Method</td><td>PSNR↑</td><td>SSIM↑</td><td>LPIPS↓</td><td>rFID↓</td></tr><tr><td rowspan="3">127×80</td><td>VQGAN</td><td>14.14</td><td>0.227</td><td>0.211</td><td>222.94</td></tr><tr><td>Reg-VQ</td><td>13.88</td><td>0.241</td><td>0.211</td><td>223.91</td></tr><tr><td>Ours</td><td>14.99</td><td>0.326</td><td>0.147</td><td>195.77</td></tr><tr><td rowspan="3">254×160</td><td>VQGAN</td><td>15.63</td><td>0.304</td><td>0.207</td><td>197.58</td></tr><tr><td>Reg-VQ</td><td>15.51</td><td>0.326</td><td>0.203</td><td>185.31</td></tr><tr><td>Ours</td><td>16.88</td><td>0.417</td><td>0.138</td><td>130.06</td></tr><tr><td rowspan="3">508×320</td><td>VQGAN</td><td>17.33</td><td>0.389</td><td>0.182</td><td>132.09</td></tr><tr><td>Reg-VQ</td><td>17.24</td><td>0.406</td><td>0.178</td><td>129.39</td></tr><tr><td>Ours</td><td>19.05</td><td>0.514</td><td>0.117</td><td>73.73</td></tr><tr><td rowspan="3">1016×640</td><td>VQGAN</td><td>19.42</td><td>0.485</td><td>0.148</td><td>79.33</td></tr><tr><td>Reg-VQ</td><td>19.24</td><td>0.498</td><td>0.147</td><td>77.45</td></tr><tr><td>Ours</td><td>21.73</td><td>0.614</td><td>0.094</td><td>41.28</td></tr><tr><td rowspan="3">2032×1280</td><td>VQGAN</td><td>21.18</td><td>0.552</td><td>0.119</td><td>50.66</td></tr><tr><td>Reg-VQ</td><td>20.84</td><td>0.561</td><td>0.121</td><td>49.16</td></tr><tr><td>Ours</td><td>23.76</td><td>0.676</td><td>0.072</td><td>23.62</td></tr></table>
530
+
531
+ ![](images/9148ebe3c902b45a65289dd356cc4263a04084474e4d433ea75ca651f8c020af.jpg)
532
+ Figure 14. Additional reconstruction results on CelebA-HQ dataset.
533
+
534
+ ![](images/121b8fbc8e9135fc386bffacb49967206e59cfd8f24079f912a9387437922146.jpg)
535
+ Figure 15. Generation results on ADE20K and CelebA-HQ datasets. The first column is the semantic segmentation map and the subsequent columns show the generated results conditioned on it.
536
+
537
+ ![](images/ebc76723bf49cb9d3d0ef899425e9501feda113d3aea6a241e1e5746030910c4.jpg)
538
+ Figure 16. Cross-domain reconstruction results on MS-COCO, LSDIR, and DIV2K datasets.
539
+
540
+ ![](images/a8b471e90e9543cd69e2c59e162cc0f4829d76461acc69822aa551164a37bf78.jpg)
541
+ Figure 17. Multi-resolution cross-domain visualization on DIV2K validation set (0865) with five resolutions from high to low. Please zoom in for a better view.
542
+
543
+ ![](images/c32fee1f00ad658cb8c479ea25369d56cf2186e86b96b413d5e210089a2447b3.jpg)
544
+ Figure 18. Super-resolution visualization on DRealSR validation set.
2024/Kepler codebook/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ef77be90e74819b306b88d9aaefe4644e876c5e6b1371a28b513f1f6b2124cb4
3
+ size 2155237
2024/Kepler codebook/layout.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/Kernel Debiased Plug-in Estimation_ Simultaneous, Automated Debiasing without Influence Functions for Many Target Parameters/92d586ff-e6c9-4103-b016-e4da7e2f5a98_content_list.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/Kernel Debiased Plug-in Estimation_ Simultaneous, Automated Debiasing without Influence Functions for Many Target Parameters/92d586ff-e6c9-4103-b016-e4da7e2f5a98_model.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/Kernel Debiased Plug-in Estimation_ Simultaneous, Automated Debiasing without Influence Functions for Many Target Parameters/92d586ff-e6c9-4103-b016-e4da7e2f5a98_origin.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:77380b4dae835a8f4a89b9f97bd533bf1fae36e28554b018a03127d3aa1ee5b7
3
+ size 3248336
2024/Kernel Debiased Plug-in Estimation_ Simultaneous, Automated Debiasing without Influence Functions for Many Target Parameters/full.md ADDED
The diff for this file is too large to render. See raw diff
 
2024/Kernel Debiased Plug-in Estimation_ Simultaneous, Automated Debiasing without Influence Functions for Many Target Parameters/images.zip ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:691976cb231b331bfaa1d5ad09cb9d2b005b77c116a3add778993811d1bce01b
3
+ size 1111830
2024/Kernel Debiased Plug-in Estimation_ Simultaneous, Automated Debiasing without Influence Functions for Many Target Parameters/layout.json ADDED
The diff for this file is too large to render. See raw diff
 
2024/Kernel Semi-Implicit Variational Inference/ee6ad02a-42ab-40fd-a7d8-00cf05e58390_content_list.json ADDED
The diff for this file is too large to render. See raw diff