Tenstorrent Grayskull 上的 SRAM 注意力机制
Attention in SRAM on Tenstorrent Grayskull
AI总结:
针对 Tenstorrent Grayskull 架构,提出利用其大容量 SRAM 的融合注意力内核和专用 Softmax 内核,相比 CPU 实现分别获得最高 10 倍和约 1.8 倍的加速,且成本远低于高端 GPU。
摘要:
当 Transformer 的自注意力层利用 SRAM 而非 DRAM 时,可以实现显著的加速。Tenstorrent Grayskull 架构提供了分布在核心网格上的大容量 SRAM。本工作为 Grayskull 提出了一种融合内核,该内核通过结合矩阵乘法、注意力分数缩放和 Softmax 操作,完全利用其大容量 SRAM。此外,还提出了一个利用 SRAM 的专用 Softmax 内核,以及一个作为基线的 CPU 实现。在 Grayskull 上,从查询和键计算注意力权重的过程中,Softmax 操作消耗了大部分运行时间。与 CPU 实现相比,专用 Softmax 内核的加速比高达 10 倍,而融合内核内部的 Softmax 实现比专用 Softmax 内核快约 1.8 倍。所有实现的时间和内存复杂度均为序列长度的二次方。目前,Grayskull e150 对公众而言比 Nvidia H100 PCIe(一种最先进的 GPU)便宜约 30 倍,并提供约 1.5 倍的 SRAM。
英文摘要:
When implementations of the Transformer's self-attention layer utilize SRAM instead of DRAM, they can achieve significant speedups. The Tenstorrent Grayskull architecture provides a large SRAM, distributed across a grid of cores. This work presents a fused kernel for Grayskull, that exclusively utilizes its large SRAM by combining matrix multiplication, attention score scaling and Softmax operations. Additionally, a dedicated Softmax kernel utilizing the SRAM and a CPU implementation serving as a baseline are presented. The Softmax operation consumes most of the runtime in the computation of attention weights from queries and keys on Grayskull. The speedup of the dedicated Softmax kernel compared to the CPU implementation is up to $10 \times$, and the Softmax implementation inside the fused kernel is approximately $1.8 \times$ faster than the dedicated Softmax kernel. The time and memory complexity of all implementations is quadratic in sequence length. Currently, the Grayskull e150 is approximately $30 \times$ cheaper for the general public than an Nvidia H100 PCIe (a state-of-the-art GPU) and offers approximately $1.5 \times$ more SRAM.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。