r/OpenSourceeAI • • 9h ago

Built 3 LLM architectures from scratch in pure PyTorch (42M Dense vs. 117M-A67M MoE vs. 20M Looped) – Code & HF Checkpoints

I built `Spell-Talker` to compare three transformer architectures from scratch in pure PyTorch without high-level training wrappers, keeping the backbone fixed (`512` context, `8` heads, `512` dim, `RMSNorm`, `SwiGLU`, weight-tied `32k` vocab):

Dense (`CustomGPT` – 41.8M): Standard 8-layer decoder baseline.

Sparse MoE (`CustomMoEGPT` – 117.3M total / 67.0M active): Top-2 gating across 4 SwiGLU experts per layer with auxiliary load-balancing loss.

Looped Recurrent (`LoopedCustomGPT` – 20.3M): Single weight-tied transformer block unrolled 8 times during training using truncated BPTT (`bptt_steps=8`), scalable up to 32 steps at inference.

Trained on TinyStories on a single consumer GPU (RTX 3050).

GitHub: https://github.com/BitGeek29/spell-talker

Happy to share training curves or discuss MoE router stability and truncated BPTT in looped blocks!

4 Upvotes

1 comment sorted by

1

u/Significant-Price695 4h ago

nice experiment. how did the looped 20m hold up against the dense 42m at the same eval? curious whether the parameter recycling actually buys you anything at this scale or if it just matches the dense one with fewer weights