Recurloop, Hyper-Connections, and Parallel KV Caching
Introduction
Our target in Core Cognition and Looped Transformers is a small, dense cognitive core [1] that gets maximum reasoning accuracy out of a fixed parameter count and FLOP budget. Rather than spending billions of unique weights memorizing static facts, a looped core reuses a compact set of shared weights across many passes so extra compute goes straight into latent deduction.
While mapping out where looped language models are heading next, we dug into Recurloop [2]—and stumbled into ARLoop [3], Hyper-Connections [4], and DeepSeek’s mHC [5] along the way. Working through them from scratch came down to four mental models:
- Why depth-only loops (
ARLoop) stay trapped inside a single pass—and inside their training loop count. - How
Recurloopresolves the parallel paradox to pass a token’s final thought forward to the next token without giving up parallel training. - Why two-stream
Hyper-Connections(andmHC) are needed once clean token embeddings and carried thoughts share the same weights. - How
Parallel KVcaching handles multi-pass state during autoregressive decoding.
Vertical Loops First: ARLoop and the Step-Index Trap
Most looped Transformers—including ARLoop [3]—loop strictly vertically at each token position. In its simplest form (ARLoop-Full), every layer inside every loop pass appends its output into one accumulating list (history = [b0, b1, b2, ...]), and Attention Residuals [6] uses a learned step query q_depth[step] ([D]) to collapse that list back into one [B, T, D] input vector before the next block runs. Because an unbounded list grows linearly with loop count (O(N) memory and attention dilution at deep passes), ARLoop-SW caps the list to a pinned b0 anchor plus a FIFO sliding window of the last W block outputs ([b0] + window[-W:]):
Stepping through the list and q_depth[step] above exposes two limits:
- Locked to training depth. Because
q_depthlearns a separate parameter vector for every loop indexstep, the router only knows the step indices seen during training—the exact same extrapolation trap we hit with MeSH [7] when rolling out deeper at test time. - No top-to-bottom handoff across tokens. When token
t - 1finishes allRvertical loops at the top of the stack, its final representationh_final[t - 1]goes straight to the LM head to predict tokent. Tokentstill starts at the bottom from its raw embeddinge_talone, never seeingh_final[t - 1].
Looping Across Depth and Tokens: The Parallel Paradox
Recurloop [2] asks a simple question: what if token t could start at the bottom with both its own token embedding e_t and the finished deep thought h_final[t - 1] from the previous token—like one step of continuous latent Chain-of-Thought without printing scratchpad words?
At first glance, that hits a parallel paradox. During training and prefill, a Transformer processes all T tokens in parallel ([B, T, D]). By the time h_final[t - 1] exists at the top of column t - 1, token t has already finished running alongside it. If token t had to wait on t - 1, which waited on t - 2, training would turn into a slow token-by-token RNN.
Recurloop resolves this by calling the parallel R-loop model twice (Sweep 0 and Sweep 1), shifting the finished thoughts right by one token slot in between:
- Sweep 0 (
KV_0) runs allTtokens in parallel throughRloops of the shared block with no neighbor feedback yet, producing a draft thoughth0([B, T, D]) at the top of every column. shift_right_1slidesh0one position to the right along the token axis (padding zero att = 0), so columntreceivesh0[t - 1].- Sweep 1 (
KV_1) runs allTtokens in parallel a second time through the exact same weights andRloops, seeded withh0[t - 1]at the bottom, and sendsh1to the LM head.
Both sweeps stay parallel [B, T, D] tensor calls on the GPU. Each extra sweep buys one hop of top-to-bottom latent handoff (Sweep 0 gives t - 1 → t), trading 2× parallel compute for zero new layer weights.
Parallel KV Caching at Decode Time
During autoregressive decoding, each sweep builds its own KV cache: KV_0 comes from Sweep 0, and KV_1 comes from Sweep 1 (stored per inner loop step, just like any looped causal LM).
Tracing a concrete prompt like ["2", "+", "3"] followed by decoding "=" shows why both sweeps still run in a single batched pass per generated token:
- Prefill on
["2", "+", "3"].Sweep 0computes[h0_"2", h0_"+", h0_"3"]and populatesKV_0.Sweep 1shifts those right ([0, h0_"2", h0_"+"]), populatesKV_1, and predicts"=". Notice thath0_"3"was never used yet—we keeph0_"3"in our pocket for the next token. - Decoding
"="(1new token; past tokens stay frozen inKV_0andKV_1). We need two jobs on"=":Sweep 1of"="readsh0_"3"from our pocket and attends toKV_1to predict"5"right now.Sweep 0of"="starts with zero neighbor feedback and attends toKV_0to computeh0_"="for tomorrow’s pocket (when"5"arrives).
Because Sweep 0 of "=" and Sweep 1 of "=" do not depend on each other, they stack along the batch dimension (batch = 2) and run simultaneously through one weight read from GPU memory:
def decode_one_token_parallel_kv(tok_t, pocket_h0_prev, KV_0, KV_1):
# tok_t: [1, 1] newly sampled token (e.g. "=")
# pocket_h0_prev: [1, 1, D] Sweep 0 output saved from token t-1 (e.g. h0_"3")
e = embed(tok_t) # [1, 1, D]
a_1 = torch.sigmoid(W_g(e)) * rms_norm(pocket_h0_prev) # [1, 1, D]
H_0 = torch.stack([e, e], dim=-2) # Sweep 0 input: [1, 1, 2, D]
H_1 = torch.stack([e, e + alpha_fb * a_1], dim=-2) # Sweep 1 input: [1, 1, 2, D]
H_pair = torch.cat([H_0, H_1], dim=0) # [2, 1, 2, D] -> 1 weight load!
H_pair, KV_0, KV_1 = run_looped_core_batched(H_pair, [KV_0, KV_1])
h0_curr, h1_curr = rms_norm(H_pair.sum(dim=-2)).chunk(2, dim=0) # [1, 1, D] each
return lm_head(h1_curr), h0_curr, KV_0, KV_1 # h0_curr goes into pocketAt batch = 1 autoregressive generation, runtime is bottlenecked by loading model weights from HBM rather than arithmetic, so folding both sweeps into one weight load avoids paying a 2× wall-clock latency penalty while keeping KV_0 and KV_1 aligned with training.
Results and Connection to Our Cognitive Core
| Comparison | Setting | Gain |
|---|---|---|
| Pretraining efficiency | Matched validation CE loss | 2.0×–2.4× fewer FLOPs |
Recurloop-1.3B vs. Qwen3.5-2B-Base |
Math, code, and CRUXEval |
Beats 2B dense baseline |
Parallel KV vs. naive 1-pass decode |
MATH-500 and GSM8K |
+7.6 points at 1 weight load |
Needing less than half the pretraining FLOPs to reach the same cross-entropy loss—and beating a larger dense baseline on multi-step state tracking—points directly at the same target as our cognitive core: turning shared parameters and structured loop state into higher accuracy per parameter and per FLOP. Where Recurloop separates clean token embeddings from cross-token feedback in two lanes, our gated-delta core [8] separates Attention and MLP loop memory (S_attn, S_mlp) so wrong intermediate deductions are erased rather than averaged, and halts early once ΔS settles.