mlsanityData to 14 Oct 2026

Learning When to Attend: Conditional Memory Access for Long-Context LLMs

arXiv 2603.17484 ↗First posted 18 Mar 2026cs.CL cs.LGcited by 3

Not on the map. Why?

Abstract (arXiv)

Language models struggle to generalize beyond pretraining context lengths, limiting long-horizon reasoning and retrieval. Continued pretraining on long-context data can help but is expensive due to the quadratic scaling of Attention. We observe that most tokens do not require (Global) Attention over the entire sequence and can rely on local context. Based on this, we propose L2A (Learning To Attend), a layer that enables conditional (token-wise) long-range memory access by deciding when to invoke global attention. We evaluate L2A on Qwen 2.5 and Qwen 3 models, extending their effective context length from 32K to 128K tokens. L2A matches the performance of standard long-context training to within 3% while skipping Global Attention for ~80% of tokens, outperforming prior baselines. We also design custom Triton kernels to efficiently implement this token-wise conditional Attention on GPUs, achieving up to ~2× improvements in training throughput and time-to-first-token over FlashAttention. Moreover, L2A enables post-training pruning of highly sparse Global Attention layers, reducing KV cache memory by up to 50% with negligible performance loss. Our code is released under Apache 2.0 at https://github.com/awslabs/hybrid-model-factory/tree/main/examples/research/L2A.

Key facts. Cited by 3 papers in the map (data through 14 Oct 2026). Builds on 57 of its 68 references that are in the map. First posted on arXiv 18 Mar 2026.

Builds on

57 of 68 references.

References · 57

  1. 2017Attention Is All You Needcited by 60,361
  2. 2020Retrieval-Augmented Generation for Knowledge-Intensive NLP Taskscited by 9,297
  3. 2023Mamba: Linear-Time Sequence Modeling with Selective State Spacescited by 4,718
  4. 2017Outrageously Large Neural Networks: The Sparsely-Gated Mixture-of-Experts Layercited by 3,509
  5. 2023SWE-bench: Can Language Models Resolve Real-World GitHub Issues?cited by 3,373
  6. 2023FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioningcited by 2,598
  7. 2023Efficient Streaming Language Models with Attention Sinkscited by 2,186
  8. 2013Estimating or Propagating Gradients Through Stochastic Neurons for Conditional Computationcited by 2,079
  9. 2023Self-RAG: Learning to Retrieve, Generate, and Critique through Self-Reflectioncited by 1,839
  10. 2020Transformer Feed-Forward Layers Are Key-Value Memoriescited by 1,336
  11. 2021Improving language models by retrieving from trillions of tokenscited by 1,293
  12. 2023H2O: Heavy-Hitter Oracle for Efficient Generative Inference of Large Language Modelscited by 832
