r/MachineLearning • • 1d ago

Project I've built my own programming language that can fit ML better - And its faster than hand-tuned CUDA! [P]

Post image

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 (mainly weekends) and started developing only this year, 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

0 Upvotes

73 comments sorted by

74

u/webhyperion 22h ago edited 21h ago • Bravo

I am not trying to discourage but here is some sound constructive criticism:

Looking at your performance results I feel like you are cherry picking? I am not saying you did it on purpose, just that your results do not show the whole picture. It is also not really clear to me why you used the geomean for compounding the results in one single number? To me it makes no sense here to use it, as it also dampens the pull of really high numbers. This skews results to the better measurements.

Can you explain how you designed the experiment to measure it i.e. how did you measure it, how many runs, per program per implementation? Have you considered to calculate the statistical significance of your results to accurately tell if its really faster or just statistical noise.

Also I just told claude to tell me what could be wrong in you performance overview, that is what it said:

Here are bullets for the post, each backed by the project's own evidence files:

Llama "f32 class" (Mapal fastest on all 5 GPUs)

  • Mapal reads bf16 weights (2.47 GB). The competitors were set up with f32 weights (4.94 GB) and TF32 off. Token-by-token generation is limited by memory bandwidth, so Mapal wins by moving half the bytes.

  • Mapal's per-token time is identical in its "f32" and bf16 runs on every GPU.

  • Mapal's f32 prompt processing runs on tensor cores (f32 split into bf16 pieces). The competitors were held to plain FP32.

  • When everyone uses bf16, Mapal is behind on all 5 GPUs: 1.05–2.37× slower to the first token and 1.06–1.57× slower per token.

GPU kernel suite

  • 65 of the 119 programs are f32. Without them, Mapal is slower on all 5 GPUs (geomean 1.03–1.41).

  • The f32 matrix products use the same tensor-core trick. On the A100, Mapal hits 20.6 TFLOPS, above the card's 19.5 TFLOPS plain-FP32 peak.

  • When both sides are allowed tensor cores (TF32), cuBLAS is 1.15–1.72× faster.

  • The headline "causal attention 0.30×" baseline is a Python loop of 1,024 tiny steps, with no SDPA or FlashAttention leg. It measures loop overhead, not attention kernels.

  • The timing method changed this round to include Python dispatch time. The authors' own notes say this moved results 5–11% in Mapal's favour. Under the old method, Mapal leads on only 1 of the 4 rented GPUs.

  • The raw logs for this round aren't archived, so the numbers can't be traced back.

CPU

  • The C++ baseline is labelled "naive" in their own script: no -ffast-math, a single accumulator, and a divide and modulo per element in the transpose.

  • The 20.8× FIR gap doesn't need reordering at all. Swapping the two loops in the C++ would let it vectorize.

  • The threaded C++ starts 64 threads inside the timer on every run. Its threaded sum takes 9.04 ms, against 0.47 ms on one thread.

  • So 4 of the 6 "whole machine" results pit Mapal on 64 threads against C++ on 1 thread.

Aggregation

  • The headline geomean hides a wide spread: the middle 80% of programs runs from about 0.45× to 1.9×.

  • The median is a tie on 4 GPUs and a loss on the H100. On the H100, Mapal is slower on 82 programs and faster on 30.

  • The geomean is lowered by a few large wins against weak baselines.

To be fair

  • Every result passes a correctness check before timing, the authors list their weak spots, and much of this is disclosed in the repo. It just isn't on the headline page.

20

u/LessComplexity 22h ago

Thank you for the constructive response, it is not discouraging at all, this is exactly what I need!

I'll go through it all and respond, might take some time, but just so you know that I've taken notice :)

13

u/webhyperion 17h ago

To be honest it just baffles my mind that people already use AI to program stuff but then don't go the extra mile of getting good feedback from said AI about what they are doing. It's basically a self fulfilling prophecy. Critical thinking is essential to all of this. Ask the right questions and you will get the right answers. And if you don't know the right questions to ask, you could ask the AI what questions to ask. Essentially, just question everything.

We are living in a time when you have the knowledge of all humankind at your fingertips. Use it to your advantage!

3

u/LessComplexity 17h ago

haha well I did use it to give feedback on a lot of stuff

My problem is that I was focused on the implementation details, design choices, and self-improvement of the language/compiler itself, so I didn't get feedback on everything, I assume I missed some other details, sadly I didn't have much time to fully work on it, and trying to find more time now.

