# Neural Garbage Collection: Learning to Forget while Learning to Reason

*Michael Li, Jubayer Ibn Hamid, Emily Fox, Noah Goodman*

[NeurIPS page](https://neurips.cc/virtual/2026/poster/151937) · [OpenReview](https://openreview.net/forum?id=WibVOPxZMf) · [alphaXiv](https://www.alphaxiv.org/abs/2604.18002) · [Open on the map](../papers.html#p151937)

Category: [Efficient LLM Inference & Training](../pcat/14.md) › [KV Cache Optimization](../pgroup/283.md) · Type: new method · Keywords: language model reasoning, KV cache management, reinforcement learning, memory compression, chain-of-thought

Areas: [LLM Reasoning](../areas/reasoning.md) › Efficient Reasoning › KV Cache Compression; [Memory](../areas/memory.md) › Model Memory Optimization › KV Cache Optimization

## Summary
Neural Garbage Collection (NGC) is an end-to-end reinforcement learning approach that lets language models learn to evict KV cache entries while reasoning, achieving 2-3× compression in peak KV cache size without sacrificing accuracy.

## Explained to a 5-year-old
A computer brain learns to think step by step. While it thinks, it keeps a notebook of what it remembers. It learns to decide which notes to throw away so it doesn't get too full. By learning when to forget, it can still solve hard math problems. This helps the computer work better and use less memory.

## Explained to a 5-year-old, longer
A computer program can think by writing down each step of its reasoning. It stores these steps in a special place called a cache. The cache can get very big if the program thinks a lot. To stop the cache from getting too big, the program learns to choose which steps to forget. It decides what to keep based on what it needs to finish the problem. The program learns this forgetting skill by trying to solve math problems. It gets a reward when it solves the problem correctly. By learning both how to think and when to forget, it works faster. It can still solve hard problems even though it remembers less. This makes the program more efficient and uses less memory. It helps the computer do more with fewer resources. In the end, the program becomes smarter and leaner at the same time.

## For a technical reader
The paper presents an end-to-end reinforcement learning framework that jointly optimizes reasoning and memory management in language models. The model treats both reasoning tokens and cache eviction decisions as actions sampled from the model, updating its policy based on task reward. During inference, the model periodically pauses to evict selected KV cache entries, continuing reasoning conditioned on the remaining cache. This approach achieves 2-3× compression of peak KV cache size while preserving accuracy and outperforming prior eviction baselines. The method eliminates the need for hand-crafted eviction heuristics and proxy objectives, demonstrating a scalable path toward more efficient language model inference.

## Problem
Chain-of-thought reasoning expands the KV cache with each step, creating a memory bottleneck that limits scaling. Existing methods use hand-designed eviction criteria, which cannot fully optimize reasoning and memory jointly.

## Method
The approach treats both chain-of-thought tokens and cache eviction decisions as discrete actions sampled from the language model, using reinforcement learning to optimize reasoning and memory management jointly from a single task reward signal. The model periodically pauses during reasoning to decide which KV cache entries to evict and continues reasoning conditioned on the remaining cache. This end-to-end training avoids supervised fine-tuning or proxy objectives.

## Results
The approach maintains strong accuracy compared to full-cache baselines while achieving 2-3× compression in peak KV cache size and significantly outperforms existing eviction methods on the evaluated tasks.

## Contributions
A reinforcement learning framework that jointly optimizes reasoning and memory management, learning to evict KV cache entries from a single task reward without supervised signals, and empirical results showing effective cache compression and performance gains.

## Practical relevance
It enables scaling language models with longer reasoning chains by efficiently managing memory, paving the way for more capable and resource-efficient AI systems.

## Research questions this paper is counted under

- [How can we compress or evict key-value cache entries to reduce memory usage without degrading LLM performance?](../q/21.md)

This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. [Suggest a correction](../feedback/?on=p/151937)
