@maxxfuu: Day 13/90 of Inference Engineering I built a MNIST classifier in C. Not proud of it, man enough to say it. It took me 5…
Summary
The author shares their experience building an MNIST classifier in C, emphasizing the importance of understanding fundamentals over coding, and explains the intuition behind matrix multiplication with 1D vectors.
View Cached Full Text
Cached at: 07/20/26, 05:31 PM
Day 13/90 of Inference Engineering
I built a MNIST classifier in C.
Not proud of it, man enough to say it. It took me 5 days to fully understand and get the intuition behind a matmul with 1D vectors.
It’s just 3 nested for-loops, and somehow, it just didn’t click. It was not intuitive at all. Here are some things I wish I knew before starting.
Practically speaking, I think sometimes drawing things out, creating different visualizations, and talking to language models to build that understanding can help out a lot, if done correctly.
I spent around 6 hours just tracing the code, drawing the data flow, predicting the shapes, and understanding the math. None of which required any coding. Once I fully understood the flow of MNIST, writing the code became blazingly fast. Implementing MNIST in C took about 1 hour, understanding everything took 6 hours.
Mindset-wise, I think learning about Deep Learning truly is a different game. Coming from a fullstack engineering perspective, there’s almost a playbook on building robust backends and building tasteful frontends. I’ve found that diving straight into things and figuring it out along the way teaches you more than reading the documentation.
However, learning Inference, CUDA, and building a simple project like MNIST just isn’t the same as fullstack engineering. There’s this big hurdle of understanding why something works and building an intuition of things. Moving forward, I’m definitely spending my tokens on understanding the fundamentals instead of coding.
On the technical side, here’s the intuition that made the triple for-loops implementation of the matmul_forward() click! Since the matrices are in the form of a 1D vector, selecting the right cell is just figuring out which of the three indexing variables corresponds to the step, stride, and pin.
This isn’t formal terminology, but it just makes sense.
The step is the axis you’re moving on. It could span row-wise or column-wise. Which way you span is determined by the pin. The stride is how big of a jump you make on the 1D array with each step.
Take a look at B[l*k + j] that’s in the animation. The pin is j which pins you to one column, so the only free variable is the step, l. The iteration flows top to bottom down that column. Since B lives in a 1D array, “down one row” isn’t one cell over, it’s a full stride or row width of k.
While which variable plays the stride, pin, and step depends entirely on how the for-loops are structured, I’ve been able to generalize variations of matmuls using this framework.
Starting tomorrow, I’ll be able to rewrite this C code in CUDA!
Similar Articles
@maxxfuu: Day 6/90 of Inference Engineering I wrote a CUDA kernel for 1D Convolution, just getting the reps in for writing unopti…
A developer shares their day 6 of inference engineering, writing a CUDA kernel for 1D convolution, explaining PagedAttention's memory efficiency, and providing an overview of GPU memory hierarchy (global, register, local, constant, shared).
@sumitdotml: week 25, 2026: cpu tensor core basics (add/mul, reduce, stride, 2d matmul, etc.) in c, reading some arcee
The author shares progress on building a CPU-only tensor library in C, covering basics like add/mul, reduce, strides, and 2D matmul, along with insights from reading Arcee's technical blogs on foundation models.
@harshbhatt7585: https://x.com/harshbhatt7585/status/2063593933314113587
The author shares learnings from training a 160M parameter LLM from scratch, experimenting with architectures like multi-token prediction and hierarchical reasoning models. They emphasize the importance of fast iteration, simplifying ideas, and understanding why architectures work.
@DivyanshT91162: Andrej Karpathy built his whole reputation on one idea: "You don't really understand it until you can build it from scr…
A Twitter thread discusses the irony of Andrej Karpathy's teaching philosophy—learning by building from scratch—while he now uses AI to code, and shares a 3-week learning journey using Claude Opus 4.8 to master deep learning the old way.
@0x0SojalSec: Want to truly stand out in AI/ML not just use the tools, but understand and improve them? understand why gradient desce…
A tweet promoting a curated collection of math and deep learning resources for understanding the foundations behind models like Claude, including linear algebra, real analysis, optimization, and representation theory.