A 14-Year-Old Built Lyra, a 326M Open-Source AI, on One Consumer GPU
A 14-year-old built the full pretraining, SFT, and inference stack for a 326M-parameter transformer on a single RTX 3060 Ti, using 57 kWh of power.
Takeaways
- Lyra is a 326M decoder-only transformer trained from scratch by a 14-year-old on one RTX 3060 Ti.
- Pretraining used 6.4B tokens from FineWeb-Edu, Cosmopedia v2, and Python-Edu, reaching perplexity 10.19.
- Total cost was roughly 180 hours and 57 kWh of electricity, around 10,000 tokens per second sustained.
- SFT on 78k examples from Tulu-3, OpenOrca, SciQ, DailyDialog and more produces the instruct variant.
- Architecture uses QK-Norm, SwiGLU, RMSNorm, residual scaling and a 1024-token context window.
- Code is Apache-2.0, weights are CC-BY-NC-4.0 due to DailyDialog and Tulu-3 subset licenses.
A 14-year-old developer in Serbia has released Lyra, a 326 million-parameter, decoder-only transformer trained from scratch on one Nvidia RTX 3060 Ti. The release includes the checkpoints, data pipeline, training code, supervised fine-tuning setup, chat interface, documentation, and a record of the failures encountered during training.
At 326 million parameters, Lyra is small by current language-model standards, which makes its implementation easier to inspect and reproduce. A decoder-only transformer predicts the next token from the tokens before it, the same basic design used by GPT-style models. Lyra shows how that design moves from pretraining to a usable conversational model on consumer hardware.
One GPU, the Full Pipeline
| Item | Details |
|---|---|
| Parameters | 326 million |
| Architecture | Decoder-only transformer |
| GPU | RTX 3060 Ti with 8 GB of VRAM |
| System memory | 32 GB |
| Pretraining | 195,312 steps over roughly 180 hours |
| Throughput | About 10,000 tokens per second |
| Reported energy use | Approximately 57 kWh |
| Context limit | 1,024 tokens |
| Pretraining validation loss | 2.32 nats, equivalent to perplexity of about 10.19 |
The release provides a base checkpoint and an instruction-tuned checkpoint. The base model learns general next-token prediction from pretraining data, while the instruct model receives additional training on conversational examples so it can follow prompts and produce assistant-style responses.
Pretraining used a mixture of FineWeb-Edu at 70%, Cosmopedia v2 at 20%, and Python-Edu at 10%. Perplexity is the exponential of the validation loss and summarizes how uncertain the model is about the next token; comparisons remain meaningful only when models use compatible evaluation data and tokenization.
Stability Choices for a Small GPT
Lyra uses several techniques common in newer transformer recipes: per-head QK-Norm, residual-branch scaling by 1/sqrt(24), and custom tokens that delimit chat roles.
QK-Norm applies RMS normalization to each attention head’s query and key vectors before their dot product. This constrains the scale of attention scores and reduces the risk of unstable logits during training. Residual scaling similarly limits how much each branch adds to the running hidden state.
The Supervised Fine-Tuning Recipe
- Optimizer: AdamW with
beta1=0.9,beta2=0.95, and zero weight decay. - Learning rate: A peak of
5e-5, 3% warmup, and cosine decay to5e-6. - Batching: Roughly 2,048 tokens per micro-batch with four gradient-accumulation steps.
- Sequence lengths: Batches bucketed at 128, 256, 384, 512, 768, and 1,024 tokens to reduce padding.
- Precision:
bf16autocast withfp32master weights. - Memory control: Full activation checkpointing.
- Training volume: About 78,000 examples over three epochs.
- Runtime: Roughly two to three hours on the RTX 3060 Ti.
- Result: Validation loss near 1.5 nats on assistant tokens.
Supervised fine-tuning computes loss only on the assistant’s reply tokens. User and system turns remain available as context, while gradient updates teach the model to generate the response. This masking prevents the training objective from rewarding imitation of the prompt.
Limits With Concrete Examples
The model card defines a narrow operating range for Lyra and documents several recurring failure modes:
- It can invent entities, dates, sources, and citations.
- Multi-step arithmetic and logic problems often fail.
- The context window ends at 1,024 tokens.
- Sampling can produce different answers to the same prompt.
- Generated code cannot be executed or verified by the model.
- Its training and intended use are limited to English.
- Conversations do not persist between sessions.
Suitable tasks include short question answering, rewriting, simple explanations, brainstorming, and basic code snippets. The documented limitations rule out factual verification, long-context work, and other uses that require reliable reasoning or citations.
An intermediate checkpoint at 1.5 billion training tokens showed semantic drift, including a claim that Luxembourg was the capital of France. The project classifies this behavior as an expected stage of training: fluent syntax had emerged while sparse factual associations remained weak.
Nine Bugs, Traced to Their Causes
The file docs/architecture.md records nine bugs found during development, including symptoms, causes, and fixes. Three cases capture the practical value of that ledger:
- Misreported loss: A dashboard displayed a loss of 35.2 because the GPU accumulator summed micro-steps while the readout divided by optimizer steps. Training remained healthy; the reporting calculation was wrong.
- Stale resume checkpoint:
best.ptwas saved only when validation improved. A restart therefore loaded a checkpoint from 20,000 steps earlier and discarded about 10 hours of compute. - CUDA graph collisions:
torch.compileinmax-autotunemode interacted with gradient accumulation andset_to_none=True. The backward pass allocated new gradient tensors inside the captured graph, causing an immediate out-of-memory failure.
These incidents distinguish model failures from monitoring, checkpointing, and runtime failures. That distinction matters during long single-GPU runs, where a silent resume error can waste more time than an explicit crash.
Start With the Instruct Checkpoint
The published instruct weights can be used without repeating pretraining or fine-tuning:
git clone https://huggingface.co/luka0x12/Lyra-326M-Instruct
cd Lyra-326M-Instruct
pip install torch sentencepiece safetensors numpy
python chat.py
The bf16 weights occupy about 0.65 GB, leaving additional memory requirements for activations, the runtime, and generated-token state. The model fits on modest GPUs and can run on a CPU at lower generation speeds.
Code and Weights Use Different Licenses
| Artifact | License | Practical effect |
|---|---|---|
| Source code | Apache 2.0 | Permits commercial use subject to the license terms. |
| Model weights | CC BY-NC 4.0 | Requires attribution and prohibits commercial use. |
| Custom persona dataset | CC0 | Released without copyright restrictions. |
The non-commercial restriction on the weights reflects the supervised fine-tuning mixture, which includes DailyDialog and non-commercial subsets of Tulu 3. Products can reuse the Apache-licensed code, but Lyra’s published weights cannot be incorporated into commercial services under their current license.
A Complete Reference With Clear Boundaries
Lyra packages data streaming, pretraining, supervised fine-tuning, inference, licensing, and failure analysis into one readable project. Projects such as nanoGPT established the viability of small single-GPU training runs; Lyra adds the later stages needed to turn a base checkpoint into a conversational application.
The result gives developers a practical view of the full language-model lifecycle on accessible hardware. Its scope remains specific: one consumer GPU can train a small conversational model in about a week, provided the pipeline carefully manages memory, checkpoints, precision, and runtime failures.