38 more
  1. 2024Evaluating Very Long-Term Conversational Memory of LLM Agentscited by 830
  2. 2025Mem0: Building Production-Ready AI Agents with Scalable Long-Term Memorycited by 779
  3. 2023Extending Context Window of Large Language Models via Positional Interpolationcited by 740
  4. 2024KIVI: A Tuning-Free Asymmetric 2bit Quantization for KV Cachecited by 637
  5. 2023YaRN: Efficient Context Window Extension of Large Language Modelscited by 601
  6. 2023Enabling Large Language Models to Generate Text with Citationscited by 595
  7. 2022Efficiently Scaling Transformer Inferencecited by 539
  8. 2024Gated Delta Networks: Improving Mamba2 with Delta Rulecited by 532
  9. 2023Ring Attention with Blockwise Transformers for Near-Infinite Contextcited by 457
  10. 2024Adaptive-RAG: Learning to Adapt Retrieval-Augmented Large Language Models through Question Complexitycited by 451
  11. 2025Native Sparse Attention: Hardware-Aligned and Natively Trainable Sparse Attentioncited by 407
  12. 2024DataComp-LM: In search of the next generation of training sets for language modelscited by 398
  13. 2024MInference 1.0: Accelerating Pre-filling for Long-Context LLMs via Dynamic Sparse Attentioncited by 383
  14. 2024LongRoPE: Extending LLM Context Window Beyond 2 Million Tokenscited by 313
  15. 2024Mixture-of-Depths: Dynamically allocating compute in transformer-based language modelscited by 258
  16. 2025TokenSkip: Controllable Chain-of-Thought Compression in LLMscited by 249
  17. 2022ASQA: Factoid Questions Meet Long-Form Answerscited by 234
  18. 2024BABILong: Testing the Limits of LLMs with Long Context Reasoning-in-a-Haystackcited by 215
  19. 2023Landmark Attention: Random-Access Infinite Context Length for Transformerscited by 213
  20. 2024Auxiliary-Loss-Free Load Balancing Strategy for Mixture-of-Expertscited by 205
  21. 2024Leave No Context Behind: Efficient Infinite Context Transformers with Infini-attentioncited by 200
  22. 2024InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context Memorycited by 197
  23. 2025Qwen2.5-1M Technical Reportcited by 164
  24. 2024How to Train Long-Context Language Models (Effectively)cited by 146
  25. 2020Sparse GPU Kernels for Deep Learningcited by 141
  26. 2024LLM Maybe LongLM: Self-Extend LLM Context Window Without Tuningcited by 136
  27. 2025Mixture-of-Recursions: Learning Dynamic Recursive Depths for Adaptive Token-Level Computationcited by 133
  28. 2023Scaling Laws of RoPE-based Extrapolationcited by 125
  29. 2024HELMET: How to Evaluate Long-Context Language Models Effectively and Thoroughlycited by 125
  30. 2023LM-Infinite: Zero-Shot Extreme Length Generalization for Large Language Modelscited by 124
  31. 2025FlexPrefill: A Context-Aware Sparse Attention Mechanism for Efficient Long-Sequence Inferencecited by 123
  32. 2024The Mamba in the Llama: Distilling and Accelerating Hybrid Modelscited by 122
  33. 2024Retrieval Augmented Generation or Long-Context LLMs? A Comprehensive Study and Hybrid Approachcited by 119
  34. 2023Attention Sorting Combats Recency Bias In Long Context Language Modelscited by 90
  35. 2024Michelangelo: Long Context Evaluations Beyond Haystacks via Latent Structure Queriescited by 88
  36. 2024Eigen Attention: Attention in Low-Rank Space for KV Cache Compressioncited by 72
  37. 2024Training-Free Long-Context Scaling of Large Language Modelscited by 62
  38. 2025InfLLM-V2: Dense-Sparse Switchable Attention for Seamless Short-to-Long Adaptationcited by 32

50 most cited of 57 All 57 (JSON)

Built on by

Cited by year (2026 to 14 Oct)

Citing papers per year: 2026: 3.

3 papers.

Similar, not cited

Close in wording, no citation either way

  1. 2024A Little Goes a Long Way: Efficient Long Context Training and Inference with Partial Contexts
  2. 2025Every Token Counts: Generalizing 16M Ultra-Long Context in Large Language Models
  3. 2025Breaking Quadratic Barriers: A Non-Attention LLM for Ultra-Long Context Horizons
  4. 2024Discovering the Gems in Early Layers: Accelerating Long-Context LLMs with 1000x Input Token Reduction
  5. 2026MKA: Memory-Keyed Attention for Efficient Long-Context Reasoning
  6. 2024TokenSelect: Efficient Long-Context Inference and Length Extrapolation for LLMs via Dynamic Token-Level KV Cache Selection
  7. 2025From 128K to 4M: Efficient Training of Ultra-Long Context Large Language Models
  8. 2026Probe and Skip: Self-Predictive Token Skipping for Efficient Long-Context LLM Inference