Manuscript Offprint

arXiv:2610.07742

Cleave: Scaling Tensor Program Optimization via Decoupled Algebraic Search and Operator Scheduling

David Pissarra, Jinkun Lin, Haitian Jiang, Aurojit Panda, Jinyang Li

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

David Pissarra ∗^{*}

New York University

New York, USA

david.pissarra@nyu.edu

Jinkun Lin ∗^{*}

Cornell University

Ithaca, USA

jinkun.lin@nyu.edu

Haitian Jiang

New York University

New York, USA

haitian.jiang@nyu.edu

Aurojit Panda

New York University

New York, USA

apanda@cs.nyu.edu

Abstract

Optimized kernels such as FlashAttention and FlashDecoding are crucial for accelerating today's large models. Most of them are handwritten by experts because existing ML compilers cannot match their efficiency. Producing such kernels requires fusing computations with multiple reductions, which requires both algebraic transformation of the computation graph and operator scheduling of the transformed graph. Unfortunately, searching the two jointly yields a space too large to navigate. We propose CLEAVE, an ML compiler built on symbolic decoupling: CLEAVE discovers transformations by performing superoptimization on a graph with symbolic shapes, and then schedules each resulting graph on concrete shapes. Representing shapes as symbols makes equivalence checking cheap and lets a new Split operator, with a symbolic split count, parallelize along a reduction dimension. CLEAVE's scheduler fuses graphs with multiple reductions through iterative tiling and horizontal fusion. Evaluation on common LLM subgraphs shows that CLEAVE generates kernels up to 2.8×2.8\times faster than the best baseline ( 1.6×1.6\times on average) and reduces compilation time by 5.9×5.9\times on average compared to Mirage. For dynamic workloads captured from production serving traces, CLEAVE compiles each operator once and achieves geometric mean speedups of 1.4×1.4\times and 1.7×1.7\times over FlashInfer's handwritten FA2 and FA3 backends. CLEAVE's code is available at: https://github.com/nyu-systems/cleave.

1 Introduction

Efficient execution of deep learning models requires high-performance GPU kernels, which must minimize data movement and exploit hardware parallelism. Kernel fusion is an important optimization technique for reducing data movement: it combines multiple operations into one kernel so that intermediate results can be kept in shared memory or registers, thereby avoiding global memory traffic. Building efficient fused kernels, as in FlashAttention [6, 26] and FlashDecoding [7], has required substantial effort from human experts. Automating this work would reduce the effort

Jinyang Li

New York University

New York, USA

jinyang@cs.nyu.edu

Figure

Figure 1. Symbolic decoupling in CLEAVE, illustrated by the fusion of RMSNorm followed by Matmul. The first phase performs algebraic transformation that finds an equivalent graph which orders the row-wise scaling after Matmul. The second phase performs operator scheduling which makes each slice of X feed both reductions in a single loop over K.

needed to optimize new models. However, despite extensive work on ML compilers [10, 11, 16, 19, 27, 28, 30, 31, 36, 41, 44–48], automatically generating fused kernels that match the efficiency of expert implementations remains difficult.

Kernel fusion is difficult for modern deep learning models because of their extensive use of various reduction-based operations, including matrix multiplication, convolution, normalization and softmax. Fusing these computations often requires combining multiple reductions in one kernel. However, dependencies between reductions can require more intermediate storage than shared memory and registers provide. Furthermore, the straightforward way of partitioning the output across threads may expose too little parallelism to use the GPU efficiently.

Resolving these challenges requires more than determining how to tile, order and map the computation to GPU

∗^{*}Equal contribution.

threads, a process we refer to as operator scheduling. It also requires algebraic transformation to restructure the computation graph to enable tile-by-tile execution and expose additional parallelism. For example, when RMSNorm is followed by a Matmul (Fig. 1), moving the row-wise scaling of RMSNorm after the Matmul allows both reductions to consume the same input tile together, avoiding materialization of the normalized input. The same transformation, applied to the softmax normalization, underlies FlashAttention (§2.2). Scheduling then determines how to tile and execute the transformed graph. Likewise, when a reduction produces too few output tiles to occupy the GPU, algebraic transformation can decompose it into independent partial computations whose results are subsequently combined, a technique commonly referred to as Split-K. Scheduling then determines the partition sizes and maps the partial computations across threadblocks, as in FlashDecoding.

