LSTM-Style Looped Transformers with Shared KV Caches
Abstract
Recurrent transformers reuse weights to perform deep computation with fewer parameters. We study an LSTM-style transformer that also shares one key--value cache across its recurrent core. At width 1024, it uses 40.4% fewer parameters than an untied control at nearly matched forward FLOPs, and reduces persistent cache sets from fifteen to four. Parallel training supplies cache entries from a standard-attention pass, whereas continuation reads entries produced recursively using shared attention. We address this mismatch by aligning the two training passes' cache entries with a consistency loss during the final 10% of a fixed training-token budget. Across three model widths on FineWeb, this removes 81--89% of the continuation-loss penalty relative to full-cache evaluation. The improvement replicates on disjoint documents for two training seeds. Across four widths and 1.05--4.19B training tokens, the loss cost of weight tying is smallest at lower token budgets, suggesting an opportunity to use recurrent computation when data and model storage are limited.
Figures & tables
| Width | Model | Params (M) | Forward FLOPs (M/token) | Sets | KV (KiB/token) | Full-cache loss | Shared-cache loss |
|---|---|---|---|---|---|---|---|
| 512 | Untied | 70.01 | 178.0 | 15 | 15 | 3.3679 | — |
| Two-pass | 46.93 | 181.1 | 4 | 4 | 3.4395 | 3.5589 | |
| Repaired | 46.93 | 181.1 | 4 | 4 | 3.4420 | 3.4570 | |
| 768 | Untied | 135.98 | 328.9 | 15 | 22.5 | 3.2393 | — |
| Two-pass | 85.24 | 336.0 | 4 | 6 | 3.2827 | 3.3347 | |
| Repaired | 85.24 | 336.0 | 4 | 6 | 3.2839 | 3.2938 |
| Update | Adapter | Params (M) | Loss | loss |
|---|---|---|---|---|
| Gated carry | No | 46.61 | 3.4517 | — |
| Plain overwrite | No | 45.43 | 3.4838 | (0.0003) |
| Gated carry | Yes | 47.79 | 3.4518 | (0.0003) |
| Plain overwrite | Yes | 46.61 | 3.4683 | (0.0003) |
| Huginn-style | Yes | 46.61 | 3.4745 | (0.0003) |
| Width | continuation loss | full-cache loss | Residual penalty |
|---|---|---|---|
| 512 | (0.0022) | (0.0002) | |
| 768 | (0.0010) | (0.0003) | |
| 1024 | (0.0013) | (0.0003) |
Appendix figures & tables23 assets
Supplementary material from the paper’s appendix.
Appendix
| Endpoint updates | Decay starts | Training tokens |
|---|---|---|
| 4,000 | 3,600 | 1,048,576,000 |
| 8,000 | 7,200 | 2,097,152,000 |
| 16,000 | 14,400 | 4,194,304,000 |
| Width | Trained model | Total params | Non-emb. | (%) | Forward FLOPs | (%) | Training FLOPs |
|---|---|---|---|---|---|---|---|
| 384 | Untied | 43.66 | 24.34 | — | 115.8 | — | 347.4 |
| 384 | Standard cell | 30.97 | 11.66 | -29.1 | 117.6 | +1.5 | 352.7 |
| 384 | Two-pass cell | 30.97 | 11.66 | -29.1 | 117.6 | +1.5 | 687.5 |
| 512 | Untied | 70.01 | 44.25 | — | 178.0 | — | 534.0 |
| 512 | Standard cell | 46.93 | 21.18 | -33.0 | 181.1 | +1.8 | 543.4 |
| 512 | Two-pass cell | 46.93 | 21.18 | -33.0 | 181.1 | +1.8 | 1058.2 |
| Width | Params (M) T / U | Training FLOPs T / U | Compute ratio T/U | T loss | U loss | loss T U |
|---|---|---|---|---|---|---|
| 384 | 30.97 / 43.66 | 1.442 / 1.457 | 0.989 | 3.6257 | 3.4819 | |
| 512 | 46.93 / 70.01 | 2.219 / 2.240 | 0.991 | 3.4967 | 3.3710 | |
| 768 | 85.24 / 135.98 | 4.112 / 4.139 | 0.993 | 3.3448 | 3.2394 | |
| 1024 | 136.20 / 228.49 | 6.670 / 6.706 | 0.995 | 3.2514 | 3.1557 |
| Width | Tokens | Untied | Std. cell | Two-pass std. | Two-pass shared | ||
|---|---|---|---|---|---|---|---|
| 384 | 1.049 | 3.6880 | 3.7158 | 3.7338 | 3.7329 | +0.0278 | +0.0449 |
| 384 | 2.097 | 3.5641 | 3.6083 | 3.6271 | 3.6257 | +0.0442 | +0.0617 |
| 384 | 4.194 | 3.4819 | 3.5408 | 3.5594 | 3.5582 | +0.0589 | +0.0763 |
| 512 | 1.049 | 3.5759 | 3.5941 | 3.6076 | 3.6035 | +0.0182 | +0.0276 |
| 512 | 2.097 | 3.4549 | 3.4864 | 3.5011 | 3.4967 | +0.0315 | +0.0417 |
| 512 | 4.194 | 3.3710 | 3.4138 | 3.4292 | 3.4256 | +0.0428 | +0.0546 |
| Tokens | Seed | Untied | Two-pass std. | Two-pass shared | |
|---|---|---|---|---|---|
| 1.049 | 0 | 3.4462 | 3.4624 | 3.4571 | +0.0109 |
| 1.049 | 1 | 3.4476 | 3.4637 | 3.4587 | +0.0111 |
| 1.049 | 2 | 3.4444 | 3.4620 | 3.4569 | +0.0125 |
| 2.097 | 0 | 3.3254 | 3.3504 | 3.3448 | +0.0194 |
| 2.097 | 1 | 3.3264 | 3.3531 | 3.3479 | +0.0215 |
| 2.097 | 2 | 3.3235 | 3.3512 | 3.3455 | +0.0220 |
| Seed | Parent shared | Repaired shared | Shared difference | Full-cache difference | Untied |
|---|---|---|---|---|---|
| 0 | 3.3346 | 3.2911 | 3.2390 | ||
| 1 | 3.3235 | 3.2936 | 3.2336 |
| Auxiliary objective | Full | Shared | Penalty | chunk std. |
|---|---|---|---|---|
| None | 3.2827 | 3.3353 | +0.0526 | +0.0000 |
| Donor + epilogue, | 3.2826 | 3.3029 | +0.0203 | +0.0001 |
| Donor + epilogue, | 3.2834 | 3.2956 | +0.0122 | +0.0010 |
| Donor only, | 3.2832 | 3.3001 | +0.0169 | +0.0004 |
| Donor only, | 3.2839 | 3.2938 | +0.0099 | +0.0013 |
| Donor only, | 3.2884 | 3.2902 | +0.0018 | +0.0052 |
| Update | Params (M) | Fwd MFLOPs/tok | Cold loss | loss (SE) | |
|---|---|---|---|---|---|
| Cell | 0 | 46.933 | 181.1 | 3.7961 | — |
| Cell | 0.3 | 46.933 | 181.1 | 3.6587 | |
| Plain | 0 | 46.408 | 178.0 | 3.7658 | — |
| Plain | 0.3 | 46.408 | 178.0 | 3.6844 | |
| Injection | 0 | 46.932 | 181.1 | 3.6945 | — |
| Injection | 0.3 | 46.932 | 181.1 | 3.6674 |
| Checkpoint | ||||||
|---|---|---|---|---|---|---|
| Untreated | 3.2568 | 3.2510 | 3.2994 | 3.3246 | 3.3290 | 3.3313 |
| Late donor consistency | 3.2579 | 3.2515 | 3.2596 | 3.2640 | 3.2663 | 3.2671 |
| Producer | Training objective | Tokens (B) | Train cost | Fwd MFLOPs/tok | Cold loss |
|---|---|---|---|---|---|
| Late | Two-pass + consistency | 1.049 | 181.1 | 3.6587 | |
| Early | Two-pass | 1.049 | 181.7 | 3.7362 | |
| Early | Shared CE | 1.049 | 181.7 | 3.7247 | |
| Early | Shared CE | 2.036 | 181.7 | 3.6240 |
| Producer | Tokens (B) | Train FLOPs ( ) | Fwd MFLOPs/tok | Cold loss |
|---|---|---|---|---|
| Late, two-pass + consistency | 4.194 | 4.4382 | 181.144 | 3.4494 |
| Early, shared CE | 2.036 | 1.1095 | 181.668 | 3.5903 |
| Sweeps | Tokens (B) | Train compute | Handoff | Cold | Chunk std. | |
| 2 | 0 | 1.049 | 3.7122 | 3.7961 | 3.6081 | |
| 2 | 0.3 | 1.049 | 3.6523 | 3.6587 | 3.6101 | |
| 4 | 0 | 1.049 | 3.6684 | 3.6522 | 3.6100 | |
| 4 | 0.3 | 1.049 | 3.6733 | 3.6539 | 3.6113 | |
| 4 | 0 | 0.663 | 3.7592 | 3.7484 | 3.7173 | |
| 4 | 0.3 | 0.663 | 3.7632 | 3.7515 | 3.7187 |
| Tokens, | Cold | ||||||
|---|---|---|---|---|---|---|---|
| 1.049B, 0 | 3.6001 | 3.6525 | 3.6482 | 3.5882 | 3.6413 | 3.6215 | 3.6073 |
| 1.049B, 0.3 | 3.6016 | 3.6639 | 3.6501 | 3.5886 | 3.6526 | 3.6376 | 3.6099 |
| 0.663B, 0 | 3.7170 | 3.7546 | 3.7462 | 3.7053 | 3.7328 | 3.7249 | 3.7175 |
| 0.663B, 0.3 | 3.7185 | 3.7595 | 3.7523 | 3.7059 | 3.7475 | 3.7388 | 3.7213 |
| Arm | Full-cache continuation | Shared continuation | Chunk standard |
|---|---|---|---|
| Parent | 3.2827 | 3.3347 | 3.2728 |
| Reset control | 3.4093 | 3.4602 | 3.3917 |
| KL only, | 3.4207 | 3.4272 | 3.4035 |
| K/V, | 3.4099 | 3.4287 | 3.3929 |
| Both | 3.4220 | 3.4199 | 3.4045 |
| Update | Adapter | 1.049B tokens | 2.097B tokens | 4.194B tokens |
|---|---|---|---|---|
| Gated carry | No | 3.4517 | 3.3427 | 3.2643 |
| Plain overwrite | No | 3.4838 | — | — |
| Gated carry | Yes | 3.4518 | — | — |
| Plain overwrite | Yes | 3.4683 | — | — |
| Huginn-style | Yes | 3.4745 | 3.3649 | 3.2891 |
| Untied | — | 3.4462 | 3.3254 | 3.2394 |
| Update | Backpropagation | |||||
|---|---|---|---|---|---|---|
| Cell | Full | 3.6656 | 3.6112 | 3.6028 | 3.6065 | 3.6287 |
| Cell | Last eight | 3.7076 | 3.6748 | 3.6731 | 3.6822 | 3.7107 |
| Huginn-style | Full | 3.6581 | 3.6052 | 3.6036 | 3.6036 | 3.6037 |
| Huginn-style | Last eight | 3.6472 | 3.5913 | 3.5896 | 3.5896 | 3.5896 |
| Evaluation | Fixed standard | Fixed shared | Variable standard | Variable shared |
|---|---|---|---|---|
| 3 | 3.3504 | 3.3448 | 3.3693 | 3.3577 |
| 4 | 3.4142 | 3.4691 | 3.3513 | 3.3452 |
| 5 | — | — | 3.3477 | 3.3436 |
| 6 | 3.7543 | 3.9704 | 3.3483 | 3.3449 |
| 8 | — | — | 3.3551 | 3.3515 |
| Serving rule | Untreated | Whole-run consistency | Late consistency |
|---|---|---|---|
| Fixed | 3.4187 (3.00) | 3.3899 (3.00) | 3.3862 (3.00) |
| Fixed | 3.4115 (4.00) | 3.3803 (4.00) | 3.3761 (4.00) |
| Fixed | 3.4149 (6.00) | 3.3832 (6.00) | 3.3779 (6.00) |
| Halting, cap 6 | 3.4151 (5.17) | 3.3826 (4.18) | 3.3816 (4.75) |
| Width | Layout | Peak | Peak base | ||||
|---|---|---|---|---|---|---|---|
| 768 | Cell, standard | 9.1 | 8.6 | 14.0 | 29.1 | 8259 | 7897 |
| 768 | Cell, shared | 8.3 | 9.0 | 13.9 | 28.9 | 2980 | 2618 |
| 768 | Untied | 7.8 | 7.7 | 13.5 | 28.7 | 8556 | 7996 |
| 1024 | Cell, standard | 9.2 | 8.4 | 17.6 | 20.7 | 11136 | 10561 |
| 1024 | Cell, shared | 8.3 | 8.4 | 17.3 | 37.2 | 4097 | 3522 |
| 1024 | Untied | 8.0 | 8.2 | 17.3 | 20.6 | 11691 | 10740 |
| Comparison | Rule or scope fixed beforehand | Observed outcome |
|---|---|---|
| Untied control | Match reference forward FLOPs within 5% before comparing losses. | Fifteen blocks; residual forward mismatch 1.5–2.4%. |
| Width/token ladder | Widths 384/512/768/1024, three annealed token endpoints, same data and recipe. | Complete; recurrent gaps generally widen with tokens and shrink with width. |
| Gradient-path control | Cell/injection crossed with full/last-eight gradients; width 512, uniform depth 4–32. | Large truncation penalty for the cell; small full-gradient difference between updates. |
| Training-seed replication | Three paired seeds for the width-768 two-pass and untied models, with fixed data order. | Shared-minus-untied gap positive in all nine endpoint/seed pairs. |
| Repair effect and quality | Shared continuation improvement at least 0.01 nats, with paired uncertainty; chunk-standard degradation at most 0.005. | Selected late donor repair meets both at tested widths and adaptive caps; whole-run adaptive treatment exceeds the quality limit. |
| Branch control | Before comparing auxiliary terms, reproduce parent parallel losses within 0.005 and continuation penalty within 0.01. | Control meets both tolerances. |
Recurrent Transformers
Recurrent Transformers reuse layers or state across steps to extend context, reasoning depth, and sequence modeling with less parameter growth.
See all 180 papers