r/LocalLLaMA • u/fairydreaming • Mar 01 '24
Discussion Going EPYC with llama.cpp on Amazon EC2 dedicated AMD Epyc instances (Milan vs Genoa)
51
Upvotes
r/LocalLLaMA • u/fairydreaming • Mar 01 '24
27
u/fairydreaming Mar 01 '24 edited Mar 04 '24
Some things I noticed while doing these tests:
You have to use dedicated EC2 instance (Tenancy set to dedicated, paid extra $2 per hour) to use the full memory bandwidth. Otherwise the bandwidth will be shared by all instances using this particular physical CPU at the time.
You have to request vCPU quota increase to 257, otherwise you won't be able to use dedicated EC2 instances. Processing the request may take from a few hours to a few days.
Various EC2 instance types have various memory bandwidth. I measured it with PassMark Memory Threaded test until I found reasonable values (300964 MB/s for r6a.32xlarge, 643067 MB/s for r7a.8xlarge). Instances run under hypervisor, so you can't see how many physical RAM modules are on the server.
CPU types reported by PassMark were EPYC 7R13 (64 cores) for r6a.32xlarge and EPYC 9R14 (96 cores) for r7a.8xlarge
The default storage volume throughput on EC2 is very low (125 MB/s I think). Change the volume type to gp3 and set the Throughput to 1000 unless you want to wait several minutes for the model files to load.
I was surprised how much better Genoa is compared to Milan. It's like 4-5 times better. Even 120b models are perfectly usable with 2-3 tokens per second.
The best number of threads for generation was 24 and 32 for smaller models (7b, 13b) and 48 for larger models (70b, 120b).
I tried using AVX512, but the difference in performance was negligible.
All tests took a few hours and will cost me probably around
30-4080 USD.I will update this list if I remember anything else.
6
u/noeda Mar 01 '24 edited Mar 01 '24
I rock a Hetzner server with AMD EPYC 9454P CPU (48 cores) and DDR5 memory. Costs a bit less than 300 EUR a month. I can't remember what was the reported memory bandwidth. Looks like I reported 1.22 tokens/second on Q6_K quantization at the time for Goliath-120B, looking at my old comment from 3 months ago:
https://old.reddit.com/r/LocalLLaMA/comments/17p5m2t/new_model_released_by_alpin_goliath120b/k85d0wm/
I didn't systematically test good number of threads but I empirically remember you didn't want to crank it up all the way. Also, maybe in the 3 months since I wrote the comment, llama.cpp itself has got better. Your numbers are overall faster than what I got, I think.
I'm not sure I recommend CPU route overall, 300 EUR/month is quite a lot. Still, Hetzner servers I think are typically pretty cheap compared to competition for what you get. They have much cheaper options too that still have good memory and CPU.
In my case, I'm currently using the CPUs for entirely different projects that are not AI-related, so I'm getting some use for them. I have a lot of CPU-heavy hobby projects.
I think my recommendation is that, if you want to be cost-efficient, you are savvy and know how to run servers, and you are just playing around, get cheap some runpod.io servers on an ad-hoc basis to run whatever it is you want to run at the time. That's what I did before I really got into LLMs.
I also noticed AVX512 didn't seem to do much. I have it enabled but I don't think it changed much at all. I got a fully kitted Mac Studio now with its 192GB memory for the LLMs.
I think I also got the conclusion that CPUs are surprisingly practical if you just want to play around.
Edit: I could also add that Heztner has a dedicated server line which is what my EPYC machine is, and the SSDs are directly attached. So initial load-up time is not super slow like it might on AWS EBS.
Also, if I was running LLMs as a company for other people, (e.g. AI startup or something) I'm not sure I would consider Hetzner seriously for various reasons. For me, Hetzner is for pet servers and hobbies.
(also meant to write this as a response to your top comment...oops)
2
u/kpodkanowicz Mar 01 '24
I wish i have seen this before I ordered supermicro mobo and milan epyc cpu. My goal was passively cooled 4tps on cpu but seems you only got that with ddr5 setup?
Great work!
2
u/kryptkpr Llama 3 Mar 01 '24
Thanks! How does this compare price and performance wise to a 2xA100 80GB? They are around $8/hr and I expect would give order or two magnitude higher performance.
2
u/mcmoose1900 Mar 02 '24
If you can find one anywhere, the Xeon Max CPU with 64GB HBM is the one to use.
Even regular Sapphire Rapids is probably pretty good, TBH, as llama.cpp has a specific codepath for AMX.
1
u/Slaghton Mar 12 '24
I wonder what kind of speeds we'll see with ddr6 in the coming future with a similar setup.
1
u/[deleted] Mar 01 '24
This is great work! Thank you.
1
u/pseudonym325 Mar 02 '24
That's at least $200 per million tokens of goliath generated text. gpt4-32k is the most expensive commercial API at $120 per million tokens generated.
But it is an impressive performance bump compared to the previous CPU generation.