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 7BLlama 3.1 8BRatio
Parameters6.74B 6,738,415,6168.03B 8,030,261,2481.19×
Active per tokenall (dense)all (dense)1.19×
Layers3232same
Hidden size (d)4,0964,096same
Attention32 heads, 32 KV heads × 12832 heads, 8 KV heads × 128
FFNSwiGLU, 11,008SwiGLU, 14,336
Vocabulary32,000128,2564.01×
Tied embeddingsnono
Max context4K128K32.00×
Weights, BF1613.5 GB16.1 GB1.19×
Weights, 4-bit3.4 GB4.0 GB1.19×
KV cache per token (BF16)524.3 KB131.1 KB0.25×
KV cache at 32K tokens– (max 4K)4.3 GB2.00×
FLOPs per token (4K context)15.6 GFLOPs18.2 GFLOPs1.17×

The full workings: Llama 2 7B · Llama 3.1 8B · change the models