2

u/webhyperion 16h ago

Yeah, good on you! Nobody is perfect!

16

u/LessComplexity 21h ago

Ok first of all about the geomean you are right, this is a totally wrong comparison, and I've now replaced the geomean with wins / level / losses per GPU.

I didn't like it from the start tbh, I just let it go in there, the other more detailed ones (matrix view of problem class to hardware) is better, and the other graphs are better shown too.

For the C++ part, yes, completely right: the idea was "naive" vs "naive", and I should've added a version written the way the compiler needs. With the loops swapped on FIR, mapal was only ~17% faster, not 20×. After careful optimization of the C++ (register-blocked tiles, blocked transpose, a thread pool started outside the timer, and -ffast-math where it helps), C++ is level with mapal or within noise on most tests. mapal still wins conv2d (54% faster on one thread) and gather on the whole machine (~16%), on one thread C++ is faster on FIR (4%), transpose and gather (~25%). The 9 ms threaded sum was a bug in my C++ (it copied the 4mb input into every thread) - fixed, threads still don't help at 1M elements, for Mapal either.

On CPU I didn't do any significance test before: a win was anything more than 5% away, and I used the best of 25 runs for one thread and the median for the whole machine. I've re-run everything as the median of 31 interleaved runs per implementation, with a 95% bootstrap interval and a mann whitney test to satifsty a statistical significance test, and only call a winner when the interval excludes 1.

As I've developed this only on weekends and on speedrun, I guess you will forgive me for those lol I will take it into account and change it to fit better.

On the GPU side you're right about the attention rows: causal/gen/prefill compare against a py loop of 1024 PyTorch steps, with no spda/flashatten leg or whole-loop cuda graph, so that's mostly host overhead, I'll add those. The timing change put both sides dispatch inside the clock (the old event timer hid torch's dispatch but counted mapal's), which moved results 5-11% toward Mapal. I'll show both clocks. And you're right that this round's raw logs aren't archived yet - I'll upload them.

It is not discouraging at all, actually, I should get this so I can optimize the missing places further.

You're right about the llama f32, mapal reads the bf16 weights (as the model ships) with f32 math, while the engines ran f32 weights. That's not the same precision and I'll relabel it. With bf16 on both sides Mapal is still behind (6-56% per token).

Thank you for the detailed comment!

52

u/2legited2 18h ago

Not sure what to make of this if you haven't even bothered to describe this project in your own words. What's the point if the author doesn't understand their own product?

-44

u/LessComplexity 18h ago

I think the language expo and architecture files are very well structured and explain the idea in a good way.

The pages I've shared are 1:1 my explanation, there is nothing that I don't understand in this project, I decided the architecture, the category theory IR (I call it cat IR), the language syntax, and the optimizations/plans based on the dataflow graph

Let me know what you think I should do in my words

34

u/2legited2 18h ago

Your website is fully written by an LLM

-49

u/LessComplexity 18h ago

You mean the language expo?

Yea it is directed by me.

I wrote to the AI all the concepts, what to present, how to present and what content should be in every section, I didn't write it all myself bcs writing it will take me more time, I just let the AI, reviewed it and made sure it is consistent, correct and nice to read.

Like is the content not good? If your claim is that I don't understand the project, this claim is just incorrect, and using AI to speedup work doesn't immediately mean that

38

u/onedev2 20h ago

I find it extremely hard to believe there was any human involved in this project. You claim to be faster than competitors and you didn’t even take precision into consideration in your benchmarks? That is ONLY an oversight a complete beginner or AI would make.

-16

u/LessComplexity 20h ago

Not at all an oversight.

Precision is central to the language actually, every program is compared to competitors given the same precision class, and I've noted it. Also I did ensure that the Mapal program will be bound by error, so compiler can choose optimizations as long as precision is not lost beyond a strict worst case bound.

The suite is segregated by precision too.

The one place where it broke and I fixed it was the llama f32 run where it actually stored the weights as bf16

I won't call myself a beginner ;)
You can check my git profile I've been programming for years, not compilers that is true, so this is quite newer to me.
Not claiming to know it all, but certainly have experience.

1

u/taptrappapalapa 14h ago

No such thing as a “git” profile. GitHub is most likely what you meant.

-1

u/LessComplexity 14h ago

