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},
}

Metadata

Release files for RLT-pytorch 0.0.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for RLT-pytorch 0.0.11
File Size Uploaded Provenance Actions
rlt_pytorch-0.0.11.tar.gz 9.2 kB Without provenance Details for rlt_pytorch-0.0.11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for RLT-pytorch 0.0.11
File Interpreter ABI Platform Actions
rlt_pytorch-0.0.11-py3-none-any.whl Python 3 none any Details for rlt_pytorch-0.0.11-py3-none-any.whl

Total release size: 17.8 kB

Release files / rlt_pytorch-0.0.11.tar.gz

Download URL rlt_pytorch-0.0.11.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ab546f0cc46332179407c836a600a7e8ca28ffbb47329c4931d89415ffdadced
BLAKE2b-256 checksum
How to use checksums
e83051f495fef363cea524f449d6f55d8810df91dd083bc574ea43f4fea07ee0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Release files / rlt_pytorch-0.0.11-py3-none-any.whl

Download URL rlt_pytorch-0.0.11-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
17a7bfaff7b8a405fdd9634d644e6af5092a2c29719174eb768d6b408efd83ec
BLAKE2b-256 checksum
How to use checksums
19a01487085db2b91234e2c944bfcba5863b20e538557e5b71e91335d8fc728e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.17

Security for RLT-pytorch 0.0.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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