[论文解读] Monarch Mixer: A Simple Sub-Quadratic GEMM-Based Architecture
Monarch Mixer (M2) 通过 Monarch 矩阵引入子二次混合,在非因果、因果和视觉任务中实现与 Transformer 相当或更好的性能,同时参数量更少。它在序列长度和模型维度上都实现了子二次扩展,并提供一个因果参数化。
Machine learning models are increasingly being scaled in both sequence length and model dimension to reach longer contexts and better performance. However, existing architectures such as Transformers scale quadratically along both these axes. We ask: are there performant architectures that can scale sub-quadratically along sequence length and model dimension? We introduce Monarch Mixer (M2), a new architecture that uses the same sub-quadratic primitive along both sequence length and model dimension: Monarch matrices, a simple class of expressive structured matrices that captures many linear transforms, achieves high hardware efficiency on GPUs, and scales sub-quadratically. As a proof of concept, we explore the performance of M2 in three domains: non-causal BERT-style language modeling, ViT-style image classification, and causal GPT-style language modeling. For non-causal BERT-style modeling, M2 matches BERT-base and BERT-large in downstream GLUE quality with up to 27% fewer parameters, and achieves up to 9.1$ imes$ higher throughput at sequence length 4K. On ImageNet, M2 outperforms ViT-b by 1% in accuracy, with only half the parameters. Causal GPT-style models introduce a technical challenge: enforcing causality via masking introduces a quadratic bottleneck. To alleviate this bottleneck, we develop a novel theoretical view of Monarch matrices based on multivariate polynomial evaluation and interpolation, which lets us parameterize M2 to be causal while remaining sub-quadratic. Using this parameterization, M2 matches GPT-style Transformers at 360M parameters in pretraining perplexity on The PILE--showing for the first time that it may be possible to match Transformer quality without attention or MLPs.
研究动机与目标
- 在序列长度和模型维度上同时扩展的子二次架构的动机与开发。
- 展示 Monarch 矩阵可以表达广泛的线性变换并且对 GPU 硬件友好。
- 在非因果语言与视觉任务以及因果语言建模中展示 M2 的性能。
- 为基于 Monarch 的层提供因果参数化的理论基础。
- 在吞吐量和参数效率上对比 Transformer 基线进行基准测试。
提出的方法
- 将 Monarch 矩阵定义为分块对角因子的乘积,交错置换以实现 O(p N^{(p+1)/p}) 的计算量。
- 通过沿序列和嵌入轴对 Monarch 块和逐元素运算来构建 M2,完成混合。
- 在 BERT 风格、ViT 风格和 GPT 风格设置中,用 M2 原语替代 Transformer 的注意力和 MLP 块。
- 通过多变量多项式求值/插值提供因果参数化,以实现子二次因果屏蔽。
- 从理论上分析 M2 参数化的因果性条件(定理 3)。
- 提供实现叙述和在 GPU 上的硬件利用基准。
实验结果
研究问题
- RQ1一个子二次原语(Monarch 矩阵)是否可以在序列长度和模型维度上提供与 Transformer 相当或更优的性能?
- RQ2是否可以在具备子二次计算量的前提下实现 Monarch 基层的因果性?
- RQ3在非因果语言、因果语言和视觉任务中,M2 变体是否能在减少参数的同时达到或超过 Transformer 的性能?
- RQ4相对于密集的 MLP 与注意力,M2 的硬件利用特征如何?
- RQ5多项式解释视角如何为 M2 提供有原理的因果参数化?
主要发现
- 在非因果语言建模中,M2 在参数分别减少 27% 和 24% 的情况下达到 BERT-base 与 BERT-large 的 GLUE 质量。
- M2 在序列长度为 4K 时的吞吐量最高可比 HuggingFace 的 BERT 高出 9.1×。
- 在 ImageNet 上,M2-ViT-b 的性能比 ViT-b 高出 1%,参数量只有一半。
- 带有因果参数化的 M2-GPT 在 The PILE 上达到类似 GPT 风格 Transformer 的困惑度,参数为 360M 时无注意力/MLP。
- 在因果设置中,M2 实现了具有竞争力的困惑度,显示出潜力在结构完全不同的情况下达到 Transformer 的质量。
- 在各基准上,M2 展示出有利的 FLOP 利用率和对 dense 基线的子二次扩展增益。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。