LLMs Write GPU Code That Is Wrong And Slow
Based on research by Han Wang, Jintao Zhang, Kai Jiang, Haoxu Wang, Jianfei Chen
LLMs are touted as the future of high-performance computing, promising to write faster GPU code than humans. But a new benchmark reveals a harsh reality: while these models can sometimes generate code that runs, they frequently fail to understand the underlying physics of hardware efficiency. The gap between syntactic correctness and actual performance is widening, exposing a critical blind spot in current AI capabilities.
Researchers introduced KernelBench-X, a comprehensive test suite evaluating LLM-generated GPU kernels across 176 tasks in 15 categories. The study dismantles the assumption that better algorithms automatically yield better code. Instead, the structure of the task itself is the primary driver of success. For instance, mathematical tasks are solved consistently, while complex fusion tasks fail across all tested methods. This suggests that the difficulty lies not in the AI's design, but in the inherent complexity of coordinating global operations within the GPU architecture.
The findings deliver a surprising double-edged sword. Iterative refinement helps the AI fix syntax errors, raising the compile rate significantly. However, this improvement comes at a cost: the performance of the newly corrected kernels drops compared to those that were correct from the start. Even more alarming is the disconnect between correctness and speed. Nearly half of the kernels that successfully compiled were actually slower than standard PyTorch baselines. The model also completely failed at quantization tasks, indicating a fundamental misunderstanding of numerical precision rather than simple coding mistakes.
The takeaway is clear: generating code that compiles is no longer enough. Future progress requires moving beyond surface-level syntax to explicitly model numerical precision and hardware efficiency. Until AI can grasp the global coordination required for true optimization, LLM-generated kernels will remain a novelty rather than a reliable tool for high-performance computing.