Show HN: I built a toy TPU that can do inference and training on the XOR problem

tinytpu.com

131 points by evxxan 3 days ago


We wanted to do something very challenging to prove to ourselves that we can do anything we put our mind to. The reasoning for why we chose to build a toy TPU specifically is fairly simple:

- Building a chip for ML workloads seemed cool - There was no well-documented open source repo for an ML accelerator that performed both inference and training

None of us have real professional experience in hardware design, which, in a way, made the TPU even more appealing since we weren't able to estimate exactly how difficult it would be. As we worked on the initial stages of this project, we established a strict design philosophy: TO ALWAYS TRY THE HACKY WAY. This meant trying out the "dumb" ideas that came to our mind first BEFORE consulting external sources. This philosophy helped us make sure we weren't reverse engineering the TPU, but rather re-inventing it, which helped us derive many of the key mechanisms used in the TPU ourselves.

We also wanted to treat this project as an exercise to code without relying on AI to write for us, since we felt that our initial instinct recently has been to reach for llms whenever we faced a slight struggle. We wanted to cultivate a certain style of thinking that we could take forward with us and use in any future endeavours to think through difficult problems.

Throughout this project we tried to learn as much as we could about the fundamentals of deep learning, hardware design and creating algorithms and we found that the best way to learn about this stuff is by drawing everything out and making that our first instinct. In tinytpu.com, you will see how our explanations were inspired by this philosophy.

Note that this is NOT a 1-to-1 replica of the TPU--it is our attempt at re-inventing a toy version of it ourselves.

ganiszulfa - 2 days ago

Amazing project, and amazing write-up, I especially like the animations. What's the end goal here? Putting these TPUs in the consumer hands or edge devices?

jacquesm - 2 days ago

Sometimes it is the projects where you don't know that you really don't know what you are doing that are the most satisfying, kudos, amazing work you have done.

skybrian - 2 days ago

It's unclear to me what the end result is. Did you build real hardware or is it simulated somehow? If it's hardware, what kind and how did you make it?

airza - 2 days ago

What did you use to make the illustrations? It looks nice.

zoobab - 2 days ago

Maybe try to build a proto with LiteX?

utopcell - 2 days ago

The Google team used Chisel instead of SystemVerilog. You could consider switching to that if it makes sense for your project.

UncleOxidant - 2 days ago

Have you tried it out in an FPGA?

skyzouwdev - 3 days ago

This is super cool. The fact that you went in without hardware experience and still pushed through makes it even more impressive. I like the philosophy of trying the “hacky” way first instead of just copying existing designs—it’s probably the fastest path to real understanding. Curious, what was the hardest part where you almost gave up?