TL;DR
This paper introduces CATS (Contextually-Aware Thresholding for Sparsity), a novel framework that sparsifies LLM activations to reduce inference costs without significant performance degradation. By employing a new activation function and a custom GPU kernel, CATS achieves substantial speedups and maintains performance close to base models, even at high sparsity levels.
What Problem Does This Paper Address?
Large Language Models (LLMs) have shown remarkable capabilities, but their massive size leads to prohibitively high computational costs for inference. This is a major bottleneck for their widespread deployment. While techniques like activation sparsity aim to reduce these costs by zeroing out less important activations, they often result in a significant drop in performance on downstream tasks. The challenge is to achieve substantial inference speedups through sparsity without sacrificing model accuracy.
Methods
The core of the CATS framework is a new non-linear activation function that introduces a controllable level of sparsity. This function, applied within the Gated-MLP blocks of LLMs, effectively "zeros out" activations that are deemed less important based on their magnitude relative to a learned threshold. This threshold is determined by the desired sparsity level and the distribution of activations within a layer.
Crucially, the paper also introduces a custom GPU kernel designed to translate this activation sparsity into actual wall-clock time speedups. This kernel optimizes memory access patterns, which are a bottleneck for MLP layers in LLMs, by exploiting the sparse activations to avoid unnecessary computations.
Datasets
The paper uses the following datasets:
- RefinedWeb dataset: Used for evaluating perplexity and for fine-tuning experiments.
- OpenBookQA, ARC_Easy, Winogrande, HellaSwag, ARC_Challenge, PIQA, BoolQ, and SCI-Q: A suite of datasets from the Eleuther AI Evaluation Harness, used for evaluating downstream task performance.
Key Insights and Ideas
- Activation distribution is key: The paper highlights that activations in LLM MLP blocks are often concentrated around zero, suggesting a natural opportunity for sparsity.
- Sparsity without fine-tuning is possible: CATS demonstrates that significant sparsity can be achieved with minimal performance loss even without any fine-tuning, which is a major advantage.
- Controllable sparsity: The CATS framework allows for a precise control over the desired sparsity level, offering flexibility in balancing performance and efficiency.
- GPU kernel is essential for speedup: Simply having sparse activations isn't enough; a specialized kernel is needed to translate this sparsity into tangible inference speedups by optimizing memory operations.
- CATS is more effective than ReLUfication: The paper shows CATS outperforms ReLUfication, a prior method for inducing sparsity, especially when fine-tuning is involved.
Key Results
- Performance preservation: CATS-based models achieve downstream task performance within ~1-2% of their base models, even at 50% activation sparsity, and without any fine-tuning.
- Outperforming baselines: CATS significantly outperforms ReLUfication in downstream task performance at the same sparsity levels.
- Faster convergence: With parameter-efficient fine-tuning (targeting 1% of parameters), CATS-based models converge faster and achieve better task performance than competing techniques.
- Inference speedup: The custom GPU kernel implementation of CATS results in approximately a 15% improvement in wall-clock inference latency for token generation on both Llama-7B and Mistral-7B models. For example, at 50% and 70% sparsity, the sparse kernel achieves ~40% and ~70% speedup, respectively, over the dense MLP.
- Scalability: The benefits of CATS appear to scale with model size, with performance degradation becoming even more minimal for larger models like Llama-13B.
Limitations and Future Work
- Model scope: The empirical evaluations were primarily restricted to Mistral-7B and Llama2-7B. While the authors suspect CATS would apply to larger models, a precise empirical study is left for future work.
- Architecture generalization: Future work could investigate applying CATS to other MLP architectures beyond Gated-MLP, or even to attention layers, while minimizing performance degradation.
- Enforcing minimum sparsity: Exploring methods to enforce a minimum sparsity layer-wise could be a direction for future research, investigating the trade-offs between sparsity, latency, and downstream task performance.
Summary updated