Independent AI intelligence Two editions daily · ET
Fervor AI

Analysis · December 4, 2026 · repo

luka0x12/Lyralocal-aifine-tuning

Lyra Trained a Language Model From Scratch on One 8 GB GPU. The Bug Log Is the Real Gift.

A 326M-parameter model, 6.4B tokens, about 180 hours on an RTX 3060 Ti, and a written list of the nine things that broke along the way.

Training a language model from nothing still sounds like something only labs do. You picture racks of GPUs, a cluster scheduler and a budget with commas in it.

Then a repo like Lyra sits at number two on Trendshift's daily board of rising GitHub repos (as read around 7:12 AM ET on December 4). Lyra is a 326-million-parameter model pretrained from random weights on about 6.4 billion tokens of text, using one NVIDIA RTX 3060 Ti with 8 GB of video memory and 32 GB of system RAM. Pretraining took about a week. The whole pipeline, from data streaming to a terminal chat app, is in the repo under Apache-2.0.

The model itself is small and makes things up. That is expected at this size, and the author says so plainly. What makes Lyra worth your time is something most training projects never publish: a ledger of the nine bugs that cost real hours, written so you can skip them. If you fine-tune or train anything, even a small adapter on a rented GPU, several of those bugs can bite you too.

What Lyra actually is

Lyra is a decoder-only transformer, the same basic shape as GPT-style models: it reads text and predicts the next token (a token is a word or a piece of one). The architecture notes list the specs:

  • 326,160,384 parameters across 24 layers
  • A 1,024-token context window, described as a "hard ceiling"
  • A 16,384-token vocabulary
  • Standard modern building blocks (RMSNorm, SwiGLU and QK-norm) that keep training stable and efficient

The project ships two models on Hugging Face, a base model that only continues text and an instruct model tuned to answer questions. The README describes pretraining on a mix of FineWeb-Edu (70%), Cosmopedia v2 (20%) and Python-Edu (10%), then supervised fine-tuning (SFT, training on example question-and-answer pairs) on about 78,000 examples.

For scale: 326M parameters is about a hundredth of the 35B main parameters in Qwen's new Qwen4-35B-A3B, a model built for local use this week. Nobody should pick Lyra as an assistant. Read it as a fully documented, end-to-end training run on hardware a lot of people already own.

The numbers, and why they hold together

Three figures from the repo are worth checking against each other.

The architecture notes give a sustained speed of about 10,000 tokens per second and about 178 hours of pretraining (the README rounds the total to about 180). Multiply 10,000 tokens per second by 178 hours and you get about 6.4 billion tokens, which matches the training total the repo claims. When a project's own numbers agree with each other like this, it is a good sign someone measured them rather than guessed.

The energy figure is about 57 kWh. At a household rate of, say, 15 to 30 cents per kWh (my assumption, not the repo's), that is somewhere around $9 to $17 of electricity for the full pretraining run. The real cost was the week of a machine you could not use for anything else, and the hours of debugging.

One more detail I liked while reading the notes: the training run was named NINE-SEVEN, after the starting loss of a model that guesses uniformly across 16,384 tokens (the natural log of 16,384 is about 9.70). The README reports that pretraining brought validation loss down to 2.32.

How it fits in 8 GB

An 8 GB card is tight for training even a small model, because training holds far more than the weights. It also stores the intermediate results of every layer (activations), the gradients, and the optimizer's bookkeeping. The notes list the tricks that made it fit, and they are the same ones you will reach for on any memory-limited job:

  • bf16 mixed precision. The math runs in a 16-bit format, which halves the size of most tensors, while a 32-bit master copy of the weights keeps updates accurate.
  • Gradient accumulation. Instead of one big batch, the loop runs 4 small batches 8 times and adds up the results before each weight update, for 32,768 tokens per step. Same learning signal, a fraction of the memory.
  • Activation checkpointing. Rather than keeping every layer's intermediate results for the backward pass, it throws them away and recomputes them when needed. Slower, but it is what makes 24 layers fit. One gotcha if you rerun it: the documented run used full checkpointing, while train.py at the reviewed commit defaults to --checkpoint selective, so pass --checkpoint full to match the notes.
  • Fused cross-entropy on bf16 logits. The loss calculation skips a cast to 32-bit that would have created a 134 MB tensor, which on an 8 GB card is the difference between running and crashing.

None of these are new. The value is seeing them all in one small, readable codebase (model.py, train.py, data.py, instruct.py) where you can watch each one do its job.

The failure ledger: nine bugs you can skip

The architecture notes close with a failure ledger of the major bugs hit during the project. Several of them generalize to almost any training or fine-tuning work.

The 8x loss illusion. The dashboard showed a loss of about 35 while validation sat around 4.4. The training loop added up one loss value per small batch, eight per weight update, but the display divided by the number of updates only. The model was fine. The readout was eight times too high. The lesson: when a number looks impossible, check the arithmetic of the display before you touch the model.

The resume rewind. The script saved a checkpoint only when validation improved. Restarting with --resume loaded that "best" file, which could be 20,000 steps old, and the README says this threw away about 10 hours of compute. The fix was a separate last.pt file that always holds the latest progress. If your training script has one checkpoint file, you have this bug waiting.

The data prep crash. Holding token IDs in ordinary Python lists costs about 36 bytes per number, and the notes say that crashed a 32 GB machine at 645 million tokens. The fix was to stream documents and write raw 32-bit integers straight to disk. Python lists are a convenience, not a storage format.

The checkpoint memory leak. Loading a 1.3 GB checkpoint directly onto the GPU, then never releasing the variable, kept a second copy alive in video memory. Loading to the CPU first fixed it.

Shape thrashing. torch.compile, PyTorch's speed-up compiler, rebuilds its compiled program every time it sees a new input shape. The fine-tuning batcher grouped examples by exact length, which produced hundreds of shapes and constant recompiling. Snapping lengths to a few fixed sizes fixed it.

The ledger also includes CUDA graph errors from combining torch.compile's most aggressive mode with gradient accumulation, and a stage at 1.5 billion tokens where the base model wrote fluent nonsense (the README's example is calling Luxembourg the capital of France). That last one was not a bug. It was a half-trained model behaving like one, and knowing that saves you from "fixing" something that only needed more tokens.

