如何训练你的小龙:教小型语言模型构建与优化GPU优化脚本
How to Train Your Little Dragon: Teaching a Small Language Model to Construct and Refine GPU Optimization Scripts
AI总结:
该研究提出名为LITTLE DRAGON的训练方法,教80亿参数的小型语言模型构建与优化GPU优化脚本,其性能优于多个参数规模更大的前沿大语言模型。
摘要:
编译器变换相互作用,使得GPU内核优化成为在保留计算的同时提升性能的组合搜索任务。我们提出了HOW TO TRAIN YOUR LITTLE DRAGON,一种训练方法,该方法教小型语言模型既构建完整的优化脚本,又改进现有优化脚本。与对候选进行排名或生成内核代码不同,我们的模型生成优化脚本。我们设计了一种紧凑、无损的表示形式,其确定性解码可重建精确的编译器轨迹,保留其变换参数和依赖关系。我们使用编译器框架TVM MetaSchedule在54116个不同工作负载上构建训练数据,并在两个训练集中构建了108594个示例:60236个示例用于教模型从未优化的内核生成优化脚本,48358个示例用于教模型在给定内核和部分优化脚本的情况下生成更好的脚本。监督微调从这些搜索衍生的示例中教模型构建和改进优化脚本。随后,我们添加带有塑形奖励的强化学习,该奖励结合了正确性和实测性能,仅对数值正确的内核授予基于延迟的奖励。我们将此训练方法应用于具有80亿参数的模型。经过监督微调与强化学习后,该模型在构建任务上的单次尝试正确率为91.27%,在优化任务上的单次尝试正确率为92.01%;在102个构建任务中,强化学习生成的内核比监督训练生成的更快的有88个,在170个优化提示中,强化学习生成的内核更快的有145个。仅用80亿参数,我们的LITTLE DRAGON在单次尝试正确率和内核性能上优于六个前沿大语言模型,包括GPT-6 Astra、Opus 5、Kimi-K3和GLM-5.3,这些模型每个具有数百亿至万亿参数,且无法进行特定任务训练或训练成本高昂。
英文摘要:
Compiler transformations interact, making GPU kernel optimization a search for combinations that preserve the computation while improving performance. We introduce HOW TO TRAIN YOUR LITTLE DRAGON, a training method that teaches a small language model both to construct complete optimization scripts and to improve existing ones. Instead of ranking candidates or generating kernel code, our model generates optimization scripts. We devise a compact, lossless representation whose deterministic decoding reconstructs the exact compiler trace, preserving its transformation parameters and dependencies. We use a compiler framework TVM MetaSchedule to build training data on 54,116 distinct workloads, and construct 108,594 examples in two training sets: 60,236 teach the model to generate an optimized script from an unoptimized kernel, while 48,358 teach it to produce a better script given the kernel and a somewhat optimized script. Supervised fine-tuning teaches the model to construct and improve optimization scripts from these search-derived examples. We then add reinforcement learning with a shaped reward that combines correctness with measured performance, awarding a latency-based bonus only to numerically correct kernels. We apply this training method to a model with 8 billion parameters. After supervised fine-tuning and reinforcement learning, the model achieves per-attempt correctness of 91.27% for construction and 92.01% for refinement, while reinforcement learning produces faster kernels than supervised training on 88 of 102 construction tasks and 145 of 170 refinement prompts. With only 8B parameters, our LITTLE DRAGON achieves higher per-attempt correctness and better kernel performance than six frontier LLMs: GPT-6 Astra, Opus 5, Kimi-K3, and GLM-5.3 among them, each with hundreds of billions to trillions of parameters, for which task-specific training is unavailable or expensive.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。