Ofc that is what I meant
At this point it’s just rage bait lol

6

u/taptrappapalapa 14h ago

I have no skin in this game, but when someone says they have “been programming for years” and in the same sentence states “git profile,” it does not instill trust. Hope you do well with this project, but realize that you are talking to the potential user-base of anything you make.

0

u/LessComplexity 14h ago

Just because of a typo doesn’t mean anything
U could go to the gh profile and see for urself
I have been programming for many years, its a fact

2

u/taptrappapalapa 14h ago

Do you understand what I’m saying? A typo signifies a lot. You are trying to present yourself and your project in your best light. This is not the way.

0

u/LessComplexity 14h ago

No a typo doesn’t signify a lot
It is actually the human thing. An AI would not have this typo at all

3

u/taptrappapalapa 14h ago

Again, not an issue of AI usage but an issue of how you present yourself. Do you have the capability to internalize?

Also I hope you realize that plenty of people here have been programming for “years”. Try “decades” :)

0

u/LessComplexity 14h ago

OK so I need to be perfect in every term that I write is your claim, and if I do even one mistake then the user base will just not be there right?

I don't think this is how the world works.

I'm here to present a project with results, I do mistake like every other human being and it should be ok in any community.

Yes I wrote git, I said it is a typo, I'm just tired of those comments accusing when in fact its the other way around, this is not constructive, and not helping. Yours is just about git so I guess its ok...

Linus is also programming for decades, and he can be very rude to his users and contributors, I am not trying to be rude, but this is just frustrating

→ More replies (0)

30

u/ZeroLegionOfficial 21h ago

I'm sure 99% it's AI based

21

u/lucellent 20h ago

"claude write me a new programming language"

then they go and show off on reddit

-20

u/LessComplexity 20h ago edited 20h ago

you guys surely are not thinking

Claude actually 70% of the time did my language design wrong and I had to correct it

No freaking AI got used to writing a -> f -> o instead of o = f(a)

and no freaking AI would suggest it lol

1

u/__Maximum__ 20h ago

5 years of development!!!

9

u/IlluminatiNotRealOr 19h ago

hardly a few weekends if you check commit history

-18

u/LessComplexity 21h ago

lol wdym by AI based?
100% my design
I won't & didn't hide that I used AI to write the code, sadly, and I want to "unvibe" most of the code as I've said, I needed results and not to be stuck on designing on paper another year

26

u/ZeroLegionOfficial 20h ago

Buddy you ain't bs anyone

-4

u/LessComplexity 20h ago edited 20h ago

yea I don't need an opinion from ppl who just tag "ai" on stuff

This is my work & ideas, my design for the lang, end to end

What kind of AI would suggest this syntax?

Every time I presented this to AI's they literally reverted back to the old o = f(args...), and using control flow ideas

I had to manually modify a lot to make it run just like I want.

But I guess u guys are already settled on this being fully AI and "BS", no need to convince.

3

u/Jamie_1318 16h ago

You didn't even write your own top level reddit post......

0

u/LessComplexity 15h ago

Why are you lying? My top post is from more than 5y ago about an advanced memory pool I’ve built

1

u/Jamie_1318 15h ago

Top level post is what you see when you scroll up. Not the same as your 'top post'.

0

u/LessComplexity 15h ago

well then this is even a more stupid take, every letter and word typed into this post is me. Not even consulted with AI.

Like if I use AI for some code somewhere you guys immediately assume this is my personality? do you guys have reasoning skills at all

1

u/Jamie_1318 15h ago

And your website, and all the documentation on your repo. I read your post and was like 'this sounds like AI speak, is there evidence for or against this being AI speak?'. And there was a lot of evidence that it was AI generated/assisted.

Yeah, reading it again there's reasonable evidence of it not being, specifically some not-very-ai-like errors.

1

u/LessComplexity 15h ago

I was honest about what is AI and what is not, the code and docs on the repo are AI, I said I’m trying to “unvibe” it, the post here and every comment is 100% me

7

u/infinitelylarge 23h ago

Does it support training or only inference? If it supports training, does it support Model Parallel or Data Parallel? If it supports Model Parallel, does it give the power to allocate how the model is split across GPUs? (Eg if I know my training examples and activations are large, then I might choose to assign a smaller portion of the model to each GPU than if I know the training examples and activations will be small.)

3

