Full Report
Contents5 sections
Does putting the loop in the encoder really make it more useful?
henry from the Non-Obvious Lab
QbitAI | WeChat Official Account QbitAI
What happens if you turn DeepSeek V4.1-Flash into the recently popular Loop Transformer?
The answer: with the same 8 rounds of looping, the global KV footprint per token is only 1/36.8 of the previous amount!
This result comes from the latest research by UC San Diego, Tsinghua University, Nanjing University, and other institutions:

In the study, the team grouped 18 layers in the encoder into a loop block on the DeepSeek V4.1-Flash architecture, running the same set of weights continuously for 8 rounds.
As a result, not only did the global KV cache footprint per token drop to 1/36.8 of the traditional approach, but the concurrent capacity of the same machine also increased substantially.
In tests on 4 GB200s, the traditional layer-by-layer, round-by-round caching scheme could not even fit a single 128K request and immediately ran out of GPU memory; with the paper's new method, it fit 38 at once!
In another concurrency test with 8K input and 1K output, the new scheme's peak throughput also reached 3.6x the traditional baseline.
How was this achieved?
The same set of layers can run 8 times, so why store 8 copies of the KV?
Overall, the core idea of this paper is to graft the multi-round loop computation of the Loop Transformer onto the shared cache architecture (CED) of DeepSeek V4.1-Flash, and to let different rounds share the same history cache.
First, look at the Loop Transformer. As the name suggests, its core is to make some network layers of the Transformer work in a loop.
Take the 18 layers in this study: after the first round of computation, the model sends the resulting intermediate state back to the entrance of these 18 layers and computes it again with the same set of weights.
To prevent the model from "forgetting" the original input words after several rounds, each round uses a gating mechanism to "mix" the original input features back in, equivalent to glancing down at the original question in every round of thinking.
By repeating this, the model can perform multiple rounds of computation before predicting the next token without increasing the number of parameters, gaining deeper network expressiveness.
But problems follow. During actual inference, the intermediate state produced by each loop round may differ, and the corresponding KV cache naturally changes as well.
If, according to the traditional scheme, the KV of every round is saved, then 8 rounds of looping mean maintaining separate caches for different rounds.
This makes the KV cache grow continuously with the number of loop rounds, ultimately offsetting the parameter-efficiency advantage of the Loop Transformer.
To solve this problem, the research team focused on a design already adopted by DeepSeek V4.1-Flash: the causal encoder-decoder architecture (CED).
Specifically, the model no longer has every layer independently store a global KV covering the long context; instead, a small number of layers in the encoder are responsible for generating the global KV, and subsequent decoder layers share and read it.
At the same time, each layer only needs to keep a short sliding window cache (SWA) for attending to the most recent 128 tokens. In this way, long-context information that originally had to be repeatedly stored across different layers can be shared.
But the question is: cross-layer sharing is solved, but what about cross-round sharing?
If the Loop Transformer is plugged in directly, the layers responsible for writing the global KV will still produce a new KV cache in every loop round.
The research team made two key changes for this.
First, put the loop in the encoder, so that the layers responsible for writing the global KV also participate in the loop.
Specifically, in every loop round, the encoder reprocesses the history information and updates the global KV.
In this way, when subsequent tokens are computed, they can read long-range information that has been iteratively refined over multiple rounds.
In contrast, if the loop is placed in the decoder, every round still reads the global KV pre-generated by the encoder.
Although the decoder performs multiple rounds of computation, the global KV itself is not updated accordingly.

Second, randomly decide the number of loop rounds during training, and keep only the last round's KV during inference.
This is the key to the entire scheme's cache compression.
The research team did not fix the number of loop rounds at 8; instead, during training they randomly sampled the number of loop rounds for each sequence, averaging about 8 rounds.
In this way, the model needs to adapt to computation results under different loop depths and learn to maintain consistency of output state across different numbers of rounds.
As the number of loop rounds increases, the state changes between rounds become smaller and smaller, eventually approaching a stable state, the so-called "fixed point."
Experiments show that by the 8th round, the inter-layer state change is already only 1.7%.
This means that the KV states produced by multiple loop rounds are already highly similar. During inference, the model only needs to keep the last round's KV cache, allowing the computation of other rounds to share this cache.
The KV that originally had to be saved separately for multiple loop rounds now only needs to be stored once.
Does putting the loop in the encoder really make it more useful?
In the experimental stage, to verify the usefulness of putting the loop in the encoder, the research team also conducted a series of experiments to validate the loop position, caching strategy, and actual inference efficiency.
First, what is the difference in effect between placing the loop in the encoder versus the decoder?
The researchers had the model predict a piece of text that repeats verbatim after 1024 tokens, testing the model's ability to capture long-range information.
On a 150-million-parameter model, with the non-looped CED as the baseline, encoder looping reduced the prediction loss by 0.084 BPB.
In contrast, decoder looping instead slightly increased the prediction loss by 0.005 BPB.

