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

基于克罗内克稀疏矩阵的快速推理

Fast Inference with Kronecker-Sparse Matrices

ENS de Lyon, CNRS, Inria, Université Claude Bernard Lyon 1, LIP, UMR 5668, 69342, Lyon cedex 07, France;Huawei Lagrange Mathematics;Computing Research Center, Paris, France;Institute of Mathematics, EPFL, Lausanne, Switzerland;Toulouse School of Economics, Toulouse, France

Antoine Gonon, Léon Zheng, Pascal Carrivain, Quoc-Tung Le

AI总结:

针对现有KS矩阵乘法GPU内核数据移动成本高的问题,提出融合式输出驻留GPU内核,大幅降低内存流量,实现速度与能耗优化,并通过实际模型验证了端到端延迟降低效果,同时开源了相关代码。

摘要:

克罗内克稀疏(Kronecker-sparse,KS)矩阵——其支撑集为单位矩阵与全1块的克罗内克积——是Butterfly矩阵和Monarch矩阵的结构基础,有望实现更高效的模型。然而,现有用于KS矩阵乘法的GPU内核存在数据移动成本高的问题,高达50%的时间耗费在内存受限的张量置换上。我们提出了一种融合式、输出驻留的GPU内核,可消除这些开销,将全局内存流量降低三倍。在600种KS模式下,我们的内核在FP32精度下实现了1.4倍的中位加速比,并将能耗降低15%。一种基于KS模式参数的简单启发式算法可预测我们的方法何时优于现有方法。我们在github.com/PascalCarrivain/ksmm上发布了所有代码,包括一个兼容PyTorch的KSLinear层,并展示了在FP32精度下,ViT-S/16的端到端延迟降低高达22%,GPT-2 medium的端到端延迟降低16%。

英文摘要:

Kronecker-sparse (KS) matrices -- whose supports are Kronecker products of identity and all-ones blocks -- underpin the structure of Butterfly and Monarch matrices and offer the promise of more efficient models. However, existing GPU kernels for KS matrix multiplication suffer from high data movement costs, with up to 50% of time spent on memory-bound tensor permutations. We propose a fused, output-stationary GPU kernel that eliminates these overheads, reducing global memory traffic threefold. Across 600 KS patterns, our kernel achieves in FP32 a median speedup of x1.4 and lowers energy consumption by 15%. A simple heuristic based on KS pattern parameters predicts when our method outperforms existing ones. We release all code at github.com/PascalCarrivain/ksmm, including a PyTorch-compatible KSLinear layer, and demonstrate in FP32 end-to-end latency reductions of up to 22% in ViT-S/16 and 16% in GPT-2 medium.

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

↑