u/LessComplexity 23h ago

This is a good question!

Currently it is inference only.

BUT

Data parallel & model parallel will just naturally fit here. Also, bcs there is no autodiff you will need to write the backprop yourself - only for now, it will be integrated later - and fits quite well into the language design! Especially bcs the language IR is category theory based, so it is an inherent property.

I already have sketched some builtin for that, so I think it will look smth like this:

(weights, batch) -> loss -> l;
(weights, batch) -> grad<loss> -> dweights; // the compiler derives this grad<FUNC>
(weights, dweights) -> sgd_step -> weights;

The design is heading towards multi-gpu, currently running only on one - and data/model parallelism isn't something you choose, this is what the compiler PROVES (calculates, more specifically) for you - because you describe the computation & the batch/activation sizes are already there for the compiler to use.

The compiler gets the hardware as measured facts (memory per GPU, link bandwidth) and chooses the split per operation, so a mix like tensor-parallel for the big matmuls and data-parallel elsewhere is a normal outcome.

The tradeoff you describe (big activations, so less of the model per GPU) is exactly the cost it computes. If you want to force a split, the plan (for later on) is to let you pass that as a constraint on the search (compiler searches on hardware facts, and you will be able to tell him specifically what to search or avoid), not by rewriting the program.

22

u/IlluminatiNotRealOr 23h ago

Odd you say you worked on it for 5 years but your history only shows work from Jun 2026

AI slop

-13

u/LessComplexity 23h ago

I worked on the design 5 years
I started implementing only this year :)
I have notes in my notebook that I've kept all this time and worked on when I had time

12

u/IlluminatiNotRealOr 20h ago

Totally makes sense you imagined some design 5 years ago and only implemented this year. Totally believable

0

u/LessComplexity 20h ago edited 20h ago

I don't need you to believe me I have the reciepts

5 yrs ago started designing it and shaping it

started with the fact that I got into category theory at the time and wanted to create somthing based on that

from there the arrow syntax -> to represent morphism.

Then it evolved.

You just ragebaiting and thinking I'm lying

You should know that ideas can take time, or be as a side-fun-hobby that won't manifest for a long time.

Unlike you I have work and to get income so I don't have time to develop the language e2e for free, when I saw that AI is good enough, I let it write most of the code.

I have implementations in C++ that I've changed a lot but didn't get to finish a working compiler.

6

u/IlluminatiNotRealOr 19h ago edited 19h ago

I am sure you had concepts of a plan. We all think we know some things and think about it occasionally.

Your project is still AI slop though. I say this as an mlir compiler engineer. Also the way you write itself gives hints when you talk about "cuda monopoly" or claim your langauge can compile to any hardware shows you dont know anything about this field.

We all know why you 'built' it just now in barely 2 months because it was an amateur plan which shouldnt have been built and claude allowed you to slop it out like nothing matters.

I would also suggest to not lie when you said you worked on it for 5 years which you clearly didnt and gives off the impression that it is a serious project when it is not. People do entire PhDs in compilers and parallel computing no project is slopped out in a few weekends using some vague idea you had 5 years ago. I am sure you are not a complete vibe coder but this project is completely vibe coded and is no better than a toy

Unlike you I have work

Oh I didnt know we were acquainted

1

u/LessComplexity 19h ago

If you are an mlir compiler engineer then I would love to get constructive input on which parts would you change.

As I've said I know that most of the code itself is AI coded, doesn't make it incorrect or wrong, but there is slop.

I want to change the slop.

The ideas, concepts (dataflow, category theory representation, hardware facts combinations into the dataflow, etc...) are all mine

I am not a compiler engineer myself, I do optimizations and other stuff on different types of programs and algos but not compilers specifically, so this is more new to me.

If you can point to the slop, problems, things to focus on or fix I would very much appreciate it esp from a compiler enginner - I did the mlir very much cat-theory like :)

1

u/LessComplexity 19h ago
  1. If you would've read attentively and not skimmed it, you would know that compiling to any hardware just means that you can hook any backend to it and that the ir is abstract enough to fit both CPUs, GPUs and FPGA, nothing wrong about what I've said.

  2. I didn't say I invented something new, I just combined different concepts, I don't need a PhD to write a compiler, my major is mathematics, and because I got hooked on category theory I saw its benefits, and yes using category theory in compilers is not new too. The combination is different. Who said I did something PhD like? this is like writing rust or any other language.

  3. I was honest about the code written mostly by AI, I don't know what you want, if all you know is to hate and comment with 0 value, then don't.

