We accidentally built an LLVM compiler for Jax
Posted by infinitewalk 3 days ago
Comments
Comment by kingstnap 1 day ago
> this is not going to beat XLA for standard deep learning workloads. XLA has years of hyper-specific optimizations for linear algebra on GPUs and TPUs.
I'm not so convinced about this.
It's actually really easy to write two mathematically equivalent formulations in Python of something basic that have over a 2x performance difference in them after jax jit.
XLA is not that smart. And I'm not talking some niche nonsense I mean simple matrix multiplication graphs and residual connections on the CUDA backend.
Comment by kingstnap 1 day ago
Can you figure out that 16 matrix vector multiplications into a concatenate is the same as concatenating first into a matrix matrix operation which can go on the GEMM. This is like the most basic thing you can imagine doing.
Turns out no it doesn't and there is a 23% performance difference by moving the concatenate up in the python code in my specific test.
Not to say that it didn't recognize it. I had an agent look at the XLA and the graph actually does a partial fusion into a sum and stack. But does not realize the whole thing is just a GEMM.
In more complicated examples the differences you can get can be much larger.
Comment by Gangway0829 1 day ago
I think this is a great area for LLMs. You write the correct physics code, the LLM analyzes intent and goes back and forth with the compiler and your correct code to rewrite it in something that emits performant code
Comment by Archit3ch 22 hours ago
> Something to note is that quantum algorithms are never purely quantum. There is a tonne of classical processing needed to get inputs ready, post-process outputs, and even construct and represent the quantum circuits themselves.
2. Did you face any problems for the 'surrounding' areas by JAX imposing the limitation of pure functions?
Comment by infinitewalk 18 hours ago
Comment by Archit3ch 18 hours ago
Comment by Gangway0829 14 hours ago
And having spent too much of my life writing some extremely high performance physics code, 99% of the code complexity comes from the stupid stuff, like handling configuration and IO and restarting. Python handles that stuff great. Oh, and tests. Ever tried to write unit tests in Fortran? You'll hug python tight and promise it you'll never leave again.
Comment by steeve 1 day ago
I don't get it, Bazel is incredible.
Comment by melodyogonna 1 day ago
Comment by fragmede 23 hours ago
Comment by ndesaulniers 1 day ago
> So if XLA already uses LLVM, why is our approach different?
Uses MLIR, XLA does not.
> So… what is the point?
> Honestly? We aren’t entirely sure yet.
> Let me be perfectly clear: this is not going to beat XLA for standard deep learning workloads. XLA has years of hyper-specific optimizations for linear algebra on GPUs and TPUs. If you are training a massive transformer, stick to standard JAX.
> But what we do think is cool is what happens when you connect JAX directly to the broader LLVM ecosystem and drop the heavy XLA runtime. (Plus, no need to build XLA using Bazel either! You’re welcome.)
Comment by infinitewalk 1 day ago
I would love to hear those stories! Sadly I'm based in Toronto, so dropping by the Bay Area meetups isn't in the cards anytime soon.
If any of that history ever makes it into a blog post, I'd be first in line to read it.
Comment by gregdaniels421 1 day ago
Comment by mathisfun123 1 day ago
Comment by gregdaniels421 1 day ago
I am an active contributer to MLIR, if you knew my name and you weren't some weirdo, you could know me. This is a pseudonym account of which I have several, since I grew up in an age where you hid your identity. Now how XLA interacts with that I have no clue dude. Maybe help with that and don't be a low effort dick.
Comment by mathisfun123 1 day ago
relax you'll live longer.
Comment by steeve 1 day ago
Comment by ndesaulniers 22 hours ago
Comment by mathisfun123 1 day ago
https://github.com/search?q=repo%3Aopenxla%2Fxla+mlir&type=c...
> 1.5k files
you're behind the times. XLA moved over probably ~2 years ago - "Captain Awesome" eventually relented.
Comment by throwaway647272 1 day ago
Comment by ndesaulniers 22 hours ago