Abstract
Fine-tuning Large Language Models (LLMs) for long-context tasks is severely limited by activation memory, which scales linearly with sequence length. While parameter-efficient methods like LoRA reduce weight memory, they fail to address the activation bottleneck. We present LeMo (LEss token involvement for MOre context), a system that exploits contextual token sparsity to dynamically eliminate redundant tokens during fine-tuning. LeMo achieves up to a 1.93× reduction in memory and 1.36× speedup while maintaining accuracy, enabling 32K+ sequence training on a single GPU.
Introduction: The Activation Memory Wall
As Large Language Models (LLMs) are increasingly applied to massive documents and long-form conversations, the "memory wall" becomes a critical barrier. Parameter-Efficient Fine-Tuning (PEFT) methods, such as LoRA, significantly reduce the memory required for model weights. However, they do not mitigate the activation memory bottleneck—the intermediate tensors stored during the forward pass for gradient calculation in the backward pass.
In long-context scenarios, activation memory scales linearly with sequence length. Even existing "sparse attention" methods like LongLoRA suffer from Shadowy Activation: although a token may not be heavily attended to, it remains in the computation pipeline, requiring its activations to be stored. This prevents training on sequences exceeding 32K tokens without excessive hardware resources.
Methodology: Exploiting Contextual Token Sparsity
LeMo introduces a system-level approach to exploit Contextual Token Sparsity—the observation that not every token in a long sequence is equally informative at every layer. The system is built upon three primary pillars:
1. Information-driven Token Elimination
LeMo calculates an "informativeness score" for tokens based on their interactions within the attention block. By partitioning tokens into blocks and applying layer-specific thresholds, the system identifies and excludes redundant blocks from further computation in that specific layer.
2. Context-aware Pattern Prediction
To avoid the high cost of calculating full attention scores for token dropping, LeMo utilizes lightweight, trainable neural network "predictors" in each layer. These predictors estimate the sparsity pattern based on token embeddings, allowing the system to skip redundant operations with minimal overhead. To further optimize, "Elastic Size Transformation" prunes inactive neurons in these predictors during training, reducing their memory footprint by approximately 50%.
3. High-performance Kernel Optimization
To translate these algorithmic gains into hardware performance, custom GPU kernels were developed:
- Permutation-free Movement: Token selection and padding are fused into the computation to avoid costly data shuffling in global memory.
- Segment-based Peak Cutting: The final loss computation is partitioned into smaller segments to prevent memory spikes at the end of the training step.
Experimental Results
The authors evaluated LeMo across benchmarks including RedPajama, PG19, Proof-Pile, and LongBench.
Memory and Scaling
LeMo reduced the activation memory footprint by an average of 38.2% at 4K context and 50.5% at 8K context compared to LoRA. On a single A800 (80GB) GPU, while LoRA and LongLoRA were limited to 16K sequences for OPT-1.3B, LeMo successfully enabled training on 32K and 64K sequences.
Speed and Accuracy
The system achieved up to a 1.36× speedup in end-to-end fine-tuning. Critically, despite aggressive token dropping, LeMo maintained performance comparable to dense fine-tuning on the LongBench suite, with only negligible increases in perplexity.
Conclusion
LeMo addresses the activation memory bottleneck in long-context LLM fine-tuning by leveraging token-level sparsity. By dynamically eliminating redundant tokens and optimizing GPU kernels, it enables significantly longer context windows on standard hardware without sacrificing model accuracy. Future work may combine LeMo with activation quantization or offloading to further extend context limits.
Summary updated