A research writeup on building a sub-quadratic 25M-parameter LM on an RX 9070XT, showing that a few well-spaced sparse 'memory hops' with a Gated Delta module outperform placing recurrent memory in every layer, beating a parameter-matched RoPE Transformer (with YaRN) while decoding ~6× faster with a tiny constant cache.
AI Disclosure: LLM tools and coding agents (Opencode) were used to assist with PyTorch implementation boilerplate, running automated benchmark sweeps, and structuring this writeup. All architectural hypotheses, experimental ablations, causality/parity audits, and reported metrics were designed and verified by me. Over the last few months, I’ve been experimenting on my RX 9070XT to see how far you can push a sub-quadratic language modelling when you cleanly separate local token mixing, static FFN capacity, and global content-based memory. I didn't set out to build a sparse-hop architecture, but was backed into it after a string of dead ends: Multi-scale dilated convolutions weren't enough for retrieval: I originally tried using multi-scale dilated convolutions (inspired by wavelets/multi-scale feature extraction) with learned scale routing to handle long-range context. On synthetic associative-recall tests, it hovered right around the random-guessing floor (~51%). Which gave the unfortunate result of Fixed-stride filters simply can't do content-based lookup when the target sits at an arbitrary past offset. Adding Gated Delta fixed retrieval, so I dropped the multi-scale convs: Adding a chunkwise-parallel Gated Delta state (L2-normalized queries/keys, per-head decay and write gates, blocked WY triangular solve) which solved associative recall immediately. Replacing Mult-scale dilated convs with a single depthwise causal conv: Ablations showed the multi-scale conv branches weren't pulling their weight and replacing them with a simple causal k=4 depthwise conv and moving the parameter savings into wider SwiGLU layers improved perplexity by ~5% and trained 1.6× faster. Where the memory sits mattered more: At 25M parameters (d=384, 6 blocks), my first prototype ran a single 3×128 Delta module as a parallel bypass reading from token embeddings and adding its output after Block 6. It extrapolated smoothly to 4,096 tokens, but trailed a parameter-matched RoPE Transformer by ~2.5 PPL at native T=1024 (26.38 vs 23.93). Moving that exact same 3×128 module inside the stack after Block 3 (B3), so earlier blocks contextualize keys/queries and later blocks process retrieved values (or atleast thats what I think is happening), dropped native PPL from 26.38 to 23.85 with zero extra cache (0.217 MiB). Putting Delta in every layer actually hurt: Next, I tested placing a 3×128 Delta module in all 6 blocks (which narrowed SwiGLU layers). Native PPL degraded to 26.76 while training almost 2× slower. Giving a few well-spaced global "memory hops" (B2+B4) plenty of SwiGLU capacity beat dense recurrent layers across every length. Parameter-Matched Results (25M, WikiText-103, 100M Targets) All models share the exact same ~21.46M non-embedding parameter budget (d=384, T=1024 native training, BF16 + torch.compile). One thing I ran into during eval was, raw RoPE blew up to 96.24 PPL at 4096 tokens, which initially looked like a huge extrapolation win; until I evaluated that same RoPE checkpoint with zero-shot YaRN, which brought it down to 23.27. Even against YaRN, the 2-hop B2+B4 model held a slight edge across all three context lengths while decoding ~6× faster with a constant 0.407 MiB cache. Model (~21.46M backbone) Delta Hops PPL u/1024 (s42 / s1337 / mean) PPL u/2048 (mean) PPL u/4096 (mean) Train tok/s Decode ms/tok u/4096 Cache MiB RoPE Transformer (+ eval YaRN) 0 23.93 / 24.32 / 24.12 23.34 23.27 190,391 10.953 146.250 In-Stack Sparse Delta (B3) 1 23.85 / 24.52 / 24.19 23.54 23.20 178,148 1.471 0.217 In-Stack Sparse Delta (B2+B4) 2 23.66 / 24.25 / 23.96 23.30 22.94 147,810 1.781 0.407 Dense Delta (B1–B6, s42 only) 6 26.76 / — / 26.76 25.95 25.50 93,884 3.558 1.169 Caveats & What's Next Scale & data: Everything above is at 25M parameters on WikiText-103 (100M targets), and the dense 6-hop control was only run on a single seed. (I neither have the GPU budget to go above 125M nor the monetary budget to rent a GPU for testing higher scales). Verification: Every checkpoint passed a strict FP64 suffix-causality audit (0.0 leakage from future tokens) and step-by-step cached-decode parity checks. Next step: I just cleaned up the codebase into a standalone pure-PyTorch repo (sparse-delta-lm) with 125M presets (1:3 sparse-hop ratio, 4 hops across 12 blocks) and lm-evaluation-harness hooks to see if this holds up on FineWeb-Edu (2.5B tokens) and standard zero-shot tasks (PIQA, HellaSwag, ARC-Easy, WinoGrande, LAMBADA). Repo: https://github.com/SnappierSoap318/sparse-delta-lm If anyone has tried similar sparse recurrent/linear-attention interleaving at larger scales—or sees flaws in how I parameter-matched the SwiGLU width trade-off—I’d love to hear your thoughts.
An IBM Research/Cornell paper shows that pretraining Looped Prediction Transformers (LPT) so later recursions share the KV cache of the first recursion improves perplexity while using 76–79% less context memory at 150M–1B parameter scale, establishing memory sharing as a beneficial architectural inductive bias rather than just a deployment-time trick.
MemOnce is a scalable memory architecture for LLMs that caches a small subset of final-layer hidden states and dynamically decodes them into KV caches, combined with layer-shared sparse attention, achieving linear-time complexity. Adapting Qwen3.5-4B with MemOnce reduces memory state cache by 1313x and prefill latency by 6.9x at 1M context while improving throughput by 3.5x.
An educational thread explaining that the main bottleneck in LLM inference is data movement, not computation, and highlighting techniques like quantization, KV cache optimization, and FlashAttention to reduce memory traffic.
This paper introduces CoMem, a method that exploits the depth-wise division of labor in LLMs to cache intermediate residual tensors and recompute only upper layers for retrieval, enabling bounded read compute and memory independent of stored-context length. Evaluated on Qwen3-8B, CoMem achieves strong long-context performance with significant memory savings and prefill speedups.
This paper introduces sparse prefix caching for hybrid and recurrent LLMs, which stores recurrent states at a limited set of checkpoint positions to avoid dense caching while minimizing recomputation. The method outperforms standard heuristics on real-world data, especially when requests share substantial but non-identical prefixes.