SparseDitto: An Agentic Sparse Compilation Framework through Architecture-Aware Synthesis on GPUs

Shiyang Li, Guangyan Sun, Jinwei Tang, Yanzhi Wang, Mingyi Hong, Caiwen DingarXiv 2026

TL;DR

SparseDitto is an "agentic" sparse compilation framework that automatically synthesizes highly optimized CUDA kernels for sparse matrix operations on GPUs. By jointly optimizing data representation, execution scheduling, and hardware mapping using a learned cost model and LLM-guided code generation, it achieves geometric-mean speedups of up to $2.79\times$ over NVIDIA's cuSPARSE library.

What Problem Does This Paper Address?

Sparse matrix operations—such as Sparse Matrix-Vector Multiplication (SpMV), Sparse Matrix-Matrix Multiplication (SpMM), and Sparse Matrix-General Matrix Multiplication (SpGEMM)—are foundational to scientific computing, graph analytics, and machine learning. However, optimizing these operations on GPUs is notoriously difficult.

The core challenge is that a matrix's performance is highly sensitive to its specific sparsity pattern and the target hardware architecture. A data layout or execution schedule that works brilliantly for a uniform, block-dense matrix might fail catastrophically on an irregular, power-law graph matrix, causing massive "performance cliffs" (up to a $350\times$ slowdown).

Existing solutions fall short of solving this comprehensively:

  • Specialized libraries (like cuSPARSE) or expert-designed kernels only target specific sparsity patterns or operators.
  • Sparse compilers rely on rigid, developer-defined static rules.
  • General LLM-based coding agents can write functionally correct CUDA code but lack the domain-specific, sparse-architectural awareness needed to choose optimal data layouts and thread mappings.

SparseDitto bridges this gap by treating sparse kernel generation as a joint optimization problem across three coupled dimensions: data representation, execution schedule, and target-specific hardware constraints.

Figure 1. SparseDitto’s design space and compilation work- flow. Prior-work annotations in (a) highlight representative mechanisms.

Methods

SparseDitto operates via a three-stage pipeline that combines structural analysis, architecture-aware synthesis, and iterative agentic refinement:

  1. Structural Feature Extraction & Overhead Modeling: For any incoming sparse workload, SparseDitto extracts 36 distinct structural features. These capture intrinsic patterns (e.g., row-length variation, block occupancy), representation overheads (e.g., padding factors for formats like ELL or BSR), and operator-induced intermediate workloads.
  2. Architecture-Aware Synthesis: An interpretable, learned additive energy model acts as a cost model to rank established optimization templates (like CSR, COO, or Tensor-Core blocked layouts). The framework combines this ranking with the target GPU's physical constraints (L2 cache size, shared memory limits, SM count) to synthesize a unified compilation plan.
  3. LLM-Guided Lowering & Profile-Grounded Refinement: An LLM coding agent (GPT-5.6-terra) takes the compilation plan and lowers it into specialized CUDA code. Crucially, the framework doesn't just trust the first output; it compiles the code, validates numerical correctness, and profiles it on the actual target GPU using NVIDIA Nsight Compute (NCU). Feedback from this runtime profiling is fed back into the synthesizer to iteratively refine the plan and code.
Figure 2. One 16 × 16 matrix exposes intrinsic pattern cues and format-induced costs. The matrix contains an irregular dense tile, a high-degree column, an empty row, and uneven row lengths. CSR and CSC traverse compressed rows and columns, respectively. SELL-C with 𝐶= 8 introduces slice-local padding, while 4 × 4 BSR introduces block fill. The right column shows the resulting work granularity and imbalance for rows, columns, slice slots, and blocks.

Datasets

The authors evaluated SparseDitto using a stratified set of 60 matrices from the SuiteSparse Matrix Collection. This benchmark spans regular stencils, finite-element matrices, web graphs, road networks, and circuit simulations. For training the underlying template-ranking energy model, an independent offline corpus of 400 SuiteSparse matrices was utilized. End-to-end application performance was tested using the Reddit dataset for a two-layer full-batch Graph Convolutional Network (GCN) training loop.

Key Insights and Ideas

  • The Asymmetry of Sparse Optimization: The authors observe that sparse optimization is highly asymmetric. While finding the absolute perfect format yields modest gains over a "good" format, picking a poor format results in devastating orders-of-magnitude slowdowns. Therefore, a compiler's primary job is avoiding bad pairings.
  • Mandatory Co-design: Data layout, parallel thread scheduling, and hardware staging cannot be decoupled. For instance, choosing a blocked layout (Representation) dictates whether Tensor Cores can be used (Schedule), which in turn is strictly bounded by the available shared memory per CTA (Hardware Mapping).
  • Static Prior + Dynamic Feedback: While static structural analysis provides an excellent initialization prior, actual cache residency and warp occupancy can only be accurately determined via target-hardware profiling. Merging LLMs with dynamic profiling feedback loop creates a highly adaptable compiler.

Key Results

The framework was evaluated on two distinct architectures: an NVIDIA RTX PRO 6000 (Blackwell/CUDA 13.0) and an NVIDIA H200 (Hopper/CUDA 12.9).

  • Vs. cuSPARSE: SparseDitto achieved a geometric-mean speedup of $2.68\times$ on the RTX PRO 6000 and $2.79\times$ on the H200, with maximum individual speedups reaching up to $146.61\times$.
  • Vs. Specialized State-of-the-Art Systems: It consistently outperformed specialized frameworks (such as CB-SpMV, DTC-SpMM, HSMU-SpGEMM, and SparseTIR) by $1.57\times$ to $5.37\times$, largely because these older baseline systems failed to adapt to newer GPU architectures and runtime versions.
  • End-to-End GCN Acceleration: Integrating SparseDitto's generated SpMM kernels into full-batch GCN training on the Reddit dataset accelerated the entire training epoch by up to $3.39\times$.
Performance comparison against cuSPARSE and specialized baselines

Limitations and Future Work

The primary bottleneck of SparseDitto is its one-time compilation cost. On average, it takes about 30 minutes per matrix to run through the synthesis, LLM code generation, and iterative profiling cycles. This also introduces commercial LLM API costs (approximately \$20 per matrix during evaluation).

While this overhead is easily amortized for workloads where the same sparsity structure is reused millions of times (like deep learning training loops or iterative scientific solvers), it makes the framework unsuitable for ad-hoc, single-run sparse operations. Future work could focus on utilizing smaller, open-source local LLMs fine-tuned specifically for CUDA generation to eliminate API costs and reduce latency.

Summary updated

BibTeX
@misc{li2026sparseditto,
  author = {Shiyang Li and Guangyan Sun and Jinwei Tang and Yanzhi Wang and Mingyi Hong and Caiwen Ding},
  title = {{SparseDitto: An Agentic Sparse Compilation Framework through Architecture-Aware Synthesis on GPUs}},
  year = {2026},
  eprint = {2608.05033},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2608.05033},
}
Figure