Mixture of Weight-shared Heterogeneous Group Attention Experts for Dynamic Token-wise KV Optimization

Guanghui Song, Dongping Liao, Yiren Zhao, Kejiang Ye, ChengZhong Xu, Xitong Gao · OpenReview

Abstract

Transformer models face scalability challenges in causal language modeling (CLM) due to inefficient memory allocation for growing key-value (KV) caches, which strains compute and storage resources. Existing methods like Grouped Query Attention (GQA) and token-level KV optimization improve efficiency but rely on rigid resource allocation, often discarding "low-priority" tokens or statically grouping them, failing to address the dynamic spectrum of token importance. We propose mixSGA, a novel mixture-of-expert (MoE) approach that dynamically optimizes token-wise computation and memory allocation. Unlike prior approaches, mixSGA retains all tokens while adaptively routing them to specialized experts with varying KV group sizes, balancing granularity and efficiency. Our key novelties include: (1) a token-wise expert-choice routing mechanism guided by learned importance scores, enabling proportional resource allocation without token discard; (2) weight-sharing across grouped attention projections to minimize parameter overhead; and (3) an auxiliary loss to ensure one-hot routing decisions for training-inference consistency in CLMs. Extensive evaluations across Llama3, TinyLlama, OPT, and Gemma2 model families show mixSGA's superiority over static baselines. On instruction-following and continued pretraining tasks, mixSGA achieves higher ROUGE-L and lower perplexity under the same KV budgets.

Introduction

In modern Transformer models, the Key-Value (KV) cache is a major scalability hurdle. To generate text efficiently, models store the "keys" and "values" of every previous token in memory. As sequences grow longer, this cache consumes significant GPU memory and slows down inference.

Existing solutions like Grouped Query Attention (GQA) reduce memory by sharing keys/values across multiple attention heads but apply the same compression to every token regardless of importance. Alternatively, token eviction methods delete "low-priority" tokens, which can lead to hallucinations or loss of context. mixSGA addresses this by recognizing that token importance is a dynamic spectrum and adjusting memory usage accordingly without discarding information.

Methodology: The mixSGA Framework

The core of mixSGA is a Mixture of Weight-shared Heterogeneous Group Attention Experts. This framework treats different attention granularities as "experts" in a Mixture-of-Experts (MoE) setup.

The mixSGA architecture showing the routing mechanism for prefill and decode tokens across heterogeneous experts.

Key components include:

  • Heterogeneous Experts: Experts represent different attention configurations (e.g., full resolution vs. compressed grouping).
  • Weight-Sharing: All experts share the same underlying projection weights to minimize parameter overhead.
  • Autoregressive Expert-Choice Routing: A learned router assigns tokens to experts. An "Expert-Choice" mechanism is used where experts pick the best tokens to fill their capacity, ensuring consistency between prefill and decode phases.
  • Auxiliary Loss: Encourages "one-hot" routing decisions, preventing ambiguity during inference.

Experimental Setup

The authors evaluated mixSGA across several model families, including Llama3, TinyLlama, OPT, and Gemma2. The evaluation used:

  • Dolly-15k: For supervised fine-tuning (SFT) and instruction-following.
  • MiniPile: For continued pretraining (1.6B tokens).
  • Zero-shot Benchmarks: HellaSwag, PIQA, Winogrande, and ARC for general reasoning.
  • WikiText-2: To measure perplexity.

Results and Discussion

mixSGA consistently outperforms static baselines like GQA under the same memory budgets. Analysis confirmed that token importance is indeed a spectrum, and a "3:1:6" ratio (30% high-res, 10% medium, 60% low-res) often provides the best balance of efficiency and accuracy.

Performance comparison of mixSGA against GQA across various model architectures and instruction-following datasets.

Key findings include:

  • Superior Performance: On Llama3.1-8B, mixSGA achieved an average ROUGE-L score of 27.08, significantly higher than GQA's 19.97.
  • Lower Perplexity: In continued pretraining, mixSGA achieved lower perplexity than both GQA and Cross-Layer Attention (CLA) at similar memory footprints.
  • Efficiency: The implementation adds only a 3-4% throughput overhead, which can likely be further reduced with optimized kernels.

Conclusion

mixSGA demonstrates that dynamic, token-wise KV cache optimization is a viable and effective strategy for improving LLM efficiency. By preserving all tokens in varying states of compression, it maintains context better than eviction-based methods. Future work will focus on making expert capacities dynamic and optimizing implementation for ultra-long context scenarios.

Summary updated

Abstract

Transformer models face scalability challenges in causal language modeling (CLM) due to inefficient memory allocation for growing key-value (KV) caches, which strains compute and storage resources. Existing methods like Grouped Query Attention (GQA) and token-level KV optimization improve efficiency but rely on rigid resource allocation, often discarding "low-priority" tokens or statically grouping them, failing to address the dynamic spectrum of token importance. We propose mixSGA, a novel mixture-of-expert (MoE) approach that dynamically optimizes token-wise computation and memory allocation. Unlike prior approaches, mixSGA retains all tokens while adaptively routing them to specialized experts with varying KV group sizes, balancing granularity and efficiency. Our key novelties include: (1) a token-wise expert-choice routing mechanism guided by learned importance scores, enabling proportional resource allocation without token discard; (2) weight-sharing across grouped attention projections to minimize parameter overhead; and (3) an auxiliary loss to ensure one-hot routing decisions for training-inference consistency in CLMs. Extensive evaluations across Llama3, TinyLlama, OPT, and Gemma2 model families show mixSGA's superiority over static baselines. On instruction-following and continued pretraining tasks, mixSGA achieves higher ROUGE-L and lower perplexity under the same KV budgets.
BibTeX
@inproceedings{song2025mixture,
  author = {Guanghui Song and Dongping Liao and Yiren Zhao and Kejiang Ye and ChengZhong Xu and Xitong Gao},
  title = {{Mixture of Weight-shared Heterogeneous Group Attention Experts for Dynamic Token-wise KV Optimization}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2025},
}
Figure