r/MachineLearning • u/LessComplexity • 4h ago
Project I've built my own programming language that can fit ML better - And its faster than hand-tuned CUDA! [P]
So I've built my own programming language.
It has a different concept (but not new) -> dataflow, parallel first language.
But with a twist.
I've designed it for 5 years, the aim was to create a parallel language, with a different kind of optimization.
The optimization does not focused on the control flow of the application like most other compiler, it focuses on fitting data and data usage onto the hardware device it is running on.
So at comptime, the language creates a dataflow map of the data of the program into processes of the program, this "map" is category-theory based, allowing to use category theoretic rules to prove facts about the program you wrote.
I combine those facts onto the hardware facts that I want to run on (e.g. the compute unit capabilities, total compute units, the memory locations and bandwidths, and how processes use data to ensure efficient re-use when needed).
This also allows the same code to run on nvidia, amd, any cpu, and at the end even on FPGA/printed as its own ASIC. Basically, a language because for years I've hated the monopoly of CUDA, and now officially I'm faster than even CUDA implementations!
The nice results: caching results for matrix mul is automatic, it is not hardcoded, the language just proves it, and creates a cache when needed, it re-computes only what is necessary, multiplications & additions that can be done in parallel WILL be done in parallel for you, so you don't need to specify it, the compiler just works. It also will place/process matrix muls and similar operations in a sequence that uses memory layout in the most efficient way for the hardware it runs on, and not bcs I told it to, but bcs it proves it 🔥
Now I've had a bit of a problem, I did design the language and its algorithms, but the problem is that I let claude make out with the code bcs I wanted results fast.
Now I've managed to prove that this language is faster in most cases than even hand-tuned kernels, numpy and other tools, all accomplished using even "naive" implementations in the language.
This week I've ran llama-3.2-1B and using f32 it is faster than all engines that have optimized the sh*t out of it by hand - and my language? naive implementation of the model.
Here is the language exposition with code examples and performance results against other languages/libraries (even numpy is losing on most hardware I've ran on):
https://lesscomplexity.github.io/mapal/language-exposition.html
For those that want to dig into the architecture I've made a nice file that explains it:
https://lesscomplexity.github.io/mapal/architecture-map.html
Right now I'm trying to "unvibe" the code.
Because the results are awesome, I'm not fully satisfied with how claude did it, even though I've review ALL the code it did, I did it fast to reach results.
Now that I have them the work is on making the compiler more efficient.
I would love to know what you guys think about the language, the syntax, honest opinions as much as you can, and ppl that are willing to help/experiment with it 😄
You can already install the language compiler, its LSP and syntax highlighting both for neovim & vscode.
Here is the official repo: https://github.com/LessComplexity/mapal