FACT:基于三阶段代理工作流的组合内核合成
FACT: Compositional Kernel Synthesis with a Three-Stage Agentic Workflow
AI总结:
FACT框架通过三阶段代理工作流实现PyTorch模块的多模式组合优化,结合CUTLASS C++实现内核合成,提升GPU计算性能。
摘要:
FACT框架通过三阶段代理工作流实现PyTorch模块的多模式组合优化,结合CUTLASS C++实现内核合成,提升GPU计算性能。深度学习编译器和供应商库提供了强大的基线性能,但受限于有限的、由工程师-curated的目录。当这些目录缺少所需的优化时,从业者会使用手写的CUDA或CUTLASS代码,需要具备GPU微架构和C++模板元编程的专业知识。最近的基于LLM的代理专注于原始CUDA中的内核生成,迫使重新发现已编码在成熟库中的优化。我们提出了FACT(用于代理CUTLASS转换的框架),该框架采用三阶段、由代理驱动的工作流,通过多模式组合优化PyTorch模块,同时基于CUTLASS C++进行内核合成。(1)模式发现:一个LLM代理检查跟踪图,将子图匹配到优化规则,从架构特定的索引中检索经过验证的例子,并输出优先级模式。(2)模式实现:每个模式被实现为一个CUTLASS内核,包装在PyTorch扩展中,经过验证,并通过扫描参数推断自CUTLASS层次结构进行自动调优。(3)模式组合:扩展被加载到单一组合模块中进行端到端基准测试。我们使用KernelBench的评估框架和提供的模块在NVIDIA A100上评估该工作流。在Level 1,我们应用该工作流到三个GEMM工作负载(平方矩阵乘法、批量矩阵乘法和大-K矩阵乘法)。自动调优的CUTLASS内核在PyTorch cuBLAS基线上提高了1.06倍至1.18倍。在Level 3 MiniGPT块中,将融合多头注意力与融合MLP GEMM+GELU组合,实现了2.79倍的端到端加速。我们的工作结合了代理级别的图模式发现、自动调优和动态模式表,为从跟踪PyTorch到可部署内核的实用路径提供了可能,通过自动化CUTLASS内核合成和自动调优。
英文摘要:
Deep learning compilers and vendor libraries deliver strong baseline performance but are bounded by finite, engineer-curated catalogs. When these omit needed optimizations, practitioners substitute hand-written CUDA or CUTLASS, demanding expertise in GPU microarchitecture and C++ template metaprogramming. Recent LLM-based agents target kernel generation in raw CUDA, forcing rediscovery of optimizations already encoded in mature libraries. We present FACT (Framework for Agentic CUTLASS Transpilation), a framework that employs a three-stage, agent-driven workflow optimizing PyTorch modules through multi-pattern composition while grounding synthesis in CUTLASS C++. (1) Pattern discovery: an LLM agent inspects the traced graph, matches subgraphs to optimization rules, retrieves vetted examples from an architecture-specific index, and outputs prioritized patterns. (2) Pattern realization: each pattern is implemented as a CUTLASS kernel wrapped in a PyTorch extension, verified, and auto-tuned by sweeping parameters inferred from the CUTLASS hierarchy. (3) Pattern composition: extensions are loaded together into a single composed module for end-to-end benchmarking. We evaluate the workflow using KernelBench's evaluation framework and provided modules on an NVIDIA A100. On Level 1, we apply the workflow to three GEMM workloads (square matrix multiply, batched matrix multiply, and large-$K$ matrix multiply). Auto-tuned CUTLASS kernels improve over PyTorch cuBLAS baseline by $1.06\times$--$1.18\times$. On Level 3 MiniGPT block, composing fused multi-head attention with fused MLP GEMM+GELU yields $2.79\times$ end-to-end speedup. Our work couples agentic graph-level pattern discovery with auto-tuning and a dynamic pattern table, offering a practical path from traced PyTorch to deployable kernels by automating CUTLASS kernel synthesis and auto-tuning.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。