提问而非装备:面向深度内核优化的提问驱动编码智能体

·

研究论文 · 2026/11/05

针对GPU内核优化的LLM智能体在结构自由度上存在权衡:脚本化智能体通过固定策略或优化菜单实现样本高效,但泛化性差;开放式智能体允许模型自主变异内核种群,但需大量试验。两者都试图通过提供更多工具(如性能分析输出、反汇编、文档检索)来应对困难目标,但缺乏方向性。本文提出KernelSeek,一种问题驱动的智能体,通过决策点提问(先由人类提供,后由问题库自问)来提供假设方向,而不限制智能体的后续行动。在相同任务、评估器、硬件和一周时间内,工具丰富的自主智能体在133步后仅达到0.50倍FlashAttention-3,而KernelSeek达到1.13倍。KernelSeek还为Hopper和Blackwell架构生成了无依赖的FlashAttention前向内核(单CUDA文件,无CUTLASS/CuTe/cuBLAS/cuDNN),在所有182个场景中正确,几何平均分别为1.16倍和1.46倍于FlashAttention-3/4。分析162条人类消息和11.5K次工具调用发现,所有大幅提升都源于促使智能体转向系统不同层次或否定声称限制的问题,而非提供信息的问题。本文开源了内核、测试框架、问题库和所有轨迹。

该研究揭示了LLM智能体在GPU内核优化中缺乏方向性的关键问题,并提出简单有效的问题驱动方法,在相同条件下显著超越现有工具丰富的自主智能体,且生成的内核性能超越FlashAttention-3/4,具有重要的实践和启发意义。

LLM agents for GPU kernel optimization sit at two ends of a structure-freedom tradeoff. Scripted agents fix what the model does at each step, via a learned policy, an optimization menu, or fixed roles, and are sample-efficient where the recipe applies and stall where it does not. Open-ended agents let a self-directed model mutate a population of kernels and pay for the freedom in trials: thousands of evaluations, repeated edits, and wrong candidates. Both respond to hard targets by equipping the agent with more: parsed profiler output, disassembly analysis, retrieval over documentation and libraries, and stores of lessons. We argue that both lack direction, a hypothesis about where the remaining gap is, and that a short question asked at the right moment supplies it without narrowing what the agent may do next. We present KernelSeek, a question-driven agent that makes an existing CUDA kernel faster with no operator-specific knowledge and no faster implementation to imitate: a general-purpose coding agent, a minimal harness that enforces a verifiable goal, and questions at decision points, first from a human, then from a bank the agent applies to itself. On the same task, evaluator, hardware, and week, a tool-rich autonomous agent built in the prevailing style plateaued at 0.50x FlashAttention-3 after 133 model-driven steps; KernelSeek reached 1.13x. It then produced dependency-free FlashAttention forward kernels for Hopper and Blackwell, single CUDA files with no CUTLASS, CuTe, cuBLAS, or cuDNN, correct on all 182 scenarios per architecture and 1.16x FlashAttention-3 and 1.46x FlashAttention-4 (geometric mean). Across 162 human messages and 11.5K agent tool calls, every large gain followed a question that moved the agent to a different layer of the system or rejected a claimed limit, never one that supplied information. We release the kernels, harness, question bank, and all traces.

阅读原文

参与讨论