News for hackers. Stuff that matters.

muchlakshay

thanks!!!! appreciate that a lot. i’ve mainly tested it on MNIST for now, the CUDA backend trains one epoch in ~0.4ms (batch size 1000, RTX 3060, as i mentioned in the post). It was primarily a deep dive into CUDA/C++, manual memory management, and building a dual backend architecture with a custom matrix lib (GPU-side completely from scratch). this was actually my 4th serious attempt at building a GPU-based MLP from scratch. I failed multiple times, sometimes due to a single line of code. in earlier attempts, i had this optimization idea: store both the weights and their transposes in GPU memory, so i wouldn’t have to compute the transpose each epoch. Seemed clever, until training started failing badly. Turned out I was only updating the original weights matrix after backprop, but the transposed one was still holding stale values from earlier. this broke training completely, and I spent weeks trying to debug it, couldn’t figure it out until this current version.

honestly, the biggest gotchas were-

-memory coherence issues like above (esp. when trying to cache 'smartly')

-launching kernels in the right order while keeping data in sync

-maintainingg modularity without sacrificing too much performance

i avoided fused kernels/shared memory in this version to keep things clean and reusable, but now that the core works, I plan to start optimizing that layer too.

Show HN: I Am 15 and Built a Dual Backend MLP from Scratch Using CUDA C++

https://github.com/muchlakshay/Dual-Backend-MLP-From-Scratch-CUDA

hii everyone! I'm a 15-year-old and I just completed a dual backend MLP from scratch that supports both CPU and GPU (CUDA) training.for the CPU backend, I used only Eigen for linear algebra, nothing else.for the GPU backend, I implemented my own custom matrix library in CUDA C++. The CUDA kernels aren’t optimized with shared memory, tiling, or fused ops (so there’s some kernel launch overhead),...

( Read More... | 2 comments | on HN )
ive seen many people recommending Rust over C++, i think it would be great to rearn Rust. And i am not into those web frameworks. BTW TY for your advise!!!

Show HN: I'm 15 and built a neural network from scratch in C++,just math

https://github.com/muchlakshay/MLP-From-Scratch

I’m 15 and self-taught. I'm learning ML from scratch because I want to really understand how things work. I’m not into frameworks. I prefer math, logic, and C++.I implemented a basic MLP that supports different activation and loss functions. It was trained via mini-batch gradient descent. I wrote it from scratch, using no external libraries except Eigen (for linear algebra).I learned how a...

( Read More... | 3 comments | 5 points | on HN )