Ouroboros: Dynamic Weight Generation for Recursive Transformers via Input-Conditioned LoRA Modulation

Jaber Jaber, Osama Jaber
4/2/2026
cs.LGcs.CL

Official code: RightNow-AI/ouroboros (35 stars, PyTorch, last commit 2026-04-02).

Abstract

Recursive transformers reuse a shared weight block across multiple depth steps, trading parameters for compute. A core limitation: every step applies the same transformation, preventing the model from composing distinct operations across depth. We present Ouroboros, a system that attaches a compact Controller hypernetwork to a recursive transformer block. The Controller observes the current hidden state, produces a per-step diagonal modulation vector, and applies it to frozen SVD-initialized LoRA bases, making each recurrence step input-dependent. We combine this with gated recurrence (bias-initialized to 88% retention) and per-step LayerNorm for stable deep iteration. On Qwen2.5-3B split into a Prelude/Recurrent/Coda architecture (17 of 36 layers retained), Ouroboros reduces training loss by 43.4% over the unmodified 17-layer baseline, recovering 51.3% of the performance gap caused by layer removal. The full system adds only 9.2M trainable parameters (Controller, gate, and per-step norms) yet outperforms equivalently-sized static per-step LoRA by 1.44 loss points at depth 1 and remains ahead across all tested depths (1, 4, 8, 16) and ranks (8, 32, 64). We also find that gated recurrence is essential: without it, recursive layer application makes the model strictly worse. These gains are measured on the training distribution; on held-out text, the Controller does not yet improve over the baseline, a limitation we attribute to frozen downstream layers and discuss in detail. Code: https://github.com/RightNow-AI/ouroboros

View on arXivView PDF

Code Implementations(1)

PyTorch

Dynamic weight generation for recursive transformers via input-conditioned LoRA modulation

355Shell, PythonApr 2, 20266 months agoNOASSERTION
adaptive-computationdeep-learninghypernetworkslorapytorch+2 more

Cite this paper

@article{jaber2026ouroboros,
  title  = {Ouroboros: Dynamic Weight Generation for Recursive Transformers via Input-Conditioned LoRA Modulation},
  author = {Jaber Jaber and Osama Jaber},
  year   = {2026},
  eprint = {2604.02051},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2604.02051v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2604.02051.svg)](https://codeofpaper.com/paper/2604.02051)

Discussion