@qingke_ai: 循环 Transformer 的投机解码,速度提升了 10 到 14 倍。原因不是模型变强,是 KV cache 的搬运方式改了。 循环 Transformer 用共享权重块反复迭代 R 步,每步各自维护一份 KV cache。WaveF…
摘要
论文提出 LoopCache,通过置信度引导的动态草稿更新与循环 KV cache 调度,加速循环 Transformer 的长上下文自投机解码,相比 WFD 和 LoopSpec 分别实现 10.25 倍和 14.56 倍平均加速。
查看缓存全文
缓存时间: 2026/11/21 06:15
循环 Transformer 的投机解码,速度提升了 10 到 14 倍。原因不是模型变强,是 KV cache 的搬运方式改了。
循环 Transformer 用共享权重块反复迭代 R 步,每步各自维护一份 KV cache。WaveFront 和 LoopSpec 这类「波前式投机」把不同循环的起草与验证流水化,但有两个毛病:只在固定循环起草,中间预测变了也不知道,算力浪费在过期轨迹上;而且每步要把不同循环的 token 拼批,最多要加载 R 倍的 KV cache,长上下文下显存带宽直接爆炸。
LoopCache 对应两处改动。一是根据「预测切换」与「输出置信度」的相关性,做置信度引导的动态草稿更新,让草稿在所有中间循环里持续修正。二是循环 KV cache:轮流使用各循环的 KV,把每步的 KV 流量压到一份,同时把 token 批到最近的匹配周期上做无损验证。再加上对少数「循环敏感」的浅层单独保留 KV,接受率也上去了,开销可以忽略。
结果:相对 WFD 平均 10.25 倍、相对 LoopSpec 平均 14.56 倍加速。
判断:这类工作的价值在于暴露了循环架构的隐性成本——不是算力,是每步都在搬多份 KV。改数据流比改模型结构便宜得多。
边界:只针对循环 Transformer 这一族架构;倍数是相对这两个基线的,换成别的投机方法结论会变;长上下文场景下的显存占用改善需要看具体序列长度。
https://arxiv.org/abs/2611.24301
Accelerating Long-Context Self-Speculative Decoding for Looped Transformers
Source: https://arxiv.org/html/2611.24301
LoopCache: Accelerating Long-Context Self-Speculative Decoding for Looped TransformersThanks:Contact email:[email protected]. Corresponding author: Meng Li ([email protected]).
Haochen HuangShengxuan QiuLinye WeiAffiliation:Ziyu Tang Runsheng Wang Meng LiAffiliation:Peking University
Abstract
Looped Transformers achieve large effective depth with compact models by repeatedly applying a weight-shared block acrossRRrecurrent steps, each maintaining a loop-specific key-value (KV) cache. To accelerate sequential loop execution, recent wave-style self-speculative methods like WaveFront Decoding (WFD) and LoopSpec pipeline draft and target tokens across loops in a single step. However, they face two critical limitations. First, they draft only at fixed loops and ignore intermediate prediction changes, wasting computation on stale trajectories. Second, batching tokens from different loops loads up toR×R\timesthe KV cache per step, severely amplifying memory traffic in long-context scenarios. To address these challenges, we propose LoopCache, an efficient self-speculative decoding framework for long-context Looped Transformers. Based on the correlation between prediction switches and output confidence, LoopCache introduces confidence-guided dynamic draft updating to refine drafts in flight across all intermediate loops. Furthermore, LoopCache employs cyclic loop KV cache scheduling that rotates through loop-specific KV caches, restricting per-step KV traffic to a single loop while batching tokens at the nearest matching cycle for lossless verification. By also selectively retaining independent KV caches for a few loop-sensitive shallow layers, LoopCache improves acceptance rates with negligible overhead. Experiments show that LoopCache achieves average 10.25×\timesand 14.56×\timesspeedup over WFD and LoopSpec.Code repository:https://github.com/zZzZ9zZ9/LoopCache.
1Introduction
Figure 1:Architecture of looped Transformers.Looped Transformers have recently emerged as a promising architecture for scaling test-time compute[18,40,28,37,30,24,14]. By repeatedly applying a shared block of layers across multiple recurrent steps, these models refine hidden representations iteratively, increasing effective depth without adding parameters. Meanwhile, modern applications such as chain-of-thought reasoning[8,26,31]and long-horizon agents[23,37]increasingly demand long-context decoding over tens of thousands of tokens[2,15,16,27,9,35,17]. However, combining recurrent depth with long contexts creates a severe inference bottleneck, as every generated token requires multiple sequential passes through the recurrent block while attending toa massive key-value (KV) cache.
As illustrated in Fig.1, a looped Transformer contains a recurrent block between optional prelude and coda layers. The block runs forRRloops, whereRRdenotes the recurrence depth. Although the recurrent steps share the same model weights, each step maintains its own KV cache. Under conventional autoregressive (AR) decoding, each token must complete allRRrecurrent steps before the next token can be processed, as shown in Fig.2(a). Nevertheless, intermediate recurrent states can already provide useful next-token predictions, so a shallow loop can act as a natural draft model for the full-depth model. This makes looped transformers well suited to self-speculative decoding[25,22,13,38,5,39,32,34]. A straightforward approach is Draft-then-Verify (DtV), shown in Fig.2(b). DtV first generates multiple draft tokens using shallow recurrent computation, then verifies them in a batch using the remaining recurrent steps. However, drafting and verification remain separate phases, limiting their execution overlap.
Figure 2:Token generation dataflows and per-step KV cache read overheads for a Looped Transformer (R=4R=4) under (a) AutoRegressive, (b) Draft-then-Verify, and (c) WaveFront Decoding / LoopSpec.To overcome the sequential bottleneck of DtV, recent works such as WaveFront Decoding (WFD)[19]and LoopSpec[10]introduce wave-style pipelined self-speculative decoding. Exploiting the shared weights across recurrent blocks, these methods batch draft and target tokens at different recurrent depths into a single global step, as shown in Fig.2(c). This wave-style pipeline enables early verification and immediate trajectory correction compared to DtV, achieving higher token throughput in short-context scenarios.
Despite this progress, existing wave-style methods face two critical challenges. First, intermediate loops are underused. WFD and LoopSpec draft only at fixed loops, yet in a looped transformer every loop can produce a draft token. The predicted next token may change between an early loop and an intermediate loop. This change is ignored until the final loop verifies the token, and all later tokens built on the outdated draft are wasted. Second, wave-style batching inflates KV cache traffic. The batched tokens in one step sit at different loops, and each token reads the KV cache of its own loop. As Fig.2(c) shows, each step reads up toR×R\timesthe KV cache of AR and DtV. In long-context scenarios, thisR×R\timesmemory traffic amplification completely offsets the benefits of pipelined early verification.
To address these challenges, we propose LoopCache, an efficient self-speculative decoding framework for long-context looped transformers. First, we observe that token predictions frequently change across recurrent loops, while predictions at later loops increasingly agree with the final token. Based on this insight, LoopCache introduces confidence-guided dynamic draft updating, which monitors intermediate loop predictions and dynamically updates draft tokens. Second, to eliminate redundant KV-cache accesses, we propose a cyclic loop KV cache scheduling strategy. Across global steps, LoopCache accesses the loop-specific KV caches in a fixed cycle (KV R1\text{KV R}_{1}toKV RR\text{KV R}_{R}), keeping the per-step KV cache access consistent with AR and DtV. To ensure lossless verification, tokens drafted under mismatched KV caches are batched at the nearest upcoming cycle with the matching loop KV cache to compute their exact target loops in parallel. Furthermore, we identify a distinct layer-wise sensitivity across recurrent loops: shallow layers exhibit much larger KV cache variations across loops than deeper layers. By selectively retaining independent KV caches only for a small number of shallow layers during specific steps, LoopCache further improves draft acceptance with negligible memory overhead.
Our main contributions can be summarized as follows:
- •We analyze token switch behavior across recurrent loops and propose a confidence-guided dynamic draft updating mechanism. By flexibly leveraging predictions from all intermediate recurrent steps, LoopCache dynamically refines draft tokens in flight to avoidwasted computation on stale tokens.
- •Targeting long-context efficiency, we propose a cyclic loop KV-cache scheduling strategy which keeps per-step KV traffic consistent with AR and DtV, while batching exact verification at the nearest matching KV cycle. We further exploit layer-wise KV differences across loops by selectively decoupling shallow-layer KV caches to improve acceptance rates.
- •Extensive experiments across multiple Looped Transformers and long-context benchmarks demonstrate that LoopCache achieves average 10.25×\timesand 14.56×\timesspeedup over WFD and LoopSpec, while delivering average 5.12×\timesand 2.52×\timesspeedup compared tostandard AR and DtV decoding.
2Background
Looped Transformers
Looped Transformers extend recurrent computation to standard Transformer blocks by repeatedly applying a weight-shared block forRRsteps[12,18,40,28,37,30]. As illustrated in Fig.1, current architectures mainly follow two designs: Ouro[40]repeats the entire Transformer stack, whereas Huginn[18]and Raven[28]iterate an internal recurrent block between a non-recurrent prelude and coda. Despite sharing model parameters across all recurrent steps, each loopr∈{1,…,R}r\in\{1,\dots,R\}maintains an independent KV cacheKV Rr\text{KV R}_{r}because its input hidden states evolve across loops[18,40].
Self-Speculative Decoding
Speculative decoding accelerates AR generation by using a fast draft model to propose candidate tokens and a target model to verify them in parallel, where rejection sampling guarantees an identical output distribution to the target model[25]. Self-speculative decoding eliminates the separate draft model by reusing intermediate computations of the target model itself[13,38,5,39,32,34]. In Looped Transformers, early loops naturally serve as draft models for the full-depth model[18,40]. As shown in Fig.2(b) and Fig.2(c), while DtV serializes shallow drafting and deep verification, WFD[19]and LoopSpec[10]overlap these phases via pipelined execution, batching tokens at different recurrent depths into a single step. Specifically, WFD drafts at a predefined depth and organizes in-flight tokens into a diagonal wavefront. LoopSpec further introduces a primary proposal at depthd1d_{1}and a gated residual proposal at a deeper depthd2d_{2}. However, this second proposal creates fallback branches that severely inflate the runtime batch size, reaching peak effective batch sizes of 176 and 191 on its two Raven models[10]. Moreover, both methods remain restricted to fixed drafting depths and access multiple loop-specific KV caches within each step.
Cross-Loop KV Sharing
To reduce KV cache overhead, several works share or reuse KV states across recurrent steps. Huginn explores a bounded cyclic cache that overwrites cache slots across loops[18], while Ouro[40]and WFD[19]reuse the last-loop or averaged KV cache during decoding. Similarly, Mixture-of-Recursions (MoR) reuses the first-loop KV states across subsequent recursions[1]. Although these lossy approaches reduce memory footprint and KV traffic, they inevitably cause accuracy degradation. Specifically, KV states in later loops are iteratively refined, so reusing unrefined first-loop KV states severely compromises model quality. Conversely, reusing the last-loop KV cache is incompatible with standard training and prefill phases, where all tokens are processed in parallel and future-loop KV states are not yet available when computing early loops. This discrepancy prevents effective training adaptation and similarly degrades inference accuracy. In contrast to lossy KV sharing, LoopCache reduces long-context KV traffic while preserving exact loop-specific verification for lossless acceleration.
3Motivation
Observation 1: Intermediate-loop predictions enable dynamic draft refinement.Existing wave-style methods such as WFD and LoopSpec draft at fixed recurrent depths, leaving intermediate-loop predictions largely unused[19,10]. However, every recurrent loop can produce a next-token prediction, which may change as the loop depth increases. As illustrated in Fig.5(a), a draft token may change at an intermediate loop, while subsequent speculative tokens continue along the outdated trajectory. Fig.5(b) shows that such prediction switches occur frequently, with distinct patterns across models and recurrent depths. This variation highlights the limitations of fixed-depth drafting. Although predictions from every loop could provide additional drafts, retaining all candidate branches can increase the batch size to2R−12^{R-1}in the worst case. Such exponential growth is impractical for models with many recurrent loops.

