Chips & architecture · Research feature

Meta's KernelEvolve Automates Kernel Optimization Across Heterogeneous AI Hardware

Meta's KernelEvolve framework automates kernel generation and optimization for deep learning models across diverse AI hardware platforms.

Adapted from research by Gang Liao, Hongsen Qin, Ying Wang and colleagues.

arXiv preprint revision · 2026-07-06 · Attribution & reuse
In this article
Editorial illustration of processor die.

Editor’s introduction

The study evaluates KernelEvolve, an agentic framework designed to automate kernel coding for deep learning recommendation models on heterogeneous AI accelerators. The system generates kernels through a graph-based search process that dynamically adapts to runtime conditions via prompt synthesis and retrieval-augmented policies. A key boundary of the evidence is that kernel candidates require instrumentation for profiling, and the evaluation phase—executing kernels on target hardware—depends on remote hardware access, creating a workload asymmetry between CPU-based generation and hardware-based validation. This limits real-time feedback during development but ensures correctness across diverse architectures.

Introduction

Modern online advertising systems demand massive-scale machine learning inference under stringent sub-second latency constraints. At Meta’s operational scale – serving more than hundreds of trillions of ad-ranking inferences daily across global data centers consuming hundreds of megawatts – the infrastructure deploys an extensive ensemble of multi-stage ranking models (retrieval, early-stage ranking, and second-stage ranking, often exceeding 1500 distinct models) to address diverse prediction tasks. These models execute across a heterogeneous fleet of AI accelerators, including Meta Training and Inference Accelerator (MTIA), AMD GPUs, and NVIDIA hardware. Within this ecosystem, computational kernels—the low-level primitive functions implementing tensor operations, data transformations, and feature engineering—constitute a dual bottleneck affecting both training and serving architecture.

From a performance perspective, ads serving operates under strict real-time constraints where microsecond-level kernel efficiency directly impacts user experience and revenue generation, as well as Meta’s Total Cost of Ownership (TCO). The economic implications are substantial: marginal kernel-level performance improvements translate to multi-million dollar reductions in infrastructure operating costs while simultaneously enhancing user engagement metrics that correlate directly with advertising revenue. From an architectural perspective, kernel coverage on target hardware fundamentally determines system deployment viability. When critical operators lack native implementations on AI accelerators, production systems may architect disaggregated serving topologies where missing operators execute on separate CPU tiers, or halt deployment until kernels are implemented. This fragmentation introduces cross-node network overhead (adding millisecond-scale latency), serialization costs, reduced reliability from cascading failures. Moreover, incomplete kernel coverage blocks model launches, directly constraining algorithmic innovation and competitive differentiation. This confluence of latency sensitivity, architectural constraints, and massive deployment scale elevates kernel optimization to a first-order system imperative for ads model serving infrastructure.

The Curse of Dimensionality

The computational landscape of production ads ranking systems exhibits unprecedented complexity across three critical dimensions: model architecture diversity, kernel primitive diversity and hardware generation and architecture heterogeneity. This combinatorial explosion creates a fundamental scalability crisis that manual kernel development approaches cannot address.

Each stage demands distinct kernel optimization strategies: retrieval favors batched operations maximizing memory bandwidth utilization; early-stage ranking requires balanced compute-memory workloads; final-stage ranking demands maximum single-request performance through aggressive operator fusion and specialization. This architectural diversity—spanning from traditional MLPs to attention-based sequence models—prevents one-size-fits-all kernel optimization approaches and necessitates model-aware kernel generation strategies that can synthesize implementations for both established operators and rapidly emerging architectural patterns.

Kernel Diversity Beyond GEMM. While dense matrix multiplication (GEMM) operations benefit from mature, highly-optimized libraries (cuBLAS, FBGEMM, DeepGEMM), production ads ranking workloads exhibit fundamentally different computational characteristics that necessitate broader kernel coverage. Ads ranking models execute over 200 distinct data preprocessing operators as integral components of model inference pipelines, where raw features undergo transformation before feeding subsequent neural network layers. These transformations span feature derivation (bucketization, set operations, n-gram hashing), dense normalization (variance-stabilizing transformations, one-hot encoding), and sparse normalization (cryptographic hashing with modulo reduction and type downcasting to map categorical features to embedding indices, top-k truncation with score-based ranking).

