← Back to Home

colibrì: Run a 744B-Parameter LLM on Your Laptop with Only 25GB RAM

colibrì: Run a 744B-Parameter LLM on Your Laptop with Only 25GB RAM 🐦

What is it? colibrì is a pure C, zero-dependency inference engine that runs GLM-5.2 — a 744-billion parameter Mixture-of-Experts (MoE) model — on a consumer machine with just ~25 GB of RAM and no GPU. It streams model experts from disk on demand, keeping only the dense layers resident in memory.

Why it's trending: colibrì hit 7,300+ GitHub stars in under two weeks because it fundamentally changes what "self-hosted AI" means. Until now, running a frontier-class 744B model required multiple datacenter GPUs (H100s at $30K+ each). colibrì does it on a laptop with an NVMe drive — no GPU, no cloud API, no Python runtime. The tradeoff is speed (0.05–2 tok/s depending on hardware), but for offline research, batch analysis, and privacy-sensitive workloads, it's a breakthrough.


📋 Prerequisites

Before you start, make sure you have:

  • A Linux machine (or WSL2 on Windows, or macOS, or Windows 11 native with MinGW-w64)
  • ~370 GB of free NVMe/SSD space for the int4 model weights
  • ~25 GB of RAM (16 GB bare minimum, 32+ GB recommended for caching)
  • gcc with OpenMP and AVX2 support (any modern x86-64 or ARM processor)
  • Python 3.10+ (only for the one-time model conversion, not at runtime)
  • Patience — colibrì is disk-bound; a cold start runs at ~0.05–0.1 tok/s on modest hardware

🧠 Architecture Overview

colibrì Architecture

colibrì exploits a key property of Mixture-of-Experts models: a 744B MoE activates only ~40B parameters per token. The dense parts (attention, shared experts, embeddings — ~17B params) stay in RAM at int4 (~9.9 GB). The 21,504 routed experts (~370 GB total at int4) live on disk and are streamed on demand with an LRU cache, optional pinned hot-store, and OS page cache as a free L2 tier.

The engine is a single C file (c/glm.c, ~2,400 lines) with small headers. No BLAS, no Python at runtime, no GPU required. Key components:

  • MLA Attention — Multi-head Latent Attention with compressed KV-cache (576 floats/token vs 32,768 — 57× smaller)
  • Sigmoid Router — DeepSeek-V3-style routing with no auxiliary loss
  • Native MTP Speculative Decoding — GLM-5.2's own multi-token-prediction head drafts tokens at 2.2–2.8 tokens/forward (int8 head required)
  • Grammar-Forced Drafts — On constrained outputs (JSON, function calling), the grammar itself generates pre-accepted tokens
  • Learning Cache — Records which experts you use and auto-pins the hottest ones in spare RAM
  • KV-Cache Persistence — Conversations persist across restarts with zero re-prefill

🔧 Setup & Installation

Step 1: Clone and Build

git clone https://github.com/JustVugg/colibri.git
cd colibri/c
./setup.sh

The setup script checks for gcc, OpenMP, and AVX2, then builds the engine and runs a self-test. You should see "32/32 positions" confirming the architecture is correct.

Step 2: Download the Pre-Converted Model

The easiest path is to download a pre-converted int4 model with int8 MTP heads (critical for speculative decoding):

# Install git-lfs first
git lfs install

# Download the model (~370 GB)
git clone https://huggingface.co/mateogrgic/GLM-5.2-colibri-int4-with-int8-mtp /path/to/glm52_i4

⚠️ Critical: The MTP head must be int8. The int4 MTP head gives 0% draft acceptance, meaning speculation silently never engages. Verify with ls -l /path/to/glm52_i4/out-mtp-* — correct int8 files are ~3.5 GB, ~5.3 GB, and ~1.0 GB.

Step 3: Measure Your Disk Performance

Before running the model, benchmark your NVMe to set expectations:

cd c
gcc -O2 -fopenmp iobench.c -o iobench
./iobench /path/to/glm52_i4/out-00069.safetensors 19 64 8 1   # O_DIRECT mode

This tests the random 19 MB reads that colibrì uses during inference. A PCIe 4.0 NVMe typically gets 3–5 GB/s; PCIe 5.0 reaches 8–12 GB/s.

Step 4: Chat!

COLI_MODEL=/path/to/glm52_i4 ./coli chat

