从令牌到区域:面向GPU内核生成的CUDA敏感指令微调
From Tokens to Regions: CUDA-Sensitive Instruction Tuning for GPU Kernel Generation
AI总结:
提出CuSeT方法,通过自适应令牌级掩码和区域感知样本重加权,在简单SFT框架内提升LLM生成CUDA内核的功能正确性。
摘要:
高性能CUDA内核对于可扩展的AI系统至关重要,而大型语言模型(LLM)由于严格且隐式的执行约束,仍然难以生成正确的内核。现有的基于LLM的方法要么依赖昂贵的智能体或强化学习(RL)流水线,要么采用监督微调(SFT)目标,但未能显式建模CUDA敏感性,即与执行约束紧密耦合的代码令牌或区域。在这项工作中,我们从令牌置信度模式的角度研究CUDA敏感性,表明CUDA敏感性出现在令牌和区域两个层面,其中大多数CUDA敏感令牌以高置信度被预测,而较小的低置信度子集形成对应于执行关键结构的区域。这些发现表明,有效的CUDA内核生成应同时利用高置信度的CUDA敏感令牌并保留低置信度的CUDA敏感区域。基于这些见解,我们提出了\textbf{\underline{CU}DA-\underline{Se}nsitive Instruction \underline{T}uning (CuSeT)},一种在简单SFT框架内的低成本后训练方法。CuSeT遵循“从令牌到区域”的原则,结合了\emph{自适应令牌级掩码}和\emph{区域感知样本重加权}。实验表明,CuSeT在多个模型系列和规模上一致地提高了功能正确性,优于标准SFT和高级SFT变体,同时以显著更低的推理成本达到了与前沿CUDA内核生成模型相竞争的性能。
英文摘要:
High-performance CUDA kernels are essential for scalable AI systems, while Large Language Models (LLMs) still struggle to generate correct kernels due to strict and implicit execution constraints. Existing LLM-based approaches either rely on costly agentic or reinforcement-learning (RL) pipelines, or adopt supervised fine-tuning (SFT) objectives that fail to explicitly model CUDA sensitivity, namely code tokens or regions tightly coupled with execution constraints. In this work, we investigate CUDA sensitivity from the perspective of token confidence patterns, showing that CUDA sensitivity appears at both token and region levels, where most CUDA-sensitive tokens are predicted with high confidence, while a smaller low-confidence subset forms regions corresponding to execution-critical structures. These findings suggest that effective CUDA kernel generation should both leverage high-confidence CUDA-sensitive tokens and preserve low-confidence CUDA-sensitive regions. Building on these insights, we propose \textbf{\underline{CU}DA-\underline{Se}nsitive Instruction \underline{T}uning (CuSeT)}, a low-cost post-training method within a simple SFT framework. CuSeT follows the principle of ``from tokens to regions'' by combining \emph{adaptive token-level masking} with \emph{region-aware sample reweighting}. Experiments show that CuSeT consistently improves functional correctness across multiple model families and scales, outperforming standard SFT and advanced SFT variants, while achieving competitive performance against frontier CUDA kernel generation models with substantially lower inference cost.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。