利用快速沃尔什-哈达玛变换工程化压缩矩阵乘法
Engineering Compressed Matrix Multiplication with the Fast Walsh-Hadamard Transform
AI总结:
该研究通过快速沃尔什-哈达玛变换改进压缩矩阵乘法,实现高速计算并优于现有DGEMM性能。
摘要:
我们提出了Pagh压缩矩阵乘法算法的一种实现,这是一种随机算法,通过构建矩阵的草图来计算其乘积的无偏估计。通过利用FFT实现快速多项式乘法,该算法在乘积矩阵稀疏或仅包含少量具有显著大于其余元素大小的条目时能够实现高性能。我们实证显示该算法具有实用性,并且在乘积矩阵具有少量非零元素或由少量大元素主导时能够超越最先进的DGEMM实现。作为次要的理论贡献,我们在草图乘法中用快速沃尔什-哈达玛变换(FWHT)取代FFT,保持了原始算法的所有正确性和方差保证。在我们精心设计的多线程CPU实现上,针对64核CPU节点上的各种合成基准测试,展示了变量稀疏性模式,结果显示FWHT变体比基于FFT的版本快4倍。在乘积矩阵具有有利稀疏性和大小模式时,我们的FWHT实现相对于Intel MKL的DGEMM实现了高达40倍的加速,估计误差的概率很低。我们的实现作为免费软件发布,并附带与NumPy兼容的Python绑定。
英文摘要:
We present an implementation of Pagh's compressed matrix multiplication algorithm, a randomized algorithm that constructs sketches of matrices to compute an unbiased estimate of their product. By leveraging fast polynomial multiplication via the FFT, the algorithm achieves high performance when the product matrix is sparse or contains only a small number of entries with magnitudes significantly larger than the rest. We show empirically that the algorithm is practical and can outperform state-of-the-art DGEMM implementations when the product matrix has few nonzero entries or is otherwise dominated by a small subset of elements with large magnitude. As a minor theoretical contribution, we replace the FFT with the Fast Walsh-Hadamard Transform (FWHT) in sketched multiplication, preserving all correctness and variance guarantees of the original algorithm. Experiments with our carefully engineered multithreaded CPU implementation for dense double-precision matrices on 64-core CPU nodes across a range of synthetic benchmarks, exhibiting variable sparsity patterns, show that the FWHT variant is up to 4 times faster than the FFT-based version. Under favorable sparsity and magnitude patterns in the product matrix, our FWHT-based implementation achieves a speedup of up to 40 over DGEMM from Intel MKL, with low probability of error in the estimates. Our implementation is released as free software and comes with NumPy-compatible Python bindings.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。