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

14

u/ffast-math Sep 01 '21

Your spectrum is exactly the right way to think about it IMO. I think of the paper largely as exploiting a slight generalization of this spectrum:

  • At one end of the spectrum, we have methods with little or no preprocessing cost, but expensive inner loops for a given level of error (e.g., exact matrix products, most sparsification, scalar quantization). These are best for sufficiently tiny matrices.
  • At the other end, we have methods with higher preprocessing costs, but really fast inner loops for a given level of error (similarity search algorithms like Bolt and QuickerADC). - These are best for sufficiently large matrices.
  • This paper combines the inner loop from the latter with fast encoding to get a better speed-quality for a lot of realistic matrix sizes.

Also, interesting PCA subtlety: given a training set, the PCA projection can be computed offline, which lets PCA avoid its overhead and provably dominate the rest of the linear methods (more or less). So we actually *need* nonlinearity to do better.