arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2311.05908cs.LG
收藏

FlashFFTConv:利用张量核心实现长序列的高效卷积

FlashFFTConv: Efficient Convolutions for Long Sequences with Tensor Cores

Stanford University(斯坦福大学)

Daniel Y. Fu, Hermann Kumbong, Eric Nguyen, Christopher Ré

AI总结:

针对长序列卷积中FFT硬件利用率低的问题,提出FlashFFTConv,利用矩阵分解和核融合优化FFT卷积,并引入两种稀疏卷积算法,显著提升速度与模型性能。

摘要:

具有长滤波器的卷积模型在许多长序列任务中展现出最先进的推理能力,但在墙钟时间上落后于优化最好的Transformer。一个主要瓶颈是快速傅里叶变换(FFT)——它使得长卷积在序列长度N下以O(N logN)时间运行,但硬件利用率较低。在本文中,我们研究如何优化FFT卷积。我们发现了两个关键瓶颈:FFT没有有效利用专门的矩阵乘法单元,并且它在内存层次结构的层之间产生昂贵的I/O。为此,我们提出了FlashFFTConv。FlashFFTConv使用一种矩阵分解,通过矩阵乘法单元计算FFT,并实现长序列的核融合,从而减少I/O。我们还提出了两种稀疏卷积算法——1)部分卷积和2)频率稀疏卷积——它们可以通过在矩阵分解中简单地跳过块来实现,从而进一步节省内存和计算。FlashFFTConv将精确FFT卷积的速度比PyTorch提升最多7.93倍,端到端速度提升最多4.4倍。在相同计算预算下,FlashFFTConv使Hyena-GPT-s在PILE上困惑度提升2.3点,使M2-BERT-base的GLUE分数提升3.3点——与参数数量两倍的模型相匹配。FlashFFTConv在Path-512上还实现了96.1%的准确率,这是一个高分辨率视觉任务,此前没有模型取得超过50%的成绩。此外,部分卷积支持更长序列的模型——产生了第一个能够处理最长人类基因(2.3M碱基对)的DNA模型——而频率稀疏卷积加速了预训练模型,同时保持或提高了模型质量。

英文摘要:

Convolution models with long filters have demonstrated state-of-the-art reasoning abilities in many long-sequence tasks but lag behind the most optimized Transformers in wall-clock time. A major bottleneck is the Fast Fourier Transform (FFT)--which allows long convolutions to run in $O(N logN)$ time in sequence length $N$ but has poor hardware utilization. In this paper, we study how to optimize the FFT convolution. We find two key bottlenecks: the FFT does not effectively use specialized matrix multiply units, and it incurs expensive I/O between layers of the memory hierarchy. In response, we propose FlashFFTConv. FlashFFTConv uses a matrix decomposition that computes the FFT using matrix multiply units and enables kernel fusion for long sequences, reducing I/O. We also present two sparse convolution algorithms--1) partial convolutions and 2) frequency-sparse convolutions--which can be implemented simply by skipping blocks in the matrix decomposition, enabling further opportunities for memory and compute savings. FlashFFTConv speeds up exact FFT convolutions by up to 7.93$\times$ over PyTorch and achieves up to 4.4$\times$ speedup end-to-end. Given the same compute budget, FlashFFTConv allows Hyena-GPT-s to achieve 2.3 points better perplexity on the PILE and M2-BERT-base to achieve 3.3 points higher GLUE score--matching models with twice the parameter count. FlashFFTConv also achieves 96.1% accuracy on Path-512, a high-resolution vision task where no model had previously achieved better than 50%. Furthermore, partial convolutions enable longer-sequence models--yielding the first DNA model that can process the longest human genes (2.3M base pairs)--and frequency-sparse convolutions speed up pretrained models while maintaining or improving model quality.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