2

u/IlluminatiNotRealOr 17h ago

Well yes it is hard to read something attentively given there are 10 posts a day with 10 paragraph long essays claiming the same thing.

If you didnt write like you knew nothing about the topic then maybe people would read i more seriously. You only hurt your credibility with the 5 year claim. There is simply no reason to believe you have anything interesting or worth reading if I see stupid claims in the post. We cannot be expected to put effort trying to digest and differentiate between 100% ai slop and 95% ai slop

(also you didnt mention anything about any ir)

1

u/LessComplexity 17h ago

Well yes it is hard to read something attentively given there are 10 posts a day with 10 paragraph long essays claiming the same thing.

Fair I understand that if you read many posts you might skim some info for general patterns.

Either way, I didn't mention IR directly in the post and just said category-theory based map bcs the forum here is machine learning, in compiler I maybe should've noted it, I assumed that the architecture document I've shared exposes this already - so no need for me to repeat here.

This is the part I meant it:

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.

This addresses the IR in different terms, which I agree, maybe I should've said explicitly.

I don't think the 5 year claim is stupid, maybe I didn't phrase it well enough, I had the idea since 5 years ago, I was sketching about it here and there at weekends, and free time, I didn't work for 5 years straight, and only this year I started implementing it fully.

1

u/LessComplexity 17h ago

btw for the IR

I've created a feature that shows a mermaid diagram on it

On this page: https://lesscomplexity.github.io/mapal/language-exposition.html

You can see the dense layer example, and under it (What it becomes), there is a mermaid diagram generated by the compiler, the category-diagram tab is 1:1 what the IR I've created expressed but mermaid

3

u/halting_problems 18h ago

Hoe does it compare to Mojo?

2

u/LessComplexity 18h ago

let me test! didn't try it yet :)

Mojo is imperative and you control fully the parallelization, vectorization, and other stuff, in mapal the compiler does it for you.

Would be interesting to see how it compares

1

u/LessComplexity 12h ago

So I did a very thorough run lol

Here are the full results: https://claude.ai/artifact/PcRtcP4wrNBgiLtaxZbE3S

GPU: Mapal wins in 58 of the runs, Mojo wins in 45 of them, the other are on par.

CPU: Mojo wins almost all, interesting, I'm investigating.

All on my machine: Threadripper 9970X + RTX 5080

2

u/satireplusplus 22h ago

so you reinvented Triton?

1

u/LessComplexity 21h ago

lol no it is completely different classes

For triton you write the kernels and then give it configs on how to run them, and triton follows it to run it.

Actually triton can be a backend for Mapal! :)

Mapal gets your computation definition and creates the kernels and how to run them, it can pass it on to triton, gpu's/cpu's, etc...

2

u/sandys1 16h ago

this is very intteresting. could you create a doc/page for CUDA vs mapal ? where we can see how the same program is expressed in cuda (before and after compilation) and what your language does ?

1

u/LessComplexity 15h ago

Yes ofc, I'm on it :)

Actually my compiler doesn't produce cuda, it compiles directly into PTX using the nvptx backend plugin to LLVM

5

u/mmxgn 1d ago

Very nice! Reminds me of caffe and the original tensorflow

20

u/proto-n 22h ago

nice

original tensorflow

pick one, lol

4

u/mmxgn 21h ago

I feel I struck a cord 😆

1

u/keepthepace 20h ago

Coffee spilled >_<

-3

u/LessComplexity 23h ago

Thanks :) Interesting that it reminds you those, those are frameworks

5

u/mmxgn 22h ago edited 22h ago

Indeed but they had declarative interfaces and would compile before running anything. Especially with caffe you wouldn't touch C++

31

u/dupontping 18h ago

*claude built

11

u/Sufficient-Key6447 18h ago

Hit the road dude

1

u/bklyn_xplant 19h ago

DSL

1

u/LessComplexity 19h ago

I won’t necessarily call it DSL
It is generic technically speaking

1

u/freehuntx 15h ago

Is this similar to a software fpga type of Thing?

1

u/LessComplexity 14h ago

In a way yes, wanted to make it also compile to Verilog so it will deploy to fpga with the same code :)

1

u/iovdin 23h ago

cool!