This shows that in this architecture, letting the encoder responsible for generating the global KV participate in the loop is indeed more conducive to the model handling long-range dependencies.
Second, will keeping only the last round's KV hurt model accuracy?
The research team compared two schemes: round-by-round caching and last-round caching.
The results show that for models trained with a random number of rounds, after switching to last-round caching, the BPB changes of three models of different sizes were all within 0.0002, almost negligible.

Finally, how much concurrency can the saved KV cache actually buy?
The research team used the DeepSeek V4.1-Flash backbone to run an 8-round cyclic serving test on 4 GB200 GPUs. They compared three approaches:
- Traditional per-layer, per-round caching: KV is stored separately for each layer and each round.
- Cross-layer sharing only: different layers can share a global KV, but different loop rounds are still cached separately.
- Cross-layer sharing + last-round caching: cross-layer and cross-round sharing are achieved simultaneously, keeping only the last round's KV.
The results show that under this configuration, the traditional approach cannot even accommodate a single 128K decoding request; with cross-layer sharing only, it can accommodate 7; and with the full new approach, it can accommodate 38 at once.

In other words, compared with the traditional approach, the new method reduces the global KV cache footprint of this architecture by 36.8x.
In another concurrency test with 8K input and 1K output, the peak throughput of the new approach also reached 3.6x that of the traditional per-layer, per-round caching baseline.
It is worth noting, however, that saving KV cache does not mean model computation becomes cheaper as well.
With 8 loop rounds, the model still has to actually perform 8 rounds of computation.
On the 552-billion-parameter backbone model, the single-step decoding latency with 8 loop rounds is still 3.95x that of the original non-looped version.
In addition, because the loop is placed in the encoder, when facing ultra-long inputs, the prefill stage also needs to perform 8 rounds of computation.
To this end, the research team also tested a compromise: loop only 4 rounds during the prefill stage, then restore 8 rounds after entering the decoding stage.
Experiments show that this can still retain more than 99% of the accuracy gains while reducing prefill time by nearly half.
About the Authors
Finally, let us meet the author team behind this research.
Jiaqi Leng, a PhD student at the Hao AI Lab at the University of California, San Diego, advised by Hao Zhang, and received his bachelor's degree from Fudan University.
He previously published research on hierarchical sparse attention as a co-first author at ICLR 2026, focusing mainly on how models handle contexts longer than those seen during training.

Minshen Zhang, a master's student in computer science at the University of California, San Diego, also from Hao Zhang's lab, and received his bachelor's degree from ShanghaiTech University.
His research interests include large model inference infrastructure, GPU/TPU operator optimization, and sparse attention. He is a co-first author of the inference engine FastAFD paper.

Zhaofeng Sun, an undergraduate in computer science at Tsinghua University, collaborating with Hao Zhang at the Hao AI Lab on efficient language model architectures and parallel decoding.
He is also the first author of InfuseLoop, which focuses on how to keep training stable for parallel looped Transformers as the number of loop rounds increases.

Yu-Yang Qian, a PhD student at LAMDA at Nanjing University, advised by Zhihua Zhou, and also a visiting student at the Hao AI Lab. As first author, he has published OnlineSpec and d3LLM, which improve speculative decoding through online learning and accelerate diffusion language model inference, respectively.

Peng Zhao, a tenure-track associate professor and doctoral supervisor at the School of Artificial Intelligence at Nanjing University, and a member of LAMDA. His research interests include online learning and optimization, as well as large model inference work such as speculative decoding.

Hao Zhang, an assistant professor at the University of California, San Diego and head of the Hao AI Lab, and the senior author of this paper.
He mainly researches the intersection of machine learning and computer systems. His representative work includes the large model inference engine vLLM and DistServe, which deploys prefill and decoding separately.
Reference links [1] https://www.alphaxiv.org/pdf/2611.13378