Free(): Learning to Forget in Malloc-Only Reasoning Models

Yilun Zheng, Dongyang Ma, Tian Liang, Jiahao Xu, Xinting Huang, Lihui Chen, Haitao Mi, Yan WangCOLM 2026

TL;DR

Reasoning models often "crash" when they think for too long because they lack a way to discard redundant information. Free()LM introduces a plug-and-play LoRA adapter that allows models to periodically prune their own context, transforming them from "malloc-only" engines into sustainable reasoners that can handle ultra-long trajectories (>100k tokens) without performance collapse.

What Problem Does This Paper Address?

Modern Large Language Models (LLMs) have achieved impressive reasoning capabilities by scaling "test-time compute"—essentially, giving the model more "thinking tokens" to work through a problem. However, the authors identify a critical bottleneck: as reasoning chains grow longer, they accumulate noise, repetitive loops, and obsolete intermediate steps.

Standard LLMs operate as "malloc-only" engines; they can allocate memory (add tokens to the context) but have no native free() function to deallocate it. Empirically, once thinking tokens occupy 70–90% of a context window, performance often drops sharply. In extreme cases, models like Qwen3-235B suffer a total collapse (0% accuracy) on tasks requiring over 80k tokens because the "cluttered" context becomes too noisy for the model to navigate.

Standard LLMs passively accumulate noise, leading to reasoning collapse, while Free()LM maintains a compact state.

Methods

The authors propose Free()LM, which augments a standard LLM backbone with a lightweight LoRA adapter called the Free-Module. The system operates in a cyclic two-mode framework:

  1. Reasoning Mode (Unmerged): The Free-Module is inactive. The model functions as a standard reasoning engine, generating tokens to solve the problem.
  2. Cleaning Mode (Merged): Once a specific token limit is reached, the Free-Module is merged into the backbone. The model stops reasoning and instead scans its own context to identify redundant segments. It outputs a structured JSON command (specifying unique "prefix" and "suffix" anchors) to prune these segments.
Figure 2: The Free()LM Inference Framework. The model operates on a cyclic Reasoning- Cleaning mechanism. Reasoning: The Main model generates tokens normally with the Free-Module unmerged. Cleaning: Upon reaching a chunk limit, the Free-Module is merged to identify and prune redundant chunks. Resumed Reasoning: The module is unmerged, and reasoning resumes on the cleaned context.

To train this module, the authors developed a sophisticated Data Construction Pipeline. They used a powerful "teacher" model (Gemini-2.5-Pro) to suggest candidate prunings and then applied a Reward Mechanism: a pruning operation was only kept in the training set if it maintained or improved the model's accuracy across multiple reasoning rollouts.

Figure 3: The Data Construction Pipeline. (a) Data Synthesis: We segment raw trajecto- ries into 1k-token chunks and employ Gemini-2.5-Pro to sequentially generate candidate training instances. (b) Reward Mechanism: By executing K = 8 parallel rollouts, we retain an instance only if the pruned context Cnew maintains or improves accuracy compared to the original (Acc(Cnew) ≥Acc(Craw)).

Datasets

The model was evaluated on a diverse suite of benchmarks categorized by reasoning length:

  • Long-Horizon Reasoning: AIME 24&25, BrUMO25, HMMT, BeyondAIME, Humanity’s Last Exam (HLE), and IMOAnswerBench. These require complex, multi-step logic often exceeding 20k tokens.
  • General Reasoning & Safety: BBH, MMLU-Pro, MMLU-STEM, and GPQA-Diamond. These served as control groups to ensure that the "forgetting" mechanism doesn't hurt general knowledge or short-form reasoning.
  • Training Data: Synthesized from 1,000 trajectories from the DeepMath-103k dataset.

Key Insights and Ideas

  • The Power of Forgetting: Sustainable intelligence requires the freedom to forget as much as the power to think. By pruning, the model keeps itself in a "sweet spot" of context length where it operates most comfortably.
  • "Deep Pruning" vs. Heuristics: Unlike heuristic methods (like H2O) that prune tokens based on attention scores, Free()LM performs "logic-aware" pruning. It understands which semantic steps are no longer needed. Heuristic methods often caused catastrophic degeneration by accidentally deleting essential clues.
  • Cross-Model Generalization: Remarkably, a Free-Module trained on an 8B model can be plugged into a 685B model (DeepSeek-V3.2-Speciale) without retraining, providing significant performance gains and context reduction. This suggests the "policy of forgetting" is somewhat universal across architectures.
  • Asymmetric Cost: The anchor-based pruning is highly efficient. A command of fewer than 100 tokens can trigger the removal of tens of thousands of context tokens, and the system can reuse the KV cache for the unchanged prefix to save compute.

Key Results

  • Performance Boost: Free()LM achieved a 3.3% average improvement across all benchmarks and model scales. It set a new SOTA on IMOAnswerBench using DeepSeek V3.2-Speciale.
  • Recovery from Collapse: On the HLE benchmark, while the vanilla Qwen3-235B model's accuracy dropped to 0% for trajectories longer than 80k tokens, Free()LM restored performance to ~50%.
  • Efficiency: It reduced average response lengths by 21% to 26% and achieved a 45% reduction in KV cache usage, which is critical for real-world serving where memory bandwidth is a bottleneck.
Figure 4: Performance vs. Reasoning Length on HLE. While standard Qwen3-235B-A22B suffers from Degradation on trajectories longer than 80k tokens, Free()LM exhibits a striking rebound in accuracy. On these cases, the Free-Module reduces the context length by ∼45%, effectively mitigating context pollution.

Limitations and Future Work

  • Fixed Intervals: Currently, the cleaning cycle is triggered at fixed token intervals. The authors note that a dynamic trigger based on context "pollution" levels might be more optimal.
  • Re-prefilling Overhead: The current implementation in vLLM requires re-prefilling the context after a deletion, which adds latency. The authors suggest that "KV Cache Pruning" (directly excising memory blocks) could reduce this overhead to ~20%, but it is not yet natively supported by standard serving frameworks.
  • Training Cost: The rollout-based verification used to create training data is computationally expensive. Future work could explore more efficient ways to generate high-quality "forgetting" supervision.

Summary updated

BibTeX
@inproceedings{zheng2026free,
  author = {Yilun Zheng and Dongyang Ma and Tian Liang and Jiahao Xu and Xinting Huang and Lihui Chen and Haitao Mi and Yan Wang},
  title = {{Free(): Learning to Forget in Malloc-Only Reasoning Models}},
  booktitle = {COLM},
  year = {2026},
  url = {https://openreview.net/forum?id=2BVxx3DDdJ},
}
Figure