53 points · by matt_d · 1y ago · 18 comments
Oh no, I'm never not going to read this as "tera-electron Volts". I wish they picked a different acronym!
So much computation these days are done on tensors, mostly for easy parallelism reasons. But we can't get completely rid of recursion. Great to have work like this making them more computationally compatible!
in order to perform that kind of canonicalization/folding/cse you effectively need to embed a whole-ass tensor ops interpreter into your compiler. note this isn't so far-fetched
https://github.com/openxla/stablehlo/blob/main/docs/interpre...
the problem is it needs to be performant as well. so what some people do is jit these canonicalizations using the compiler (yo dawg i heard you like compiling...).
also FYI they're not magically calculating closed form solutions to recurrence relations here (that's not possible) - they're basically just iterating the loop arithmetic.
For this case, you can actually calculate a closed form for many recurrences, in the same way that SCEV works. You don’t need to interpret the loop to do this. If you mark your induction variables and put the loop in the right form then it’s possible to do recurrence analysis in constant time. This isn’t particularly complex or novel (and, to be fair, the paper doesn’t do much other than go “hmm what if we did this for tensors”) so I suggest you look up how it’s done in traditional compilers.
SCEV does not compute closed forms ... because that's impossible. if you don't understand why it's impossible you can consult this same team's slides on SCEV in LLVM, a "traditional compiler":
https://llvm.org/devmtg/2018-04/slides/Absar-ScalarEvolution...
specifically pages 16-18
int foo = 0;
for (int i = 0; i < n; ++i) {
foo += 1;
}
Both foo and i have an addrec of {0, +, 1}. Given the loop iteration count n it is pretty clear that you can calculate the value at exit to be n without actually running the loop n times. In fact you don't even know n and can still convert it to a closed form at compile time. So what's the point of disagreement here?I’m guessing lots of people who are on HN. I’ll go with - me for one. Guessing I’m not alone.
Remember - it’s a big world. Lots of POVs.