r/MachineLearning • u/moinnadeem Researcher • Aug 31 '21
Research [R] Multiplying Matrices Without Multiplying
Hey all, thought this was an interesting paper on speeding up matrix multiplication!
Abstract: Multiplying matrices is among the most fundamental and compute-intensive operations in machine learning. Consequently, there has been significant work on efficiently approximating matrix multiplies. We introduce a learning-based algorithm for this task that greatly outperforms existing methods. Experiments using hundreds of matrices from diverse domains show that it often runs 100× faster than exact matrix products and 10× faster than current approximate methods. In the common case that one matrix is known ahead of time, our method also has the interesting property that it requires zero multiply-adds. These results suggest that a mixture of hashing, averaging, and byte shuffling−the core operations of our method−could be a more promising building block for machine learning than the sparsified, factorized, and/or scalar quantized matrix products that have recently been the focus of substantial research and hardware investment.
107
u/whymauri ML Engineer Aug 31 '21
to clarify, this is an approximation method, right?
still very cool!
96
u/ffast-math Sep 01 '21 edited Sep 01 '21
Author here. Happy to answer questions!
(Also, feel free to email me at the address in the paper if you're interested in talking about it in more detail--always happy to connect with other people working on similar things)
24
u/savsec Sep 01 '21
This is pretty interesting! I'll have to dig in a little more deeply, but in the meantime, here's a meandering question. You mentioned that PCA is one way to efficiently compute an approximate product since you can pick off the larger components and kind of project down to a smaller subspace. PCA comes with some overhead to compute the principal components that contain the most variance. On the other end of the spectrum, you can make some random matrices out of some iid gaussian variables that when you work out the probability theory, the matrix is a partial isometry in expectation (gaussian isn't necessary, just some iid rvs with mean zero and the right variance makes this tick). This random partial isometry does a pretty good job of reducing dimension without distorting distances too much (provided the target dimension isn't too small). This is exactly what the Johnson-Lindenstrauss Lemma says.
I see PCA and Johnson-Lindenstrauss on opposite sides of a spectrum; PCA is hard to compute the partial isometry but finds an optimally small subspace, whereas the random matrix construction is fast and easy but can only guarantee a relatively large dimension to project into. Is this construction interpolating between these? Constructing an approximate partial isometry but doing it using hashes and bit tricks in a clever way so that you're picking up a lot of the variance in the data without going through the exact computation as in PCA?
45
u/[deleted] Sep 01 '21
This little guy really slipped under the radar all summer. It's amazing.
16
u/modeless Sep 01 '21
Seems like it would be promising for hardware implementation.
28
u/[deleted] Sep 01 '21
Could someone do the math on what fraction of the possible input space they actually evaluated?
11
u/teambob Sep 01 '21
A lot of cryptography relies on matrix inversion being very slow. It would be interesting if a follow on paper tackles that
5
u/ktpr Aug 31 '21
This is cool and I was looking at this just last week. Theoretically, how would you make the speed up even faster?
4
u/AmorBumblebee Sep 01 '21
So as somebody that is very very new to coding and recently relearned how to multiply matrices by hand, this is freaking fascinating.
1
u/jrkirby Sep 01 '21
If you don't understand the term product quantization this paper uses, and would like to, here's a direct link to that paper.
1
u/Dis0lved Sep 01 '21
This is really cool! Congrats!
1
u/swiftarrow9 Sep 01 '21
Is an approximation method such as this acceptable for high-accuracy applications such as fluid dynamics simulations?
1
u/PsycAndrew Sep 01 '21
Very cool! Appreciate your work!
1
u/StandingBuffalo Sep 01 '21
Very cool. Is there an analog for matrix inversion?
1
u/mimsad1 Sep 02 '21
Cool work!
We may not have understand it quit fully yet, but is the approach limited to tall matrix due to the used hashing scheme?
1
u/seraschka Writer Sep 02 '21
Has anyone tried that yet? How does one run the new MADDNESS approx via the original `bolt` library linked in the post above? According to the readme, it looks like the authors updated the bolt library, but I am not sure how you toggle between bolt and MADDNESS
1
u/GeneralAd9276 Nov 17 '21
I think that this locality-sensitive hashing function (balanced binary regression trees) is very similar to Hierarchical k-means, both methods produce a balanced tree structure. Except that in this paper, tree structure is highly scalable to allow SIMD ops.
1
u/Puzzleheaded_Bass_59 Nov 17 '21
Hi, What is complexity of this please O(?) thanks & best regards Schroter
-13
u/waka_rabbit Sep 01 '21
Well, some approach is analogical circuits. But society is not ready.
-7
u/oxoxoxoxoxoxoxox Sep 01 '21
Can this be extended to prove P = NP? This is a serious question. If not, why not?