Guided large language models improve efficiency of gpu code
D2K-Bench: Can LLM Agents Turn Expert Designs into Efficient GPU Kernels?
Machine LearningArtificial IntelligenceDistributed, Parallel, and Cluster Computing
Summary
Generating fast GPU programs is tricky, and large language models (LLMs) often produce slower code than experts. The authors created a benchmark called D2K-Bench to test how well LLMs turn expert design tips into efficient GPU code. They found that giving LLMs detailed guidance on algorithm design, data flow, and low-level tricks helped them write more correct and faster code across many tasks. However, some complex design aspects were still missed by the models, showing room for improvement.
What this means in practice
- •For gpu software engineers: Improve GPU kernel efficiency by using expert design guidance with large language models in code generation.
- •For ai developers: Use guided LLM agents to produce correct and faster GPU code, enhancing AI model training and deployment.
Authors
Daifeng Li, Huiqiang Jiang, Chengruidong Zhang, Wei Wu, Xudong Guo, Jianhong Tu, Jianwei Zhang, Binhang Yuan, Dayiheng Liu
Abstract
GPU kernels generated by large language model (LLM) agents can remain less efficient than expert implementations, but runtime alone does not reveal how the gap relates to design discovery and implementation. We introduce D2K-Bench, a diagnostic benchmark of 26 tasks and 85 workloads that measures how effectively agents translate expert design guidance into efficient GPU kernels. The guidance covers L1: high-level algorithmic insights, L2: dataflow design, and L3: low-level optimization tricks, including dependencies among these levels. Pairwise runs with and without guidance share task descriptions, workloads, tools, hardware, and a 350-turn budget. Complementary assessments examine independently proposed designs and the design properties implemented in generated code. Across five models on NVIDIA B200 GPUs, guidance raises correctness over 130 model-task pairs from 93.1% to 98.5% and increases the Performance Score over all 26 tasks from 1.46 to 1.95. For the three frontier models with correct submissions on all 26 tasks in both runs (GPT-6-Astra, Claude-Opus-4.8, and GPT-5.6-Sol), geometric mean speedup increases from $1.69\times$ to $2.49\times$. Across all five models, the mean combined implementation score increases from 57 to 70 out of 100. These results show the value of expert design guidance while identifying design properties that remain unimplemented.