用进化算法自动优化GPU内核,提升运行速度并适配不同硬件。
KernelFoundry: Hardware-aware evolutionary GPU kernel optimization
- 通过质量-多样性搜索探索多种优化策略,保持设计空间多样性。
- 在KernelBench上生成的SYCL内核平均快2.3倍,优于基线方法。
- 支持跨平台、可远程访问多硬件,适合真实场景的内核生成。
GPU内核优化对大语言模型而言比普通代码生成更具挑战性,需理解硬件架构、并行优化策略及性能分析结果。现有基于LLM的方法多依赖简单提示和反馈循环,仅通过性能分析间接实现硬件感知。本文提出KernelFoundry,一种进化式框架,通过三种机制高效探索GPU内核设计空间:(1) 针对内核特性的行为维度进行MAP-Elites质量-多样性搜索,维持对多样化优化策略的探索;(2) 元提示进化,与内核协同演化以发现任务特定优化策略;(3) 基于模板的参数优化,将内核适配输入数据和硬件环境。我们在KernelBench、robust-kbench及自定义任务上评估该框架,生成SYCL跨平台内核,并与CUDA内核对比。结果表明,该方法持续超越基线,在KernelBench上对SYCL内核实现平均2.3倍加速。此外,KernelFoundry为分布式架构,支持远程访问多样硬件,实现快速基准测试,并具备灵活用户输入层,可扩展至广泛真实应用场景。
原文摘要 · Abstract (English)
Optimizing GPU kernels presents a significantly greater challenge for large language models (LLMs) than standard code generation tasks, as it requires understanding hardware architecture, parallel optimization strategies, and performance profiling outputs. Most existing LLM-based approaches to kernel generation rely on simple prompting and feedback loops, incorporating hardware awareness only indirectly through profiling feedback. We introduce KernelFoundry, an evolutionary framework that efficiently explores the GPU kernel design space through three key mechanisms: (1) MAP-Elites quality-diversity search with kernel-specific behavioral dimensions to sustain exploration across diverse optimization strategies; (2) meta-prompt evolution, which co-evolves prompts with kernels to uncover task-specific optimization strategies, and (3) template-based parameter optimization to tune kernels to inputs and hardware. We evaluate this framework on KernelBench, robust-kbench, and custom tasks, generating SYCL kernels as a cross-platform GPU programming model and CUDA kernels for comparison to prior work. Our approach consistently outperforms the baseline methods, achieving an average speedup of 2.3x on KernelBench for SYCL. Moreover, KernelFoundry is implemented as a distributed framework with remote access to diverse hardware, enabling rapid benchmarking and featuring a flexible user input layer that supports kernel generation for a wide range of real-world use cases beyond benchmarking.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。