Search papers, labs, and topics across Lattice.
This study introduces DataKernelBench, a framework that translates SQL queries into validated PyTorch TorchPlan programs to evaluate the optimization capabilities of various LLMs on GPU-accelerated database queries. The results show that the best-performing full-query CUDA configuration achieves a 2.11x speedup over traditional compilation methods, highlighting the effectiveness of kernel fusion and execution-strategy changes. Notably, the findings reveal that workload context is more critical than hardware context, and stronger models benefit significantly from full-query specialization, particularly when handling larger datasets through on-demand partition loading with Dask-cuDF.
LLMs can optimize database queries on GPUs, achieving over 2.5x speedup by leveraging advanced execution strategies and kernel fusion.
GPUs increasingly accelerate database systems, but query-specific peak performance still often relies on hand-written kernels. Existing LLM kernel benchmarks focus on machine learning operators, leaving irregular, heterogeneous, data-movement-heavy database-style operators untested. We introduce DataKernelBench, which translates SQL into validated PyTorch TorchPlan programs and evaluates LLMs that optimize either the core tensor-bounded snippet or the full query in CUDA or Triton through execution-guided repair. Across ten proprietary and open-weight models on TPC-H SF10 with an H100 GPU, the strongest full-query CUDA configuration achieves $2.11\times$ speedup over torch.compile at full pass rate. We find that higher-performing implementations commonly use kernel fusion and execution-strategy changes, stronger models benefit most from full-query specialization, and workload context matters more than hardware context. To handle data larger than GPU memory, we extend TorchPlan with Dask-cuDF for on-demand partition loading on TPC-H SF100 with four H100 GPUs, achieving $2.54\times$ speedup