Figure 3:Intermediate-loop prediction behavior. (a) Fixed-depth drafting versus draft updating with intermediate-loop predictions. (b) Token switch probability across recurrent loops. (c) Agreement between intermediate-loop and final-loop predictions.Figure 4:KV cache overhead and long-context decoding performance. (a) Total KV cache reads and global steps, normalized to AR. (b) Decoding speedup over AR across different context lengths.
Figure 5:Cross-loop KV cache characteristics. (a) Pairwise cosine similarity of key and value states across recurrent loops. (b) Layerwise cosine distance of key and value states between consecutive loops.
Importantly, Fig.5(c) shows that agreement with the final prediction generally increases with loop depth, indicating that later predictions are more likely to match the final token. This motivates dynamically replacing outdated drafts rather than retaining all candidate branches. As shown on the right side of Fig.5(a), intermediate predictions can be used to update in-flight drafts and prune their outdated speculative continuations. By guiding these updates with prediction confidence, LoopCache exploits intermediate-loop information while maintaining a single active draft trajectory to avoid excessive branching.
Observation 2: KV cache traffic limits wave-style decoding in long contexts.WFD and LoopSpec reduce sequential execution by batching tokens at different recurrent depths, but each global step accesses multiple loop-specific KV caches[19,10]. As shown in Fig.5(a), despite requiring fewer global steps than AR and DtV, both methods incur substantially higher total KV cache reads. This overhead becomes increasingly critical as context length grows, since decoding becomes dominated by KV cache memory traffic. Consequently, Fig.5(b) shows that WFD and LoopSpec suffer declining speedups as context length increases, often becoming slower than conventional AR decoding.
Directly sharing KV caches between draft and target loops cannot resolve this issue without compromising exact computation. When a draft token is accepted, its recurrent computation must remain consistent with the target model. However, using a mismatched loop KV cache during drafting produces incorrect hidden states and KV entries. These states cannot be reused for subsequent target computation without recomputation, even if the draft token itself is accepted. Therefore, lossless acceleration requires reducing KV traffic while preserving exact loop-specific computation during verification. This motivates a cyclic KV cache access strategy that batches exact verification at the corresponding loop cycles.
Observation 3: Cross-loop KV similarity exhibits strong layer-wise differences.Although exact verification requires loop-specific KV states, the shared weights and iterative refinement of Looped Transformers suggest potential similarities across recurrent loops. Fig.5(a) shows that the key and value states of corresponding layers exhibit high cosine similarity across loops. This suggests that reusing KV caches from other loops during drafting may preserve useful intermediate predictions while reducing memory traffic. Combined with exact loop-specific verification, such approximate reuse offers an opportunity to improve speculative decoding efficiencywithout compromising correctness.
However, cross-loop KV similarity varies considerably across layers. As shown in Fig.5(b), shallow layers exhibit larger KV differences between consecutive loops, while deeper layers remain relatively stable. Thus, uniformly sharing KV caches across all layers would degrade draft quality and reduce acceptance rates. Instead, selectively maintaining independent KV caches for a few sensitive shallow layers can better preserve intermediate predictions with small memory overhead. This provides an opportunity to improve draft acceptance while retaining the efficiency of cross-loop KV reuse.
4LoopCache
Building on the observations in Section3, we propose LoopCache, a self-speculative decoding framework that combines dynamic draft refinement with efficient KV cache scheduling. As illustrated in Fig.6, LoopCache uses confidence-guided updates to maintain a single active draft trajectory and cyclically schedules loop-specific KV caches to reduce long-context memory traffic.A separate verification pathpreserves exact target computation, while selective shallow-layer KV accesses further improve draft quality.
4.1Confidence-Guided Dynamic Draft Updating
As discussed in Observation 1, existing wave-style methods draft at fixed recurrent depths, potentially wasting computation on outdated speculative trajectories[19,10]. As shown in Fig.5(a), intermediate-loop predictions can correct these drafts before final verification. However, unconditionally updating every changed prediction may cause repeated reversals, disrupting speculative progress.
Aharmful switchoccurs when a replaced draft reappears at a later loop. Letzr(v)z_{r}(v)denote the logit of tokenvvafter looprr, andyr=argmaxvzr(v)y_{r}=\arg\max_{v}z_{r}(v)its prediction. For a current draftxxand new candidates=yr≠xs=y_{r}\neq x, the harmful-switch indicator is
hr(x→s)=𝟏[∃k∈{r+1,…,R}:yk=x],h_{r}(x\rightarrow s)=\mathbf{1}\left[\exists\,k\in\{r+1,\ldots,R\}:y_{k}=x\right],(1)where𝟏[⋅]\mathbf{1}[\cdot]is the indicator function. The frequency of such reversals characterizes the harmful-switch risk.
To avoid unnecessary switches, LoopCache measuresupdate confidenceusing the new-old logit gap:
Δzr=zr(s)−zr(x)=logpr(s)pr(x),\Delta z_{r}=z_{r}(s)-z_{r}(x)=\log\frac{p_{r}(s)}{p_{r}(x)},(2)whereprp_{r}denotes the softmax probability distribution. This gap measures how strongly the current loop favors the new candidate over the existing draft. Fig.7shows that harmful-switch probability decreases consistently as the logit gap increases across models.
Figure 6:Overview of LoopCache. (a) Cyclic loop KV scheduling with concurrent speculative and exact verification paths. (b) Confidence-guided dynamic draft updating versus unconditional updating. (c) Selective shallow-layer KV decoupling for the batch ats15s_{15}in (a).
Figure 7:Relationship between harmful-switch probability and the new-old logit gapΔz\Delta zacross different Looped Transformers.Based on this correlation, LoopCache updates the draft only whenΔzr≥τ\Delta z_{r}\geq\tau, whereτ≥0\tau\geq 0is aconfigurable confidence threshold.Once triggered, the new candidate replaces the current draft, and all speculative descendants conditioned on the previous candidate are pruned. Otherwise, the existing trajectory is retained. Fig.6(b) illustrates how this confidence-guided mechanism avoids repeated reversals compared with unconditional updating, preserving speculative progress without introducingadditional candidate branches.
4.2Cyclic Loop KV Cache Scheduling
Wave-style decoding overlaps drafting and verification but requires concurrent access to multiple loop-specific KV caches, causing substantial memory traffic in long contexts[19,10]. To retain pipelined execution without this overhead, LoopCache exploits cross-loop KV similarity for speculative computation while preserving exact loop-specific KV accesses for verification.
Cyclic KV Scheduling.Instead of accessing different loop KV caches within the same global step, LoopCache fixes the accessed cache according to a cyclic schedule. For global decoding stepg≥1g\geq 1, the selected KV loop ID is
c(g)=1+((g−1)modR),c(g)=1+((g-1)\bmod R),(3)whereRRis the total recurrence depth. Thus, the global steps repeatedly accessKV R1→KV R2→⋯→KV RR\text{KV R}_{1}\rightarrow\text{KV R}_{2}\rightarrow\cdots\rightarrow\text{KV R}_{R}. All active token states in each step share the same long-prefix KV cacheKV Rc(g)\text{KV R}_{c(g)}, reducing the number of distinct full-prefix KV accesses from up toRRto one per step. To support this schedule while maintaining exact decoding, LoopCache organizes token computation into two concurrent paths, as shown in Fig.6(a).
Spec Branch.The speculative path advances in-flight tokens through their respective recurrent loops while using the KV cache selected by the current global step. Letdddenote a token’s current recurrent loop ID. Even whend≠c(g)d\neq c(g), the token usesKV Rc(g)\text{KV R}_{c(g)}to compute its intermediate state and predict subsequent tokens. Although this computation is approximate, the high similarity of KV states across loops allows it to provide useful draft predictions. The Spec Branch therefore retains the early drafting capability of wave-style decoding while sharing long-prefix KV accesses across tokens.
KV Branch.To ensure exact verification, each surviving speculative token is recomputed through the correct loop-specific KV caches. The KV Branch starts at the nearest upcoming complete KV cycle and advances through loops11toRRin order, using the corresponding KV cache at each loop. This recomputation restores the exact hidden states and KV entries under the candidate prefix, even when the Spec Branch predicts the correct token. The KV Branch provides exact target logits for greedy decoding and rejection sampling. If a candidate is rejected, its dependent speculative states are discarded, and decoding resumes from the corrected token.
Intermediate predictions from both branches can trigger confidence-guided draft updates, while the KV Branch determines the committed output. When the two branches have matching recurrent depths, their computations are identical and can be merged into a single path, denoted asAlignedin Fig.6(a). This avoids redundant computation while preserving exact target verification.
4.3Selective Shallow-Layer KV Decoupling
Although cyclic KV sharing reduces memory traffic, using a mismatched loop cache can degrade draft predictions, especially when the draft loop differs substantially from the current KV loop. As observed in Fig.5(b), shallow layers exhibit larger cross-loop KV differences than deeper layers. To address this imbalance, LoopCache selectively restores loop-specific KV accesses for a few shallow layers in the Spec Branch.
LetLLdenote the number of physical layers in the recurrent block, and letKVℓ,r\mathrm{KV}_{\ell,r}denote the valid prefix KV cache of physical layerℓ\ellat looprr. Given a selected shallow-layer set𝒮⊆{1,…,L}\mathcal{S}\subseteq\{1,\ldots,L\}and a loop-ID difference thresholdδ≥1\delta\geq 1, the KV cache used by the Spec Branch is
KVℓSpec(d,c)={KVℓ,d,ℓ∈𝒮,|d−c|≥δ,KVℓ,c,otherwise,\mathrm{KV}_{\ell}^{\mathrm{Spec}}(d,c)=\begin{cases}\mathrm{KV}_{\ell,d},&\ell\in\mathcal{S},\ |d-c|\geq\delta,\\ \mathrm{KV}_{\ell,c},&\text{otherwise},\end{cases}(4)whereddis the draft’s recurrent loop ID andc=c(g)c=c(g)is the globally scheduled KV loop ID.
As illustrated in Fig.6(c), selecting the first two physical layers with𝒮={1,2}\mathcal{S}=\{1,2\}andδ=1\delta=1allows mismatched drafts to access their own loop-specific KV caches in these layers. All remaining layers continue sharing the current cyclic KV cache. This selective decoupling improves draft quality with only a small number of additional shallow-layer KV reads. The KV Branch always uses the correct loop-specific caches, preserving exact verification.
5Experiments
5.1Experimental Setup
Models and Hardware
We evaluate LoopCache on six Looped Transformers, including Ouro-1.4B, Ouro-2.6B, Huginn-3.5B, and three Raven variants based on Llama-3.2, OLMo-2, and TinyLlama[40,18,28]. Table1summarizes their configurations and per-loop KV cache footprints at 32K. All experiments use eight NVIDIA A100 GPUs, with context parallelism for longer contexts.
Table 1:Model configurations and per-loop KV cache sizes at 32K.
Baselines and Benchmarks
We compare LoopCache against AR, DtV, DFlash, WFD, and LoopSpec[25,7,19,10]. For DFlash, we train a block diffusion drafter using multiple datasets[11,6,20,33,3,36]. Training supports sequence lengths up to 128K, with an effective batch size of 32 and a block size of 16. We evaluate context lengths from 4K to 128K on LongBench v1/v2[2,4], RULER[21], and LongReason[26]. For contexts beyond the native window, we apply YaRN for context extension[29].
5.2Main Results
Figure 8:Decoding speedup across six Looped Transformers, three long-context benchmarks, and sequence lengths from 4K to 128K.#### End-to-End Decoding Speedup
Fig.8presents the decoding speedup across different models, benchmarks, and context lengths. On average, LoopCache achieves 10.25×\timesand 14.56×\timesspeedup over WFD and LoopSpec, respectively, and 5.12×\timesand 2.52×\timesover AR and DtV. These results demonstrate the effectiveness of LoopCache across diverse models and long-context workloads.
Figure 9:Acceptance rates of differentmethods across models.
Figure 10:AR-normalized KVcache reads and TPF.
Acceptance Rate
Fig.10compares the acceptance rates of different methods. LoopCache maintains consistently high acceptance rates across different sequence lengths. Although LoopCache uses approximate cross-loop KV states in most Spec Branch layers, confidence-guided dynamic draft updating corrects outdated predictions, while selective shallow-layer KV decoupling preserves critical loop-specific information. Together, these mechanisms enable LoopCache to achieve higher acceptance rates than existing methods.
KV Cache Traffic and Token Parallelism
We measure total KV cache reads and tokens per forward (TPF), where TPF is defined as the number of committed output tokens divided by the total number of loop forwards (global steps). Fig.10reports both metrics normalized to AR. While WFD and LoopSpec achieve high TPF, they incur substantial KV cache reads by accessing multiple loop-specific caches within each global step. In contrast, LoopCache reads only one full-prefix loop-specific KV cache per global step, with limited additional shallow-layer accesses, substantially reducing memory traffic while maintaining high TPF.
![[Uncaptioned image]](https://arxiv.org/html/2611.24301v1/experiment-4.png)
Figure 11:Decoding speedup at 4K across batch sizes from 1 to 32.#### Batch-Size Scaling
Fig.5.2shows the decoding speedup at a 4K context length with batch sizes ranging from 1 to 32 across models. Existing wave-style methods suffer from reduced speedups as the batch size increases, since KV cache traffic becomes increasingly dominant. By limiting KV cache accesses, LoopCache maintains better performance across batch sizes.
Figure 12:Ablation study of LoopCache. (a) Component contributions. (b) Confidence threshold. (c) Number of decoupled shallow layers.
5.3Ablation Study
Fig.5.2evaluates the key design choices in LoopCache.
Component Contributions
Fig.5.2(a) shows the cumulative speedup gains of the three components, normalized to the fixed-proposal baseline WFD. M1 denotes confidence-guided draft updating, M2 denotes cyclic loop KV scheduling, and M3 denotes selective shallow-layer KV decoupling. Each component contributes additional gains, with the complete design achieving the best performance.
Confidence Threshold
Fig.5.2(b) evaluates the impact of the confidence thresholdτ\tau. Pruned states per token measures the number of live speculative token states invalidated by draft replacement or verification rejection, normalized by the number of committed decoding tokens. We selectτ=0.125\tau=0.125, which provides the best overall trade-off between speedup and speculative state pruning.
Shallow-Layer KV Decoupling
Fig.5.2(c) evaluates different numbers of decoupled shallow layers in terms of speedup, TPF, and time per forward, which denotes the latency of one loop forward. All metrics are normalized to the setting without shallow-layer decoupling. Selecting the first two physical layers as shallow layers preserves high TPF while limiting additional KV accesses and forward latency, achieving the best overall speedup. Accordingly, we set𝒮={1,2}\mathcal{S}=\{1,2\}and the loop-ID difference threshold toδ=1\delta=1.
6Conclusion
We presented LoopCache, an efficient self-speculative decoding framework for long-context Looped Transformers. By exploiting intermediate-loop predictions, confidence-guided dynamic draft updating corrects outdated drafts early and avoids unnecessary speculative computation. Cyclic loop KV scheduling substantially reduces memory traffic by sharing loop-specific KV accesses while preserving exact target verification. Selective shallow-layer KV decoupling further improves draft acceptance with minimal additional overhead. Extensive experiments demonstrate that LoopCache achieves average speedups of 5.12×\timesand 2.52×\timesover AR and DtV, and 10.25×\timesand 14.56×\timesover WFD[19]and LoopSpec[10], respectively. These results highlight the effectiveness of LoopCache in enabling fast and lossless long-context decoding for Looped Transformers.
References
- [1]S. Bae, Y. Kim, R. Bayat, S. Kim, J. Ha, T. Schuster, A. Fisch, H. Harutyunyan, Z. Ji, A. C. Courville, and S. Yun(2025)Mixture-of-recursions: learning dynamic recursive depths for adaptive token-level computation.ArXivabs/2507.10524.Cited by:§2.
- [2]Y. Bai, X. Lv, J. Zhang, H. Lyu, J. Tang, Z. Huang, Z. Du, X. Liu, A. Zeng, L. Hou, Y. Dong, J. Tang, and J. Li(2023)LongBench: a bilingual, multitask benchmark for long context understanding.ArXivabs/2308.14508.Cited by:§1,§5.1.
- [3]Y. Bai, X. Lv, J. Zhang, Y. He, J. Qi, L. Hou, J. Tang, Y. Dong, and J. Li(2024)LongAlign: a recipe for long context alignment of large language models.InConference on Empirical Methods in Natural Language Processing,Cited by:§5.1.
- [4]Y. Bai, S. Tu, J. Zhang, H. Peng, X. Wang, X. Lv, S. Cao, J. Xu, L. Hou, Y. Dong, J. Tang, and J. Li(2024)LongBench v2: towards deeper understanding and reasoning on realistic long-context multitasks.ArXivabs/2412.15204.Cited by:§5.1.
- [5]J. Bang, E. Cho, R. Hwang, J. Chung, and M. Rhu(2026)SpecMoE: a fast and efficient mixture-of-experts inference via self-assisted speculative decoding.Proceedings of the 63rd ACM/IEEE Design Automation Conference.Cited by:§1,§2.
- [6]S. Chaudhary(2023)Code alpaca: an instruction-following llama model for code generation.GitHub.Note:https://github.com/sahil280114/codealpacaCited by:§5.1.
- [7]J. Chen, Y. Liang, and Z. Liu(2026)DFlash: block diffusion for flash speculative decoding.ArXivabs/2602.06036.Cited by:§5.1.
- [8]Q. Chen, L. Qin, J. Liu, D. Peng, J. Guan, P. Wang, M. Hu, Y. Zhou, T. Gao, and W. Che(2025)Towards reasoning era: a survey of long chain-of-thought for reasoning large language models.ArXivabs/2503.09567.Cited by:§1.
- [9]R. Chen, Z. Wang, B. Cao, T. Wu, S. Zheng, X. Li, X. Wei, S. Yan, M. Li, and Y. Liang(2024)ArkVale: efficient generative llm inference with recallable key-value eviction.Advances in Neural Information Processing Systems 37.Cited by:§1.
- [10]S. Cho, L. Cui, S. Kim, D. Han, and I. Han(2026)LoopSpec: pipelined self-speculative decoding for looped transformers.Cited by:§1,§2,§3,§3,§4.1,§4.2,§5.1,§6.
- [11]K. Cobbe, V. Kosaraju, M. Bavarian, M. Chen, H. Jun, L. Kaiser, M. Plappert, J. Tworek, J. Hilton, R. Nakano, C. Hesse, and J. D. Schulman(2021)Training verifiers to solve math word problems.ArXivabs/2110.14168.Cited by:§5.1.
- [12]M. Dehghani, S. Gouws, O. Vinyals, J. Uszkoreit, and L. Kaiser(2018)Universal transformers.ArXivabs/1807.03819.Cited by:§2.
- [13]M. Elhoushi, A. Shrivastava, D. Liskovich, B. Hosmer, B. Wasti, L. Lai, A. Mahmoud, B. Acun, S. Agarwal, A. Roman, A. A. Aly, B. Chen, and C. Wu(2024)LayerSkip: enabling early exit inference and self-speculative decoding.InAnnual Meeting of the Association for Computational Linguistics,Cited by:§1,§2.
- [14]T. Fu, Y. You, Z. Chen, G. Dai, H. Yang, and Y. Wang(2025)Think-at-hard: dynamic looped transformers for improved reasoning.Cited by:§1.
- [15]Z. Fu, X. Guo, W. Zeng, S. Zhong, Y. Zhang, P. Chen, R. Wang, L. Ye, and M. Li(2025)H2EAL: hybrid-bonding architecture with hybrid sparse attention for efficient long-context llm inference.2025 IEEE/ACM International Conference On Computer Aided Design (ICCAD),pp. 1–9.Cited by:§1.
- [16]Z. Fu, R. Wang, and M. Li(2026)Scaling parameter and context in attention: native sparse attention from mixture-of-head.Cited by:§1.
- [17]Z. Fu, W. Zeng, R. Wang, and M. Li(2026)Attention sink forges native moe in attention layers: sink-aware training to address head collapse.ArXivabs/2602.01203.Cited by:§1.
- [18]J. Geiping, S. McLeish, N. Jain, J. Kirchenbauer, S. Singh, B. R. Bartoldson, B. Kailkhura, A. Bhatele, and T. Goldstein(2025)Scaling up test-time compute with latent reasoning: a recurrent depth approach.ArXivabs/2502.05171.Cited by:§1,§2,§2,§2,§5.1.
- [19]H. Ha and J. Kim(2026)WaveFront decoding: parallelized self-speculative decoding for looped language models.Cited by:§1,§2,§2,§3,§3,§4.1,§4.2,§5.1,§6.
- [20]D. Hendrycks, C. Burns, S. Kadavath, A. Arora, S. Basart, E. Tang, D. X. Song, and J. Steinhardt(2021)Measuring mathematical problem solving with the math dataset.ArXivabs/2103.03874.Cited by:§5.1.
- [21]C. Hsieh, S. Sun, S. Kriman, S. Acharya, D. Rekesh, F. Jia, Y. Zhang, and B. Ginsburg(2024)RULER: what’s the real context size of your long-context language models?.ArXivabs/2404.06654.Cited by:§5.1.
- [22]H. Huang, S. Qiu, and M. Li(2026)S2-moe: enabling efficient self-speculative decoding for mixture-of-experts on edge devices.ArXivabs/2608.15018.Cited by:§1.
- [23]W. Huang, W. Zhang, Y. Liang, Y. Bei, Y. Chen, T. Feng, X. Pan, Z. Tan, Y. Wang, T. Wei, S. Wu, R. Xu, L. Yang, R. Yang, W. Yang, C. Yeh, H. Zhang, H. Zhang, S. Zhu, H. P. Zou, W. Zhao, S. Wang, W. Xu, Z. Ke, Z. Hui, D. Li, Y. Wu, L. He, C. Wang, X. Xu, B. Huang, J. Tan, S. Heinecke, H. Wang, C. Xiong, A. Metwally, J. Yan, C. Lee, H. Zeng, Y. Xia, X. Wei, A. Payani, Y. Wang, H. Ma, W. Wang, C. Wang, Y. Zhang, X. E. Wang, Y. Zhang, J. You, H. Tong, X. Luo, X. Liu, Y. Sun, W. Wang, J. McAuley, J. Zou, J. Han, P. S. Yu, and K. Shu(2026)A survey of agent memory in the second half: towards self-evolving and long-horizon agents.Trans. Mach. Learn. Res.2026.Cited by:§1.
- [24]H. Kim, J. Lee, S. Cho, D. Han, I. Han, and S. Kim(2026)ResidualQuant: kv cache quantization for looped transformers with 2-bit residuals.Cited by:§1.
- [25]Y. Leviathan, M. Kalman, and Y. Matias(2022)Fast inference from transformers via speculative decoding.InInternational Conference on Machine Learning,Cited by:§1,§2,§5.1.
- [26]Z. Ling, K. Liu, K. Yan, Y. Yang, W. Lin, T. Fan, L. Shen, Z. Du, and J. Chen(2025)LongReason: a synthetic long-context reasoning benchmark via context expansion.ArXivabs/2501.15089.Cited by:§1,§5.1.
- [27]G. Liu, C. Li, J. Zhao, C. Zhang, and M. Guo(2024)ClusterKV: manipulating llm kv cache in semantic space for recallable compression.2025 62nd ACM/IEEE Design Automation Conference (DAC),pp. 1–7.Cited by:§1.
- [28]S. McLeish, A. Li, J. Kirchenbauer, D. S. Kalra, B. R. Bartoldson, B. Kailkhura, A. Schwarzschild, J. Geiping, T. Goldstein, and M. Goldblum(2025)Teaching pretrained language models to think deeper with retrofitted recurrence.ArXivabs/2511.07384.Cited by:§1,§2,§5.1.
- [29]B. Peng, J. Quesnelle, H. Fan, and E. Shippole(2023)YaRN: efficient context window extension of large language models.ArXivabs/2309.00071.Cited by:§5.1.
- [30]H. Prairie, Z. Novack, T. Berg-Kirkpatrick, and D. Y. Fu(2026)Parcae: scaling laws for stable looped language models.ArXivabs/2604.12946.Cited by:§1,§2.
- [31]S. Qiu, S. Guo, Z. Song, Y. Sun, Z. Cai, J. Wei, T. Luo, Y. Yin, H. Zhang, Y. Hu, C. Wang, C. Tang, H. C. Chang, Q. Liu, Z. Zhou, T. Zhang, J. Zhang, Z. Liu, M. Li, Y. Zhang, B. Jing, X. Yin, Y. Ren, Z. Fu, J. Ji, W. Wang, X. Tian, A. Lv, L. Man, J. Li, F. Tao, Q. Sun, Z. Liang, Y. Mu, Z. Li, J. Zhang, S. Zhang, X. Li, X. Xia, J. Lin, Z. Shen, J. Chen, Q. Xiong, B. Wang, F. Wang, Z. Ni, B. Zhang, F. Cui, C. Shao, Q. Cao, M. Luo, Y. Yang, M. Zhang, and H. Zhu(2025)PHYBench: holistic evaluation of physical perception and reasoning in large language models.ArXivabs/2504.16074.Cited by:§1.
- [32]R. Sadhukhan, J. Chen, Z. Chen, V. Tiwari, R. Lai, J. Shi, I. E. Yen, A. May, T. Chen, and B. Chen(2024)MagicDec: breaking the latency-throughput tradeoff for long context generation with speculative decoding.ArXivabs/2408.11049.Cited by:§1,§2.
- [33]M. Suzgun, N. Scales, N. Schärli, S. Gehrmann, Y. Tay, H. W. Chung, A. Chowdhery, Q. V. Le, E. H. Chi, D. Zhou, and J. Wei(2022)Challenging big-bench tasks and whether chain-of-thought can solve them.InAnnual Meeting of the Association for Computational Linguistics,Cited by:§5.1.
- [34]R. Tiwari, H. Xi, A. Tomar, C. R. C. Hooper, S. Kim, M. Horton, M. Najibi, M. W. Mahoney, K. Keutzer, and A. Gholami(2025)QuantSpec: self-speculative decoding with hierarchical quantized kv cache.ArXivabs/2502.10424.Cited by:§1,§2.
- [35]J. Xu, J. Pan, H. Wang, Y. Zhou, J. Ye, Y. Wang, and G. Dai(2025)SpeContext: enabling efficient long-context reasoning with speculative context sparsity in llms.Proceedings of the 31st ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 2.Cited by:§1.
- [36]P. Xu, W. Ping, X. Wu, C. Xu, Z. Liu, M. Shoeybi, and B. C. Catanzaro(2024)ChatQA 2: bridging the gap to proprietary llms in long context and rag capabilities.ArXivabs/2407.14482.Cited by:§5.1.
- [37]C. Yang, C. Huang, F. Lan, H. Chen, H. Zhou, H. Song, J. Cao, J. Zhu, J. Niu, K. Wang, L. Huang, Q. Liang, R. Le, R. Feng, S. Sun, T. Gu, T. Zhang, T. Luo, Y. Song, Y. Xing, Y. Wen, Z. Xu, Z. Chen, and Z. Li(2026)Nanbeige4.2-3b: unlocking agentic capabilities in a compact model.ArXivabs/2607.22083.Cited by:§1,§2.
- [38]J. Zhang, J. Wang, H. Li, L. Shou, K. Chen, G. Chen, and S. Mehrotra(2024)Draft& verify: lossless large language model acceleration via self-speculative decoding.InProceedings of the 62nd Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers),pp. 11263–11282.Cited by:§1,§2.
- [39]Y. Zhao, J. Tang, K. Zhu, Z. Ye, C. Chang, C. Lin, J. Park, G. Xiao, M. S. Abdelfattah, M. Gao, B. Kasikci, S. Han, and I. Stoica(2025)Accelerating large-scale reasoning model inference with sparse self-speculative decoding.ArXivabs/2512.01278.Cited by:§1,§2.
- [40]R. Zhu, Z. Wang, K. Hua, T. Zhang, Z. Li, H. Que, B. Wei, Z. Wen, F. Yin, H. Xing, L. Li, J. Shi, K. Ma, S. Li, T. Kergan, A. K. Smith, X. Qu, M. Hui, B. Wu, Q. Min, H. Huang, X. Zhou, W. Ye, J. Liu, J. Yang, Y. Shi, C. Lin, E. Zhao, T. Cai, G. Zhang, W. Huang, Y. Bengio, and J. K. Eshraghian(2025)Scaling latent reasoning via looped language models.ArXivabs/2510.25741.Cited by:§1,§2,§2,§2,§5.1.
相似文章
循环扩散 Transformer:在每个去噪步骤中重复运行相同的模块,并且可以在采样时调整循环深度 [R]
介绍 Looped Diffusion Transformer 论文:通过在每个去噪步骤内重复运行共享的 transformer 块,并结合深度监督和自调制注意力,使 260M 模型以 4.9 倍更少的推理计算超越 6.5 倍大的模型,且循环深度可在采样时调节;作者还用 MIT 开源权重在 M5 Pro 上实测了不同深度的效果。
TRACE:面向通信高效分布式边缘推理的Transformer残差激活码本编码
论文提出 TRACE(Transformer Residual Activation Codebook Encoding),在每个 Transformer 层的后注意力残差处放置向量量化器并预计算码本索引化的键值表示,使分布式边缘设备推理中接收方通过查表直接恢复 K/V,实现通信-计算重叠;在 ViT-Base 与 ViViT-B 上相比最优 VQ 分布式推理框架最高提升 1.89% 精度与 1.27 倍端到端加速,通信开销最高降低 22,624 倍。
Transformers 停止思考得太早,而一个小小的 LoRA 就能解决这个问题
研究发现,预训练 transformer 在遵循上下文引用时极少使用其深度(仅可靠遵循 1.4-3.6 行),而一个冻结所有权重、只在早期层添加的 rank-8 LoRA 即可大幅扩展该能力——Qwen3-8B 在 24 行链上的精确准确率从 15.5% 提升至 99%。LoRA 起到「接力」作用,使程序行通过中间层传递链身份信息。
@mylifcc: 你想象中的所谓大模型升级:多买 H100、花几百万美元重训练、把参数从 70B 堆到 700B……
Apple 研究人员的论文《Decoding Looped Transformers Better for (Almost) Free》表明,通过对比解码(Contrastive Decoding)复用推理时被丢弃的中间状态,可以在零训练成本的前提下将计算消耗降低 47%,同时将数学问题的 pass@1 从 61% 提升到 73%——这标志着大模型发展正从硬件堆叠转向算法层面的精细优化。
采用共享 KV 缓存的 LSTM 式循环 Transformer
本文研究了一种 LSTM 风格的循环 Transformer,其循环核心共享权重和单个键值缓存,在宽度为 1024 时将参数量减少了 40.4%,并将持久缓存组数从十五组减少到四组。通过一致性损失对齐并行与递归训练过程,消除了 81–89% 的续写损失惩罚;在较低的 token 预算下,权重绑定的成本最低。