Session

Coding with AI Agents to Supercharge Your Spark UDFs with GPU-Acceleration

Overview

ExperienceIn Person
TrackArtificial Intelligence & Agents
IndustryEnterprise Technology
TechnologiesDatabricks SQL
Skill LevelBeginner

NVIDIA cuDF enables GPU-accelerated query execution for Apache Spark workloads. However, a common performance bottleneck for vectorized query engines are User-Defined Functions (UDFs). Since UDFs contain opaque custom code, the engine must fall back to row-at-a-time execution.

 

We present a new set of agents skills in Project Aether to convert Spark UDFs into GPU-compatible implementations: either native SQL expressions or GPU UDFs invoking cuDF or CUDA primitives. The agent reasons through tasks in an end-to-end workflow: 1) generating CPU-behavior tests, 2) producing a GPU implementation, 3) running benchmarks, and 4) profiling and optimizing performance, with correctness verified through iterative feedback loops.

 

By transforming UDFs to run on GPUs, agents enable full query acceleration for the cuDF plugin, RAPIDS Accelerator for Apache Spark, unlocking significant 20x+ UDF speedups.

 

In this session we will go into the practical learnings from building an AI agent for Spark.

Session Speakers

Felix Cheung

/Product
NVIDIA

Rishi Chandra

/Systems Software Engineer
NVIDIA

Full Summary

Using AI agents to rewrite Spark UDFs for GPU acceleration

User-defined functions are common across Spark pipelines, but they often break vectorized execution and erase much of the benefit of GPU acceleration. The session explains why UDFs become performance bottlenecks and presents an agent-driven workflow that converts CPU UDFs into validated GPU implementations without sacrificing correctness. The approach targets teams that want faster analytics and lower costs on platforms such as the Databricks Platform, where understanding the data and AI strategy behind platform consolidation can help teams prioritize which workloads to accelerate first.

FAQ


Not necessarily. Rewriting a UDF against the Spark QDF plugin's columnar interface preserves encapsulation, so callers do not need to change. Rewriting into built-in SQL operators is more invasive and usually does require application-level edits, especially when the UDF is reused widely.

Custom kernels are overkill for simple relational logic. They become attractive when a single UDF performs substantial compute or complex processing that benefits from fusing work into one specialized kernel for peak performance.

The workflow enforces byte-for-byte output comparisons between CPU and GPU results and uses a judge sub-agent to catch patterns like silent CPU fallback or hard-coded test handling. Agents can also flag out-of-scope edge cases, creating an audit trail rather than masking deviations.

Results vary with the function and pipeline. A customer example cited more than a 20x reduction in summed operator time for a heavily reused UDF and about a 3x wall-clock speedup on a 16 TB job. Removing CPU fallback islands often compounds gains across vectorized stages.

The skills are provided in NVIDIA's open source repository. They include a project template with a testing harness, benchmark setup, and reference examples to run the full workflow end to end.