正在加载视频...

视频加载失败

I spent my summer building TinyTPU : An open source ML inference and training chip. it can do end to end inference + training ENTIRELY on chip. here's how I did it👇:

356,700 次观看 • 1 年前 •via X (Twitter)

48 条评论

surya 的头像
surya1 年前

I worked on this with @evanliin, @XanderChin, and @kennykgguo — incredibly smart people! check out our article to see how our chip works and how we went about developing it: you can also find the code here and play with it yourself:

surya 的头像
surya1 年前

our first step was to decide the scale of this project. we decided to target the simplest possible neural network — the XOR problem. however, we still wanted to make this scalable so a core design philosophy for us was to ensure all of our mechanisms could scale to larger networks.

surya 的头像
surya1 年前

before we got to designing any hardware, we started off with properly understanding the math behind MLPs. we worked out the math by hand for inference and training of our network.

surya 的头像
surya1 年前

then we build the heart of any TPU: the systolic array! each processing element (PE) in the systolic array performs a multiply-accumulate in one clock cycle. when connected in a grid, multiple output matrix elements compute simultaneously. this allows us to very efficiently perform matrix multiplication, the most compute-heavy operation in neural networks!

surya 的头像
surya1 年前

the next operation is adding the bias, for which we made a bias module. since this is an element wise operation, we placed 2 bias modules right under the systolic array (one for each column). we structured the activation module similarly — we chose the leaky ReLU and placed one module under each column of the systolic array.

surya 的头像
surya1 年前

however, we had a big problem with our systolic array — computation at the end of every layer to load in the weights of the new layer (this was negligible with a 2x2 systolic array, but it would very inefficient if we scaled it) to solve this, we introduced double buffering to the systolic array. Each PE in the systolic array would have two buffers — an active and inactive buffer. while the outputs of the previous layer are being computed, we can load in the weights of the next layer in the inactive buffers. once the previous layer is finished, we can instantly start computation on the next layer. this nearly DOUBLES the speed of our TPU when we scaled to a larger systolic array size.

surya 的头像
surya1 年前

now we can move on to training! this was easily the most challenging part since we couldn’t find any resource where someone has done this before. a key insight we had while doing the math for training was that the long chain in the computational graph of the backdrop was identical to the forward pass computation graph. this meant we could calculate the long chain first, cache the gradients and then compute the individual weight and bias gradients!

surya 的头像
surya1 年前

the only problem was...we didn't have any on-chip to store the gradients (LOL) so we decided to make a unified buffer. as we developed this, we realized the unified buffer could replace our accumulators as well, making our design more elegant!

surya 的头像
surya1 年前

the VPU was the next big change we made. all those modules UNDERNEATH the systolic array (bias, activation, loss, derivatives) process column vectors element-wise. we unified them into one scalable unit with pathway bits to enable/skip operations, which is a lot more elegant than interfacing with N number of individual modules (N scales with systolic array size).

surya 的头像
surya1 年前

and finally, here's our 94-bit VLIW instruction set:

surya 的头像
surya1 年前

this was our final TPU architecture:

surya 的头像
surya1 年前

having no hardware knowledge or experience at all until just 6 months ago, this was a very ambitious project to work on. I had no idea how difficult this would be or if I could even complete it without the "prerequisites". but throughout the last 4 months, I developed a style of thinking and solving problems that I can carry forward with me. it can be encompassed by these two philosophies: - always try the dumb ideas first - DRAW EVERYTHING OUT to TRULY understand a concept you can read more about our background and thought process at and with that here's our final waveform that shows the outputs of inference and training:

Lloret 的头像
Lloret1 年前

Bro’s bout to receive a job offer from an AI lab

evan 的头像
evan1 年前

@karpathy

Xander Chin 的头像
Xander Chin1 年前

greatest thing ive ever helped create

Thread Reader App 的头像
Thread Reader App1 年前

Your thread is going viral! #TopUnroll 🙏🏼@ain3sh for 🥇unroll

krupa 的头像
krupa1 年前

@karpathy ‼️

Noah Vandal 的头像
Noah Vandal1 年前

wow this is very nice. were you at all tempted to use verilog and fpgas?

surya 的头像
surya1 年前

yes we did use verilog to build this if you look at we did everything in simulation so far, but plan to deploy on an fpga very soon

Noah Vandal 的头像
Noah Vandal1 年前

wow that is cool

saksham 的头像
saksham1 年前

@karpathy

sλrthak 的头像
sλrthak1 年前

this guy is CRACKED af

evan 的头像
evan1 年前

best teammates i could ask for 🫶

Priyav K Kaneria 的头像
Priyav K Kaneria1 年前

love it when randomly some cracked team shows up with something cooked up hard

Peaboff 的头像
Peaboff1 年前

Nice, I did a project like this too. Implemented it for the DE1-SoC + TensorFlow compatible quantization. The hardest part is wrapping your head around the quantization and wrangling all the hardware bits. I remember I was having so much difficulty getting the DMA reading to work

mikael haji 的头像
mikael haji1 年前

🔥

richa 👩‍💻 的头像
richa 👩‍💻1 年前

@devpatelio KILLED IT

yash karthik 的头像
yash karthik1 年前

Cool!

Satvik Garimella 的头像
Satvik Garimella1 年前

This was a great read!

Little Architect 的头像
Little Architect1 年前

very nice work. you should try parametrizing your buffer sizes, pe sizes, and of course the systolic array num elements and do some sweeps on those to get some insights on the scaling you can get on lat and throughput, the balance needed for bw/compute and hw costs.

saksham 的头像
saksham1 年前

inspirational bro

braeden hall 的头像
braeden hall1 年前

i dont understand it, but its cool asf

dhruvr_43 的头像
dhruvr_431 年前

Yoooo bro went viral. Congrats tho inspirational fr

Andy 的头像
Andy1 年前

this is crazy!!!

Satvik Garimella 的头像
Satvik Garimella1 年前

Very informative

omkaar 的头像
omkaar1 年前

i think @Si_Boehm's diagrams were in the spirit of this article

ταῦ 的头像
ταῦ1 年前

Dope! 🔥

chi 的头像
chi1 年前

incredible

Milind Kumar 的头像
Milind Kumar1 年前

Jeez big man, let’s gooo! 💪

Satvik Garimella 的头像
Satvik Garimella1 年前

Wowwww. Greattttt

tornikeo 的头像
tornikeo1 年前

This is literally you guys 😅 this is some actually impressive stuff. Also the blog reads very well! Nice work!

Lingstr 的头像
Lingstr1 年前

Great post, I see lot of research is done behind this. Thanks for sharing this

cumalot daddy 的头像
cumalot daddy10 个月前

Thanks for sharing your work. I have been looking for something like this.

Aayush 的头像
Aayush1 年前

goat 🐐

Hazel Bains 的头像
Hazel Bains1 年前

🔥super impressive growth in 6 months

Atif Saleem 的头像
Atif Saleem1 年前

Are you launching your inference cloud with competitive pricing without compromising on performance? Or is it just open-source? Need to read more about this

unathi 🇿🇦 的头像
unathi 🇿🇦1 年前

fire!

grasgor 的头像
grasgor10 个月前

Insane

相关视频