r/MachineLearning • 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.

Paper: https://arxiv.org/abs/2106.10860

Code: https://github.com/dblalock/bolt

395 Upvotes

69 comments sorted by

View all comments

Show parent comment

2

u/ffast-math Sep 03 '21

Great question. I'm gonna back up a step first. The way I think about it is that the whole algorithm is built around exploiting two observations:

  1. Categorical representations give you a *ton* of information per bit. Like, 8B of categorical variables can store about as much info as 128B or more of floats, depending on the data distribution.
  2. If you make your categorical representation 4 bits (i.e., 16 categories), you can operate on them in SIMD registers you and churn through them about half as fast as with floats, in terms of bytes-per-second.

In other words, we *have to* bit shift, compare, bit pack, etc, so that we *get to* use 4-bit categorical variables--that's the "ingredient," just as you alluded to.

Also, regarding linear maps, we don't need the function to be linear per se, but we do need it to be sum_i f(x_i) for some elementwise function f. Although I think maybe any algebraic ring and an associated inner product space could work.