I noticed you interface with the native code via ctypes. I think cffi is generally preferred (eg, https://cffi.readthedocs.io/en/stable/overview.html#api-mode... ). Although you'd have more flexibility if you build your own python extension module (eg using pybind), which will free you from a simple/strict ABI. Curious if this strict separation of C & Python was a deliberate design choice.
Show HN: I built a tensor library from scratch in C++/CUDA
11–20 of 30 posts
Re: Show HN: I built a tensor library from scratch in C++/CUDA
#12Re: Show HN: I built a tensor library from scratch in C++/CUDA
#13Cool stuff! Is the goal of this project personal learning, inference performance, or something else? Would be nice to see how inference speed stacks up against say llama.cpp
Re: Show HN: I built a tensor library from scratch in C++/CUDA
#14It's very C-like, heavy use of macros, prefixes instead of namespaces, raw pointers for arrays etc. Technically you're compiling C++, but... not really. No negative or positive comment on its usability though, I'm not an ML/Neural Network simulation person.
Coming from a background of working with OS kernels and systems software, I don't mind the kind of explicit "C++ lite" style used by the OP. Left to my own devices, I usually write things that way. I would think twice if I was trying to design a large framework, but ... I try to avoid those.
Re: Show HN: I built a tensor library from scratch in C++/CUDA
#15This is very cool. I'm wondering if some of the templates and switch statements would be nicer if there was an intermediate representation and a compiler-like architecture. I'm also curious about how this compares to something like Jax. Also curious about how this compares to zml.
Re: Show HN: I built a tensor library from scratch in C++/CUDA
#16Do you have any plan for the serialization and deserialization of your tensor and nn library?
Re: Show HN: I built a tensor library from scratch in C++/CUDA
#17super n00b question , what kind of labtop do you need to do project like this? Is mac ok? or do you need dedicated linux labtop?
Re: Show HN: I built a tensor library from scratch in C++/CUDA
#18I noticed you interface with the native code via ctypes. I think cffi is generally preferred (eg, https://cffi.readthedocs.io/en/stable/overview.html#api-mode... ). Although you'd have more flexibility if you build your own python extension module (eg using pybind), which will free you from a simple/strict ABI. Curious if this strict separation of C & Python was a deliberate design choice.
Yes, when I designed the API I wanted to keep a clear distinction between Python and C. At some point I had two APIs: 1 in Python and the other in high-level C++ and they both shared the same low-level C API. I find this design quite clean and easy to work with if multiple languages are involved. When I'll get to perf I plan to experiment a bit with nanobind ( https://github.com/wjakob/nanobind ) and see if there's a…
https://news.ycombinator.com/item?id=31378277
Even if the number reported there is off, it's not far off because ctypes just calls out to libffi which is known to be the slowest way to do ffi.
Re: Show HN: I built a tensor library from scratch in C++/CUDA
#19Re: Show HN: I built a tensor library from scratch in C++/CUDA
#20Cool stuff! Is the goal of this project personal learning, inference performance, or something else? Would be nice to see how inference speed stacks up against say llama.cpp
Thanks! To be honest, it started purely as a learning project. I was really inspired when llama.cpp first came out and tried to build something similar in pure C++ ( https://github.com/nirw4nna/YAMI ), mostly for fun and to practice low-level coding. The idea for DSC came when I realized how hard it was to port new models to that C++ engine, especially since I don't have a deep ML background. I wanted something that…