Kernel Forge: An Agent Harness for LLM-based Generation and Optimization of CUDA Kernels
Kernel Forge is an open-source agentic harness that uses LLMs to automatically generate and optimize CUDA kernels for PyTorch models without requiring manual code integration. It supports vision, diffusion, and LLM workloads and employs Monte Carlo Tree Search (MCTS) to explore multiple optimization paths rather than relying on a single linear refinement chain. Evaluated on four PyTorch models across diverse domains, Kernel Forge achieved speedups of up to 2.83× over PyTorch eager mode after onl
Analysis
TL;DR
- Kernel Forge is an open-source agentic harness that uses LLMs to automatically generate and optimize CUDA kernels for PyTorch models without requiring manual code integration.
- It supports vision, diffusion, and LLM workloads and employs Monte Carlo Tree Search (MCTS) to explore multiple optimization paths rather than relying on a single linear refinement chain.
- Evaluated on four PyTorch models across diverse domains, Kernel Forge achieved speedups of up to 2.83× over PyTorch eager mode after only 50 optimization iterations per kernel.
- The system includes a graphical user interface for monitoring progress, inspecting candidate kernels, and debugging failures, enhancing usability and transparency.
- Unlike prior tools that focus narrowly on isolated kernels or LLM-only models, Kernel Forge operates directly on unmodified PyTorch models, enabling broader applicability in real-world deployments.
Why It Matters
This work represents a significant step toward democratizing high-performance GPU kernel optimization by reducing reliance on expert-level CUDA programming. By integrating LLM-based agent systems with automated search strategies like MCTS, Kernel Forge lowers the barrier to entry for performance tuning while maintaining compatibility with existing ML workflows. Its ability to deliver measurable speedups across multiple model types suggests potential for widespread adoption in both research and production environments where latency and cost are critical concerns.
Technical Details
- Architecture: Kernel Forge functions as an end-to-end agentic framework that interfaces directly with unmodified PyTorch models, extracting compute kernels for optimization without requiring source code changes.
- Optimization Strategy: Instead of sequential refinement, it leverages Monte Carlo Tree Search (MCTS) to explore diverse kernel transformation paths simultaneously, increasing the likelihood of discovering high-performing variants.
- Supported Workloads: The tool handles three major categories—vision (e.g., ResNet-50), diffusion (e.g., Stable Diffusion 3.5 Medium), and large language models (e.g., Gemma 4 E2B, Qwen 3.5 35B-A3B)—demonstrating cross-domain versatility.
- Evaluation Setup: Experiments were conducted on an NVIDIA DGX Spark equipped with GB10 GPUs; performance was measured against PyTorch’s default eager execution mode.
- Performance Results: After 50 iterations per kernel, Kernel Forge improved throughput on key operations: adaptive_avgpool2d (+1.52×), group_norm (+1.70×), softmax in Gemma 4 E2B (+2.83×), and softmax in Qwen 3.5 35B-A3B (+1.54×).
- User Interface: A built-in GUI enables users to visualize optimization trajectories, examine generated CUDA code, identify bottlenecks, and troubleshoot failed optimizations interactively.
Industry Insight
The development of Kernel Forge signals a shift toward autonomous software optimization pipelines powered by AI agents, which could drastically reduce engineering overhead in deploying efficient deep learning systems. As organizations increasingly deploy complex multimodal models at scale, tools that automate low-level performance tuning will become essential for maintaining competitiveness in inference speed and energy efficiency. Furthermore, the open-sourcing of such frameworks encourages community-driven improvements and accelerates innovation in compiler-augmented ML stacks, potentially leading to standardized APIs for LLM-assisted kernel synthesis across hardware platforms.
Disclaimer: The above content is generated by AI and is for reference only.