LLM4LLM: Bridging Kernel Benchmarks and Real Deployment via Closed-Loop Agentic Optimization
Organizations: Xidian University · Zhongguancun Academy · National Key Laboratory of Advanced Communication Networks, Shijiazhuang, Hebei, P. R. China · Zhongguancun Institute of Artificial Intelligence
Abstract
Large language models have become increasingly capable agents for low-level code and kernel optimization, but isolated kernel benchmarks provide only a proxy for the deployment behavior that matters in language-model inference. We identify a benchmark-to-deployment gap: candidate kernels that appear correct and fast in standalone harnesses can exhibit different performance, safety, or phase behavior after integration into a real inference workload. We introduce LLM4LLM, a deployment-aware closed-loop optimization framework that starts from a target inference script, extracts phase-aware optimization tasks, searches with an experience-guided episodic agent, and accepts patches through in-model validation. Across ten language-model inference workloads on A100 and H100 GPUs, LLM4LLM improves end-to-end latency for every evaluated model, achieving 3.91/6.98 geometric-mean speedups on A100/H100; as supporting kernel-level evidence, it also attains up to 2.745 GeoMean speedup on KernelBench Level 2.
Figures & tables
| Model | A100 | H100 | ||||
|---|---|---|---|---|---|---|
| Eager | Ours | Speedup | Eager | Ours | Speedup | |
| Qwen3-4B | 693.9 | 229.0 | 3.03 | 380.2 | 100.7 | 3.78 |
| Qwen3-32B | 3032.3 | 1387.1 | 2.19 | 1516.7 | 594.4 | 2.55 |
| Llama-2-7B | 658.8 | 353.9 | 1.86 | 329.8 | 148.4 | 2.22 |
| Llama-2-13B | 1082.2 | 603.7 | 1.79 | 538.1 | 280.7 | 1.92 |
| Mamba (130M) | 626.4 | 28.0 | 22.37 | 537.7 | 16.4 | 32.79 |
| A100-SXM4-80GB | H100-80GB-HBM3 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Method | Lang. | Pass | Fast1 | Fast2 | Mean | GeoMean | Method | Lang. | Pass | Fast1 | Fast2 | Mean | GeoMean |
| CUDA-L1 | CUDA | 100 | 98 | – | 3.55 | – | CUDA-L1 | CUDA | 96 | 96 | – | 6.64 | – |
| KernelSkill | CUDA | 100 | 100 | – | 2.82 | – | KernelBlaster | CUDA | 81 | 84.85 | – | 10.223 | 2.592 |
| STARK (A100-40G) | CUDA | 100 | 100 | – | 2.69 | – | QiMeng-Kernel | Triton | 99 | 86 | 12 | 1.28 | – |
| QiMeng-Kernel | Triton | 99 | 66 | 8 | 1.22 | – | AI CUDA Engineer | CUDA | 82 | 61.33 | – | 1.356 | 1.214 |
| LLM4LLM | Triton | 100 | 97 | 39 | 22.157 | 2.745 | LLM4LLM | Triton | 99 | 95 | 41 | 15.847 | 2.628 |
| vs. PyTorch eager | vs. torch.compile | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Model | Method | Pass | Fast1 | Fast2 | Mean | GeoMean | P50 | P75 | Fast1 | Fast2 | Mean | GeoMean | P50 | P75 |
| GPT-5.4 | Sample-1 | 46 | 4 | 1 | 0.693 | 0.555 | 0.511 | 0.640 | 2 | 1 | 0.643 | 0.507 | 0.500 | 0.562 |
| Sample-10 | 75 | 63 | 8 | 1.417 | 1.230 | 1.064 | 1.336 | 44 | 9 | 1.344 | 1.124 | 1.009 | 1.323 | |
| Iter-10 | 100 | 64 | 4 | 1.171 | 0.999 | 1.011 | 1.220 | 41 | 5 | 1.065 | 0.887 | 0.980 | 1.144 | |
| LLM4LLM w/o restart (10) | 100 | 89 | 32 | 6.782 | 1.961 | 1.250 | 4.221 | 66 | 31 | 6.573 | 1.742 | 1.143 | 3.986 | |
| LLM4LLM (10) | 100 | 91 | 32 | 14.962 | 2.005 | 1.332 | 4.110 | 71 | 31 | 14.716 | 1.781 | 1.230 | 4.020 | |
Appendix figures & tables1 asset
Supplementary material from the paper’s appendix.
Appendix
| Family | Module | Phase / bucket | Main specialization | Task speedup |
|---|---|---|---|---|
| Transformer | LlamaAttentionPrefill | q_len > 1 | Causal online-softmax attention with fused QKV wiring | 2.40 |
| Transformer | Qwen3AttentionDecode | q_len = 1 | Grouped-query decode sharing each KV tile across query heads | 2.01 |
| Mamba2 | Mamba2MixerPrefill | prefill scan | Compact recurrent scan with cache-safe mixer wiring | 14.31 |
| Mamba | MambaMixerDecode | single-token decode | Fused Conv1d–SiLU–projection chain for cached decode | 2.06 |
| Recurrent | RecurrentGemmaRglru | recurrent update | Fused gate normalization plus recurrent-state scan | 6.85 |
LLM Inference Acceleration
LLM inference acceleration develops algorithms and systems that reduce language-model latency, memory use, and serving cost while preserving output quality.
See all 1,084 papers