Llama on Apple M4

Can I run Llama 3.1 8B on an Mac Studio M4 Max 128GB?

Yes. Llama 3.1 8B at Q4_K_M uses 6.1 GB of the 96.0 GB available on a Mac Studio M4 Max 128GB, and runs at about 67.8 tokens per second. You can push the context to 128K.

Runs comfortably

6.1 GB of 96.0 GB · 6%
096 GB
Weights 4.6 GB
KV cache 1.0 GB
Runtime overhead 0.5 GB

Llama 3.1 8B at Q4_K_M leaves 89.9 GB spare on a Mac Studio M4 Max 128GB. There is room to raise the context length or move up a quantisation level.

Generation67.8tok/s
Prompt processing889tok/s
Max context128Ktokens
KV per 1K tokens0GB

Every quantisation of Llama 3.1 8B on a Mac Studio M4 Max 128GB

Highlighted row is the highest quality that still fits at 8K context.

QuantisationbpwWeights TotalVerdictMax ctxtok/s
FP16 / BF16 16.00 15.0 GB 16.5 GB Runs comfortably 128K 22.6
INT8 / W8A8 8.50 7.7 GB 9.2 GB Runs comfortably 128K 42.5
Q8_0 (GGUF) 8.50 7.7 GB 9.2 GB Runs comfortably 128K 42.5
FP8 (E4M3) 8.00 7.5 GB 9.0 GB Runs comfortably 128K 43.7
Q6_K 6.56 6.1 GB 7.7 GB Runs comfortably 128K 52.4
AWQ 4-bit 4.25 5.4 GB 6.9 GB Runs comfortably 128K 58.8
GPTQ 4-bit 4.25 5.4 GB 6.9 GB Runs comfortably 128K 58.8
MXFP4 4.25 5.4 GB 6.9 GB Runs comfortably 128K 58.8
Q5_K_M 5.67 5.3 GB 6.8 GB Runs comfortably 128K 59.9
Q5_K_S 5.52 5.2 GB 6.7 GB Runs comfortably 128K 61.3
Q4_K_M 4.85 4.6 GB 6.1 GB Runs comfortably 128K 67.8
Q4_K_S 4.58 4.4 GB 5.9 GB Runs comfortably 128K 70.8
Q4_0 4.55 4.4 GB 5.9 GB Runs comfortably 128K 71.2
IQ4_XS 4.25 4.1 GB 5.6 GB Runs comfortably 128K 74.9
Q3_K_M 3.91 3.8 GB 5.4 GB Runs comfortably 128K 79.5
IQ3_M 3.70 3.7 GB 5.2 GB Runs comfortably 128K 82.7
IQ3_XXS 3.06 3.2 GB 4.7 GB Runs comfortably 128K 94.3
Q2_K 2.63 2.8 GB 4.3 GB Runs comfortably 128K 104
IQ2_XXS 2.06 2.3 GB 3.9 GB Runs comfortably 128K 121
IQ1_M 1.75 2.1 GB 3.6 GB Runs comfortably 128K 132

Also worth checking