Skip to main content

RLT (wip)

Unofficial implementation of the Recurrent Looped Transformer proposed by Yifan Zhang of Princeton.

Will also do some exploration of the Recurrent Transformer proposed by Costin-Andrei Oncescu et al. of Harvard, if I have any remaining time

Install

$ pip install rlt-pytorch

Usage

import torch
from RLT import RLT

model = RLT(
    num_tokens = 256,
    dim = 512,
    enc_depth = 4,
    dec_depth = 4,
    dec_sliding_window_size = 16,
    tbptt_step_size = 16 # optional truncated bptt
)

tokens = torch.randint(0, 256, (2, 1024))

# forward for loss

loss = model(tokens, return_loss = True)
loss.backward()

# generate

prompt = torch.randint(0, 256, (2, 32))

sampled = model.generate(prompt, max_len = 128) # (2, 96)

Test

Train on enwik8

$ uv run train_enwik8.py

Citations

@techreport{zhang2026recurrentlooped,
    title  = {Recurrent Looped Transformer},
    author = {Zhang, Yifan},
    year   = {2026},
    month  = {Sep},
    url    = {https://github.com/yifanzhang-pro/recurrent-looped-tranformer}
}
@misc{oncescu2026recurrenttransformergreatereffective,
    title     = {The Recurrent Transformer: Greater Effective Depth and Efficient Decoding},
    author    = {Costin-Andrei Oncescu and Depen Morwani and Samy Jelassi and Alexandru Meterez and Mujin Kwun and Sham Kakade},
    year      = {2026},
    eprint    = {2604.21215},
    archivePrefix = {arXiv},
    primaryClass = {cs.LG},
    url       = {https://arxiv.org/abs/2604.21215},
}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rlt_pytorch-0.0.11.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rlt_pytorch-0.0.11-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file rlt_pytorch-0.0.11.tar.gz.

File metadata

  • Download URL: rlt_pytorch-0.0.11.tar.gz
  • Upload date:
  • Size: 9.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for rlt_pytorch-0.0.11.tar.gz
Algorithm Hash digest
SHA256 ab546f0cc46332179407c836a600a7e8ca28ffbb47329c4931d89415ffdadced
MD5 38faed3a1cffa87c58417f76baefa685
BLAKE2b-256 e83051f495fef363cea524f449d6f55d8810df91dd083bc574ea43f4fea07ee0

See more details on using hashes here.

File details

Details for the file rlt_pytorch-0.0.11-py3-none-any.whl.

File metadata

File hashes

Hashes for rlt_pytorch-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 17a7bfaff7b8a405fdd9634d644e6af5092a2c29719174eb768d6b408efd83ec
MD5 c8a37e6d03295213a3c2d3ece2e0b7bb
BLAKE2b-256 19a01487085db2b91234e2c944bfcba5863b20e538557e5b71e91335d8fc728e

See more details on using hashes here.

Release history Release notifications | RSS feed

0.0.14

2 files

0.0.12

2 files

This release

0.0.11 This release

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page