RISC-V向量处理器中具有低成本指数计算的向量化FlashAttention
Vectorized FlashAttention with Low-cost Exponential Computation in RISC-V Vector Processors
AI总结:
本研究首次在RISC-V向量处理器上向量化FlashAttention,通过低成本指数近似和优化平铺策略,无需扩展指令集即显著提升注意力层处理性能。
摘要:
注意力机制是众多机器学习和人工智能模型中的核心操作。本研究聚焦于在向量处理器中,特别是基于RISC-V指令集架构(ISA)的处理器上,利用FlashAttention算法加速注意力内核。本研究首次尝试将FlashAttention向量化,最小化标量代码,并简化注意力中softmax所需的指数评估的计算复杂度。通过利用浮点运算中低成本的指数近似,我们在无需扩展基线向量ISA以添加新自定义指令的情况下,降低了指数函数的计算成本。此外,我们探索了适当的平铺(tiling)策略以改善内存局部性。实验结果凸显了我们方法的可扩展性,展示了在实际应用中处理注意力层时,向量化实现带来的显著性能提升。
英文摘要:
Attention is a core operation in numerous machine learning and artificial intelligence models. This work focuses on the acceleration of attention kernel using FlashAttention algorithm, in vector processors, particularly those based on the RISC-V instruction set architecture (ISA). This work represents the first effort to vectorize FlashAttention, minimizing scalar code and simplifying the computational complexity of evaluating exponentials needed by softmax used in attention. By utilizing a low-cost approximation for exponentials in floating-point arithmetic, we reduce the cost of computing the exponential function without the need to extend baseline vector ISA with new custom instructions. Also, appropriate tiling strategies are explored with the goal to improve memory locality. Experimental results highlight the scalability of our approach, demonstrating significant performance gains with the vectorized implementations when processing attention layers in practical applications.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。