A few months ago, I was looking at GPU memory usage on my laptop, wondering why my small language models kept running out of VRAM. Every AI researcher and engineer working with language models eventually hits this wall. You want to optimize for performance, but your hardware budget dictates otherwise. So I decided to dig deeper into memory usage and attention mechanisms in LLMs. I wasn't trying to build the next GPT-5, but had different ambitions: models that could actually run on regular hardware without sacrificing quality. The Memory Problem with LLMs The main memory bottleneck is the standard multi-head attention mechanism which creates massive key-value caches during inference. Every token you generate stores information that grows linearly with sequence length. For a 512-token context, you're looking at several MBs of cache data per token on a modest 30M parameter model. To find suitable alternatives, I started looking more into latent multi-head attention (MLA): a technique that compresses these key-value representations through learned projections. DeepSeek-V2 had shown great results with larger models, but surprisingly, nobody had tested it on small models where every parameter counts. Experimental Results I trained eight different configurations of GPT models on 100,000 synthetic stories from the TinyStories dataset: simple vocabulary, clear narrative structures which are perfect for isolating the effects of architectural changes. I expected MLA to help with memory. An unplanned surprise was how much rotary position embeddings (RoPE) would matter. Without rotary embeddings, MLA actually performed worse than standard attention: about 3-5% higher validation loss. Then I added RoPE to see if it could help offset the loss in quality. MLA+RoPE wasn't just matching standard attention. It was beating it by 2%. The optimal spot emerged at half-rank compression (r = d/2). The impact was as follows: 45% reduction in KV-cache memory usage1.4x inference speedupOnly 0.3% increase in validation loss (practically identical quality) 45% reduction in KV-cache memory usage 1.4x inference speedup Only 0.3% increase in validation loss (practically identical quality) I also pushed compression further: quarter-rank, eighth-rank, even thirty-second-rank. The models held together surprisingly well until around r = d/16, then fell off a cliff and started generating repetitive gibberish. Modeling Recipe MLA works by factorizing key and value projections through a bottleneck: instead of storing full K and V matrices, you store compressed latent representations and reconstruct them during attention computation. The compression ratio determines the trade-off between memory and quality. RoPE provides an important missing piece by encoding relative positions through rotation matrices, which helps models understand token relationships even with compressed attention and without explicit position embeddings. Applications Memory efficiency isn't only about fitting models on cheaper hardware. It also unlocks longer conversations, bigger batch sizes, and deployment scenarios that were previously difficult or impossible. We benchmarked this performance on NVIDIA A100s, but the implications also extend to mobile devices and edge computing. When every megabyte matters, architectural choices become as important if not more, than just raw parameter counts. I also ran the generated stories through GPT-4 for quality evaluation. Across grammar, creativity, narrative consistency: MLA+RoPE always scored highest across the board (7.4/10 overall vs 6.2/10 for standard attention). The automated scores matched our perplexity results almost perfectly. Lessons Learnt These smaller models themselves aren't revolutionary! Thirty million parameters won't replace GPT-5 anytime soon! But the architectural insights should also transfer to larger models and real-world applications. We proved that small models can serve as effective testbeds for efficiency research. Looking Forward This research opens several paths worth exploring. Adaptive compression schemes that vary by layer or attention head could push efficiency further. Combining MLA with quantization or pruning techniques might compound the benefits. More importantly, we need to rethink the assumption that bigger is always better. In a world where AI needs to run everywhere (not just in data centers) architectural innovation matters as much as raw scale. For more details on the methodology and complete results, check out this paper on arXiv. You might also be interested in DeepSeek-V2's approach to MLA and the original RoPE paper that inspired our positional encoding strategy. For more details on the methodology and complete results, check out this paper on arXiv paper on arXiv . You might also be interested in DeepSeek-V2's approach to MLA DeepSeek-V2's approach to MLA and the original RoPE paper the original RoPE paper that inspired our positional encoding strategy.