United States of Banan is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber.
Get full access to United States of Banan at konradb.substack.com/subscribe
Audio and video play straight from the show's own hosting. PodSubs stores and serves no media.
Transcript
From the show. Tap a time to play from there.
SPEAKER_00Large language models have evolved to support extremely long inputs. Claude supports 1M tokens, while Gradient AI extends LAMA3 to 4M tokens. However, this creates significant memory challenges. For instance, generating 1M tokens with LAMA3-8B requires 207Gi memory, 15GB for parameters, 64GB for activation, 128GB for KV cache. This makes long context inference impossible on consumer GPUs like the RTX 4090.
Current solutions with quantization or layer-wise offloading still have limitations.
SPEAKER_00HeadInfer introduces a fundamentally new approach. Figure 2 illustrates the key innovation of HeadInfer. Attention head-level granularity for KV cache management. Standard approaches keep the entire KV cache on GPU. Layer-wise offloading moves entire transformer layers to CPU memory, but still keeps all heads in a layer together. HeadInfer takes this to the finest granularity by operating on individual attention heads, keeping just one head's KV cache on GPU at any time while
offloading the rest to CPU. This dramatically reduces memory footprint while preserving exact mathematical
SPEAKER_00equivalents with standard inference. Headinfer exploits the independence of attention heads to decompose attention computation in a headwise manner. Each attention head has its own KV cache. KAH, RSXDH, VH, RSXDH, where DHH, DH. This allows for selective offloading of specific heads. Headinfer overlaps computation and communication using a ping-pong memory design. While one head is being processed on GPU,
the next head is being prefetched from CPU.
SPEAKER_00For shorter contexts, multiple heads are grouped together to reduce overhead, with granularity increasing as context length grows. Figure 3 demonstrates HeadInfer's hierarchical approach to memory management across three dimensions. Standard inference keeps everything on GPU. Chunked pre-filled processes, only parts of the sequence at a time, reducing activation memory. Layer-wise offloading keeps only select layers on GPU, offloading others.
HeadInfer introduces the finest granularity by managing individual attention heads
SPEAKER_00within layers. This creates a flexible system that can adapt to different hardware constraints, allowing precise control over which parts of KV cache and activations remain on GPU. The paper provides a detailed roofline analysis to prove HeadInfer's efficiency. For pre-fill with contexts, tokens, the process remains compute bound even when offloading, with arithmetic intensity growing as context length increases. For shorter contexts, 1K, there's some memory bound overhead.
SPEAKER_00Decoding is naturally memory bound for all approaches. HeadInfo's architecture doesn't alter this fundamental performance profile, meaning it achieves its memory savings without significantly impacting computational efficiency. The system dynamically adapts head grouping based on context length to maintain performance. Experimental results demonstrate HeadInfer's impressive real-world performance. For 1M token input with LAMA38B, GPU memory footprint was reduced from 207GB to just 17GB,
SPEAKER_00a 92% reduction. The maximum context length increased from 25K tokens, standard inference, to 4M tokens on a single RTX 4090. Importantly, HeadInfer maintained accuracy on long context benchmarks like LongBench V2 and SCBench, outperforming other methods. The system also scaled to 70B parameter models with 1M context using pipeline parallelism across multiple GPUs,
SPEAKER_00making previously impossible inference tasks feasible. HeadInfer represents a significant breakthrough in making long-context LLM inference accessible. By enabling 4M token inference on consumer GPUs like the RTX 4090 without approximation methods, it democratizes access to advanced AI capabilities. The system is easily integrated into existing frameworks like HuggingFace with minimal code changes. This opens up new possibilities for applications requiring
massive context windows.
SPEAKER_00book summarization, video generation, and complex reasoning tasks. Headinfer's approach could become a standard technique for efficient LLM inference in resource-constrained environments.
Paper: https://arxiv.org/abs/2504.11159 United States of Banan is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber. Get full access to United States...
Paper: https://arxiv.org/abs/2604.16748 United States of Banan is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber. Get full access to United States...
Paper: https://arxiv.org/html/2604.01845v1 United States of Banan is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber. Get full access to United...
Paper: https://arxiv.org/abs/2604.13253 United States of Banan is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber. Get full access to United States...
Paper: https://arxiv.org/abs/2604.05257 United States of Banan is a reader-supported publication. To receive new posts and support my work, consider becoming a free or paid subscriber. Get full access to United States...