While individually exhibiting low arithmetic intensity compared to GEMM operations, kernel availability for these preprocessing operators fundamentally determines deployment architecture. The lack of optimized preprocessing kernels on AI accelerators creates a binary constraint: without native accelerator implementations, models become ineligible for unified accelerator deployment. Executing preprocessing on accelerator host CPUs proves infeasible: (1) host CPUs in accelerator servers are underprovisioned compared to dedicated CPU tiers, lacking capacity for preprocessing-intensive workloads; (2) heterogeneous preprocessing demands—varying compute and memory bandwidth requirements—contend with accelerator I/O and system management for limited host resources; (3) allocating additional host CPU capacity negates accelerator consolidation’s economic and power efficiency benefits.

The architectural implications prove severe: preprocessing kernel absence creates a binary deployment constraint rather than incremental performance loss. A single missing preprocessing operator—regardless of arithmetic intensity—blocks entire model deployments on new accelerators, forcing disaggregated architectures with system-level costs exceeding individual kernel inefficiency. This constraint paradoxically elevates preprocessing operators to equal or greater priority than compute-intensive kernels: while suboptimal GEMM implementations degrade performance incrementally, missing preprocessing kernels impose architectural penalties preventing monolithic deployment entirely. Consequently, comprehensive kernel coverage enabling monolithic accelerator deployment—where preprocessing and neural network computation co-locate—emerges as a first-order requirement for cost-effective serving. This architectural imperative motivates KernelEvolve’s automated generation framework synthesizing optimized implementations across the complete operator-hardware matrix, treating data preprocessing as first-class optimization targets alongside traditional compute kernels.

System Architecture

Generated kernels undergo comprehensive evaluation across multiple dimensions. TritonBench validates correctness by comparing generated Triton kernels against PyTorch reference implementations while measuring speedup over baselines. System-level profiling via Torch Profiler captures CPU/GPU time, kernel launch overhead, and function execution durations to identify host-device bottlenecks. However, modern AI accelerator optimization faces a fundamental challenge: performance signals are fragmented across abstraction layers—DSLs, compiler IR, CUDA/PTX/SASS, runtime APIs, and hardware counters—requiring manual correlation across siloed tools. Intra-kernel tracers such as Triton Proton expose instruction-level behavior, kernel profilers report occupancy and memory throughput, while system profilers capture execution timelines and communication patterns. No single tool provides complete stack visibility. To address this fragmentation, Meta developed MPP (Multi-Pass Profiler), a federated tooling framework that unifies instrumentation, compiler transforms, profiling, and trace synthesis as composable job graph tasks. Integrated with existing ecosystems including MLIR, Proton, NCU, and NVBit, MPP enables KernelEvolve to automate cross-stack experiments and access metrics previously gated by tool fragmentation. Hardware-specific profilers (MTIA Insight and Triton Proton) provide platform-specific insights across MTIA, GPU, and AMD interpreters. The evaluation framework in KernelEvolve produces accuracy validation, performance metrics, and profiling insights that collectively determine each search tree node’s status (correct or buggy) and assign optimization insights to guide automatic exploration strategy.

The persistent storage layer enables continuous learning and knowledge accumulation across optimization runs. The metadata store maintains a comprehensive execution context for each kernel candidate, including unique identifiers, parent-child relationships that encode the search tree structure, quality scores from evaluation results, and boolean flags (is_buggy) indicating whether the kernel has execution errors or accuracy failures. Path references in the metadata store link to the object store, which maintains the actual kernel implementations organized by unique identifiers along with associated Triton kernel files and overview documentation (overview.md) containing profiling results analysis and optimization recommendations. This separation of metadata and content allows efficient querying and comparison of kernel variants while preserving complete implementation history. The architecture’s modularity supports flexible deployment configurations with different LLM backends and hardware targets while maintaining a consistent optimization methodology. By systematically exploring the solution space and learning from both successful optimizations and failed attempts, KernelEvolve progressively generates higher-quality kernel implementations that approach theoretical performance limits for given hardware constraints.

Kernel Evaluation on FaaS

Tree search execution decomposes each node expansion into two phases: kernel generation and kernel evaluation. Generation comprises prompt synthesis, knowledge base retrieval, and LLM invocation—CPU-bound operations requiring no accelerator access. Evaluation executes generated kernels on target hardware through TritonBench correctness validation, Torch Profiler timeline capture, and Triton MPP instruction-level analysis. This workload asymmetry—generation on CPU hosts versus evaluation on AI accelerators—motivates architectural disaggregation enabling independent, non-blocking evaluation execution on remote hardware.

