ACL2026

Octopus: Gated Selective Attention for Memory-Bounded Long-Context Inference in Large Language Models

Chien Van Nguyen, Ryan A. Rossi, Linh Ngo Van, Franck Dernoncourt, Thien Huu Nguyen

摘要

Transformer inference becomes increasingly memory-bound as the Key–Value (KV) cache grows linearly with sequence length. While subquadratic architectures offer constant-memory inference, they rely on aggressive state compression that degrades performance on complex reasoning tasks. We propose O CTOPUS , a framework that confers fixed-memory inference onto pretrained Transform-ers without the information loss of linearization. O CTOPUS retrofits attention layers with Gated Selective Attention , a learnable module that enforces an adaptive sparsity policy over the context history. By dynamically scoring and retaining only high-utility KV states, this mechanism transforms the unbounded cache into a compact, evolving memory budget that filters out uninformative noise. Empirically, on the GSM8K benchmark, it outperforms state-of-the-art linearized baselines by over 36 points under identical memory constraints. Re-markably, O CTOPUS also surpasses its own full-cache teacher, demonstrating that learned sparse retention serves as an effective regular-izer for long-horizon reasoning.