On first launch, the engine allocates its cache (~20 GB RSS peak), loads the dense layers into RAM (~30 seconds), and then you're ready to chat.


🚀 Advanced Configuration

Performance Tuning

colibrì has several knobs to squeeze more speed from your hardware:

Setting Description Recommended
--topp 0.7 Adaptive expert top-p sampling (30–40% less disk I/O) Start here
--ram 48 Set explicit RAM budget (default: auto-detect from MemAvailable) 48 GB+ if available
DRAFT=4 MTP speculative draft depth (requires int8 head) 4 (default)
GRAMMAR=file.gbnf Grammar-forced drafts for JSON/structured output Use for API mode
THINK=1 Enable GLM-5.2's reasoning block Optional
PIN_GB=40 Pin ~40 GB of hottest experts in RAM after learning usage After running a session
# Record expert usage first
STATS=stats.txt ./coli chat --temp 0.7 --topp 0.7

# Then pin learned hot experts
PIN=stats.txt PIN_GB=40 COLI_MODEL=/path/to/glm52_i4 ./coli chat --temp 0.7 --topp 0.7

OpenAI-Compatible API

colibrì exposes a standard API endpoint:

COLI_MODEL=/path/to/glm52_i4 COLI_API_KEY=your-key ./coli serve \
  --host 127.0.0.1 --port 8000 --model-id glm-5.2-colibri

# Test it
curl http://127.0.0.1:8000/v1/chat/completions \
  -H 'Authorization: Bearer your-key' \
  -H 'Content-Type: application/json' \
  -d '{"model": "glm-5.2-colibri", "messages": [{"role": "user", "content": "Hello!"}], "stream": true}'

GPU Tier (Optional)

If you have an NVIDIA GPU with 8+ GB VRAM, colibrì can use it as an expert accelerator:

make CUDA=1                   # Build with CUDA support
COLI_CUDA=1 COLI_GPU=0 ./coli chat   # Enable GPU expert tier

✅ Verification Checklist

After setup, verify everything works:

  • Engine self-test passes: ./setup.sh shows "32/32 positions"
  • MTP head is int8: ls -l /path/to/glm52_i4/out-mtp-* shows correct file sizes
  • Model loads without errors: COLI_MODEL=/path/ ./coli chat shows "ready in ~30s · resident ~9.9 GB"
  • Model responds coherently: test with a simple prompt
  • API endpoint works (if using serve mode): curl returns valid JSON
  • Expert cache auto-sizes to your available RAM (check RSS in stats line)

📊 Performance Expectations

colibrì's speed depends entirely on your hardware. Here are real measured benchmarks:

Hardware Disk Speed Config Tokens/s
12-core WSL2, 25 GB RAM, NVMe VHDX ~1 GB/s Default 0.05–0.1
Apple M5 Max, 128 GB unified ~4 GB/s Default, MTP off 1.06
Apple M5 Max + Metal backend, 128 GB Metal on, 46.9 GB pin 2.06
Ryzen 9 9950X + PCIe 5.0 NVMe, 123 GB 8.81 GB/s Learned pin 0.28
Ryzen AI Max+ 395, 128 GB, Optane 905p 3.27 GB/s Learned pin 47.6 GB 0.40
EPYC 7443, 430 GB RAM, NVMe RAID ~1 GB/s 77.5 GB pin, 98% hit 1.00
Mac Mini M4 Pro, 48 GB unified, Metal 6.59 GB/s Metal on, 38 GB RAM 0.30

Key insight: RAM is the most important factor. More RAM → bigger expert cache → fewer disk reads → faster inference. A machine with 128+ GB RAM and a good NVMe can approach interactive speeds.


📚 Resources

← Retour à l'Accueil

colibrì : Exécutez un LLM de 744 Milliards de Paramètres sur Votre PC Portable avec Seulement 25 Go de RAM

colibrì : Exécutez un LLM de 744 Milliards de Paramètres sur Votre PC Portable avec Seulement 25 Go de RAM 🐦

Qu'est-ce que c'est ? colibrì est un moteur d'inférence en C pur, sans dépendance, qui exécute GLM-5.2 — un modèle Mixture-of-Experts (MoE) de 744 milliards de paramètres — sur une machine grand public avec seulement ~25 Go de RAM et sans GPU. Il streame les experts du modèle depuis le disque à la demande, en ne gardant que les couches denses en mémoire.

