Waltzer: A Looped Nano Model
I trained this 40-million-parameter language model from scratch on a single RTX 2080. You can run it in your browser.
A typical language model runs through a stack of layers, each with its own weights. I wanted to try a less common design at a much smaller scale: at 40 million parameters, what would happen if the model went through the same eight layers twice? The second pass adds computation without adding another copy of those weights.
The name comes from the Waltzer fairground ride. The cars spin as they go around the platform, so a car can pass the same spot facing a different way. In Waltzer, the second pass goes through the same layers with a state the first pass has already changed.
Text completion playground
Give Waltzer the start of a sentence or paragraph. The model runs on your device and keeps writing from where you left off.
The looped core
Two blocks feed into an eight-block core. I borrowed the idea of alternating short convolutions with attention from Liquid AI's LFM3. Waltzer uses both local and global attention in that core.
I run the same eight blocks twice. Before pass two, I add the original core input back to the result of pass one and apply LayerNorm. Adding that input back is an idea I borrowed from NVIDIA's Dory.
Two output blocks finish the pass. That makes 12 distinct blocks and 20 block applications each time Waltzer runs. The diagram names each block's token mixer. Every block also has a SwiGLU feed-forward layer.
Embeddings and block sizes
Waltzer represents each token as a 512-dimensional vector and adds a learned embedding for its position. The context is 800 tokens. Each attention block has eight heads of width 64. Local attention looks at the last 64 or 128 tokens, including the current one, while global attention can look back across the whole available context. The causal convolutions have a kernel width of seven, and each SwiGLU feed-forward layer has an intermediate width of 1,024.
Why an 8K tokenizer
I trained a custom byte-level BPE tokenizer on Simple English Wikipedia. It starts from bytes and learns to merge common sequences. The released vocabulary has 8,192 entries, including 12 reserved IDs. One marks the end of a document.
On held-out Wikipedia text, the 8K vocabulary used 26% fewer tokens than my earlier 2K vocabulary. Going to 16K saved another 4.7%, but would have doubled the size of both the token embedding table and the separate output weight matrix. Together those matrices already account for about 8.4 million of Waltzer's 40.4 million parameters.
From Wikipedia to FineWeb-Edu
I started with English Wikipedia and Stack Exchange Q&A. As training went on, I added FineWeb, arXiv papers and YouTube Commons transcripts, then two math datasets and FineWeb-Edu. The breaks in the validation loss chart mark changes in the validation mix. A jump across one of those breaks compares different data.

The last validation loss was 1.7533 at update 1,369,700. I saved the final checkpoint 97 updates later, at 1,369,797 updates and 6.575 billion nominal next-token targets. That count is 4,800 targets per update before masking. It can include repeats, and I didn't run validation again on the final checkpoint.
What the base model does
Waltzer was trained to predict the next token. It treats a question as text to continue and can make up facts or repeat itself. I haven't trained this checkpoint to follow instructions or call tools.
Get the model weights on Hugging Face · Read the training code on GitHub