Existing compilers address these requirements in different ways. Scheduling-based compilers [16, 27, 30, 41, 44, 46, 47] optimize loops, tile sizes, and memory layouts, but do not discover the algebraic transformations needed above. Algebraic optimizers [10, 11, 19, 28, 36, 45, 48] search for equivalent computation graphs, but graph transformations alone do not determine how to tile and execute them. Mirage [31] uses superoptimization to jointly search algebraic transformations and operator schedules, resulting in a search space that is often too large to optimize. As our evaluation (§7.3) shows, Mirage fails to optimize some commonly used kernels and runs out of memory on some searches. Beyond compilers, a separate line of work uses LLM agents to write kernels directly [3, 13, 23, 38, 40]. These agents match expert kernels on some workloads, but each new operator requires a costly new search.

We observe that, when combining algebraic transformation with scheduling for fusion, the underlying optimizations can be separated along a natural line. Algebraic transformation rewrites the computation graph into an equivalent one, changing the operators and the dependencies among them while preserving the final result. Scheduling leaves the graph unchanged and decides how it is executed: how reductions are tiled into loops, which loops are fused and how tiles are mapped to threadblocks. The validity of a transformation is a property of the graph alone and does not depend on the schedule nor the tensor shapes. Thus, it can be established once for a graph with symbolic shapes. Whether a transformed graph is profitable depends on the schedule and concrete shapes, which can be decided by a scheduler. We call this approach symbolic decoupling: the algebraic phase searches over graphs with symbolic dimensions, and the scheduling phase binds the symbols to concrete shapes and schedules each resulting graph. In effect, the algebraic search never enumerates loop structures and tile sizes, and the scheduler never reasons about algebraic equivalence.

We have implemented symbolic decoupling in CLEAVE. At a high level, CLEAVE first uses superoptimization to produce all algebraically equivalent graphs of the input and then uses a dedicated scheduler to perform fused tile-by-tile execution for each graph. CLEAVE chooses the most promising candidates according to an analytical cost model and compiles and profiles them for the final kernel. In order for this approach to work well, CLEAVE addresses two technical challenges:

  1. Enhancing and scaling algebraic search. (§4) Given the principle of symbolic decoupling, how to enable the algebraic transformation required to support Split-K? To do so, we introduce a new Split operator in the symbolic graph that partitions a reduction dimension into s parts, where s is one more symbol that divides a given tensor dimension. Superoptimization then decides where to insert Split and how to combine the partial results, while the concrete value of s is bound later by the scheduler. The symbolic graph representation also makes the search scale. Superoptimization checks the equivalence of each candidate graph by probabilistic testing [31], whose cost grows with the tensor sizes. For symbolic graphs, we can perform probabilistic testing using any small instantiation that satisfies the graph's shape constraints. Note that at the end of superoptimization, we still perform the probabilistic testing on the original shapes from the user graph to not lose the correctness guarantee.

  2. Scheduling graphs with multiple reductions. (§5) An algebraically transformed graph still needs a schedule that keeps intermediate storage small and reuses data across reductions. Treating reductions as kernel boundaries, or materializing their producers' full intermediate tensors, would lose the fusion opportunities exposed by algebraic search. Our scheduling algorithm combines two strategies: (1) iterative tiling to break reduction dimensions into smaller tiles, each of which can be computed without materializing all intermediate results in shared memory; and (2) horizontal fusion to compute reductions that share upstream producers in the same loop, reusing the tiles those producers generate.

CLEAVE also supports dynamic workloads ( §6.3§6.3), where batch size and sequence length change from one invocation to the next. In this case, scheduling is performed on a representative concrete shape, and code generation keeps the dynamic extents symbolic with runtime loop bounds, so one compiled kernel serves the varying request shapes.

We have evaluated CLEAVE on commonly used subgraphs, including GQA, MLA, and SwiGLU. Our evaluation ( §7§7) shows that kernels optimized by CLEAVE are up to 2.8×2.8\times faster than the best baseline on each subgraph, with an average speedup of 1.6×1.6\times. Compared to Mirage, CLEAVE reduces compilation time by 5.9×5.9\times on average. On dynamic workloads, a single compilation per operator serves all 303 captured shapes across nine operators, achieving geometric mean speedups of 1.4×1.4\times and 1.7×1.7\times over FlashInfer's FA2 and FA3.

Figure

Figure 2. Data-dependency in the attention graph for computing one output element, before (left) and after (right) FlashAttention algebraic transformation. Circles represent elements in the tensors. Labels indicate computation order after fusion. Before, S is fully computed and cached in SMEM before computing P, incurring high SMEM usage. After, S is streamed with P′P', reducing SMEM usage.

backends, respectively. Finally, when CLEAVE-produced kernels are used in transformer layers from GPT-2, Llama-38B, and Qwen3-32B, layer execution improves by up to 2.5×2.5\times ( 1.7×1.7\times on average) over torch.compile.

References (17)