Train LLMs on Consumer GPUs - Lyra Project
TL;DR: Lyra is a decoder-only Transformer architecture designed for constrained hardware, utilizing custom data streaming and VRAM management to train on a single 8GB GPU. Best for: Developers interested in the mechanics
TL;DR: Lyra is a decoder-only Transformer architecture designed for constrained hardware, utilizing custom data streaming and VRAM management to train on a single 8GB GPU.
Best for: Developers interested in the mechanics of LLM pretraining and SFT on consumer-grade hardware.
Repository snapshot: โญ 1 410 stars ยท ๐ด 145 forks ยท Python ยท Apache-2.0
Daily picks: Follow GitHub Open Source on Telegram
What it is
Lyra is a Python-based, decoder-only Transformer architecture designed to democratize the training lifecycle. Unlike enterprise frameworks that demand multi-GPU clusters, Lyra is optimized for constrained hardware, specifically targeting consumer-grade GPUs like the RTX 3060 Ti with 8GB of VRAM. It provides a full-stack experience, including pretraining, supervised fine-tuning (SFT), and terminal-based inference.
How it works
Lyra achieves this efficiency through custom data streaming and aggressive VRAM management. It utilizes a zero-copy memmap data streaming builder to handle large datasets without overwhelming system memory. The architecture incorporates modern techniques such as RMSNorm, SwiGLU, QK-norm, and residual scaling to maintain stability during training on limited resources.
Key features
- Hardware Efficiency: Trains on a single 8GB VRAM GPU.
- Full Lifecycle: Includes scripts for pretraining on 6.4B tokens and SFT.
- Monitoring: A built-in terminal user interface (TUI) dashboard tracks VRAM usage and training metrics in real-time.
- Inference: Features a terminal-based chat interface similar to Ollama, complete with live context gauges.
- Debugging: Includes a 'failure ledger' documenting common pitfalls like CUDA graph collisions.
Getting started
Lyra is written in Python and is best suited for developers who want to experiment with model architecture. To get started, clone the repository from GitHub (luka0x12/Lyra) and ensure you have a CUDA-enabled environment. The project is designed for educational transparency, so you can inspect the training loops directly.
git clone https://github.com/luka0x12/Lyra
cd Lyra
# Follow the setup instructions in the README for your specific environment
When not to use it
Lyra is an educational tool. It is not a replacement for production-grade distributed training frameworks like PyTorch Lightning or DeepSpeed. If your goal is to train massive models or deploy in a high-traffic production environment, this project will likely hit its limits quickly. Use it to learn the mechanics, not to build the next commercial foundation model.
Discuss
When training on a single GPU, do you prioritize batch size or model depth in your experiments?
Curated from the repository README and metadata. No hands-on test is claimed; evaluate it in a sandbox before production use.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes โ full credit and traffic to the original publisher.