Loading video...

Video Failed to Load

Go Home

I trained a 12M parameter LLM on my own ML framework using a Rust backend and CUDA kernels for flash attention, AdamW, and more. Wrote the full transformer architecture, and BPE tokenizer from scratch. The framework features: - Custom CUDA kernels (Flash Attention, fused LayerNorm, fused GELU) for 3x...

829,709 views • 6 months ago •via X (Twitter)

55 Comments

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

Everything is open source, and we wrote a thorough blog breaking down everything we did so you guys can learn. Repo: Blog:

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

Test the LLM and view the probability distribution of next tokens. All running in the browser using our own framework.

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

As per @ClementDelangue's suggestion, I uploaded the model to HuggingFace. Feel free to check it out and run the model yourself:

clem 🤗's profile picture
clem 🤗6 months ago

you should share the model on

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

Will most definitely do 🔥

Gavin's profile picture
Gavin6 months ago

Love it. Dm me?

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

For sure!

Sanjoy Das's profile picture
Sanjoy Das6 months ago

Nice! Would love to get your take on cuTile Rust:

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

Looks interesting, will play around with it a bit and share my thoughts 👀

Bryce, the CUDA Colonel's profile picture
Bryce, the CUDA Colonel6 months ago

DM me if you wanna chat about Rust for GPU programming!

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

Will definitely reach out, even before I got into AI I did a lot of GPU programming work related to game development and rendering 🔥

Taelin's profile picture
Taelin6 months ago

cost?

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

I spent ~$100 CAD of my own money, but @modal gave me ~$400 free credits at a hackathon a while back. The total was $500 of cloud compute

stan p's profile picture
stan p6 months ago

waterloo strikes again

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

have to live up to the name

Ken Wu's profile picture
Ken Wu6 months ago

how did i get into the same school as this beast

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

Lmaooo 🙈

Kenny Guo's profile picture
Kenny Guo6 months ago

first principles 🫡

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

Yessir 🔥

dnu's profile picture
dnu6 months ago

respect. writing your own framework is one thing, getting a full train run to converge is the part that usually gets ugly. what broke first for you, kernels or optimizer math?

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

We had a lot of bugs with our CUDA kernels that had to be addressed before the training started to go well 😂

Yechan Do's profile picture
Yechan Do6 months ago

This is so impressive. Can I use your work at my lecture for education purpose ?

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

@yechan_ai Yes of course, we’re honoured 🔥

Saurabh Kumar's profile picture
Saurabh Kumar6 months ago

What are they feeding Waterloo undergrads

ayush's profile picture
ayush6 months ago

my goats @_reesechong and @MankyDankyBanky this is insane

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

@_reesechong Ty bro 🙏

Xander Chin's profile picture
Xander Chin6 months ago

fire

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

Appreciate it, TinyTPU was a big inspo

ani's profile picture
ani6 months ago

🐐

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

nah you inspired me fr

Ricky Tang's profile picture
Ricky Tang6 months ago

this is crazy bro

alexine 🏴‍☠️'s profile picture
alexine 🏴‍☠️6 months ago

very cool, great work!

EDITH's profile picture
EDITH6 months ago

This is fucking great man!!!

Kaibo Huang's profile picture
Kaibo Huang6 months ago

@lucashjin good stuff aadi🔥

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

@lucashjin Thanks Kaibo looking forward to Bear hacks

mikael haji's profile picture
mikael haji6 months ago

very nice!

Aryan Dhawan's profile picture
Aryan Dhawan6 months ago

Amazing

Akram Jamil's profile picture
Akram Jamil6 months ago

@nicholaschen__ cracked

Benedict Kerres's profile picture
Benedict Kerres6 months ago

Well done

Rhys Campbell's profile picture
Rhys Campbell6 months ago

@hnshah Part time model builder, full time looksmaxxer

Freeman Jiang's profile picture
Freeman Jiang6 months ago

good stuff

Moulik's profile picture
Moulik6 months ago

holy cracked

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

thanks moulik!

NILAY1556's profile picture
NILAY15566 months ago

It's been my dream for long time to do something like that , impressive work Happy for you guyz to see you got much recognize by big giants Just great

evan's profile picture
evan6 months ago

nice work!!

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

Thanks so much Evan!

Nikhil Sonti's profile picture
Nikhil Sonti6 months ago

training a transformer from scratch used to be frontier lab work now random devs ship full implementations with custom CUDA kernels... Rust backends... BPE tokenizers built from zero as side projects what took entire teams 2 years ago is now weekend hobby territory the commodification speed is wild

Lucas Jin's profile picture
Lucas Jin6 months ago

@imdonghakim w aadi

sanjay prasad hs's profile picture
sanjay prasad hs6 months ago

Super cool stuff, man, super cool.

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

Thanks man!

benkigera's profile picture
benkigera6 months ago

Reminds me of what LLMs are doing under the hood.

Dev Shorya's profile picture
Dev Shorya6 months ago

thats actually insane. most people talk about it, you actually built it. the rust + cuda combo is hard mode too

Ajith Bondili's profile picture
Ajith Bondili6 months ago

@anirudhbv_ce W

1jmdev's profile picture
1jmdev6 months ago

Please update the demo page so it caches the model on user device it is really cool but please cache it on user device

Aadi Kulshrestha's profile picture
Aadi Kulshrestha6 months ago

Good point, will try to get this out soon!

Related Videos

Ben Thompson explains how LLMs greatly diminished Nvidia's CUDA moat even as they sent the stock to the moon "So the weird thing about large language models is they were obviously incredible for Nvidia. That's why their stock went to the moon." "They have been on and off the most valuable company in the world." "It was also very bad for Nvidia. And the reason it was bad for Nvidia is that the play with CUDA is to build a developer ecosystem on top of CUDA." "But CUDA only works on Nvidia GPUs. So you get CUDA for free. It's easier to use, and it's a tremendous investment. Nvidia almost went under trying to build CUDA at a time when no one understood what they were doing or why they were wasting money on it." "And that's why Jensen Huang will get bristly, particularly when people question their rent-seeking or profit, whatever. It's like, no, they earned their spot fair and square." "Absolutely. It shouldn't be forgotten. They have earned every dollar they've gotten through 25 years of taking massive risks." "It bottomed out in October 2022. I wrote an article like three weeks before ChatGPT came out, tracing their bottoming-out history and their search for what was next." "'Nvidia in the Valley.' So, go back to this GTC. So I wrote an article at the time called 'Nvidia Waves and Moats'." "And what was interesting about that GTC was, number one, it was very boring. All the cool stuff kind of got scrubbed out." "Now, Jensen Huang has brought that stuff back, so the last few GTCs he's more talking about other things. Now it comes across as, oh, you're still looking for something beyond the LLM." "Because the problem with the LLM is it shifts the developer platform far above where Nvidia sits. All the activity is happening on top of LLMs. And so no one who's writing an AI application today is using CUDA." "Now, some people are, if you're training your own model and you're doing some low-level things or non-LLM things." "But the vast majority of the energy and all the money and the ecosystem is far removed from CUDA." "They have no idea and don't need to know or care what chips their application is running on. They're just on the OpenAI API, or the Anthropic API, or using Bedrock on Amazon, and it's sitting on Trainium, and they're using a Chinese open-source model. It's totally abstracted away, and this is why LLMs were bad for Nvidia." "Now, again, all the money they made along the way is worth it, but their moat has been tremendously diminished." "CUDA is still a moat if you need to do stuff that requires CUDA. But the vast majority of stuff, in energy, doesn't require CUDA, like in a post-LLM world."

Fireside Alpha

12,980 views • 2 months ago