No code golf! While low line count is a guiding light of this project, anything that remotely looks like code golf will be closed. The true goal is reducing complexity and increasing readability, and deleting \ns does nothing to help with that.
https://github.com/tinygrad/tinygrad?tab=readme-ov-file#cont...
You can look at the PyTorch code base and understand a small local function instantly, but if I would have a task to have a deep understanding of either PyTorch with all kernel code and low level code, whole CUDA code base + LLVM compilation code or Tinygrad I would pick Tinygrad in an instant.
The code looks hard because what it is doing is hard, but all its layers can be debugged.
If the goal is to not abstract anything away, and always look at the implementation itself to be able to change it / rewrite it, keep it tiny and it is able to beat PyTorch+CUDA+LLVM with 1000x smaller codebase, who am I to judge?
https://github.com/tinygrad/tinygrad/blob/master/tinygrad/co...
One of the cases why I think obsession with lines of code is one of the most counterproductive metrics, it always produces code like this.
The far more interesting part is the order of magnitude. If they can pull off a 20k LOC with zero dependencies (implying a pretty concise project size) and it still works well on meaningful applications, that’s pretty neat. A 1000x reduction in code size and matching/exceeding in perf is worth looking at. Probably also implying a better architecture as code golf isn’t gonna get you 1000x less code. Again - their claims not mine, so we’ll see.
But at that point they can triple the LOC to 60k with nothing but white space, new lines, and comments, for all I care. It won’t even add a zero.
I often find myself wishing this was more ergonomic in languages.
Declarations flow down the page, definitions flow across.
I'm going to guess that you're used to codebases that use an autoformatter.
There's definitely a case to be made for autoformatters in projects with a very large (>100) number of developers, but the price you pay for that is much poorer information density per screenful of code.
For things like tinygrad or sqlite with a small dev team it's possible to use whitespace, style, and formatting to communicate important information, just like mathematicians do. The AMS journals don't autoformat mathematicians' equations!
I'm used to Python code being "Pythonic" - which is one of those "I know it when I see it" terms.
But if you have hundreds of developers on a project it does in fact make sense to sacrifice that signal in order to keep them from fighting with each other over silly formatting choices.
I think there is an opportunity there to have a tag in comments for tests.
Have a hotkey to generate an id so you could have
# lift x+y out of reduce on lt :testID: color_adjective_noun
((UPat.var("x")+UPat.var("y")).or_casted() < UPat.var("c"), lambda x,y,c: (x < (c.cast(y.dtype)-y)) if no_range(y) and no_range(c) else None),
and it creates a test that exists away from the main codebase. A process that runs tests could scan the code for testID's, intelligently extract the relevant part of the code into the test harness and runs the tests. There would need to be some infrastructure needed to handle placing the code to be tested into the right context but you could have 1. A codebase that contained no active code required simply to facilitate tests,
2. All test tags auto removable for distribution buildsI agree. Seems to be a personal preference, but still feels odd.
I think if I dealt with this on a daily basis I might end up finding if vastly more preferable, albeit at the risk of alienating fellow developers. In that respect it seems much like learning to use Emacs or vi
I agree with some poster above, the code looks hard simply because the problem is very hard, not because they want to write it that way.
It helps that a single person can read all related bits on one screen.
Funny to me that it is called simplify.py
LLMs have done two things for us: made lines of code a commodity, but arguably even more important: made understanding an arbitrary amount of lines of code a commodity too.
with this in hand, large codebases that were designed in the primordial era of requiring human cognition to grok are emabarassingly antiquated.
"umm what does this mean?" -> right click -> explain with AI -> "got it".
I literally reddit-soyjacked when i saw "tackle LLVM removal". I would argue that LLVM was/is the most well thought out and well-architected piece of software that exists today... but in the age of AI... who could possibly care now? when I say "well thought out" and "well-architected", that is in the context of human eyeballs. But who needs human eyeballs when we have much more powerful computer eyeballs? who grok code way better and way faster than we do.
now, the massive line count of projects like LLVM, Linux, and Chrome become much harder to defend in the context of code re-use. Why drag in millions of code when you can get an LLM to write just the bits you care about? LLVM has a ton of optimisations that are all well and good, but how many of them actually move the needle on HPC platforms that do an awful lot of instruction re-ordering and re-scheduling anyway?
Could we get away with 5% of the codebase to do "just the bits we care about"? in the past the answer might be, "well yes but its still a lot of (manual) coding", but now - why not? Let an LLM loose on the design doc and fill in the gaps!
GPUs don't reorder instructions at all.