Répondre à « est-ce que ça rentre ? » en trois lignes de calcul. Toutes les valeurs marquées (mesuré) proviennent du lab le 2026-09-18. Answering "will it fit?" in three lines of arithmetic. Values marked (measured) come from the lab on 2026-09-18.
# POIDS / WEIGHTS taille_poids (Go) ≈ paramètres × bits_par_poids / 8 / 1e9 bits_par_poids réel = taille_octets × 8 / paramètres # audit # CACHE KV / KV CACHE (GQA-aware) cache_KV (octets) = 2 × n_couches × n_têtes_KV × dim_tête × contexte × octets_par_élément dim_tête = dim_embedding / n_têtes # 128 courant, 256 sur certains modèles octets_par_élément : 2 en FP16 · 1 en q8_0 · 0,5 en q4_0 # TOTAL mémoire ≈ poids + cache_KV + surcoût_runtime (≈ 8 % des poids)
Q4_K_M vaut 4,83 bits/poids sur mistral:7b, 4,90 sur llama3.1:8b et 5,20 sur qwen3.8:27b (mesuré). Auditez la taille réelle du fichier.Computing with "4 bits": Q4_K_M is 4.83 bits/weight on mistral:7b, 4.90 on llama3.1:8b and 5.20 on qwen3.8:27b (measured). Audit the real file size.| ModèleModel | CouchesLayers | Têtes / KVHeads / KV | dim tête |
cache/tokencache/token | 8 k | 32 k | 128 k | total @8ktotal @8k |
|---|---|---|---|---|---|---|---|---|
llama3.1:8b4,92 Go · Q4_K_M |
32 | 32 / 8 | 128 | 128 Kio | 1,07 Go | 4,29 Go | 17,18 Go | 6,39 Go |
qwen3.8:27b17,74 Go · Q4_K_M |
65 | 24 / 4 | 256 | 260 Kio | 2,18 Go | 8,72 Go | 34,90 Go | 21,34 Go |
qwen3.8:27b annonce 262 144 tokens : à 128 k il faudrait 17,74 + 34,90 = 54,06 Go, contre 24 Go de VRAM sur le lab. llama3.1:8b annonce 131 k : 4,92 + 17,18 = 22,49 Go, soit exactement la capacité des deux cartes — sans marge. Réduisez la fenêtre au besoin réel, ou quantifiez le cache KV.
Advertised window ≠ usable window. qwen3.8:27b advertises 262,144 tokens: at 128 k you would need 17.74 + 34.90 = 54.06 GB, against 24 GB of VRAM on the lab. llama3.1:8b advertises 131 k: 4.92 + 17.18 = 22.49 GB, exactly the two cards' capacity — with no headroom. Cut the window to what you need, or quantize the KV cache.
| TypeType | bits/ poidsweight |
Taille d'un 8 BSize of an 8 B | Quand l'utiliserWhen to use |
|---|---|---|---|
| FP16 / BF16 | 16 | ~16 Go | Référence qualité ; base d'un fine-tuning (séance 7).Quality reference; base for fine-tuning (session 7). |
Q8_0 | ~8,5 | ~8,5 Go | Quasi sans perte, quand la qualité prime et que la mémoire suit.Near-lossless, when quality dominates and memory allows. |
Q6_K | ~6,6 | ~6,6 Go | Bon compromis si vous avez la marge.Good compromise if you have headroom. |
Q5_K_M | ~5,7 | ~5,7 Go | Légèrement meilleur que Q4_K_M, un peu plus lent.Slightly better than Q4_K_M, a bit slower. |
Q4_K_M | 4,8–5,2 | ~4,9 Go | Le défaut raisonnable. Meilleur rapport qualité / taille / débit.The sensible default. Best quality / size / throughput ratio. |
Q3_K_M | ~3,9 | ~3,9 Go | Dernier recours avant de changer de modèle.Last resort before changing model. |
Q2_K | ~2,8 | ~2,8 Go | Dégradation visible : code, multilingue, raisonnement.Visible degradation: code, multilingual, reasoning. |
IQ* | variablevaries | variablevaries | Meilleure qualité à très basse précision (codebook), mais plus lent à produire et parfois à exécuter.Better quality at very low precision (codebook), but slower to produce and sometimes to run. |
llama-quantize compilé sur le lab, 2026-09-18). Sortie brute pour un modèle de 1,5 B :
Verified with the real quantization tool (llama-quantize compiled on the lab, 2026-09-18). Raw output for a 1.5 B model:
model size = 2944.68 MiB (16.00 BPW) <- f16 quant size = 934.69 MiB ( 5.08 BPW) <- Q4_K_M quantize time = 33.2 s
Q4_K_M vaut 4,83 (mistral:7b), 4,90 (llama3.1:8b), 5,08 (Qwen2.5-1.5B) et 5,20 (qwen3.8:27b). La valeur exacte dépend de la proportion de tenseurs que la variante _K_M garde en précision plus élevée — elle varie donc avec l'architecture. Auditez, ne supposez pas.
5.08 bits/weight, not 4. This is the course's third independent measurement confirming the rule: Q4_K_M is 4.83 (mistral:7b), 4.90 (llama3.1:8b), 5.08 (Qwen2.5-1.5B) and 5.20 (qwen3.8:27b). The exact value depends on the proportion of tensors the _K_M variant keeps at higher precision — so it varies with architecture. Audit, do not assume.
Q 4 _ K _ M │ │ │ └── M = mélange "medium" : certains tenseurs sensibles │ │ │ restent en précision plus élevée (S / M / L) │ │ └────── K = k-quant, quantification par blocs à échelles apprises │ └────────── 4 = ~4 bits par poids (2,3,4,5,6,8) └──────────── Q = "quantized" ; IQ = i-quant (codebook)
| MatérielHardware | Ce qui rentreWhat fits | Débit attendu (mesuré)Expected throughput (measured) |
|---|---|---|
| CPU 8 cœurs, 23 Go RAMCPU 8 cores, 23 GB RAM | 7–8 B en Q4 confortablement ; 27 B en Q4 possible mais lent7–8 B at Q4 comfortably; 27 B at Q4 possible but slow | 4,07–4,15 tok/s (7–8 B Q4)(7–8 B Q4) |
| 1× RTX 3060 (12 Go)1× RTX 3060 (12 GB) | 8 B Q4 (6,4 Go) avec marge ; 8 B @32 k passe tout juste8 B Q4 (6.4 GB) with headroom; 8 B @32 k just fits | 63,9 tok/s |
| 2× RTX 3060 (24 Go)2× RTX 3060 (24 GB) | 27 B Q4 @8 k (21,3 Go) ; 8 B jusqu'à ~128 k27 B Q4 @8 k (21.3 GB); 8 B up to ~128 k | dépend du modèlemodel-dependent |
| Colab T4 / Kaggle P100 (16 Go)Colab T4 / Kaggle P100 (16 GB) | 8 B Q4 avec plus de contexte ; QLoRA sur 7–8 B confortable8 B Q4 with more context; QLoRA on 7–8 B comfortable | à mesurerto be measured |
q8_0 (÷2) puis q4_0 (÷4) · (3) prendre une quantification de poids plus agressive · (4) changer de modèle. Ne sacrifiez la fenêtre qu'en dernier : elle coûte le moins cher en qualité.
Order of sacrifices when memory runs short: (1) cut the context window · (2) quantize the KV cache to q8_0 (÷2) then q4_0 (÷4) · (3) take a more aggressive weight quantization · (4) change model. Only sacrifice the window as a last resort: it costs the least in quality.