Memory Grafting: Scaling Language Model Pre-training via Offline Conditional Memory

Runxi Cheng, Yuchen Guan, Yongxian Wei, Qianpu Sun, Qixiu Li +5 more
5/20/2026
cs.CL

No confident code implementation found for this paper. 1 possible match can be shown below.

Abstract

Scaling conditional memory offers a promising way to increase language-model capacity, but existing methods such as Engram learn large memory tables from scratch during pre-training, making memory scaling expensive and sometimes ineffective. We propose Memory Grafting, a conditional memory scaling method that utilizes frozen hidden states from a grafting model as conditional n-gram memory. Given frequent local n-grams, we run the grafting model offline, store final-token hidden representations as memory values, and let the recipient model retrieve them through exact longest-match suffix lookup. Retrieved memories are adapted by lightweight projections and gates, while a hash-based Engram fallback preserves coverage for unmatched contexts. Since the grafting model is only run offline and exact lookup has expected O(1) complexity with respect to memory-bank size, Memory Grafting expands external latent capacity with limited training and inference overhead. Experiments under matched recipient architectures and pre-training budgets show that Memory Grafting improves over both MoE and vanilla Engram baselines. In the 2.8B-scale setting, it improves the average benchmark score from 51.95 for MoE and 52.43 for vanilla Engram to 53.86. In the 0.92B-scale setting, all grafting-model variants improve over the baselines, with Qwen3.5-35B-A3B giving the strongest gains. These results suggest that pretrained models can serve as reusable constructors of external latent memory, providing a practical step toward scaling future language models beyond trainable parameters alone.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. 1 weaker match is hidden by default — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{cheng2026memory,
  title  = {Memory Grafting: Scaling Language Model Pre-training via Offline Conditional Memory},
  author = {Runxi Cheng and Yuchen Guan and Yongxian Wei and Qianpu Sun and Qixiu Li and Sinan Du and Feng Xiong and Chun Yuan and Yan Lu and Yeyun Gong},
  year   = {2026},
  eprint = {2605.20948},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2605.20948v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2605.20948.svg)](https://codeofpaper.com/paper/2605.20948)

Discussion