TritonBench: Benchmarking Large Language Model Capabilities for Generating Triton Operators

Jianling Li, Shangzhan Li, Zhenye Gao, Qi Shi, Yuxuan Li, Zefan Wang, Jiacheng Huang, Haojie Wang, Jianrong Wang, Xu Han, Zhiyuan Liu, Maosong Sun

TL;DR

This paper introduces TRITONBENCH, the first comprehensive benchmark for evaluating Large Language Models (LLMs) in generating Triton code, a high-level language for efficient GPU kernels. The benchmark reveals that current LLMs struggle significantly with generating accurate and performant Triton code, highlighting a critical gap in high-performance code generation capabilities.

What Problem Does This Paper Address?

Modern deep learning frameworks increasingly rely on efficient GPU kernels for performance. Triton is a popular Python-like language that simplifies GPU programming by abstracting away low-level complexities. However, writing optimized Triton code still demands significant expertise and trial-and-error. While LLMs have shown promise in generating general-purpose code, their ability to produce accurate and performance-optimized Triton code – a domain-specific language with unique complexities – remains largely unassessed. This lack of evaluation hinders progress in AI-assisted Triton development.

Methods

The authors introduce TRITONBENCH, a dual-channel benchmark designed to systematically evaluate LLMs' Triton code generation capabilities.

  • TRITONBENCH-G: This channel comprises 184 real-world Triton operators curated from GitHub repositories. The process involves scraping, filtering, generating natural language instructions for LLMs, and annotating test code. Crucially, it includes performance evaluation by domain experts on NVIDIA GPUs.
  • TRITONBENCH-T: This channel complements TRITONBENCH-G by focusing on operator development tasks aligned with PyTorch interfaces. It involves selecting and fusing PyTorch operators to create new tasks, with instructions derived from PyTorch documentation.

The evaluation metrics go beyond simple functional correctness to include:

  • Similarity: Assessed using CODEBLEU.
  • Call & Execution Accuracy: Whether the code runs and produces correct input-output behavior.
  • Speed Up: Relative execution time improvement compared to reference implementations.
  • GPU Efficiency: How effectively the generated operator utilizes GPU resources.

Datasets

The paper introduces TRITONBENCH as a new benchmark suite. It consists of two main components:

  • TRITONBENCH-G: A curated set of 184 real-world Triton operators sourced from GitHub repositories with at least 100 stars.
  • TRITONBENCH-T: A collection of 166 operator development tasks derived from PyTorch interfaces, including fused operators.

The authors also mention using a training corpus for supervised fine-tuning, comprising real-world data from GitHub and synthetically generated data using Ninetoothed, a Triton-based DSL.

Key Insights and Ideas

  • LLMs struggle with domain-specific performance: Despite advancements in general code generation, LLMs exhibit a significant performance gap when tasked with creating optimized Triton code, which requires understanding GPU architecture and specific language features.
  • Performance matters for GPU kernels: Unlike many code benchmarks that focus solely on functional correctness, TRITONBENCH emphasizes performance metrics like speedup and GPU efficiency, which are critical for real-world applications.
  • TRITONBENCH-G is harder than TRITONBENCH-T: The benchmark reveals that TRITONBENCH-G, with its real-world, often complex operators, presents a greater challenge to LLMs, with significantly lower execution accuracy compared to TRITONBENCH-T.
  • One-shot learning helps, but doesn't solve the problem: While providing examples (one-shot learning) improves LLM performance, it doesn't fully bridge the gap in generating high-quality Triton code, especially for more complex operators.
  • Error patterns reveal specific LLM weaknesses: Analysis of execution failures shows that LLMs struggle with syntax, name resolution, and attribute/type errors, with different models exhibiting varying sensitivities to these issues.

Key Results

  • Low Execution Accuracy: The highest execution accuracy achieved by state-of-the-art LLMs on TRITONBENCH-G was only 23.91%, while on TRITONBENCH-T, it reached 53.01%.
  • Limited Speedup: For correctly executed operators, the best speedup achieved on TRITONBENCH-G was 1.56x, and on TRITONBENCH-T, it was 1.91x.
  • Domain-Specific Models Underperform: General-purpose LLMs, particularly DeepSeek-R1 and GPT-01, generally outperformed specialized domain-specific models on Triton code generation tasks.
  • DeepSeek-R1 and GPT-01 Lead: DeepSeek-R1 achieved 53.01% Call and Execution Accuracy on TRITONBENCH-T in zero-shot settings, with GPT-01 close behind.
  • Error Analysis: In TRITONBENCH-G, syntax and name/reference errors were prevalent. In TRITONBENCH-T, DeepSeek-R1 notably avoided syntax errors, while GPT-01 showed a higher rate of name/reference errors.

Limitations and Future Work

  • GPU Architecture Specificity: The current evaluation was primarily conducted on NVIDIA A100 GPUs. The authors plan to expand evaluations to include a broader range of hardware architectures to gain more comprehensive performance insights.
  • LLM Capabilities: The study highlights that current LLMs are not yet fully capable of generating high-quality, performance-optimized Triton code, underscoring the need for further advancements in this area.
  • Future Work: The authors anticipate TRITONBENCH will serve as an essential framework for advancing automated operator generation for Triton, driving future research and development in this domain.

Summary updated

BibTeX
@inproceedings{li2025tritonbench,
  author = {Jianling Li and Shangzhan Li and Zhenye Gao and Qi Shi and Yuxuan Li and Zefan Wang and Jiacheng Huang and Haojie Wang and Jianrong Wang and Xu Han and Zhiyuan Liu and Maosong Sun},
  title = {{TritonBench: Benchmarking Large Language Model Capabilities for Generating Triton Operators}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
  url = {https://openreview.net/forum?id=W09Zf1MBuk},
}
Figure