120M parameters · trained from scratch · single GPU

A small language model, built the way the frontier ones are.

Nano-GLM re-implements the architecture behind modern GLM and DeepSeek-class models at a scale that trains on one consumer GPU — multi-latent attention, mixture-of-experts routing, and sparse attention, none of it simplified.

inputtokens MLA attentioncompressed KV cache sparse routerDSA indexer MoE experts1 shared + top-k outputnext token
Architecture

Three ideas borrowed from the frontier, scaled down honestly.

Multi-Latent Attention from DeepSeek-V3

Instead of caching a full key/value tensor per token, MLA compresses attention through a low-rank projection, closer to LoRA than to a standard cache. The memory saved is what makes training possible on 6GB of VRAM at all.

Mixture of Experts from GLM-5

Rather than one dense feed-forward block, the model routes each token to a small set of specialized experts plus one shared expert. Capacity grows without every token paying for every parameter.

DeepSeek Sparse Attention from DeepSeek-V3.2

A learned indexer decides which previous tokens are actually worth attending to, and drops the rest — attention over a shortlist instead of the full context, without giving up long-range dependencies.

Training

The engineering that makes it fit on a laptop GPU.

120M
parameters
2.4B
training tokens
6GB
VRAM target
~4,900
tokens / sec
DATA
2.0B tokens of FineWeb-Edu for the main run, 0.4B mixed tokens for a final decay phase — a 20:1 Chinchilla-optimal ratio against model size.
SCHEDULE
Warmup–Stable–Decay: peak learning rate of 6e-4 held stable for 2.0B tokens, then a cosine decay into the final phase.
PRECISION
BF16 compute on NVIDIA TF32 tensor cores — roughly half the memory and twice the throughput of FP32.
MEMORY
Gradient checkpointing recomputes activations during the backward pass instead of storing them, trading a little speed for about 40% less VRAM.
BATCHING
Gradient accumulation over 3 micro-batches simulates an effective batch of 9,216 tokens per weight update.
Live

Generate with it directly.

0.7
100
40
0 tokens 0.00s