Compiler-Grounded Hierarchical Diagnosis for LLM-Based Triton Kernel Optimization
This paper presents a compiler-grounded hierarchical diagnosis framework that links runtime symptoms to intermediate representation structures and compiler behavior to enable evidence-backed source-level rewrites for Triton kernels, achieving significant speedups on Ascend NPUs by moving beyond surface-level optimization signals.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you are trying to tune a race car to go as fast as possible. In the world of computer science, these "cars" are tiny, specialized programs called kernels that tell powerful computer chips (like the ones in your phone or a supercomputer) how to do math. For years, humans have been the mechanics, tweaking the code by hand. But recently, we've given the job to AI agents—smart computer programs that can write and rewrite code on their own. These AI agents usually work like a driver who just keeps hitting the gas and checking the speedometer. If the car is slow, the AI guesses a new part to install, tries it, and sees if it's faster. The problem is, the AI often doesn't know why the car is slow. Is it the engine? The tires? Or is it a weird rule in the factory manual that nobody told the AI about? This paper tackles that mystery, specifically for a type of computer chip called an NPU (Neural Processing Unit), which is great at running AI but can be tricky to program. The authors argue that to truly fix a slow program, you can't just guess; you need to act like a detective who checks the speed, looks under the hood at the engine's internal parts, and finally reads the factory manual to understand why the engine behaves the way it does.
The paper introduces a new system called Compiler-Grounded Hierarchical Diagnosis. Think of this system as a very smart, very patient mechanic who refuses to guess until they have the right evidence. Instead of just throwing random code changes at the problem, this system uses a "ladder" of investigation. It starts at the bottom with Pattern Triage, where it quickly checks if the problem matches a known fix, like swapping a flat tire for a spare. If that doesn't work, it moves up to Profiling Diagnosis, where it watches the program run to see exactly where it's stalling—like checking if the engine is overheating or if the wheels are spinning too much.
If the speedometer still doesn't tell the whole story, the mechanic climbs higher to IR Attribution. This is like looking at the engine's blueprints (called Intermediate Representation or IR) to see if the parts are assembled in a weird way that slows things down. Finally, if the blueprints are confusing, the system goes to the very top rung: Compiler-Source Escalation. Here, it consults the "factory manual" (the compiler's rules) to understand why the engine is built the way it is and what specific changes will actually work. The system only climbs this ladder when the lower steps aren't enough, saving time and energy.
The researchers tested this system on 37 different computer programs (kernels) designed for Huawei's Ascend 950 chips. They found that by using this step-by-step detective work, they could make the programs run much faster. On average, the optimized programs were 4.35 times faster than the original versions. For half of the programs, the speedup was at least 2.73 times. Some programs saw massive improvements, running 5 times faster or more, while others didn't change much, showing that the system isn't a magic wand that fixes everything instantly, but a powerful tool for the right jobs.
One of the most interesting parts of the story is how the system behaves. It doesn't just find the answer in the first try. In fact, for many of the programs, the best result didn't appear until the 8th round of testing, and the "best" round for the whole group was usually around the 10th try. This shows that the system is willing to keep digging deeper, moving from simple guesses to complex investigations, until it finds the real cause of the slowdown. The paper also points out that while the system is great at finding these fixes, it doesn't claim to have solved the problem for every single type of chip or code. It's a specific, careful approach that works well for the chips they tested, proving that sometimes, to go faster, you have to slow down and understand the "why" before you change the "what."
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.