Earlier quoted context omitted.
Hi, in nanoeuler I use cuBLAS (NVIDIA's super-optimized library) for all matrix multiplications, with the tensor cores in TF32 mode. It's the same thing PyTorch uses underneath, so it's very fast. What I've optimized (and will improve even more) and written by hand are the kernels for the other parts (like FlashAttention, which gave a nice 3x speedup), while I've delegated the large matrices to cuBLAS. Training the 1…
Do you have a guess why your code is so much slower than torch? I didn't look, but there must be no reason to have 2x slower code esp. for a simple grid of FMAs.
Show HN: NanoEuler – GPT-2 scale model in pure C/CUDA from scratch
21–30 of 30 posts
Re: Show HN: NanoEuler – GPT-2 scale model in pure C/CUDA from scratch
#22Wow that's really cool i'll definitely check it out! have played around with machine learning algorithms built from scratch in c / cuda too, but once i hit the cuda part of it i kinda just left it to the side. i'm curious how did you use CUDA to optimize the matrix multiplications? how optimized is training, does it take much longer then using pytorch?
Hi, in nanoeuler I use cuBLAS (NVIDIA's super-optimized library) for all matrix multiplications, with the tensor cores in TF32 mode. It's the same thing PyTorch uses underneath, so it's very fast. What I've optimized (and will improve even more) and written by hand are the kernels for the other parts (like FlashAttention, which gave a nice 3x speedup), while I've delegated the large matrices to cuBLAS. Training the 1…
did you build the backprop yourself? it is a really cool project to build and i think you can agree that it teaches you a lot of how LLMS and machine learning in general works.
Re: Show HN: NanoEuler – GPT-2 scale model in pure C/CUDA from scratch
#23Earlier quoted context omitted.
Hi, in nanoeuler I use cuBLAS (NVIDIA's super-optimized library) for all matrix multiplications, with the tensor cores in TF32 mode. It's the same thing PyTorch uses underneath, so it's very fast. What I've optimized (and will improve even more) and written by hand are the kernels for the other parts (like FlashAttention, which gave a nice 3x speedup), while I've delegated the large matrices to cuBLAS. Training the 1…
i see really cool, where i failed was trying to build my own matrix operations library, it was just too much, but using cuBLAS definitely helps, i'll look into the custom kernels you wrote they seem interesting! did you build the backprop yourself? it is a really cool project to build and i think you can agree that it teaches you a lot of how LLMS and machine learning in general works.
Re: Show HN: NanoEuler – GPT-2 scale model in pure C/CUDA from scratch
#24Very weird coding style, did you run astyle --style=python on C code? Also, your LLM left a comment in the cuda source that it is untested, does the cuda stuff work?
> Very weird coding style, did you run astyle --style=python on C code? I'm sure you mean it in a more curious way but this type of comment on a Show HN often comes across as too harshy/snarky/dismissive for what we want here (see https://news.ycombinator.com/showhn.html ).
Re: Show HN: NanoEuler – GPT-2 scale model in pure C/CUDA from scratch
#25Earlier quoted context omitted.
> Very weird coding style, did you run astyle --style=python on C code? I'm sure you mean it in a more curious way but this type of comment on a Show HN often comes across as too harshy/snarky/dismissive for what we want here (see https://news.ycombinator.com/showhn.html ).
Consider adding a rule that an author must disclose (in their own words) for what parts and to what extent LLMs have been used to assist their project.
Re: Show HN: NanoEuler – GPT-2 scale model in pure C/CUDA from scratch
#26Re: Show HN: NanoEuler – GPT-2 scale model in pure C/CUDA from scratch
#27Amazing, i’ll try to learn from your code. Thanks!
Re: Show HN: NanoEuler – GPT-2 scale model in pure C/CUDA from scratch
#28Earlier quoted context omitted.
Consider adding a rule that an author must disclose (in their own words) for what parts and to what extent LLMs have been used to assist their project.
I don't think it would help: most people wouldn't know about it, of those who did many wouldn't conform, and there would be no reliable way to enforce it.