Compare
Llama 2 7B vs Llama 3.1 8B
Llama 3.1 8B has 8.03B parameters, 1.2 times the 6.74B of Llama 2 7B. In BF16 the weights take 13.5 GB and 16.1 GB. Llama 2 7B needs 4.0 times as much KV cache per token (524.3 KB against 131.1 KB): MHA against GQA.
| Llama 2 7B | Llama 3.1 8B | Ratio | |
|---|---|---|---|
| Parameters | 6.74B 6,738,415,616 | 8.03B 8,030,261,248 | 1.19× |
| Active per token | all (dense) | all (dense) | 1.19× |
| Layers | 32 | 32 | same |
| Hidden size (d) | 4,096 | 4,096 | same |
| Attention | 32 heads, 32 KV heads × 128 | 32 heads, 8 KV heads × 128 | |
| FFN | SwiGLU, 11,008 | SwiGLU, 14,336 | |
| Vocabulary | 32,000 | 128,256 | 4.01× |
| Tied embeddings | no | no | |
| Max context | 4K | 128K | 32.00× |
| Weights, BF16 | 13.5 GB | 16.1 GB | 1.19× |
| Weights, 4-bit | 3.4 GB | 4.0 GB | 1.19× |
| KV cache per token (BF16) | 524.3 KB | 131.1 KB | 0.25× |
| KV cache at 32K tokens | – (max 4K) | 4.3 GB | 2.00× |
| FLOPs per token (4K context) | 15.6 GFLOPs | 18.2 GFLOPs | 1.17× |
The full workings: Llama 2 7B · Llama 3.1 8B · change the models