News for hackers. Stuff that matters.

anthonix1

Re:AMD Inference on Wednesday October 02, 2024 @09:54PM (#41726585)
... which also has a much lower power cap
Re:We fine-tuned Llama 405B on AMD GPUs on Monday September 23, 2024 @10:37PM (#41632620)
I just asked an instance of Hermes 3 Llama 3.1 405B running on AMD GPUs: "does pytorch scaled dot product attention run on AMD GPUs?":

"Yes, PyTorch's scaled dot product attention can run on AMD GPUs. PyTorch supports AMD GPUs through the ROCm (Radeon Open Compute) platform. To use PyTorch with an AMD GPU, you need to install the ROCm version of PyTorch, which is specifically built for AMD GPUs [...]"

And it proceeded to give the steps to follow to install and run, with example Python code to demonstrate it. One slight nitpick is that it referred to an older URL with the --index-url to install torch with pip, but otherwise it was correct.

Re:We fine-tuned Llama 405B on AMD GPUs on Monday September 23, 2024 @08:52PM (#41632072)
Yeah I would suggest taking a look at PyTorch on AMD before saying stuff like "scaled_dot_product_attention is an NVIDIA CUDA kernel exposed as a PyTorch function", because that is demonstrably false.

Also, FWIW, I would suggest getting a small Llama 3.1 model training fast before trying to do a big 405B model -- faster to iterate and almost everything you'll learn on the small models will scale to the 405B.

Re:We fine-tuned Llama 405B on AMD GPUs on Monday September 23, 2024 @08:24PM (#41631926)
Any direct comparisons to 8xH100? 2 toks/sec seems very slow!

I haven't done any LoRA training on MI300x myself, but I have done LLama 3.1 full training on 8xMI300x and got pretty close to 8xH100 performance with my own kernels (ROCm is just too slow).

Re:We fine-tuned Llama 405B on AMD GPUs on Monday September 23, 2024 @08:04PM (#41631816)
Does JAX have its own implementations of matmul, flash attention etc? Or does it use the ROCm implementations like PyTorch does? (e.g,. hipblaslt, Composable Kernel FA etc)

Not too familiar with JAX, but the abysmal PyTorch training perf on MI300x is in large part attributable to the slow perf of the ROCm libraries it is using under the hood.

Re:The Pentium as a Navajo Weaving on Sunday September 01, 2024 @10:46PM (#41422224)
Do they support curvilinear cells?
Re:The Pentium as a Navajo Weaving on Sunday September 01, 2024 @10:28PM (#41422141)
AHh gotcha.

Well yeah I reckon you render a full custom 4004 w/ koru patterned transistors into about 4m x 4m stained glass panel. Would look good as the foyer panel for the CS dept at the University of Waikato

Re:The Pentium as a Navajo Weaving on Sunday September 01, 2024 @09:51PM (#41421927)
Don't bother with the rectilinear pakeha layouts, do your half adders in curvilinear patterns, Koru style
Re:Run CUDA, unmodified, on AMD GPUs on Monday July 15, 2024 @08:53PM (#40972802)
OK, so in the case of llm.c, if you're just including the HIP headers, using hipblasLt, etc, what would be the benefit of using scale instead of hipify?
Re:Run CUDA, unmodified, on AMD GPUs on Monday July 15, 2024 @07:10PM (#40972289)
I ported Karparthy's llm.c repo to AMD devices [1], and have trained GPT2 from scratch with 10B tokens of fineweb-edu on a 4x 7900XTX machine in just a few hours (about $2 worth of electricity) [2].

I've also trained the larger GPT2-XL model from scratch on bigger CDNA machines.

Works fine.

[1] https://github.com/anthonix/llm.c [2] https://x.com/zealandic1

Re:Run CUDA, unmodified, on AMD GPUs on Monday July 15, 2024 @06:57PM (#40972201)
Hi, why do you believe that bfloat16 is not supported? Can you please provide some references (specifically the part about the hardware "doesn't do it")?

For the hardware you are focussing on (gfx11), the reference manual [2] and the list of LLVM gfx11 instructions supported [1] describe the bfloat16 vdot & WMMA operations, and these are in fact implemented and working in various software such as composable kernels and rocBLAS, which I have used (and can guarantee they are not simply being run as float). I've also used these in the AMD fork of llm.c [3]

Outside of gfx11, I have also used bfloat16 in CDNA2 & 3 devices, and they are working and being supported.

Regarding cublasLt, what is your plan for support there? Pass everything through to hipblasLt (hipify style) or something else?

Cheers, -A

[1] https://llvm.org/docs/AMDGPU/AMDGPUAsmGFX11.html [2] https://www.amd.com/content/dam/amd/en/documents/radeon-tech... [3] http://github.com/anthonix/llm.c

Re:Run CUDA, unmodified, on AMD GPUs on Monday July 15, 2024 @05:34PM (#40971655)
I just tried it with llm.c ... seems to be missing quite a few key components such as cublaslt, bfloat16 support, nvtx3, compiler flags such as -t

And its linked against an old release of ROCm.

So unclear to me how it is supposed to be an improvement over something like hipify

Re:Testing AMD's Giant MI300X on Tuesday June 25, 2024 @03:31PM (#40792618)
I have not been impressed by the perf. Slower than PyTorch for LLMs, and PyTorch is actually stable on AMD (I've trained 7B/13B models).. so the stability issues seem to be more of a tinygrad problem and less of an AMD problem, despite George's ramblings [0][1]

[0] https://github.com/tinygrad/tinygrad/issues/4301 [1] https://x.com/realAnthonix/status/1800993761696284676

Final loss from that fineweb-10B run (since then I'm up to ~100k toks/sec/GPU):

step 18865/18865 | train loss 3.280550 | norm 0.4362 | lr 0.00e+00 | 1669.06 ms | 55.4% A100 fp16 MFU | 314058 tok/s Writing state to log124M/state_00018865_00003.bin val loss 3.296179

You can buy these GPUs on Amazon for under $1k. I heard the MI300X may be available in Azure now or at least very soon.

Re:Reproduce GPT-2 (124M) in llm.c in 90 minutes for $20 on Wednesday May 29, 2024 @07:07PM (#40518173)
55.4% in the last run, at running temperature
Re:Reproduce GPT-2 (124M) in llm.c in 90 minutes for $20 on Wednesday May 29, 2024 @11:55AM (#40513314)
Yeah, I just reproduced the GPT2 from scratch results in 8.75 hours on 4x 7900 XTX. The fork is here: https://github.com/anthonix/llm.c
Re:Tinygrad 0.9.0 on Wednesday May 29, 2024 @11:26AM (#40512994)
Ran tinygrad again about a week ago, no change.

And still no comment on the issue, will re-run if there is any comment.

Re:Tinygrad 0.9.0 on Wednesday May 29, 2024 @11:18AM (#40512880)
I think the matmul issue is symptomatic of a much deeper issue.

It would be nice to see less whining and blaming AMD (PyTorch and llm.c actually work on 7900 XTX, and blow tiny grad out of the water in terms of perf!), and more just getting stuff to work.

Re:Reproduce GPT-2 (124M) in llm.c in 90 minutes for $20 on Wednesday May 29, 2024 @10:22AM (#40512312)
Maybe get a 7900 XTX. 122 TFLOPS of BF16/FP16 for less than $1k and I'm getting 55.4% MFU
Re:Reproduce GPT-2 (124M) in llm.c in 90 minutes for $20 on Wednesday May 29, 2024 @10:12AM (#40512217)
Nah, I reproduced on 4x 7900 XTX machine in 8.75 hours, so a single 7900 XTX (costs less than $1k) could do it in under 24 hours. Was hitting 55.4% MFU.
Re:Reproduce GPT-2 (124M) in llm.c in 90 minutes for $20 on Wednesday May 29, 2024 @10:10AM (#40512201)
So... successfully reproduced in ~8.75 hours, taking about 18 kWh / $2.70

The first run actually failed at step 3000 or so, and I realized I had a bug in my attention / matmul kernels, but after fixing that and restarting it worked great

[1] https://github.com/anthonix/llm.c

Re:Tinygrad 0.9.0 on Wednesday May 29, 2024 @01:14AM (#40508707)
Even without hipBLASlt, PyTorch is still ~4x faster than tinygrad on a 7900 XTX for GPT2, and works fine. Any idea why?
Re:Tinygrad 0.9.0 on Wednesday May 29, 2024 @12:43AM (#40508550)
Seems to be an issue on their side. E.g., for a step of GPT2 training on a 7900 XTX [1]: tinygrad is ~440ms, PyTorch 2.4.0.dev20240513 is ~97ms, Karpathy's llm.c with ROCm is ~79ms, and llm.c with custom kernels is ~58ms

[1] https://github.com/anthonix/llm.c [2] https://github.com/tinygrad/tinygrad/issues/4301

It converges similarly on smaller datasets.

About to kick off a training from scratch run on the same fineweb-10B, which at 324k toks/sec should take about 8.6 hours. And with my kWh cost, that is about $2.50 cost to train.

Will report back tomorrow when the training has finished..

FWIW, I'm seeing ~318,000 toks/sec throughput on a 4x AMD 7900 XTX machine (less than $4k worth of GPU), using the same settings as in the post (0.5M batch size etc).