DYAD:一种兼具描述性且规避密度的线性神经网络层高效近似方法
DYAD: A Descriptive Yet Abjuring Density efficient approximation to linear neural network layers
AI总结:
本研究提出可近似替代线性层的DYAD层,基于可分解为两块稀疏矩阵之和的近稀疏结构,在多种架构和基准上性能达稠密层90%以上,训练速度提升7%-15%且随规模增大提速更明显。
摘要:
我们设计、实现并评估了DYAD层,它可作为更快、内存效率更高的线性层(PyTorch中的nn.Linear())近似替代方案。这类层常见于Transformer的前馈(ff)模块等通用子组件中。DYAD基于一种定制的近稀疏矩阵结构,用于近似此类层(即DENSE层)典型实现中与输入做矩阵乘法的稠密“权重”矩阵W。我们提出的替代近稀疏矩阵结构可分解为2个矩阵之和,且这两个矩阵均可置换为块稀疏形式;它们可表示为3D张量,与小批量输入矩阵X做矩阵乘法时的执行速度比DENSE层更快(时间复杂度从O(W的行数 × W的列数)降至O(W的行数 × W的列数 / 块数))。实验核心部分是,我们在babyLM基准的不同token规模下,预训练了2种规模OPT架构和1种规模Pythia架构的DYAD和DENSE变体。结果发现,DYAD在零样本(如BLIMP)、少样本(OPENLM)和微调(GLUE)基准上的性能可达到DENSE的90%及以上,即便在1.25亿参数规模下,GPU上的训练速度也快7%-15%,且随着规模和模型宽度增加,提速效果更显著。
英文摘要:
We devise, implement and performance-asses DYAD, a layer which can serve as a faster and more memory-efficient approximate replacement for linear layers, (nn.Linear() in Pytorch). These layers appear in common subcomponents, such as in the ff module of Transformers. DYAD is based on a bespoke near-sparse matrix structure which approximates the dense "weight" matrix W that matrix-multiplies the input in the typical realization of such a layer, a.k.a DENSE. Our alternative near-sparse matrix structure is decomposable to a sum of 2 matrices permutable to a block-sparse counterpart. These can be represented as 3D tensors, which in unison allow a faster execution of matrix multiplication with the mini-batched input matrix X compared to DENSE (O(rows(W ) x cols(W )) --> O( rows(W ) x cols(W ) # of blocks )). As the crux of our experiments, we pretrain both DYAD and DENSE variants of 2 sizes of the OPT arch and 1 size of the Pythia arch, including at different token scales of the babyLM benchmark. We find DYAD to be competitive (>= 90%) of DENSE performance on zero-shot (e.g. BLIMP), few-shot (OPENLM) and finetuning (GLUE) benchmarks, while being >=7-15% faster to train on-GPU even at 125m scale, besides surfacing larger speedups at increasing scale and model width.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。