Pourquoi ça cartonne : colibrì a atteint 7 300+ étoiles GitHub en moins de deux semaines car il change fondamentalement ce que signifie « IA auto-hébergée ». Jusqu'à présent, exécuter un modèle frontal de 744B nécessitait plusieurs GPU de数据中心 (H100 à 30 000 $+ pièce). colibrì le fait sur un PC portable avec un disque NVMe — sans GPU, sans API cloud, sans runtime Python. Le compromis est la vitesse (0,05–2 tok/s selon le matériel), mais pour la recherche hors ligne, l'analyse par lots et les charges de travail sensibles à la vie privée, c'est une percée.


📋 Prérequis

Avant de commencer, assurez-vous d'avoir :

  • Une machine Linux (ou WSL2 sur Windows, ou macOS, ou Windows 11 natif avec MinGW-w64)
  • ~370 Go d'espace NVMe/SSD libre pour les poids du modèle int4
  • ~25 Go de RAM (16 Go minimum, 32+ Go recommandés pour la mise en cache)
  • gcc avec OpenMP et AVX2 (tout processeur x86-64 ou ARM moderne)
  • Python 3.10+ (uniquement pour la conversion unique du modèle, pas à l'exécution)
  • De la patience — colibrì est limité par le disque ; un démarrage à froid tourne à ~0,05–0,1 tok/s sur du matériel modeste

🧠 Architecture

Architecture colibrì

colibrì exploite une propriété clé des modèles Mixture-of-Experts : un MoE de 744B n'active que ~40B paramètres par token. Les parties denses (attention, experts partagés, embeddings — ~17B paramètres) restent en RAM en int4 (~9,9 Go). Les 21 504 experts routés (~370 Go au total en int4) vivent sur le disque et sont streamés à la demande avec un cache LRU, un hot-store optionnel, et le cache de pages OS comme L2 gratuite.

Le moteur est un seul fichier C (c/glm.c, ~2 400 lignes) avec de petits en-têtes. Pas de BLAS, pas de Python à l'exécution, pas de GPU requis. Composants clés :

  • Attention MLA — Attention Latente Multi-tête avec KV-cache compressé (576 flottants/token vs 32 768 — 57× plus petit)
  • Routeur Sigmoïde — Routage style DeepSeek-V3 sans perte auxiliaire
  • Décodage Spéculatif MTP Natif — La tête multi-token-prediction de GLM-5.2 ébauche des tokens à 2,2–2,8 tokens/forward (tête int8 requise)
  • Ébauches Forcées par Grammaire — Sur les sorties contraintes (JSON, appels de fonction), la grammaire elle-même génère des tokens pré-acceptés
  • Cache d'Apprentissage — Enregistre les experts utilisés et épingle automatiquement les plus chauds dans la RAM libre
  • Persistance KV-Cache — Les conversations persistent entre les redémarrages sans re-prefill

🔧 Installation

Étape 1 : Cloner et Compiler

git clone https://github.com/JustVugg/colibri.git
cd colibri/c
./setup.sh

Le script vérifie gcc, OpenMP et AVX2, puis compile le moteur et exécute un auto-test. Vous devriez voir "32/32 positions" confirmant que l'architecture est correcte.

Étape 2 : Télécharger le Modèle Pré-converti

La méthode la plus simple est de télécharger un modèle int4 pré-converti avec des têtes MTP int8 (critique pour le décodage spéculatif) :

# Installer git-lfs d'abord
git lfs install

# Télécharger le modèle (~370 Go)
git clone https://huggingface.co/mateogrgic/GLM-5.2-colibri-int4-with-int8-mtp /chemin/vers/glm52_i4

⚠️ Critique : La tête MTP doit être en int8. La tête MTP int4 donne 0% d'acceptation des ébauches, ce qui signifie que la spéculation ne s'active jamais. Vérifiez avec ls -l /chemin/vers/glm52_i4/out-mtp-* — les fichiers int8 corrects font ~3,5 Go, ~5,3 Go et ~1,0 Go.

Étape 3 : Mesurer les Performances du Disque

Avant d'exécuter le modèle, testez votre NVMe pour définir les attentes :

cd c
gcc -O2 -fopenmp iobench.c -o iobench
./iobench /chemin/vers/glm52_i4/out-00069.safetensors 19 64 8 1   # mode O_DIRECT

Ce test mesure les lectures aléatoires de 19 Mo que colibrì utilise pendant l'inférence. Un NVMe PCIe 4.0 atteint généralement 3-5 Go/s ; PCIe 5.0 atteint 8-12 Go/s.

Étape 4 : Discuter !

COLI_MODEL=/chemin/vers/glm52_i4 ./coli chat

Au premier lancement, le moteur alloue son cache (~20 Go RSS max), charge les couches denses en RAM (~30 secondes), et vous êtes prêt à discuter.


🚀 Configuration Avancée

Réglage des Performances

colibrì dispose de plusieurs paramètres pour optimiser la vitesse :

Réglage Description Recommandé
--topp 0.7 Échantillonnage adaptatif top-p des experts (30–40% moins d'E/S disque) Commencez ici
--ram 48 Budget RAM explicite (par défaut : auto-détection) 48 Go+ si disponible
DRAFT=4 Profondeur d'ébauche spéculative MTP (nécessite tête int8) 4 (défaut)
GRAMMAR=fichier.gbnf Ébauches forcées par grammaire pour JSON/sortie structurée Utile en mode API
THINK=1 Active le bloc de raisonnement de GLM-5.2 Optionnel
PIN_GB=40 Épingle ~40 Go d'experts chauds en RAM Après une session
# Enregistrer d'abord l'utilisation des experts
STATS=stats.txt ./coli chat --temp 0.7 --topp 0.7

# Puis épingler les experts chauds appris
PIN=stats.txt PIN_GB=40 COLI_MODEL=/chemin/vers/glm52_i4 ./coli chat --temp 0.7 --topp 0.7

API Compatible OpenAI

colibrì expose une API standard :

COLI_MODEL=/chemin/vers/glm52_i4 COLI_API_KEY=*** ./coli serve \
  --host 127.0.0.1 --port 8000 --model-id glm-5.2-colibri

# Tester
curl http://127.0.0.1:8000/v1/chat/completions \
  -H 'Authorization: Bearer *** \
  -H 'Content-Type: application/json' \
  -d '{"model": "glm-5.2-colibri", "messages": [{"role": "user", "content": "Bonjour !"}], "stream": true}'

Accélération GPU (Optionnel)

Si vous avez un GPU NVIDIA avec 8+ Go de VRAM, colibrì peut l'utiliser comme accélérateur d'experts :

make CUDA=1                           # Compiler avec support CUDA
COLI_CUDA=1 COLI_GPU=0 ./coli chat    # Activer le tier expert GPU

✅ Vérification

Après l'installation, vérifiez que tout fonctionne :

  • Auto-test réussi : ./setup.sh affiche "32/32 positions"
  • Tête MTP en int8 : ls -l /chemin/glm52_i4/out-mtp-* montre les bonnes tailles
  • Modèle chargé sans erreur : COLI_MODEL=/chemin/ ./coli chat affiche "ready in ~30s · resident ~9.9 GB"
  • Le modèle répond de façon cohérente : testez avec une invite simple
  • L'API fonctionne (si mode serve) : curl retourne du JSON valide
  • Le cache d'experts s'ajuste automatiquement à votre RAM disponible

📊 Performances Attendues

La vitesse de colibrì dépend entièrement de votre matériel :

Matériel Vitesse Disque Configuration Tokens/s
12 cœurs WSL2, 25 Go RAM, NVMe VHDX ~1 Go/s Défaut 0,05–0,1
Apple M5 Max, 128 Go unifiée ~4 Go/s Défaut, MTP désactivé 1,06
Apple M5 Max + Metal, 128 Go Metal, 46,9 Go épinglés 2,06
Ryzen 9 9950X + PCIe 5.0, 123 Go 8,81 Go/s Pin appris 0,28
Ryzen AI Max+ 395, 128 Go, Optane 3,27 Go/s Pin 47,6 Go appris 0,40
EPYC 7443, 430 Go RAM, RAID NVMe ~1 Go/s Pin 77,5 Go, hit 98% 1,00
Mac Mini M4 Pro, 48 Go, Metal 6,59 Go/s Metal, 38 Go RAM 0,30

Point clé : La RAM est le facteur le plus important. Plus de RAM → plus gros cache d'experts → moins de lectures disque → inférence plus rapide.


📚 Ressources