Priyam Mazumdar (@data_adventurer) header
Priyam Mazumdar (@data_adventurer) profile picture

Our eyes let us see the universe, AI may let us finally understand it! | PhD @ UIUC | Researcher @ NCSA AI Innovation | R&D Intern @ Sandia | Avid Photographer

Austin, Texas
Joined August 2024
Photo by Priyam Mazumdar (@data_adventurer)Photo by Priyam Mazumdar (@data_adventurer)Photo by Priyam Mazumdar (@data_adventurer)Photo by Priyam Mazumdar (@data_adventurer)Photo by Priyam Mazumdar (@data_adventurer)Photo by Priyam Mazumdar (@data_adventurer)Photo by Priyam Mazumdar (@data_adventurer)Photo by Priyam Mazumdar (@data_adventurer)Photo by Priyam Mazumdar (@data_adventurer)Photo by Priyam Mazumdar (@data_adventurer)
PyTorch makes our life easy. You want Layernorm? You got it. You want a Linear layer? No problem! But there is a lot of work that goes into each of these modules that we take for granted. Our goal here today is to build a completely functional Transformer model WITH NO FRAMEWORKS! This means no Autograd, no layers no nothing. We have to implement for every operation the Forward and Backward pass and train a baby GPT2 Model! Of course as credit @karpathy was the inspiration for this! Timestamps: 0:00 - Introduction 0:50 - Structure of Neural Networks 1:30 - Backprop is just Chain Rule 3:00 - Overview of MyTorch 5:10 - Why ManualGrad when AutoGrad is Easier? 8:50 - What Backprop Looks Like 13:45 - Core Ops for Transformers 15:20 - Boilerplate Code 18:30 - What is __dict__ dunder method? 20:10 - Linear Layer Derivation for single sample 25:45 - Linear Layer Derivation w/ Batch Dimension 35:00 - Linear Layer Implementation 43:40 - Softmax Jacobian Derivation 53:50 - Numerical Stability in Softmax (max trick) 55:53 - SLOW Softmax Implementation 06:45 - Can we avoid the Jacobian? Reinterpret the Softmax 1:14:40 - Efficient Softmax Implementation 1:16:50 - ReLU Activation Implementation 1:20:00 - Embedding Layer Implementation 1:28:30 - Positional Embedding Implementation 1:34:05 - LayerNorm Derivation 2:08:35 - LayerNorm Implementation 2:17:07 - MultiHeadAttention Implementation (Forward Pass) 2:32:05 - MultiHeadAttention Implementation (Backward Pass) 2:53:20 - FeedForward Layer Implementation 2:57:00 - Dropout Implementation 3:02:08 - TransformerBlock Implementation 3:09:01 - SLOW Cross Entropy Derivation (assumes probs) 3:12:00 - SLOW Cross Entropy Implementation 3:16:50 - Cross Entropy on Logits Directly Derivation 3:21:20 - Cross Entropy Implementation 3:24:12 - FlattenForLLM To Make our Shapes Match 3:25:45 - Define the Neural Network Class 3:38:14 - Define the GPT2 Model 3:41:40 - SGD Optimizer Implementation 3:44:45 - Adam Optimizer Implementation 3:52:20 - Character Shakespeare Training Script 4:04:48 - Debugging 4:08:42 - Results 4:12:39 - Why ManualGrad Matters
4
10
648
Every time more news comes out about anything AI, regardless of what’s happening, it only ever means one thing, keep building everyone!!
19
Didn’t realize how annoying prefix caching was going to be for gated delta net…
1
86
Turns out it was NCCL, latency issue is solved with a custom all-reduce!
1
81
Wait… turns out the bottleneck was NCCL… gotta learn all gathers this weekend!
1
43
Something awesome dropping soon!
1
31
MyTorch is now beating PyTorch Compiled on raw throughput (76K tps vs 70k tps) on GPT2 sized models. with a lower memory footprint (11GB vs 16GB)! After a review Ill push the new code!
1
1
36
On a 500M model (close to Nanochat) we match Pytorch Compile (both at ~49K tps) but have a slightly lower memory footprint (16gb vs 18gb)
21
vLLM has so many fun little details like Async Scheduling!
23
watching tiny 1b models generate at like 300-400 tokens/second is kind of uncanny. Like sure its wrong, but it still looks so cool
1
25
That’s crazy! Hope yall are having fun!!
1
6
81
tinyagents coming soon...
1
5
237
claude is so good at making dashboards! Glad i never have to do that again
1
2
170
I passed my Prelim! Onto the Dissertation now!
3
109
Processing billions of tokens at once is no joke... glad SLURM exists!
103
So what llms can’t always count letters in a word? There’s plenty of more interesting things for it to do!
1
61
It’s like every other model I see today is doing distillation!
56