ScanWeaver:通过关联扫描降级实现仿射递归的编译器驱动并行化
ScanWeaver: Compiler-Driven Parallelization of Affine Recurrences via Associative Scan Lowering
AI总结:
提出ScanWeaver编译器框架,将基于递归的计算转换为关联扫描表示并降级为可执行GPU程序,以解决Mamba等选择性状态空间模型中的输入相关扫描递归的并行化问题。
摘要:
诸如Mamba之类的选择性状态空间模型突显了输入相关扫描递归的实际重要性,这些递归在保持线性时间序列建模的同时提高了语言建模能力。然而,与经典的结构化SSM相比,这些递归引入了更严格的顺序依赖性,限制了在现代加速器上的并行执行。我们提出了 extbf{ScanWeaver},一个编译器框架,它将基于递归的计算转换为关联扫描表示,并端到端地降级为可执行的GPU程序。我们使用Mamba风格的选择性扫描作为更广泛的仿射递归类的激励示例,这些递归出现在现代机器学习工作负载中。ScanWeaver并非针对单个模型家族,而是将这种递归结构提升为一等编译器抽象,从而实现了基于MLIR的系统性降级,以在GPU上执行编译器生成的Blelloch扫描。在具有匹配局部递归语义的前向选择性扫描工作负载上,我们验证了仿射递归分解、Blelloch降级、MLIR GPU降级、可执行工件生成以及从生成的MLIR实际执行GPU。我们将生成的ScanWeaver GPU执行与PyTorch和CUDA顺序基线进行了基准测试,并包含了Mamba内核作为融合生产基线以提供系统上下文。
英文摘要:
Selective state-space models such as Mamba highlight the practical importance of input-dependent scan recurrences, which preserve linear-time sequence modeling while improving language modeling capabilities. However, these recurrences introduce stricter sequential dependencies than classical structured SSMs, limiting parallel execution on modern accelerators. We present \textbf{ScanWeaver}, a compiler framework that transforms recurrence-based computations into associative scan representations and lowers them end-to-end to executable GPU programs. We use Mamba-style selective scan as a motivating example of a broader class of affine recurrences that arise in modern ML workloads. Rather than targeting a single model family, ScanWeaver elevates this recurrence structure to a first-class compiler abstraction, enabling systematic MLIR-based lowering to compiler-generated Blelloch scan execution on GPUs. Across forward selective-scan workloads with matched local recurrence semantics, we validate affine recurrence decomposition, Blelloch lowering, MLIR GPU lowering, executable artifact generation, and actual GPU execution from generated MLIR. We benchmark the resulting ScanWeaver GPU execution against PyTorch and CUDA sequential baselines, and include the Mamba kernel as a fused production baseline for systems context.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。