Jaydr.eth (@Jaydeep_25) header
Jaydr.eth (@Jaydeep_25) profile picture

ai researcher post-training and llm systems epistemology | austrian econ fallibilist | optimist

India
Joined December 2014
a reminder to myself "you can just do things"
2
70
the nuances you learn while implementing things >>> in pipeline parallelism if pp = 4 and you have 16 layers, then each should get 4 layers right? No!
1
1
172
since the first stage also runs the embedding and the last stage also runs norm + output, so splitting layers equally would overload them, so the first and last stages can be given fewer transformer layers. e.g. pp=4, 10 layers, 3 per stage, so the split is 2 / 3 / 3 / 2 layers
19
so we understood the problem. Now let's understand Paged Attention, and how it works. Let's again assume we have a GPU and now we divide it into multiple blocks. For simplicity assume it to be a 100 blocks. and each block has the space to hold say KV pairs for 10 tokens. we will have two lists: i) Free Block List: [0,1,2....,99] ii) Paging table: {} which will be empty at the start Now let's assume we have 4 users/requests: A, B, C, D and the prefill tokens for A: 8, B: 5, C:12, D: 9 so after the prefill stage the allocation will look something like this: A: Block 0 (8/10) B: Block 1 (5/10) C: Block 2 (10/10), Block 3( 2/10) D: Block 4(9/10) we pop out these blocks from free block list so it becomes -> [5,6,7.....99] the paging table will look something like this: Req A: {0} Req B: {1} Req C: {2,3} Req D: {4} (dynamic allocation) then we start the decoding stage: step 1 of decoding this becomes: A: Block 0 (9/10) B: Block 1 (6/10) C: Block 2 (10/10), Block 3( 3/10) D: Block 4(10/10) step 2 of decoding: A: Block 0 (10/10) B: Block 1 (7/10) C: Block 2 (10/10), Block 3( 4/10) D: Block 4(10/10), Block 5 (1/10) we pop out block 5 from free block list -> [6,7,8,.....99] and paging table looks like: Req A: {0} Req B: {1} Req C: {2,3} Req D: {4,5} step 3 of decoding: A: Block 0 (10/10), Block 6 (1/10) B: Block 1 (8/10) C: Block 2 (10/10), Block 3( 5/10) D: Block 4(10/10), Block 5 (2/10) we pop out block 6, the list becomes -> [7,8,9,......99] and paging table looks like: Req A: {0,6} Req B: {1} Req C: {2,3} Req D: {4,5} and so on and forth. since now we don't have any requests hogging up a lot of memory from the start, we can allow for more requests to be accommodated instead of queued, a request doesn't have to wait for another request of a similar or bigger 'size' getting processed before being allocated memory, this solves the problem of external fragmentation. and the max wastage per block is the block size-1, reducing internal fragmentation. Now since we have the tokens in different blocks, how do we compute attention? We use Online Softmax! Which we will get to in the next post.
1
80
so we understood the problem. Now let's understand Paged Attention, and how it works. Let's again assume we have a GPU and now we divide it into multiple blocks. For simplicity assume it to be a 100 blocks. and each block has the space to hold say KV pairs for 10 tokens. we will have two lists: i) Free Block List: [0,1,2....,99] ii) Paging table: {} which will be empty at the start Now let's assume we have 4 users/requests: A, B, C, D and the prefill tokens for A: 8, B: 5, C:12, D: 9 so after the prefill stage the allocation will look something like this: A: Block 0 (8/10) B: Block 1 (5/10) C: Block 2 (10/10), Block 3( 2/10) D: Block 4(9/10) we pop out these blocks from free block list so it becomes -> [5,6,7.....99] the paging table will look something like this: Req A: {0} Req B: {1} Req C: {2,3} Req D: {4} (dynamic allocation) then we start the decoding stage: step 1 of decoding this becomes: A: Block 0 (9/10) B: Block 1 (6/10) C: Block 2 (10/10), Block 3( 3/10) D: Block 4(10/10) step 2 of decoding: A: Block 0 (10/10) B: Block 1 (7/10) C: Block 2 (10/10), Block 3( 4/10) D: Block 4(10/10), Block 5 (1/10) we pop out block 5 from free block list -> [6,7,8,.....99] and paging table looks like: Req A: {0} Req B: {1} Req C: {2,3} Req D: {4,5} step 3 of decoding: A: Block 0 (10/10), Block 6 (1/10) B: Block 1 (8/10) C: Block 2 (10/10), Block 3( 5/10) D: Block 4(10/10), Block 5 (2/10) we pop out block 6, the list becomes -> [7,8,9,......99] and paging table looks like: Req A: {0,6} Req B: {1} Req C: {2,3} Req D: {4,5} and so on and forth. since now we don't have any requests hogging up a lot of memory from the start, we can allow for more requests to be accommodated instead of queued, a request doesn't have to wait for another request of a similar or bigger 'size' getting processed before being allocated memory, this solves the problem of external fragmentation. and the max wastage per block is the block size-1, reducing internal fragmentation. Now since we have the tokens in different blocks, how do we compute attention? We use Online Softmax! Which we will get to in the next post.
okay, I got distracted by pagedAttention while studying flashAttention. I could say Paged Attention stole my attention from Flash Attention. hmm. wordsmith and all. anyway, so trying to have a running thread so I don't just have it in my head. Inference happens in two stages: Prefill and Decode. What is stored in the GPU during Inference? Model Weights(shared) , Activations(private to each forward pass) and the biggest component -> KV cache (private to each request and usually the largest memory consumer) For every token that's generated we need to store a key vector and a value vector -> and you can imagine that blows up very fast. So we have the painful problem of managing KV cache Memory. Let's say we have a GPU with a model on it and 4 users. Let's assume user A is estimated to generate 2000 tokens, user B is estimated to generate 1000 tokens and user C and D both are estimated to generate to 2000 tokens each. So we reserve memory for each user based on this estimation. Based on that allocation A, B, C 'fit' on the GPU but D doesn't so D has to wait. Now when decoding is happening for all of these users: the memory taken up by KV cache is only for the tokens generated so rest of the space is idle/empty/getting wasted for that token and on top of that say after the actual decoding each user's token generation was far lower than what was estimated, that again ended up wasting resources. This is internal fragmentation. Assume that now B has finished, but we can't put D there since it needs 2000 token KV cache space according to our estimation so we need to wait for A or C decoding to get over. This is external fragmentation. This problem of fragmentation stems from requests being allocated in continuous physical space in memory. And this issue of fragmentation is what Paged Attention Solves. How? Let's go into that in the next post
1
176
okay, I got distracted by pagedAttention while studying flashAttention. I could say Paged Attention stole my attention from Flash Attention. hmm. wordsmith and all. anyway, so trying to have a running thread so I don't just have it in my head. Inference happens in two stages: Prefill and Decode. What is stored in the GPU during Inference? Model Weights(shared) , Activations(private to each forward pass) and the biggest component -> KV cache (private to each request and usually the largest memory consumer) For every token that's generated we need to store a key vector and a value vector -> and you can imagine that blows up very fast. So we have the painful problem of managing KV cache Memory. Let's say we have a GPU with a model on it and 4 users. Let's assume user A is estimated to generate 2000 tokens, user B is estimated to generate 1000 tokens and user C and D both are estimated to generate to 2000 tokens each. So we reserve memory for each user based on this estimation. Based on that allocation A, B, C 'fit' on the GPU but D doesn't so D has to wait. Now when decoding is happening for all of these users: the memory taken up by KV cache is only for the tokens generated so rest of the space is idle/empty/getting wasted for that token and on top of that say after the actual decoding each user's token generation was far lower than what was estimated, that again ended up wasting resources. This is internal fragmentation. Assume that now B has finished, but we can't put D there since it needs 2000 token KV cache space according to our estimation so we need to wait for A or C decoding to get over. This is external fragmentation. This problem of fragmentation stems from requests being allocated in continuous physical space in memory. And this issue of fragmentation is what Paged Attention Solves. How? Let's go into that in the next post
1
158
this is was ofcourse AI slop. I have started to hate using AI to write. still do it on linkedn. too lazy. but I am trying to not outsource my writing and thinking, even though that trap is very hard to avoid.
I am building 5-6 products before June 30, with the understanding that most of them will fail. That's the point. Instead of debating ideas in my head, I am putting them through a public filter. Here are the rules: 1. Each product gets about 2 days of building and 1 full day of distribution. I will put it in front of the exact people it's for, rather than just dropping a link and hoping for the best. 2. Each product will have kill criteria established before I write a line of code. For example: 10 strangers try it, 3 come back on their own, and 1 offers to pay. If it misses the bar in a week, it dies. 3. When something dies, I will announce it publicly and share the reasons why. The autopsies will likely be more useful than the launches. 4. I will provide scoreboards at the end, detailing what shipped, what's showing a pulse, and what's dead. Maybe 1 or 2 will survive? The first product drops soon. Follow along if you want to watch some ideas die in public.
87
Jaydr.eth retweeted
what humanity has achieved was not merely a function of time. the phone, the app, the rocket, the vaccines, the clothes, the skyscrapers, even things more abstract like democracy, scient, freedom, liberty are all a result of humans making it happen! we must strive to make a world, where humans are free, where humans live long, are happy, are healthy. a future where we are free, and growing our knowledge, harnessing the energy of the stars, expanding human consciousness. we need to preserve the mechanisms of progress, we need to fight evil ideas that stop the growth of knowledge.
1
1
76
do great research. build great products that scale into companies. learn great things. write and talk about great things. make meaningful contributions to humanity. all problems can be solved. all of life is problem solving.
2
40
my dumbass spent 2 hours just trying to understand online softmax, logsumexp trick, blocked online softmax and yet I don't understand it completely. I thought I could wrap this up in an afternoon, will probably take a lot more time.
70
idk man, sometimes all I want is just a small home with a gym where I can train for calisthenics and streetlifitng, and loads of books, a pc setup, reading, learning and running experiments all day.
2
62
Jaydr.eth retweeted
There are many ways in which India can win in AI Talent density. We have lots of talented people, we just need less disturbance from external people and more support for the focused work, productive environment and good pay Data. India generates huge amount of data. And US companies are taking full advantage of it. Whether it’s collecting cheap egocentric view for robotics or simple data labeling. There is definitely a cost arbitrage and we should take benefit of that as well. Data collection and labeling is a huge challenge and we can do it reliably and cheaply Compute. We still lack compute but recent efforts by sarvam and other IIT labs have shown that with good funding and support we can reach the level of compute we need to run big experiments Optimism. This is where we lack. From everyday opinions from people saying “it’s too late” or “it’s just post training nothing special like deepseek” to leaders saying we don’t need sovereign LLM(spoiler we do). We have to be optimistic on the work our people are doing. Policies should support that as well
9
6
47
2,008
what humanity has achieved was not merely a function of time. the phone, the app, the rocket, the vaccines, the clothes, the skyscrapers, even things more abstract like democracy, scient, freedom, liberty are all a result of humans making it happen! we must strive to make a world, where humans are free, where humans live long, are happy, are healthy. a future where we are free, and growing our knowledge, harnessing the energy of the stars, expanding human consciousness. we need to preserve the mechanisms of progress, we need to fight evil ideas that stop the growth of knowledge.
1
1
76
I am building 5-6 products before June 30, with the understanding that most of them will fail. That's the point. Instead of debating ideas in my head, I am putting them through a public filter. Here are the rules: 1. Each product gets about 2 days of building and 1 full day of distribution. I will put it in front of the exact people it's for, rather than just dropping a link and hoping for the best. 2. Each product will have kill criteria established before I write a line of code. For example: 10 strangers try it, 3 come back on their own, and 1 offers to pay. If it misses the bar in a week, it dies. 3. When something dies, I will announce it publicly and share the reasons why. The autopsies will likely be more useful than the launches. 4. I will provide scoreboards at the end, detailing what shipped, what's showing a pulse, and what's dead. Maybe 1 or 2 will survive? The first product drops soon. Follow along if you want to watch some ideas die in public.
1
3
169
being on x makes me feel a lot more optimistic about the future. we can solve problems. we can harness the energy of the stars. we can free humanity from the drudgery of manual labor. we can be free. we can preserve human consciousness and expand it to the stars. we can reduce suffering for the entirety of humanity. and we can do cool stuff! for this we must preserve freedom. freedom of speech, freedom to error-correct. we must fight ideas that slow down the growth of knowledge. thank @elonmusk for this platform.
1
56
interesting. trying to replicate the unsloth CPT notebooks on code. rs_lora was supposed to stabilize!? but it's doing the opposite. will have to understand what's going wrong. ablations based on this blog unsloth.ai/blog/contpretrain… by @UnslothAI this was written in 2024, so not sure we have had any literature since then, thought it would be a fun experiment to run. running it on 3 seeds and will test held-out perplexity as well.
2
69
the audacity to believe in yourself with no physical evidence is literally the entire cheat code
49
1,798
36
11,251
130,655
Still haven't done it
how do I create more than I consume everyday? i read a lot, learn a lot. it seems very shallow though without any artifacts of learning. need to change that. blogs, essays, tweets, etc.
2
34
For the first time in 123 years, Argentina has achieved a sustained fiscal surplus without being in default. We are one of only 5 countries in the world in this position. LONG LIVE FREEDOM, DAMN IT...!!!
429
7,222
364
56,960
1,109,202