Megalodon: Efficient LLM Pretraining and Inference with Unlimited Context Length
Not on the map. Why?
Abstract (arXiv)
The quadratic complexity and weak length extrapolation of Transformers limits their ability to scale to long sequences, and while sub-quadratic solutions like linear attention and state space models exist, they empirically underperform Transformers in pretraining efficiency and downstream task accuracy. We introduce Megalodon, a neural architecture for efficient sequence modeling with unlimited context length. Megalodon inherits the architecture of Mega (exponential moving average with gated attention), and further introduces multiple technical components to improve its capability and stability, including complex exponential moving average (CEMA), timestep normalization layer, normalized attention mechanism and pre-norm with two-hop residual configuration. In a controlled head-to-head comparison with Llama2, Megalodon achieves better efficiency than Transformer in the scale of 7 billion parameters and 2 trillion training tokens. Megalodon reaches a training loss of 1.70, landing mid-way between Llama2-7B (1.75) and 13B (1.67). Code: https://github.com/XuezheMax/megalodon
Key facts. Cited by 46 papers in the map (data through 7 Oct 2026). Builds on 56 of its 77 references that are in the map. First posted on arXiv 12 Apr 2024.
Builds on
56 of 77 references.
References · 56
- 2017Attention Is All You Needcited by 59,932
- 2019PyTorch: An Imperative Style, High-Performance Deep Learning Librarycited by 20,160
- 2023Llama 2: Open Foundation and Fine-Tuned Chat Modelscited by 12,865
- 2020Measuring Massive Multitask Language Understandingcited by 7,768
- 2015Batch Normalization: Accelerating Deep Network Training by Reducing Internal Covariate Shiftcited by 6,979
- 2016Layer Normalizationcited by 5,579
- 2018Think you have Solved Question Answering? Try ARC, the AI2 Reasoning Challengecited by 4,710
- 2021RoFormer: Enhanced Transformer with Rotary Position Embeddingcited by 4,581
- 2020Training data-efficient image transformers & distillation through attentioncited by 4,560
- 2019HellaSwag: Can a Machine Really Finish Your Sentence?cited by 4,018
- 2023Mistral 7Bcited by 3,065
- 2016Pointer Sentinel Mixture Modelscited by 2,992
38 more
- 2017TriviaQA: A Large Scale Distantly Supervised Challenge Dataset for Reading Comprehensioncited by 2,895
- 2019PIQA: Reasoning about Physical Commonsense in Natural Languagecited by 2,818
- 2023FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioningcited by 2,551
- 2021Efficiently Modeling Long Sequences with Structured State Spacescited by 2,424
- 2019BoolQ: Exploring the Surprising Difficulty of Natural Yes/No Questionscited by 2,140
- 2019Transformer-XL: Attentive Language Models Beyond a Fixed-Length Contextcited by 1,830
- 2019Megatron-LM: Training Multi-Billion Parameter Language Models Using Model Parallelismcited by 1,829
- 2020GLU Variants Improve Transformercited by 1,724
- 2018Group Normalizationcited by 1,514
- 2019Root Mean Square Layer Normalizationcited by 1,425
- 2021Swin Transformer V2: Scaling Up Capacity and Resolutioncited by 1,215
- 2020On Layer Normalization in the Transformer Architecturecited by 906
- 2023RWKV: Reinventing RNNs for the Transformer Eracited by 814
- 2020Efficient Transformers: A Surveycited by 784
- 2018Speech Commands: A Dataset for Limited-Vocabulary Speech Recognitioncited by 741
- 2019Compressive Transformers for Long-Range Sequence Modellingcited by 699
- 2020Long Range Arena: A Benchmark for Efficient Transformerscited by 696
- 2017The NarrativeQA Reading Comprehension Challengecited by 590
- 2023YaRN: Efficient Context Window Extension of Large Language Modelscited by 584
- 2022Hungry Hungry Hippos: Towards Language Modeling with State Space Modelscited by 495
- 2021A Dataset of Information-Seeking Questions and Answers Anchored in Research Paperscited by 475
- 2023Ring Attention with Blockwise Transformers for Near-Infinite Contextcited by 448
- 2022On the Parameterization and Initialization of Diagonal State Space Modelscited by 418
- 2023Hyena Hierarchy: Towards Larger Convolutional Language Modelscited by 388
- 2021QMSum: A New Benchmark for Query-based Multi-domain Meeting Summarizationcited by 363
- 2023Effective Long-Context Scaling of Foundation Modelscited by 301
- 2020Query-Key Normalization for Transformerscited by 266
- 2019Stabilizing Transformers for Reinforcement Learningcited by 262
- 2018Adaptive Input Representations for Neural Language Modelingcited by 226
- 2022Transformer Quality in Linear Timecited by 189
- 2022Mega: Moving Average Equipped Gated Attentioncited by 178
- 2022SCROLLS: Standardized CompaRison Over Long Language Sequencescited by 170
- 2023MEGABYTE: Predicting Million-byte Sequences with Multiscale Transformerscited by 164
- 2017Searching for Activation Functionscited by 158
- 2018ListOps: A Diagnostic Dataset for Latent Tree Learningcited by 128
- 2022Block-Recurrent Transformerscited by 107
- 2022Scaling Laws vs Model Architectures: How does Inductive Bias Influence Scaling?cited by 103
- 2018Learning long-range spatial dependencies with horizontal gated-recurrent unitscited by 98
50 most cited of 56 All 56 (JSON)
Built on by
Citing papers per year: 2024: 24; 2025: 13; 2026: 9.
46 papers.
Sort:
By area:
- 2024FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precisioncited by 507
- 2024Parallelizing Linear Transformers with the Delta Rule over Sequence Lengthcited by 373
- 2024Chain of Agents: Large Language Models Collaborating on Long-Context Taskscited by 201
- 2024Samba: Simple Hybrid State Space Models for Efficient Unlimited Context Language Modelingcited by 167
- 2025Test-Time Training Done Rightcited by 121
- 2024Hyper-Connectionscited by 81
- 2024Speculative RAG: Enhancing Retrieval Augmented Generation through Draftingcited by 76
- 2026Mamba-3: Improved Sequence Modeling using State Space Principlescited by 76
- 2025The Curse of Depth in Large Language Modelscited by 58
- 2025Forgetting Transformer: Softmax Attention with a Forget Gatecited by 50
- 2025Rope to Nope and Back Again: A New Hybrid Attention Strategycited by 46
- 2024Mix-LN: Unleashing the Power of Deeper Layers by Combining Pre-LN and Post-LNcited by 37
34 more
- 2024Large Language Model Inference Acceleration: A Comprehensive Hardware Perspectivecited by 36
- 2024LongReward: Improving Long-context Large Language Models with AI Feedbackcited by 34
- 2024Conv-Basis: A New Paradigm for Efficient Attention Inference and Gradient Computation in Transformerscited by 32
- 2024Training Tensor Attention Efficiently: From Cubic to Almost Linear Timecited by 29
- 2024B'MOJO: Hybrid State Space Realizations of Foundation Models with Eidetic and Fading Memorycited by 26
- 2026MemRoPE: Training-Free Infinite Video Generation via Evolving Memory Tokenscited by 20
- 2025Understanding and Improving Length Generalization in Recurrent Modelscited by 19
- 2024Understanding and Mitigating Bottlenecks of State Space Models through the Lens of Recency and Over-smoothingcited by 17
- 2024ViG: Linear-complexity Visual Sequence Learning with Gated Linear Attentioncited by 13
- 2024CiteAssist: A System for Automated Preprint Citation and BibTeX Generationcited by 11
- 2024Efficient Streaming LLM for Speech Recognitioncited by 10
- 2024Provable Benefits of Complex Parameterizations for Structured State Space Modelscited by 9
- 2024Toward Conversational Agents with Context and Time Sensitive Long-term Memorycited by 8
- 2024EEG Emotion Copilot: Optimizing Lightweight LLMs for Emotional EEG Interpretation with Assisted Medical Record Generationcited by 6
- 2024On the Power of Convolution Augmented Transformercited by 5
- 2025From General to Targeted Rewards: Surpassing GPT-4 in Open-Ended Long-Context Generationcited by 4
- 2025Routing Mamba: Scaling State Space Models with Mixture-of-Experts Projectioncited by 4
- 2025Local Linear Attention: An Optimal Interpolation of Linear and Softmax Attention For Test-Time Regressioncited by 4
- 2024Flash Inference: Near Linear Time Inference for Long Convolution Sequence Models and Beyondcited by 3
- 2025Interactive Data Harmonization with LLM Agents: Opportunities and Challengescited by 3
- 2025Dynamic Chunking and Selection for Reading Comprehension of Ultra-Long Context in Large Language Modelscited by 3
- 2025RAT: Bridging RNN Efficiency and Attention Accuracy via Chunk-based Sequence Modelingcited by 3
- 2025MemMamba: Rethinking Memory Patterns in State Space Modelcited by 3
- 2025Elucidating the Design Space of Decay in Linear Attentioncited by 1
- 2026The Impossibility Triangle of Long-Context Modelingcited by 1
- 2026Blurry Window Attentioncited by 1
- 2026State Propagation Also Satisfies: A Complex-Valued State-Space Model for Deterministic State Trackingcited by 1
- 2024SUBLLM: A Novel Efficient Architecture with Token Sequence Subsampling for LLMcited by 0
- 2024Role-RL: Online Long-Context Processing with Role Reinforcement Learning for Distinct LLMs in Their Optimal Rolescited by 0
- 2024How much do contextualized representations encode long-range context?cited by 0
- 2026Gecko: An Efficient Neural Architecture Inherently Processing Sequences with Arbitrary Lengthscited by 0
- 2026Stacked from One: Multi-Scale Self-Injection for Context Window Extensioncited by 0
- 2026Cubit: Token Mixer with Kernel Ridge Regressioncited by 0
- 2026Cracks in the Foundation: Seemingly Minor Architectural Choices Impact Long Context Extensioncited by 0
- 2026Cracks in the Foundation: Seemingly Minor Architectural Choices Impact Long Context Extension10 Aug 2026
- 2026State Propagation Also Satisfies: A Complex-Valued State-Space Model for Deterministic State Tracking4 Aug 2026
- 2026Blurry Window Attention31 May 2026
- 2026Cubit: Token Mixer with Kernel Ridge Regression7 May 2026
- 2026The Impossibility Triangle of Long-Context Modeling6 May 2026
- 2026Mamba-3: Improved Sequence Modeling using State Space Principles16 Mar 2026
- 2026MemRoPE: Training-Free Infinite Video Generation via Evolving Memory Tokens12 Mar 2026
- 2026Stacked from One: Multi-Scale Self-Injection for Context Window Extension5 Mar 2026
- 2026Gecko: An Efficient Neural Architecture Inherently Processing Sequences with Arbitrary Lengths10 Jan 2026
- 2025Local Linear Attention: An Optimal Interpolation of Linear and Softmax Attention For Test-Time Regression1 Oct 2025
- 2025MemMamba: Rethinking Memory Patterns in State Space Model28 Sep 2025
- 2025Elucidating the Design Space of Decay in Linear Attention5 Sep 2025
34 more
- 2025RAT: Bridging RNN Efficiency and Attention Accuracy via Chunk-based Sequence Modeling6 Jul 2025
- 2025Understanding and Improving Length Generalization in Recurrent Models3 Jul 2025
- 2025Routing Mamba: Scaling State Space Models with Mixture-of-Experts Projection22 Jun 2025
- 2025From General to Targeted Rewards: Surpassing GPT-4 in Open-Ended Long-Context Generation19 Jun 2025
- 2025Dynamic Chunking and Selection for Reading Comprehension of Ultra-Long Context in Large Language Models1 Jun 2025
- 2025Test-Time Training Done Right29 May 2025
- 2025Forgetting Transformer: Softmax Attention with a Forget Gate3 Mar 2025
- 2025Interactive Data Harmonization with LLM Agents: Opportunities and Challenges10 Feb 2025
- 2025The Curse of Depth in Large Language Models9 Feb 2025
- 2025Rope to Nope and Back Again: A New Hybrid Attention Strategy30 Jan 2025
- 2024Understanding and Mitigating Bottlenecks of State Space Models through the Lens of Recency and Over-smoothing31 Dec 2024
- 2024Mix-LN: Unleashing the Power of Deeper Layers by Combining Pre-LN and Post-LN18 Dec 2024
- 2024LongReward: Improving Long-context Large Language Models with AI Feedback28 Oct 2024
- 2024Provable Benefits of Complex Parameterizations for Structured State Space Models17 Oct 2024
- 2024Flash Inference: Near Linear Time Inference for Long Convolution Sequence Models and Beyond16 Oct 2024
- 2024How much do contextualized representations encode long-range context?16 Oct 2024
- 2024Large Language Model Inference Acceleration: A Comprehensive Hardware Perspective6 Oct 2024
- 2024Efficient Streaming LLM for Speech Recognition2 Oct 2024
- 2024EEG Emotion Copilot: Optimizing Lightweight LLMs for Emotional EEG Interpretation with Assisted Medical Record Generation30 Sep 2024
- 2024Hyper-Connections29 Sep 2024
- 2024Role-RL: Online Long-Context Processing with Role Reinforcement Learning for Distinct LLMs in Their Optimal Roles26 Sep 2024
- 2024FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precision11 Jul 2024
- 2024Speculative RAG: Enhancing Retrieval Augmented Generation through Drafting11 Jul 2024
- 2024B'MOJO: Hybrid State Space Realizations of Foundation Models with Eidetic and Fading Memory8 Jul 2024
- 2024On the Power of Convolution Augmented Transformer8 Jul 2024
- 2024CiteAssist: A System for Automated Preprint Citation and BibTeX Generation3 Jul 2024
- 2024Samba: Simple Hybrid State Space Models for Efficient Unlimited Context Language Modeling11 Jun 2024
- 2024Parallelizing Linear Transformers with the Delta Rule over Sequence Length10 Jun 2024
- 2024Chain of Agents: Large Language Models Collaborating on Long-Context Tasks4 Jun 2024
- 2024SUBLLM: A Novel Efficient Architecture with Token Sequence Subsampling for LLM3 Jun 2024
- 2024Toward Conversational Agents with Context and Time Sensitive Long-term Memory29 May 2024
- 2024ViG: Linear-complexity Visual Sequence Learning with Gated Linear Attention28 May 2024
- 2024Training Tensor Attention Efficiently: From Cubic to Almost Linear Time26 May 2024
- 2024Conv-Basis: A New Paradigm for Efficient Attention Inference and Gradient Computation in Transformers8 May 2024
- 2024Samba: Simple Hybrid State Space Models for Efficient Unlimited Context Language Modelingcited by 167
- 2024Understanding and Mitigating Bottlenecks of State Space Models through the Lens of Recency and Over-smoothingcited by 17
- 2024Provable Benefits of Complex Parameterizations for Structured State Space Modelscited by 9
- 2025MemMamba: Rethinking Memory Patterns in State Space Modelcited by 3
- 2025MemMamba: Rethinking Memory Patterns in State Space Model28 Sep 2025
- 2024Understanding and Mitigating Bottlenecks of State Space Models through the Lens of Recency and Over-smoothing31 Dec 2024
- 2024Provable Benefits of Complex Parameterizations for Structured State Space Models17 Oct 2024
- 2024Samba: Simple Hybrid State Space Models for Efficient Unlimited Context Language Modeling11 Jun 2024
- 2025Test-Time Training Done Rightcited by 121
- 2025Test-Time Training Done Right29 May 2025
- 2024FlashAttention-3: Fast and Accurate Attention with Asynchrony and Low-precisioncited by 507
- 2024Parallelizing Linear Transformers with the Delta Rule over Sequence Lengthcited by 373
- 2024Hyper-Connectionscited by 81
- 2025The Curse of Depth in Large Language Modelscited by 58
- 2025Forgetting Transformer: Softmax Attention with a Forget Gatecited by 50
- 2025Rope to Nope and Back Again: A New Hybrid Attention Strategycited by 46
- 2024Mix-LN: Unleashing the Power of Deeper Layers by Combining Pre-LN and Post-LNcited by 37
- 2024Conv-Basis: A New Paradigm for Efficient Attention Inference and Gradient Computation in Transformerscited by 32
- 2024Training Tensor Attention Efficiently: From Cubic to Almost Linear Timecited by 29
- 2024B'MOJO: Hybrid State Space Realizations of Foundation Models with Eidetic and Fading Memorycited by 26
- 2026MemRoPE: Training-Free Infinite Video Generation via Evolving Memory Tokenscited by 20
- 2025Understanding and Improving Length Generalization in Recurrent Modelscited by 19
12 most cited of 31 All 31 (JSON)
- 2026Cracks in the Foundation: Seemingly Minor Architectural Choices Impact Long Context Extension10 Aug 2026
- 2026State Propagation Also Satisfies: A Complex-Valued State-Space Model for Deterministic State Tracking4 Aug 2026
- 2026Cubit: Token Mixer with Kernel Ridge Regression7 May 2026
- 2026The Impossibility Triangle of Long-Context Modeling6 May 2026
- 2026MemRoPE: Training-Free Infinite Video Generation via Evolving Memory Tokens12 Mar 2026
- 2026Gecko: An Efficient Neural Architecture Inherently Processing Sequences with Arbitrary Lengths10 Jan 2026
- 2025Local Linear Attention: An Optimal Interpolation of Linear and Softmax Attention For Test-Time Regression1 Oct 2025
- 2025Elucidating the Design Space of Decay in Linear Attention5 Sep 2025
- 2025RAT: Bridging RNN Efficiency and Attention Accuracy via Chunk-based Sequence Modeling6 Jul 2025
- 2025Understanding and Improving Length Generalization in Recurrent Models3 Jul 2025
- 2025From General to Targeted Rewards: Surpassing GPT-4 in Open-Ended Long-Context Generation19 Jun 2025
- 2025Dynamic Chunking and Selection for Reading Comprehension of Ultra-Long Context in Large Language Models1 Jun 2025
12 newest of 31 All 31 (JSON)
Similar, not cited
Close in wording, no citation either way
- 2024InfLLM: Training-Free Long-Context Extrapolation for LLMs with an Efficient Context Memory
- 2025From 128K to 4M: Efficient Training of Ultra-Long Context Large Language Models
- 2024DeciMamba: Exploring the Length Extrapolation Potential of Mamba
- 2023Response Length Perception and Sequence Scheduling: An LLM-Empowered LLM Inference Pipeline
- 2023LongLLMLingua: Accelerating and Enhancing LLMs in Long Context Scenarios via Prompt Compression
- 2025Overflow Prevention Enhances Long-Context Recurrent LLMs
- 2025LMDeploy Accelerates Mixed-Precision LLM Inference with TurboMind
- 2025AccLLM: Accelerating Long-Context LLM Inference Via Algorithm-Hardware Co-Design