SparStencil: Retargeting Sparse Tensor Cores to Scientific Stencil Computations via Structured Sparsity Transformation ‡
Qi Li, Kun Li, Haozhi Han, Liang Yuan, Junshi Chen, Yunquan Zhang, Yifeng Chen, Hong An, Ting Cao, Mao Yang · 2025
Read SparStencil: Retargeting Sparse Tensor Cores to Scientific Stencil Computations via Structured Sparsity Transformation ‡ by Qi Li, Kun Li, Haozhi Han, Liang Yuan, Junshi Chen, Yunquan Zhang, Yifeng Chen, Hong An, Ting Cao, Mao Yang (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2506-22969.txt.
Introduction
Qi Li and co-authors retarget AI chips for science computing in a 2025 paper on stencil methods. Stencils update grid points from their neighbors and sit at the heart of many simulations. AI chips have fast sparse cores, but stencils' sparse patterns are too ragged for them.
Their system, SparStencil, reshapes the patterns first. One step flattens and crushes stencil layouts into staircase forms. A graph matching step then fits them to the chip's two-in-four sparsity rule. A code builder writes tuned kernels with layout search. On seventy-nine kernels from many fields, the system ran up to seven times faster than top rivals. Average speed gains passed three-fold, with less hand code than expert tuning.
Catalog record
| CREATOR | Qi Li, Kun Li, Haozhi Han, Liang Yuan, Junshi Chen, Yunquan Zhang, Yifeng Chen, Hong An, Ting Cao, Mao Yang |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 47 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2506-22969
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
SparStencil: Retargeting Sparse Tensor Cores to Scientific Stencil Computations via Structured Sparsity Transformation ‡ Qi Li, Kun Li, Haozhi Han, Liang Yuan, Junshi Chen, Yunquan Zhang, Yifeng Chen, Hong An, Ting Cao, Mao Yang Abstract . Sparse Tensor Cores offer exceptional performance gains for AI workloads by exploiting structured 2:4 sparsity. However, their potential remains untapped for core scientific workloads such as stencil computations, which exhibit irregular sparsity patterns. This paper presents SparStencil, the first system to retarget sparse TCUs for scientific stencil computations through structured sparsity transformation. SparStencil introduces three key techniques: (1) Adaptive Layout Morphing, which restructures stencil patterns into staircase-aligned sparse matrices via a flatten-and-crush pipeline; (2) Structured Sparsity Conversion, which formulates transformation as a graph matching problem to ensure compatibility with 2:4 sparsity constraints; (3) Automatic Kernel Generation, which compiles transformed stencils into optimized sparse MMA kernels via layout search and table-driven memory mapping. Evaluated on 79 stencil kernels spanning diverse scientific domains, SparStencil achieves up to 7.1x speedup (3.1x on average) over state-of-the-art framework while reducing code complexity and matching or exceeding expert-tuned performance in both compute throughput and memory efficiency. 1. Introduction The rapid ascent of artificial intelligence (AI) workloads has fundamentally reshaped the computing landscape. Modern accelerators—especially GPUs—are now engineered not for general-purpose computing, but to saturate the needs of AI-native operations, such as matrix multiplications with structured sparsity. At the heart of this shift are Sparse Tensor Cores, which exploit fine-grained sparsity patterns (e.g., 2:4 sparsity) to skip redundant zero-element computations and significantly boost performance. Yet, scientific computing has largely remained on the periphery of this acceleration revolution. While sparse TCUs have become a cornerstone of AI performance, their capabilities remain underutilized in scientific applications, where data and compute structures diverge sharply from those in AI. This disconnect reflects a deeper tension: hardware is evolving toward AI-native execution models, but science remains anchored in patterns that predate them. Nowhere is this divergence more evident than in stencil computations, the backbone of applications such as fluid dynamics ( Huynh et al. 2014 ; Lusher et al. 2021 ) , weather prediction ( Ao et al. 2017 ; Ben-Nun et al. 2022 ) , and earth modeling ( Jacquelin et al. 2022 ) . These computations iteratively update grid values based on local neighborhoods and account for over 75% of the runtime in long-running simulations ( Denzler et al. 2023 ) . Their ubiquity and cost have earned them recognition as one of the “seven dwarfs” of scientific computing ( Asanovic et al. 2006 ; Asanovic et al. 2009 ; Li et al. 2021 ) . However, stencil computations yield clustered, irregular sparsity patterns that fundamentally differ from the dense or uniformly sparse structures seen in AI. When mapped into matrix formats for GPU acceleration, these patterns often lead to dense masking, padding, and inefficient memory access—all of which violate the alignment constraints of sparse TCUs and degrade utilization. Prior approaches have largely focused on suppressing this sparsity through dense emulation, missing the opportunity to align it with the execution model of sparse TCUs. This paper asks a fundamental question: Can we reimagine scientific computing not as a victim of hardware divergence but as a domain whose latent structure can be transformed to align with AI-native accelerators? We argue yes. And we answer with SparStencil, a stencil computing system that retargets sparse tensor cores originally designed for AI workloads to accelerate scientific stencil computations. Instead of coercing stencil computations into dense formats, SparStencil embraces their clustered sparsity, restructures it into 2:4-compatible formats, and compiles it into optimized sparse TCU kernels—automatically and portably. SparStencil is guided by four key insights that reshape how stencil sparsity can be efficiently exploited on sparse tensor cores. (1) Sparsity is not overhead—it’s alignment potential. Prior approaches treated stencil-induced sparsity as overhead to be suppressed in order to fit dense compute units. Instead, we view this sparsity as an alignment opportunity for specialized sparse execution. (2) Residual sparsity is a leverage point. Despite masking and padding, stencil workloads retain high residual sparsity (50–80%). These conditions are poorly handled by dense TCUs but can be harnessed by sparse TCUs once the structure is exposed. (3) The irregularity does not mean a lack of structure. Though irregular at first glance, stencil-induced sparsity exhibits consistently clustered spatial patterns. These can be systematically reshaped into alignment-friendly forms with the right abstraction and transformation. (4) Structure-aware compilation closes the loop. Exploiting sparse TCUs demands more than format conversion—it requires compilers that understand and reason over structure, automating the path to performance. To realize these insights, SparStencil consists of three tightly integrated stages: First, Adaptive Layout Morphing reformulates diverse stencil patterns into unified matrix-matrix representations through a two-step flatten-and-crush pipeline. It systematically eliminates redundant data accesses while exposing staircase-aligned sparsity, a regularized layout pattern that serves as the structural backbone for downstream hardware-oriented transformations. Second, Structured Sparsity Conversion transforms staircase-aligned sparsity into 2:4-compatible formats required by sparse TCUs. It is achieved by formulating a column-wise conflict graph, where nodes represent matrix columns and edges encode alignment violations. A hierarchical two-level matching algorithm is then applied to resolve conflicts, ensuring valid 2:4 alignment while minimizing zero-padding and maximizing TCU utilization. Third, Automatic Kernel Generation compiles the transformed computation into high-performance sparse MMA kernels. It integrates layout exploration, table-driven memory mapping, and code synthesis into a fully automated backend, delivering expert-level performance without manual tuning or architecture-specific reengineering. We evaluate SparStencil across 79 real-world stencil kernels drawn from a wide spectrum of application domains, including partial differential equation solvers, fluid dynamics, lattice Boltzmann methods, phase field models, and geophysical simulations. Compared to state-of-the-art baselines, SparStencil achieves an average 3.1x speedup, peaking at 7.1x, while significantly reducing code complexity. Our automatic compiler approach matches or exceeds manually optimized expert code in both compute throughput and memory efficiency. To our knowledge, SparStencil is the first system to map scientific stencil computations onto sparse AI accelerators—not by tuning low-level kernels but by structurally rethinking how stencil workloads are represented and executed. This transformation retargets sparse Tensor Cores to scientific domains, and lays the groundwork for a broader shift toward accelerator-centric design for scientific computing. 2. Background and Challenges 2.1. Sparse Tensor Core Sparse Tensor Core is a cutting-edge hardware architecture specifically designed to accelerate sparse matrix multiplication, as described in Equation 1 . (1) D_{m\times n}=(A_{m\times k}\odot M_{m\times k})\times B_{k\times n}+C_{m\times n} where M_{m\times k} is a binary mask matrix in which each group of 4 consecutive elements in a row contains exactly 2 elements equal to 1 and 2 elements equal to 0. This constraint, referred to as 2:4 sparsity, is represented as follows: (2) M_{i,4j+l-4}\in\{0,1\}\quad\text{and}\quad\sum_{l=1}^{4}M_{i,4j+l-4}=2 While sparse TCUs strictly enforce this 2:4 sparsity pattern, sub-2:4 patterns (0:4 and 1:4) can still be processed. This is achieved by treating one or two elements in the 4-element block as nonzero, even if they are zero. Since multiplying by zero does not affect the result, this approach preserves computational correctness. At the hardware level, there is an additional constraint; sparse TCUs partition matrices into uniformly sized fragments for computation. Regardless of matrix size variations, these fragments remain fixed (e.g., 16\times 16\times 8 , 16\times 32\times 8 ). ( Pool et al. 2021