FaaS Integration for Remote Evaluation. Kernel evaluation is an ideal FaaS workload: individual evaluation functions execute independently without inter-function dependencies or communication, unlike serverless databases requiring aggregation coordination. KernelEvolve migrates kernel evaluation to Meta’s FaaS (Function-as-a-Service) platform, which abstracts infrastructure complexity including service routing, Twine autoscaling, and lifecycle management. FaaS runtime auto-generates Thrift server interfaces for evaluation handlers, packaging them as fbpkg distributions with hardware interpreter dependencies. We extended FaaS’s Tasklet resource model from CPU/RAM to include GPU resources, enabling hardware-specific evaluation functions targeting NVIDIA, AMD, and MTIA platforms. When tree search generates a kernel candidate, it asynchronously dispatches evaluation requests to FaaS endpoints corresponding to target hardware. Remote workers load pre-deployed interpreter environments, execute evaluation harnesses, and return structured results (correctness status, speedup ratios, profiling metrics) consumed by the context memory sub-agent.

Benefits and Scalability. Disaggregation addresses resource contention: a single host may run hundreds of generation agents but possess limited accelerators (8 GPUs or 24 MTIA devices per host). Without separation, agents serialize through available hardware—each occupying a device for 8-12 minutes (mostly idle during generation) while other agents queue. FaaS-based evaluation provides: (1) resource decoupling—generation agents execute CPU-bound work locally while dispatching evaluation to remote accelerator pools, preventing device occupation during idle generation phases; (2) elastic capacity—evaluation distributes across FaaS worker pools with hundreds of GPUs/MTIA devices rather than serializing through local hardware. This architecture maximizes both CPU (generation) and accelerator (evaluation) utilization, eliminating the mismatch between abundant generation parallelism and scarce local hardware resources.

Future Directions

KernelEvolve demonstrates that LLM agents can generate production-quality kernels for heterogeneous accelerators, but this work represents only the first step toward a broader vision: fully automated, heterogeneous hardware-aware code generation that scales across the entire AI infrastructure stack at Meta.

Heterogeneous Hardware at Scale. As Meta’s AI infrastructure evolves to include next-generation MTIA, AMD MI series, ARM CPUs, and future NVIDIA architectures, the diversity of optimization targets will grow exponentially. We envision KernelEvolve as the unified kernel generation layer across this heterogeneous fleet—automatically adapting to new hardware through updated specifications rather than manual engineering. This requires developing hardware abstraction primitives that capture memory hierarchies, compute capabilities, and ISA constraints in a format amenable to LLM reasoning.

From Operators to Models. Current optimizations target individual operators and small modules, but the greatest performance gains lie at model level. Future work will extend KernelEvolve to reason about cross-layer fusion, global memory allocation, and end-to-end computation graphs. Combined with model transformation techniques—quantization, sparsity, architecture search—this enables co-optimization of model structure and kernel implementation, potentially discovering novel operator compositions that neither humans nor traditional compilers would identify.

Deeper Code Generation. Triton provides a productive abstraction, but certain optimizations require lower-level control. Extending KernelEvolve to modify MLIR dialects, direct PTX/SASS, or hardware diagnostic routines would unlock performance-critical scenarios where Triton’s abstractions become limiting. This vertical integration—from high-level DSLs to bare-metal code—positions LLM agents as general-purpose compilers rather than domain-specific tools.

Massively Parallel Search. The current tree search explores candidates sequentially, but kernel generation is inherently parallelizable. Relaxing consistency guarantees enables thousands of candidates to be evaluated simultaneously across distributed infrastructure, with eventual convergence to optimal solutions. This “infinite-width” search paradigm, combined with inference-time scaling laws, suggests that kernel quality may improve predictably with compute investment—a compelling property for production systems with strict performance targets.

Kernel Optimization. High-performance kernel development has traditionally relied on vendor-optimized libraries (cuBLAS, cuDNN, rocBLAS) and auto-tuning frameworks. Halide decouples algorithm specification from scheduling, enabling portable optimization across hardware targets. TVM extends this with learned cost models for automated schedule search. Triton provides a Python-embedded DSL that abstracts GPU programming at the block level while exposing performance-critical tiling decisions. Recent work introduces higher-level and lower-level abstractions: NVIDIA’s CuTe DSL as part of CUTLASS v4 provides composable layout and tensor abstractions for Tensor Core programming with Python JIT compilation. Meta’s TLX (Triton Low-Level Extensions) adds warp-aware intrinsics and explicit pipeline control for NVIDIA GPU Hopper and Blackwell architectures. OpenAI’s Gluon dialect exposes lower-level layout encoding within the Triton compiler stack whereas TileLang offers a composable tiled programming model with automatic layout inference across NVIDIA and AMD GPUs and Helion compiles high-level PyTorch-like syntax to autotuned Triton code. These abstractions reduce development effort but still require substantial domain expertise for novel kernel transformations and struggle to generalize across heterogeneous hardware without manual adaptation.

