GPU code optimization is a key performance bottleneck for HPC workloads as well as large-model training and inference. Although compiler optimizations and hand-written kernels can partially alleviate this issue, achieving near-hardware-limit performance still relies heavily on manual code refactoring and parameter tuning. Recent progress in LLM-agent-based kernel generation and optimization has been reported, yet many approaches primarily focus on direct code rewriting, where parameter choices are often implicit and hard to control, or require human intervention, leading to unstable performance gains. This paper introduces a template-based rewriting layer on top of an agent-driven iterative loop: kernels are semantically refactored into explicitly parameterizable templates, and template parameters are then optimized via search-based autotuning, yielding more stable and higher-quality speedups. Experiments on a set of real-world kernels demonstrate speedups exceeding 3x in the best case. We extract representative CUDA kernels from SGLang as evaluation targets; the proposed agentic tuner iteratively performs templating, testing, analysis, and planning, and leverages profiling feedback to execute constrained parameter search under hardware resource limits. Compared to agent-only direct rewriting, the template-plus-search design significantly reduces the randomness of iterative optimization, making the process more interpretable and enabling a more systematic approach toward high-performance configurations. The proposed method can be further extended to OpenCL, HIP, and other backends to deliver automated performance optimization for real production workloads.


翻译:GPU代码优化是高性能计算工作负载以及大模型训练与推理的关键性能瓶颈。尽管编译器优化和手写内核可以部分缓解此问题,但实现接近硬件极限的性能仍严重依赖手动代码重构和参数调优。近期基于LLM智能体的内核生成与优化研究已取得进展,然而许多方法主要关注直接代码重写,其参数选择往往隐含且难以控制,或需要人工干预,导致性能提升不稳定。本文在智能体驱动的迭代循环之上引入基于模板的重写层:内核首先通过语义重构转换为显式参数化的模板,随后通过基于搜索的自动调优优化模板参数,从而获得更稳定且更高质量的加速效果。在一组真实内核上的实验表明,最佳情况下加速比超过3倍。我们从SGLang中提取代表性CUDA内核作为评估目标;所提出的智能体调优器迭代执行模板化、测试、分析与规划,并利用性能分析反馈在硬件资源限制下执行约束参数搜索。与仅依赖智能体的直接重写相比,模板加搜索的设计显著降低了迭代优化的随机性,使过程更具可解释性,并为实现高性能配置提供了更系统化的途径。该方法可进一步扩展至OpenCL、HIP及其他后端,为实际生产工作负载提供自动化性能优化。

0
下载
关闭预览

相关内容

互联网
【ICML 2024】零阶优化器微调大模型,大幅降低内存
专知会员服务
32+阅读 · 2024年7月8日
《大型语言模型指令调优》综述
专知会员服务
73+阅读 · 2023年8月27日
盘点来自工业界的GPU共享方案
计算机视觉life
12+阅读 · 2021年9月2日
以BERT为例,如何优化机器学习模型性能?
专知
10+阅读 · 2019年10月3日
深度学习的GPU:深度学习中使用GPU的经验和建议
数据挖掘入门与实战
11+阅读 · 2018年1月3日
【强化学习】强化学习+深度学习=人工智能
产业智能官
55+阅读 · 2017年8月11日
从浅层模型到深度模型:概览机器学习优化算法
机器之心
27+阅读 · 2017年7月9日
国家自然科学基金
8+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
VIP会员
相关VIP内容
【ICML 2024】零阶优化器微调大模型,大幅降低内存
专知会员服务
32+阅读 · 2024年7月8日
《大型语言模型指令调优》综述
专知会员服务
73+阅读 · 2023年8月27日
相关基金
国家自然科学基金
8+阅读 · 2017年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员