66 points · by latchkey · 2y ago · 100 comments
Like, the post is about how you can do GEMM tuning on AMD GPUs, a subject which is inherently super interesting–there's a lot of nuance to writing optimal kernels, and some of this is expressed in the article, too. Combine that with an architecture that isn't Nvidia? It's an excellent setup for something that would be interesting to read.
Which makes the actual conclusion all the more disappointing, IMO. There's nothing about what the actual optimizations are. It's just "oh yeah we tuned our GEMMs and now LLaMA is faster". Like, I get that nobody actually cares about GEMM and they just want tokens to come out of their GPU. But still, that's like writing a blog post about how you can speed up your game with SIMD and then posting some charts of how Cyberpunk 2077 gives you 2x the frame rate now. Ok, but how? I just feel like the interesting part is missing.
https://rocm.docs.amd.com/projects/rocBLAS/en/develop/how-to...
https://chipsandcheese.com/2024/06/25/testing-amds-giant-mi3...
Elio, the person who did the testing, worked together with C&C, on my system. He then took it to the next level with this gemm work.
The docker container is linked on the article now so that anyone can reproduce the results.
AMDs mastery of chiplet designs is in stark contrast to Nvidias reliance on extremely large and complex dies and pretty lack luster forays into multi-die in the past.
If Nvidia doesn't come up with ways to combat the inherent cost and yield advantages of chiplets they could get quite easily blown away on $/perf.
GPGPU didn't have enough money behind it to justify fully exploiting all hardware vs just going with whatever was easiest (Nvidia+CUDA) and eating the cost but that has changed substantially.
If you can buy AMD at a 10%+ $/perf advantage when you are talking about laying down $100M+ for accelerators on even a moderate sized cluster you can be damn sure the software will get tuned to take advantage of it.
It's the same TSMC tech that both Nvidia and AMD use, it's not something proprietary exclusive to one or another since they're both fables.
On the contrary, AMD has to be afraid since they have no answer to Nvidia's 800GB/s data center interconnects they got from their aquisition of Mellanox, which enables Nvidia to scale.
https://www.xilinx.com/products/technology/high-speed-serial...
Don't think that Infiniband is somehow an Nvidia moat, if anything because they ate up the last somewhat independent vendor (Mellanox) it's likely it will be replaced by some variant of what is now being called Ultra Ethernet which for the most part incorporates ideas from Infiniband into the Ethernet PHY layer along with bolting into libfabric at the userland level. The people with the brains behind it include the Omni-Path folk (which is descendent from QLogic and SilverStorm before that) which have extensive experience in Infiniband and are now free from the shackles of Intel.
However this has absolutely nothing to do with chiplet designs or multi-die architectures (which Nvidia has done before with their dual GPU stuff from the GTX 900 series days etc).
The fact of the matter is that Nvidia has no experience whatsoever with chiplets or advanced packaging. AMD has on the other hand absolutely tons from yes, chiplets but also HBM, 3d-vcache etc all of which are ultimately advanced packaging techniques that all build on shared background of expertise.
Nvidia needs to rapidly catch up in this area or their future is a lot less certain.
This is putting aside what is happening with Tenstorrent/Etched/Groq, etc which threaten to eat up the vast majority of the non-training workloads associated with the current crop of AI/LLM architectures.
> mostly built upon Python libraries that are platform agnostic, or at least can be. With enough support for AMD in Pytorch etc
You can't imagine how much and how long the work in "can be" is. Thus NVIDIA has two of the deepest moats you can have: time and money (you would probably have to outspend them by 10x for 10 years to catch up).
Source: go look at how the AMD backend is implemented in pytorch vs how the AMD backend is implemented.
Edit: people must really not understand that this code (ie building this stuff) is highly non-trivial. It's not like building a competing js frontend framework. You not only need good engineers you need lots of them because the surface area is very big - hardware platforms, especially AMD's aren't at all "abstract", so really to do it right you need a team per box in the product matrix.
NVidia has a massive headstart, but there are diminishing returns to their software work. If AMD performance per dollar is 10% better at the hardware level, and their software performance is 90% of that of nvidia they are ahead.
> I don't see it. Large customers are choosing AMD over nVidia.
Please show me term sheets of contracts signed with "large customers". Please include net, gross, and recurring revenue.
> diminishing returns to their software work
Makes zero sense: software penetration follows power laws (network effects etc) not exponential decay laws.
> If AMD performance per dollar is 10% better at the hardware level, and their software performance is 90% of that of nvidia they are ahead.
Again: you cannot fathom how enormous that "if" there is so I highly recommend you actually go look at the impl to get a sense.
To this day I prefer to work on my Fuel than any other machine. But it's still dead.
Again, I’m no expert on CPUs but I think you could have argued something similar about AMD vs Intel 12 years ago. Now it’s clear AMD’s tech is superior.
Haven't seen that land meaningfully so far, but it is an interesting risk to Nvidia.
CPU was easy, GPU was hard. The major difference I could spot though was all the time I was spending batting data around between different buffers, the APIs weren't really limiting me.
Nvidia has multiple advantages.
1. Same software written in PyTorch works across all relatively modern Nvidia chips. With AMD and ROCm that's not the case.
2. M̶I̶3̶0̶0̶x̶ h̶a̶s̶ n̶o̶ F̶P̶8̶ s̶u̶p̶p̶o̶r̶t̶.
3. Comparisons against H100 are always like this:
8x AMD MI300X (192GB, 750W) GPU
8x H100 SXM5 (80GB, 700W) GPU
The fair comparison would be against 8x H100 NVL (188GB, <800W) GPU
And that they never do.4. H100 is 21 month old architecture. MI300X is 7 months. Nvidia moved into new architecture every year pace. AMD is generation behind and must step up the pace. B100 comes out this year.
AMD is getting closer, but don't except them to catch Nvidia in not time.
Also, many of these comparisons use vLLM for both setups, but for Nvidia you can and should use TensorRT-LLM which tends to do quite a bit better than vLLM at high loads.
Less than that, we paid for ours in January and received it in March. The first batch had problems and we had to send them back, which took another 3 weeks. So, let's consider the start date closer to April.
~3 months.
vLLM is not quite as performant but it's pretty close in production environments.
“We are tight on supply, so there’s no questions in the near term that if we had more supply, we have demand for that product, and we're going to continue to work on those elements as we go through the year,” Su said, adding that she’s “very pleased with how the ramp is going.”
Nvidia has shipped almost 4 million DC GPUs in 2023 to give your an idea about the sizes for it to count on the balance sheet.
Geohot's streams show you why that's a bad idea in real time.
Going by the video, the first thing that gave me pause was that a single MI300X is pulling off groq like performance, i.e. 314 tokens/second for a batch size = 1 (bs=1) with a prompt of 256 tokens and generation of 256 tokens. [1]
The Llama-2 70B is 128.48GB with FP16 (you can see this in the video). The entire model fits well within the 192GB HBM memory of the MI300X - which is awesome! However, for an regressive transformer model, during generation, the entire model weights are processed to generate a single next token. These models are "next token predictors" so to say, and you need the previous token to generate the next token. Therefore, the 128.48GB of model weights need are consumed from the HBM at the compute cores of the MI300X, per generated token. Note, I am not talking about the prefill - which only needs a single forward pass to generate the first output token. Every subsequent output token is auto-regressive.
The video shows that a single prompt (bs=1) with 256 token prompt and 256 tokens generated within 1.63 second. There is no tensor parallelism involved, or batching or anything else. This is a bs=1 case with a single card, and hence you can reason about the math fairly easy.
This shouldn't fundamentally be possible within the specs of the MI300X card. The card has a peak HBM memory bandwidth of 5.3 TB/s. You'll notice that to cycle through the weights (assuming FP16) 256 times, you'd need a minimum of 6 seconds, even at perfect ideal conditions. Napkin math: (256 * 128.48e9) / (5.3e12)
[1] https://wow.groq.com/groq-sets-new-large-language-model-perf...
256 tokens in 1 prompt/batch
Not 256 batches
The first step in understanding this is to notice that the model (llama2) generates 1 output token at a time. This is because the llama2 70B is a autoregressive decoder-only transformer.
Fundamentally, to generate a single output token you need to process the entire model weights. At each forward pass you generate 1 token.
OK, now to generate 256 output tokens - you need 256 sequential forward passes. At each forward pass, the entire model is read from the gpu VRAM.
Even at ideal memory bandwidth (5.3 TB/s) that (256 forward passes of a 128.48GB model) should take 6s.
The reported number of 1.63s should not be possible.
I'd strongly recommend checking for correctness - that the generate output is coherent. Try sending actual prompts to the "gemm tuned" model and observing the generated responses and latencies. With the "benchmark_throughput.py" you only get a final number and there is no check whether the output is valid or not.
From their benchmark table, they achieve 1.8s response time at bs=4 for 256 output tokens, which would be 569 t/s throughput.
At bs=1 you are memory bandwidth bound. So as a simple ceiling we divide the memory bandwidth by the model size (70b is roughly 140gb at fp16). That would yield roughly 24 t/s for H100 and 39 t/s for MI300x.
I'm not really sure how GEMM optimizations alone would yield these sort of improvements at fp16. With quantization, where dequant overheads start to become compute bound, or at very high batch sizes, it makes sense and there has been a lot of work with various kernels in this area. But I'm a bit confused at fp16 and bs=1.
Maybe someone smarter can chime in?
EDIT: Ok I watched their video, which shows 39.75 t/s in the unoptimized (which checks out given the above rough maths) and 313.95 t/s for the optimized. I'm not really sure what's going on here.
There is a video about the bs=1 case, i.e. a single prompt with input 256 tokens and output 256 tokens with a Llama-2 70B model, on a single MI300X (no tensor parallelism). The optimized result is giving 314 t/s and completes the entire request in 1.63s.
Now, the Llama-2 70B is a an autoregressive decoded-only model. So, that means the entire model weights are processed for every generated token.
The model weights are 128.48 GB (also shown in the video, and can be confirmed from HuggingFace). The card has 192GB of HBM, and the model entirely fits on the card. The HBM memory bandwidth for this card is 5.3 TB/s.
Even assuming the prompt 256 tokens took no time, to generate 256 tokens, we'd need roughly 6s even at ideal memory bandwidth. (256 * 128.48e9) / (5.3e12).
What's going on here?
This sheet only lists the response latency, but it does look more recent than the one you listed.
In any event, the sheet you link to shows generation speed and throughput (generation speed is cell E18 which shows 527 t/s). G18 is perhaps prefill + gen but even that doesn't add up.
Take that article and increase it by the gemm gains.
At the end of the day, MI300x is outperforming an H100.
More importantly is that you need 2xH100 to do 70B and only 1xMI300x.
llama3-70b throughput:
Chips and Cheese: 4800 tok/sec (?!)
This article: 849 tok/sec (fastest optimized)
Mixtral 7B latency:
Chips and cheese: 1.17s
This article: 2.04s (fastest unoptimised) / 0.81 (fastest optimised)
And then finally comparing mixtral 8x7b to the Reddit article using batch size 1...
Reddit: 157 tok/sec
This article: 165 tok/sec (optimized) or 141 tok/sec (unoptimised)I still can't explain throughput differences though
The video shows that the optimized run with Llama-2 70B gives 314 tokens/s for a bs=1 with 256 prompt + 256 generation. The Groq system is also a bs=1 apparatus and gets you around 300 tokens/s. Wild!
[1] https://wow.groq.com/groq-sets-new-large-language-model-perf...
Groq does not talk about how many cards they need to get those results. Someone replied to me with this comment [1] a while ago...
[0] https://www.reddit.com/r/AMD_MI300/comments/1dqhrbn/comment/...
I'm not sure what's going on here but something is not right.
Smells like written by GPT
1. Repeating the same thing multiple times with slight variation:
* "allowing developers to fine-tune their applications and unlock the full potential of their underlying hardware, ultimately maximising vLLM performance." (fine-tune, unlock potential, maximize performance are all roughly the same thing)
* "AI and machine learning models" (AI and machine learning models are the same thing in the context of this article)
* "utilise multiple threads or cores" (Why differentiate between threads and cores?)
* "tailored to enhance computational efficiency and overall throughput" (efficiency and throughput are highly related)
* "a series of graphs and data visualisations" (all the data visualizations in this article are graphs)
* "more computational effort and time" (same thing)
* "significantly enhanced the performance and efficiency" (same thing)
* "ensuring efficient processing and superior performance for complex and demanding AI workloads" (same things)
2. Explaining what "rocBLAS" stands for multiple times.
3. Other ChatGPTisms:
* "offering a comprehensive view of [...]"
* "Let’s delve into the notable advancements achieved through [...]"
* "ensures quicker processing times, which is crucial for [...]"
* "effectively mitigated these impacts, maintaining [...]"
* "elucidate the impact of"
* "significantly enhanced"
* "These results underscore the critical role of [...]"
* "Key Aspects", "Key Observations", "Key findings"
So why is this bad? - Because it undermines the trust in the the article. We do not know whether the claims are actually true or whether they were just made up by ChatGPT.
That person (yeah :p), might just be trying to create as much awareness as possible.
You might get annoyed by the usage of LLM's, some might not. I get annoyed by people still trying to undermine the testing done while everything is clearly extremely transparant, even the docker image is shared..
That said, the article is about the results, if you'd like to "delve" a bit deeper into those results, let me know, i'd be happy to go over some of the data visualisations ;-)
Snark aside I do want to thank you and others for running these tests. I just wish I could make sense of the results, which seem too good to be true?
Are claudisms different from gptisms?
Why can't these authors tell ChatGPT to write with a different prose and avoid "delve", "crucial", etc?
Wizardlm writes these same things in all its answers too
Sorry, no idea. I rarely use Claude.
> Why can't these authors tell ChatGPT to write with a different prose and avoid "delve", "crucial", etc?
The authors could do this, but that would contradict the reason for using ChatGPT, which is to do less work.
> Wizardlm writes these same things in all its answers too
WizardLM has inherited that from its instruction tuning dataset, which has been generated with ChatGPT: https://openreview.net/pdf?id=CfXh93NDgH