AIFeed

DeepSeek Rebuilt as a Looped Transformer! 8 Loops on Just 4 GPUs

AI summary

Is putting recurrence into the encoder really more useful?

Translation(model translation, not the source's own text)

DeepSeek Reworked into a Looped Transformer! 8 Loops on Just 4 GPUs

Does putting the loop into the encoder really help more?

henry from the Non-Orthodox Temple

QuantumBit | WeChat Official Account QbitAI

What happens if you rework DeepSeek V4.1-Flash into the recently popular Loop Transformer?

The answer: with the same 8 loops, the global KV footprint per token is only 1/36.8 of before!

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 concurrency capacity of the same machine also increased substantially.

In tests on 4 GB200s, the traditional per-layer, per-round caching scheme could not even fit a single 128K request, running out of VRAM outright; after switching to 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.6 times that of the traditional baseline.

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 historical cache.

First, the Loop Transformer, as the name suggests, has at its core making some of the Transformer's network layers work in a loop.

Take the 18 layers in this study: after the first round of computation ends, 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 tokens as computation goes deeper, each round re-"mixes" the original input features back in through a gating mechanism, equivalent to glancing down at the original question every round of thinking.

Repeating this, the model can perform multiple rounds of computation before predicting the next token without increasing the parameter count, 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, following the traditional scheme, the KV of every round is saved, then 8 loops mean maintaining separate caches for different rounds.

This makes the KV cache swell with the number of loops, ultimately offsetting the Loop Transformer's advantage in parameter count.

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 copy of the global KV covering the long context; instead, a small number of layers in the encoder generate 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 stored repeatedly across different layers can be shared.

But the problem is: cross-layer sharing is solved, so what about cross-round sharing?

If the Loop Transformer is plugged in directly, the layers responsible for writing the global KV would still produce a new KV cache for 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, each loop round of the encoder reprocesses the historical information and updates the global KV.

Thus, when subsequent tokens are computed, they can read long-range information that has been iteratively refined over multiple rounds.

By contrast, if the loop is placed in the decoder, each 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 whole scheme's cache compression.

The research team did not fix the number of loops at 8; instead, during training they randomly sampled the number of loop rounds for each sequence, averaging about 8.

In this way, the model needs to adapt to computation results under different loop depths and learn to keep the output state consistent across different round counts.

As the number of loops increases, the state changes between rounds grow 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 the KV states produced by multiple loop rounds are already highly close. During inference, the model only needs to keep the last round's KV cache, and the computations of other rounds can 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 into the encoder really help more?

In the experimental phase, to verify the usefulness of putting the loop into the encoder, the research team also conducted a series of experiments validating the loop position, the caching strategy, and actual inference efficiency.

First, what difference does it make whether the loop is placed in the encoder or the decoder?

The researchers had the model predict a passage 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.

By contrast, decoder looping instead slightly increased the prediction loss by 0.005 BPB.

This shows that in this architecture, having 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: per-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 across three models of different scales 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 a serving test with 8 loop rounds on 4 GB200s. They compared three schemes: 1. Traditional per-layer, per-round caching: KV is stored separately for every layer and every round. 2. Cross-layer sharing only: different layers can share the global KV, but different loop rounds are still cached separately. 3. Cross-layer sharing + last-round caching: cross-layer and cross-round sharing at the same time, keeping only the last round's KV.

The results show that under this configuration, the traditional scheme could not fit even a single 128K decoding request; with cross-layer sharing only, it could fit 7; and with the complete new scheme, it could fit 38 at once.

That is, compared with the traditional scheme, the new method reduces the global KV cache footprint of this architecture by 36.8 times.

In another concurrency test with 8K input and 1K output, the new scheme's peak throughput also reached 3.6 times the traditional per-layer, per-round caching baseline.

It is worth noting, however, that saving KV cache does not mean the model's computation also becomes cheaper.

With 8 loop rounds, the model still has to actually execute 8 rounds of computation.

On the 552-billion-parameter backbone model, the single-step decoding time with 8 loop rounds is still 3.95 times that of the non-looped original.

In addition, since the loop is placed in the encoder, when facing ultra-long inputs, the prefill stage likewise needs to execute 8 rounds of computation.

To this end, the research team also tested a compromise: loop only 4 rounds in the prefill stage, then restore 8 rounds upon entering the decoding stage.

Experiments show that this still retains more than 99% of the accuracy gains while reducing prefill time by nearly half.

About the authors

Finally, let's meet the author team behind this research.

Jiaqi Leng, a PhD student at the Hao AI Lab at UC San Diego, advised by Hao Zhang, and a graduate of Fudan University.

Previously, as a co-first author, he published research on hierarchical sparse attention 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 UC San Diego, also from Hao Zhang's lab, and a graduate of ShanghaiTech University.

His research interests include large-model inference infrastructure, GPU/TPU operator optimization, and sparse attention, and 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 parallel loop Transformers training stably as the number of loop rounds increases.

Title: DeepSeek Hacked into a Looped Transformer! 8 Loops on Just 4 GPUs

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

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

Hao Zhang is an assistant professor at the University of California, San Diego, and the head of Hao AI Lab; he is also the last author of this paper.

He mainly researches the intersection of machine learning and computer systems, and his representative work includes the large model inference engine vLLM and DistServe, which deploys prefill and decode separately.

Reference link [1] https://www.alphaxiv.org/pdf/2611.13378

  • Claude pretraining loss curves released! Compute burned far lower than expected 2026-12-05
  • A domestic Agent paper from the last century goes viral! Filled with today's AI buzzwords, produced by Wuhan University of Technology 2026-12-05
  • Just now, OpenAI claims to have disproved the four-dimensional smooth Poincaré conjecture! 2026-12-05
  • Clay Mathematics Institute: Oh no, nobody said this $1 million Millennium Prize had to be awarded to a human 2026-12-05

Related Reading

Officially recommended by DeepSeek: this is how R1 should be configured

Just now, DeepSeek made a major open-source release: the Agent foundation architecture!

AI has already found the bug itself and submitted a PR

Red-hot DeepSeek slices $4 trillion off Nvidia overnight, open-sources a new multimodal model on New Year's Eve

7B defeated DALL-E 3 and Stable Diffusion

Mafengwo AI agent becomes the first travel industry application to integrate DeepSeek

In the first phase, it will be prioritized for the already-launched "AI Tour Guizhou," "AI Tour Qianxinan," and "AI Tour Xijiang" three-tier provincial, city, and scenic-area AI application ecosystem

ByteDance found the reason DeepSeek is sometimes strong and sometimes weak

Whether it answers correctly depends on token position

DeepSeek and Huawei join forces in a hurry! SiliconFlow hits rate limits on first release, fully domestic API at cabbage price, zero-threshold deployment

Price/performance/speed all on par with the original version

The translation is machine-generated and individual terms may be off. Nothing is rewritten or cut; the original is authoritative.

Published by 量子位
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