Waltzer-40M-base

Waltzer fairground badge

I trained Waltzer-40M-base from scratch on a single GeForce RTX 2080 to see how far a small language model could get by running the same group of layers twice. It's the first model in the Waltzer family. Give it a text prefix and it predicts what comes next. It's not instruction-tuned or trained to call tools.

The training code and project documentation are in Models from Scratch on GitHub.

Model

Setting Value
Parameters 40,385,536
Context 800 tokens
Hidden width 512
Attention 8 heads of width 64, with learned per-token head gates
Convolution Gated depthwise causal convolution, width 7
Feed-forward SwiGLU, intermediate width 1,024; gated product clamped to ±2,048
Position embeddings Learned absolute positions
Tokenizer Byte-level BPE with 8,192 IDs, including 12 reserved IDs; end-of-document is 8191
Output weights Untied from input embeddings

The input and output stacks each run a convolution block followed by a full causal attention block. Between them, the shared core runs this sequence twice:

Conv → Local-64 → Conv → Global → Conv → Local-128 → Conv → Global

The local windows include the current token. Before the second pass, the model adds the original core input back into the latest core state and applies LayerNorm. Each block normalizes the mixer and feed-forward inputs and updates with RMSNorm. There are 12 distinct blocks and 20 block applications per forward pass.

Generate with PyTorch

Download the model repository files together (for example, hf download williamoverton/waltzer-40m-base --local-dir waltzer-40m-base). The example uses the bundled tokenizer and model source, not Transformers. It runs on CUDA with FP16 autocast. On a Turing GPU, install the pinned FlashAttention fork using its PyTorch 2.15 build instructions. The training setup was Linux x86-64, Python 3.14, and PyTorch 2.15 (cu132). Install safetensors in the same environment, then run from the downloaded directory:

python generate.py 'Nottinghamshire is located in the center of'

Omit the positional prompt to read it from standard input, including any newlines. For example: python generate.py --max-new-tokens 128 < prompt.txt.

The public release's model.safetensors contains FP32 model weights, not the optimizer or training state. config.json describes the exact architecture and identifies tokenizer.json by SHA-256. The command streams the continuation and stops at end-of-document or when the prompt and completion together reach 800 tokens. Set --max-new-tokens to cap the completion earlier. Sampling uses a fresh random seed each run. Pass --seed 42 to repeat the same sampling sequence. The final stderr line reports generated tokens per second, including text streaming but excluding model loading and prompt tokenization.

The FP32 generator packs each attention block's query, key, and value weights into one projection at load time. It processes the full prefix at each step and computes vocabulary logits only for the last position.

Pretraining

Waltzer learned next-token prediction on packed text using fused AdamW, FP16 mixed precision, and a batch size of six 800-token sequences. The learning rate warmed up over 4 million nominal target tokens to 3e-4, then decayed to 3e-5 at 200 million and stayed there.

The run began with Wikipedia and Stack Exchange Q&A and added sources over time. These are final sampling shares per optimizer update, not the proportions across the entire run:

Source Final share
English Wikipedia (February 2026 ZIM snapshot) 15.0%
Stack Exchange Q&A 3.6%
FineWeb sample-10BT 28.7%
arXiv Papers 16.5%
YouTube Commons 14.6%
PrimeIntellect Verifiable Math Problems 0.5%
SwallowMath 6.1%
FineWeb-Edu 15.0%

FineWeb and FineWeb-Edu were not deduplicated against each other. The training token counter counts 4,800 targets per completed update; it does not measure unique tokens or subtract targets masked by Wikipedia citation filtering.

Evaluation and limitations

Internal next-token validation uses fixed held-out windows. The final protocol uses 60 windows per source and weights each source by its sampling share. The chart reports the overall loss logged at the time, not a single benchmark applied retrospectively. Breaks mark changes to the validation mix, so losses across those boundaries are not directly comparable.

The public release uses the final checkpoint saved on shutdown. The last validation was at update 1,369,700 (weighted loss 1.7533), 97 updates before that checkpoint. The final weights were not evaluated at shutdown.

Waltzer overall validation loss with dataset additions labeled at their cutovers

This is a small, English-focused research model. Treat its output as a continuation of the prompt, not as a verified answer. It can repeat itself, make up facts, or reflect biases in its training data.

License

The model weights and original source code included in this release are available under CC0 1.0 Universal. This applies only to rights I hold in those files; it does not change the terms for training data or third-party dependencies.

Released checkpoint

  • Checkpoint kind: latest
  • Completed optimizer updates: 1,369,797
  • Nominal next-token targets: 6,575,025,600 (6 × 800 per update)

Cumulative sampling by completed optimizer update:

Source Updates Share
fineweb 303,016 22.12%
arxiv 172,867 12.62%
wikipedia 630,778 46.05%
fineweb_edu 14,272 1.04%
youtube 152,833 11.16%
swallow_math 23,131 1.69%
qa 69,984 5.11%
primeintellect_math 2,916 0.21%
Downloads last month
-
Safetensors
Model size
40.4M params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Datasets used to train williamoverton/waltzer-40m-base