Seedlabs
Source research

A Two-Stage GPU Kernel Tuner Combining Semantic Refactoring and Search-Based Optimization

Qiuyi Qu, Yicheng Sui, Yufei Sun, Rui Chen, Xiaofei Zhang, Yuzhi Zhang et al. · 2026 · 7 citationsRead the paper

All 8 authors

Haofeng Wang, Ge Lan

GPU code optimization is a key performance bottleneck for HPC workloads as well as large-model training and inference. Although compiler optimizations and hand-written kernels can partially alleviate this issue, achieving near-hardware-limit performance still relies heavily on manual code refactoring and parameter tuning. Recent progress in LLM-agent-based kernel generation and optimization has been reported, yet many approaches primarily focus on direct code rewriting, where parameter choices are often implicit and hard to control, or require human intervention, leading to unstable performance gains. This paper introduces a template-based rewriting layer on top of an agent-driven iterative loop: kernels are semantically refactored into explicitly parameterizable templates, and template parameters are then optimized via search-based autotuning, yielding more stable and higher-quality speedups. Experiments on a set of real-world kernels demonstrate speedups exceeding 3x in the best case. We extract representative CUDA kernels from SGLang as evaluation targets; the proposed agentic tuner iteratively performs templating, testing, analysis, and planning, and leverages profiling feedback to execute constrained parameter search under hardware resource limits. Compared to agent-only direct rewriting, the template-plus-search design significantly reduces the randomness of iterative optimization, making the process more interpretable and enabling a more systematic approach toward high-performance configurations. The proposed method can be further extended to OpenCL, HIP, and other backends to deliver automated performance optimization for real production workloads.

What the full text shows

Working prototype
  • The proposed two-stage tuner achieved speedups over the SGLang baseline across three representative kernels. — 1.09x to 3.55x (Best general configuration across multiple input shapes on NVIDIA TITAN RTX)
  • The method outperformed the Astra baseline (agent-only direct rewriting) most significantly on Kernel1. — 22.8% additional gain (Best general configuration on Kernel1)
  • The method provided consistent incremental improvements over Astra for Kernel2 and Kernel3. — 2.8% and 4.1% additional gain respectively (Best general configuration)
  • All optimized kernels maintained functional correctness. — 100% pass rate (Consistency checks against original SGLang implementations within numerical tolerance)
Setup
Three CUDA kernels (silu_and_mul, fused_add_rmsnorm, merge_attn_states) from SGLang, tested on an NVIDIA TITAN RTX using deepseek-chat (DeepSeek-V3.2) as the base LLM.
How
A multi-agent system (planning, generation, tuning, and testing agents) that first semantically refactors kernels into explicitly parameterizable templates and then performs search-based autotuning of those parameters under hardware resource constraints.
Limitations
Performance gains on fused operators with fixed compute/memory structures (Kernel2) were marginal compared to structural refactoring.

Summarized by Gemma 4 from the open-access full text · 22 Nov 2026. Read it