[P] Aakaar – A custom deep learning framework built from scratch in C++/CUDA

[P] Aakaar – A custom deep learning framework built from scratch in C++/CUDA

I built Aakaar to completely strip away the black-box abstraction of modern AI infrastructure (like PyTorch) and force strict, explicit interaction with hardware realities.

Technical Architecture:

  • Backend: Native C++ and CUDA kernels.
  • Frontend: Python wrapper for model definition.
  • Components: Hand-coded 18 native loss modules and 11 optimizers directly in C++.
  • Memory Management: Explicit memory contiguity management during transpositions and custom backpropagation.

Benchmarks (EMNIST): To see if this was structurally viable and not just a toy matrix library, I ran a 5-epoch training loop on the EMNIST dataset to benchmark it directly against PyTorch on my local machine (RTX 4060, 8GB VRAM).

  • Aakaar: 127.76s
  • PyTorch: 131.23s

Convergence parity was absolute, and Aakaar slightly edged out in speed due to the low-overhead C++ optimizer steps bypassing the standard Python overhead.

https://preview.redd.it/kwsriangu1eh1.png?width=803&format=png&auto=webp&s=b4b6c51dfdb8ac9347e226be5adabc1dff663022

The Hardest Challenge: Mapping abstract mathematical shapes to physical GPU hardware and strictly tracking memory layouts during the backward passes without relying on an automated autograd graph.

Links:

I would appreciate any feedback from researchers or engineers here, especially regarding potential optimization bottlenecks in the CUDA kernels or the C++ memory management approaches.

submitted by /u/AaravAggarwal
[comments]

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *