PTXBench: A new way to measure how well LLMs can optimize GPU kernels

3 September 202624 views

The benchmark evaluates models on GEMM and attention tasks for H100 and B200 GPUs — from correctness to real speedup. Results show that even precise execution of target instructions does not guarantee competitive performance.

PTXBench: A new way to measure how well LLMs can optimize GPU kernels

GPU kernel optimization usually requires a deep understanding of hardware architecture and low-level instructions. Language models still handle this inconsistently: they can generate plausible code, but it is far from always correct and fast. PTXBench is a new benchmark that tries to bring measurability and clarity to this process.

What is PTXBench and why is it needed

PTXBench is an evaluation harness for large language models that attempt to use architecture-specific PTX (Parallel Thread Execution) to optimize GPU kernels. PTX is NVIDIA's intermediate instruction representation for GPUs, and it is at this level that registers, memory, and the scheduler can be finely controlled. Regular benchmarks only check the final code, but PTXBench looks deeper: whether the model actually applies targeted low-level instructions rather than just generating "C-like" code.

The authors focused on two classic workloads: matrix multiplication (GEMM) and the attention mechanism, which is critical for transformers. The tests were run on current accelerators — H100 and B200. This choice makes it possible to test not only the model's basic skills, but also its ability to adapt to modern architectures with their specific features.

What the benchmark measures

PTXBench evaluates models on three key parameters:

  • Functional correctness — the output of the generated kernel must match the reference.
  • Execution of target instructions — checks whether the specific PTX instructions the model was supposed to use actually appear at runtime.
  • Speedup — how much faster the resulting kernel is than frontier libraries, i.e., the best existing implementations.

This approach separates three different problems. A model can write correct code but fail to use the required instructions. Or it can use them but achieve worse performance than a standard library. PTXBench makes it possible to see at exactly which stage the failure occurs.

Results: optimization is still uneven across models

The evaluation showed that LLMs' ability to work with PTX depends heavily on the task. On simple cases, models demonstrate decent results, but the share of successful solutions drops sharply on complex backward tasks for attention. This is expected: the backward pass requires more careful handling of gradients and memory.

Another important finding: executing target instructions by itself does not guarantee speed. A model can "hit" the right PTX instructions but choose a poor parallelization strategy or synchronization layout. As a result, none of the tested models could consistently compete with frontier libraries across the full set of tasks.

How the model was fine-tuned and what worked

To understand whether these skills can be improved, the authors fine-tuned the Qwen3.6-27B model using supervised fine-tuning. Additionally, they used a technique that can be called correction-conditioned training: the model learns not just to generate code, but to fix it, receiving feedback about incorrect steps.

This approach did improve several tasks, but it did not produce uniform progress. Generalization remained weak: the model could handle some kernel types well and fail on others. The analysis showed that the size of the training dataset is not the only deciding factor. More important are its coverage, the balance between different scenarios, and the quality of the "teacher" that generates examples for reasoning chains. If the data is skewed toward simple cases, the model will not learn complexity.

Key takeaway

PTXBench gives the community a verifiable test harness for tracking LLM progress in GPU kernel optimization. It does not just output a "fast/slow" score, but shows at which level the model's plans break down: at the syntax, at the application of specific instructions, or at strategy selection. This is an important step toward making automatic kernel optimization predictable and practical.

Frequently asked questions