LLM-Based Code and Kernel Generation. Beyond traditional kernel optimization, earlier work have applied evolutionary computations to improve general-purpose GPU code, such as machine learning kernels, by designing code transformation operators at the LLVM / MLIR level. And, more recently, large language models (LLM) have demonstrated remarkable capabilities in general-purpose code synthesis. Recent work extends these capabilities to performance-critical domains: AlphaCode achieves competitive programming performance through large-scale sampling, while CodeRL incorporates execution feedback via reinforcement learning. These advances establish the foundation for applying LLMs to kernel development, where correctness and performance speedup are both essential.

Inference Time Scaling. Several recent systems start to apply LLMs specifically for GPU kernel synthesis. KernelBench benchmarks LLM capabilities across operator, fusion, and model-level difficulty tiers. AutoTriton applies RL to Triton programming and KernelLLM explored supervised baseline for Triton kernel generation from PyTorch modules, while TritonRL trains models with execution-guided rewards. KernelAgent was designed around KernelLLM to generate verified Triton kernels from PyTorch programs based on a multi-agent system. GEAK targets AMD MI300X through agentic workflows, and Kevin employs multi-turn RL for CUDA generation. More recently, TritorX has been introduced as an agentic AI system that aims to generate functionally correct Triton kernels from PyTorch ATen operators – an important first step to enable automatic kernel generation for production deployed models to run on MTIAs. AlphaEvolve leverages evolutionary search with LLMs to optimize select stages of TPU/GPU kernels. While these systems demonstrate competitive results on isolated benchmarks, they target single hardware platforms with synthetic workloads, lacking heterogeneous hardware support, production operator coverage, and deployment infrastructure integration required for industry-scale adoption.

Finally, recent work demonstrates that model performance improves predictably with increased test-time compute. Chain-of-thought prompting, tree-of-thought search, and self-consistency decoding can enable complex reasoning through multi-path exploration. OpenAI’s o1 and DeepSeek-R1 demonstrate substantial gains on mathematical and coding benchmarks through scaled inference. KernelEvolve builds on these insights, applying a tree-based search algorithm with execution feedback to systematically explore kernel optimization spaces for a wide collection of heterogeneous AI hardware. Other search algorithms, such as,, can be easily integrated to further improve KernelEvolve’s design space exploration and performance optimization results.

Conclusion

This paper presents KernelEvolve, an agentic kernel generation framework addressing the three-dimensional diversity challenge in large-scale AI infrastructure: hardware heterogeneity across vendors and generations, model architectural diversity spanning retrieval to ranking stages, and kernel diversity from preprocessing to compute-intensive primitives. By formulating kernel optimization as graph-based search with retrieval-augmented prompting and persistent knowledge bases, KernelEvolve achieves 100% correctness across 480 operator-platform configurations and delivers 1.25-17× speedups on production workloads, while reducing development time from weeks to hours.

Beyond performance gains, KernelEvolve demonstrates a fundamental shift in how we approach heterogeneous accelerator deployment. Incomplete kernel coverage forces costly disaggregated architectures with 10-20ms network overhead; automated synthesis eliminates these architectural penalties, transforming kernel availability from a deployment blocker to an enabler. As AI infrastructure evolves toward increasingly diverse accelerator fleets—integrating custom silicon, next-generation GPUs, and specialized processors—the gap between hardware innovation and software ecosystem maturity widens. Manual kernel development cannot scale to this combinatorial explosion of operators, models, and platforms.

We envision a future where LLM agents serve as the universal compilation layer for heterogeneous AI systems, automatically adapting to new hardware through knowledge injection rather than manual porting. KernelEvolve represents a first step toward this vision: demonstrating that agents can generate production-quality kernels for proprietary accelerators absent from training corpora, achieve competitive performance through inference-time scaling, and operate continuously in mission-critical infrastructure serving more than hundreds of trillions of daily inferences. The insights from this deployment—multi-granularity profiling integration, automated validation frameworks, and architecture-aware optimization—establish design principles for AI-assisted systems software that we believe will prove essential as the hardware landscape continues to fragment and diversify. The path forward requires not just better kernels, but fundamentally new approaches to bridging the hardware-software gap at scale.