Put this into practice

Talk to the model in five minutes. The README's quick start clones the instruct model from Hugging Face and runs its terminal chat app:

git clone https://huggingface.co/luka0x12/Lyra-326M-Instruct
cd Lyra-326M-Instruct
pip install torch sentencepiece safetensors numpy
python chat.py

Hugging Face model repos store large files with Git LFS, so install git-lfs first if the clone comes down without the weights. Then expect grammatical, confident answers that are often wrong on anything obscure. That is the honest ceiling of 326M parameters, and seeing it firsthand is a useful calibration for how much of a large model's skill comes from size.

Read the training loop, not just the README. Open train.py and docs/architecture.md side by side. If you have only ever fine-tuned through a high-level library, this is a rare chance to see gradient accumulation, checkpointing and loss masking written out in plain PyTorch.

Steal four habits for your own runs. Whatever you train, and on whatever hardware:

  1. Save two checkpoints, "best" and "last", and resume from "last".
  2. Sanity-check every number your dashboard shows against a value you compute by hand once.
  3. Stream tokenized data to disk as raw integers instead of building it up in Python lists.
  4. If you use torch.compile, bucket sequence lengths into a handful of sizes.

Train it yourself only if the point is learning. The full pretraining run is about a week of a dedicated GPU. That is a great education and a poor way to get a useful model. For anything you plan to ship, fine-tune an existing open model instead.

Honest limitations

The architecture notes list Lyra's ceilings themselves: a 1,024-token context that cannot stretch (it uses learned position embeddings, so it has never seen a position past 1,024), English only, no memory between sessions, and "factual confabulation on obscure entities" as a structural limit of the scale. In plain words, it will not run an agent, read a long file, or answer niche questions reliably.

The license is split, and the split matters. The code is Apache-2.0. The weights are CC-BY-NC-4.0, because the fine-tuning mix includes DailyDialog (CC BY-NC-SA 4.0) and non-commercial parts of Tulu-3. The README says plainly that the final weights "cannot be used for commercial products." The small custom identity dataset (lyra_sft.jsonl) is CC0. If you want a commercial model from this pipeline, you would have to retrain the fine-tuning stage on data you can use commercially.

All the figures here are the project's own: one person, one machine, one run. The repo has no tagged releases, so this article pins its links to commit aeb08df. It had roughly 1,000 stars on December 4, 2026 (readings that day ranged from 961 on the repo page to about 1,080 from GitHub's API), which says people find it interesting, not that the numbers were independently reproduced.

Why this one is worth a star

Most open training projects publish the recipe and hide the mess. Lyra publishes the mess. A pretraining run on an 8 GB card that takes a week and about 57 kWh is a real data point for anyone who assumes this work needs a lab. The nine bugs are a free education for anyone who has ever stared at a loss curve and wondered whether the model or the dashboard was lying.

Clone it, read the ledger, and check your own training script for the resume bug before your next long run.

Sources: Trendshift daily board (read about 7:12 AM ET, December 4) · Lyra repository (reviewed at commit aeb08df) · Lyra README · docs/architecture.md · Lyra-326M-base · Lyra-326M-Instruct. Star count from the repo page and GitHub's API, December 4, 2026.