Share
Embed
Transcript
34 slides
-
BRP-SpMM: Block-Row Partition Based Sparse Matrix Multiplication with Tensor and
CUDA Cores IPDPS 2025 Yukang Dong, Wenbin Jiang, Xinhai Shen, Haihong Guo, Zhiyuan Shao, Hai Jin Presenter: BI SHUTAN 2026/4/17 1 -
Overview Background - SpMM is a fundamental operation in scientific
computing and GNNs - GPUs feature specialized Tensor Cores for dense math and general-purpose CUDA Cores Challenges - Tensor Cores offer massive throughput but struggle with high-sparsity matrices (>90%) - Existing methods suffer from unaligned memory access Proposed Method: BRP-SpMM - Partitions sparse matrix into TC Block and Residual Row parts - Customized storage format to manage these two parts efficiently - Leverages Tensor Cores and CUDA Cores separately for optimal utilization Results - Average speedup of 2.1x (up to 2.9x) over cuSPARSE on NVIDIA A800 - Accelerates GNN training by up to 1.9x compared to DGL and PyG 3 2026/4/17 -
Preliminary 1: SpMM Operation Sparse-Dense Matrix Multiplication (SpMM) β’ Computes
πΆπΓπ = π΄πΓπΎ Γ π΅πΎΓπ β’ Matrix A is sparse, Matrices B and C are dense Sparse Matrix Characteristics β’ A matrix where the number of non-zero elements is significantly fewer than the total elements. β’ Matrix A: πππ βͺ π Γ πΎ β’ High Sparsity (>90%) or Extreme Sparsity (Graph adjacency matrices >99%) 4 πΆπΓπ π΄πΓπΎ π΅πΎΓπ 2026/4/17 -
Preliminary 2: Standard Sparse Formats(π Γ π matrix) COO (Coordinate)
β’ Stores (πππ€, πππ, π£πππ’π) triples for every non-zero element. β’ Storage Space: 3 Γ πππ. CSR (Compressed Sparse Row) β’ Data Structure: Uses three arrays to minimize space: β’ π ππ€ππ‘ππ : Pointers to the start of each row (size: π + 1). β’ πΆπππΌππ₯: Column index for each value. β’ ππππ’π: All non-zero elements. β’ Computation: Number of elements in row π = π ππ€ππ‘ππ [π + 1] β π ππ€ππ‘ππ [π] β’ Storage Space: 2 Γ πππ + π. 5 CSR COO 2026/4/17 -
Preliminary 3: Tensor Core CUDA Cores: Support standard data types
(FP16, FP32, FP64, INT32) Flexible with irregular storage formats like CSR and COO Tensor Cores: Hardware designed to accelerate dense GEMM op. Deliver significantly higher throughput than CUDA Cores. Require strict blocked data formats (e.g., m8n8k4) 6 Ampere GPU SM (A100) Example: m4n4k4 D(m,n) = A(m,k) Γ B(k,n) + C(m,n) 2026/4/17 -
Related Works: TCGNN-SpMM A pioneering study focusing on SpMM operations
within Graph Neural Networks. Core Innovation: Sparse Graph Translation (SGT) (On CPU) β’ Condense sparse matrices by grouping rows into row windows. β’ These blocks serve as the basic processing unit for GPU Tensor Cores. β’ Non-zero elements within each window are condensed into 16Γ8 TC Blocks. 7 2026/4/17 -
Related Works: DTC-SpMM A state-of-the-art SpMM implementation built directly upon
the TC-GNN framework. Shifts from high-level APIs to low-level MMA PTX instructions for finer hardware control. Advanced Runtime Optimizations β’ Offloading SGT from CPU to GPU to significantly reduce preprocessing overhead. β’ Implements vectorized global memory accesses and double buffering. β’ Introduces pipeline strategies to overlap data loading with Tensor Core computation. β’ Utilizes register remapping and load balancing to improve throughput Critical Shortcomings β’ Extensive optimizations result in a significantly large kernel function (~300 lines). β’ Large program sizes risk overflowing the GPU instruction cache, reducing efficiency. β’ Does not improve upon the original SGT technique, inheriting its memory alignment flaws. 8 2026/4/17 -
Challenge 1: Inefficient Memory Access Hardware Alignment Constraints β’ GPU
memory access efficiency is maximized when: β’ Starting addresses are aligned to 128 bytes. β’ Dense block sizes are fixed (e.g., 128B). β’ GPU L2 cache line size is 32 128 bytes, managed in 32 bytes sectors β’ Cache utilization peaks only when data loads are multiples of 32 bytes The Limitation of Sparse Graph Translation (SGT) β’ Non-zero elements in each TC block are unpredictable in existing methods. β’ This leads to unaligned memory access and inefficient L2 cache usage. 9 2026/4/17 -
Challenge Challenge 2: Compute Unit Mismatch β’ Some TC blocks
generated by SGT contain only a single non-zero element β’ Tensor Cores are high-throughput units designed for dense operations β’ Processing "almost empty" blocks reduces computational efficiency 10 Challenge 3: Oversized Runtime GPU Kernels TCGNN-SpMM: Uses high-level WMMA C API but lacks advanced optimizations. DTC-SpMM: Incorporates low-level MMA PTX and numerous runtime optimizations. The Instruction Cache Bottleneck β’ Extensive optimizations result in significantly large kernel functions (~300 lines). β’ Large program sizes can lead to Instruction Cache Overflow on the GPU. 2026/4/17 -
Motivations 1. Memory Alignment & Cache Efficiency Problem: Existing SGT
methods produce blocks with unpredictable non-zero counts. Proposed Method: Implement a Fixed Non-zero Strategy to ensure 100% memory alignment 2. Optimal Compute Unit Utilization Problem: Processing nearly empty blocks on Tensor Cores wastes high-throughput hardware. Proposed Method: Adopt a hybrid strategy by offloading residuals to flexible CUDA cores. 3. Instruction Cache & Kernel Complexity Problem: SOTA kernels (e.g., DTC-SpMM) are excessively bloated and complex (~300 lines). Proposed Solution: Design Compact Kernels (1/3 size of SOTA) to maximize I-Cache efficiency. 11 2026/4/17 -
Part 1: Block-Row Partition 13 The Fixed Non-zero Strategy (π
= π) β’ BRP-SpMM fixes the number of non-zero elements per column, denoted as f. β’ By setting π = 1, every TC Block(hΓw) contains exactly w (width) non-zero elements. β’ Columns with multiple elements are split to maintain this strict density Benefits β’ Eliminates the variable non-zero counts per block β’ Minimizes TC block growth while ensuring consistent memory access patterns Note: Diagram uses simplified 4Γ4 blocks (g=2). Real-world settings uses 16Γ8 blocks (g=4). 2026/4/17 -
Part 1: Block-Row Partition 14 TC Block Group β’ Grouping
Logic: Every g TC blocks are organized into a single TC Block Group. β’ TC Block Part: Complete groups are assigned to Tensor Cores. β’ Residual Row Part: Elements failing to form a full group are offloaded to CUDA Cores. Benefits β’ 32 floats (128Byte) ensure 100% alignment with memory access widths. β’ 128B is a direct multiple of the 32B L2 cache line. Note: Diagram uses simplified 4Γ4 blocks (g=2). Real-world settings uses 16Γ8 blocks (g=4). 2026/4/17 -
Part 2: Customized Storage Format β TC Block Part 16
Field Description group_window_id Index of the row window the group belongs to. local_id Local element index within the TC block(0~β Γ π€ β 1) old_col_id Original column index in the sparse matrix values Actual non-zero data values (e.g., weights or features). 2026/4/17 -
17 Field Description res_rows_id Indices of rows containing residual non-zero
elements res_row_offset Start and end positions of non-zeros for each residual row. res_col_id Original column index for each residual non-zero element. values Actual data values in the residual sparse matrix. 0 1 2 3 8 9 10 11 Part 2: Customized Storage Format β Residual Row part 2026/4/17 -
18 Part 2: Customized Storage Format β Storage Space Matrix
Dimensions: π Γ π with πππ§ total non-zero elements. Workload Split: πππ§ = πππ§π‘ ππΆ ππππ‘ + πππ§π π ππ πππ’ππ ππππ‘ . Configuration: TC Block size β Γ π€ = 16 Γ 8; Group size π = 4 TC Block Part 4 arrays: group_window_id, local_id, old_col_id, and values TC Block Part Count = nnzt gΓw Total Size = nnzt gΓw + 3 Γ nnzt = nnzt 4Γ8 + 3 Γ nnzt β 3.03nnzt β 3nnzt Residual Row Part Upper Limit: Worst case assumes every row is a Residual Row. Total Size = π + π + 1 + 2 Γ πππ§π = 2π + 1 + 2πππ§π BRP-SPMM Total Total = 3πππ§π‘ + 2π + 1 + 2πππ§π = 2(πππ§π‘ +πππ§π ) + πππ§π‘ + 2π + 1 β 2πππ§ + πππ§π‘ + 2π 2026/4/17 -
19 Part 2: Customized Storage Format β Storage Space BRP-SPMM
β 2πππ§ + πππ§π‘ + 2π Standard CSR β 2πππ§ + π Overhead: Approximately πππ§π‘ + π additional storage, roughly 50% more compared to CSR? Trade-off: The 50% increase in storage space is a minimal cost for the significant gains in memory access efficiency and L2 cache hit rates. Standard CSR 2026/4/17 -
21 Hidden Memory Overhead in BRP-SpMM Preprocessing β’ Paper Claim:
Custom format uses only ~50% more space than standard CSR. β’ This only accounts for the final static storage, ignoring the massive peak memory footprint during preprocessing (Algorithm 1). Overhead 1: Redundant Input Formats β’ Algorithm 1 requires row_offset (CSR) AND row_idx (COO) simultaneously. β’ Input alone takes 3 Γ πππ§ + π before any processing begins. Overhead 2: Temporary array nnz_window_id β’ requires πππ§ allocation. 2026/4/17 -
22 Hidden Memory Overhead in BRP-SpMM Preprocessing Overhead 3: Out-of-Place
GPU Sorting β’ MultiKeySort on GPU (e.g., CUB/Thrust) cannot be executed in-place. β’ Sorting tuples requires Double Buffering, adding an implicit 3 Γ πππ§ temporary allocation. Peak Memory Footprint Calculation: β’ Input Data: βΌ 3πππ§ + π β’ Sort Buffers & Temp Arrays: βΌ 4πππ§ β’ Output Allocation: βΌ 3πππ§ + 2π β’ Total Peak Memory β 10πππ§ (Nearly 3x to 4x the size of standard CSR). 2026/4/17 -
24 Part 3: TC Block Kernel - Load Balance 2026/4/17
Thread Block Mapping (Load Balanced) β’ 1 Thread Block β Computes 1 TC Block Group(4 TC Block). Warp Division β’ 1 Thread Block(128 threads) = 4 Warps. β’ 1 Warp β Computes 8 columns of Matrix B.(m16n8k8) β’ Multiply TC Block Group (4 blocks of 16 Γ 8) by 8 Γ 8 π΅π‘πππ Addressing Matrix B Issue: Compression(Fixed Non-zero) changes A's original column layout. Solution: Use old_col_id to find matching rows in B. Fetching Example β’ If condensed A has πππ_πππ_ππ = [2, 5, 11, 13]... β’ Fetch rows 2, 5, 11, 13 from Matrix B. β’ Each warp fetches 8 elements from these rows -
25 Part 3: TC Block Kernel - Register Remapping 2026/4/17
The Bottleneck β’ High overhead from atomic write-backs to Matrix C. DTC-SpMM β’ 4 independent m16n8k4 instructions β 4 πΆππππ outputs. β’ Requires 4 atomic writes per thread. BRP-SpMM β’ Use 4 m16n8k8 instructions to compute 1 single πΆπ‘πππ . β’ Accumulate intermediate sums directly in registers(RC). Result & Benefit β’ Only 1 atomic write per thread. β’ Reduces atomic operations by 75%. TC Block Group(π΄ππππ ) 16 32(4Γ8) Bππππ 32(4Γ8) 8 Γ = 16 8 Cππππ -
27 Part 3: Residual Row Kernel Computation Goal β’ 1
Γ πΎ (Residual Row) Γ πΎ Γ π (Matrix B) β 1 Γ π (Row in Matrix C) 1-D Tiling Strategy β’ set ππππππ·ππ. π₯ = 1, ππππππ·ππ. π¦ = π β’ 1 Thread BlockβHandles 1 residual row(Computes 1 row in Matrix C). β’ 1 ThreadβComputes 1 element in Matrix C(Handles 1 column in Matrix B) Execution Flow & Write-Back β’ Executes serially after the TC Block kernel finishes. β’ Each thread writes to a unique element in Matrix C. β’ No Atomics: Safe to use += directly to aggregate final results (πΆ[π₯ β π + π‘ππ] += πππ π’ππ‘). 2026/4/17 Residual Row Matrix B Row in Matrix C -
Experiment: Setup Hardware Environment β’ GPU: NVIDIA A800 GPU (Ampere,
80GB memory). β’ Compute Capability: 8.6. β’ Software Stack: CUDA 12.4 β’ Measurement: Each test is repeated 100 times, reporting average results. Dataset Source: Eight widely-used graph datasets from Deep Graph Library (DGL). Key Metric: All datasets exhibit extreme sparsity, exceeding 99%. Scale Range: 20K rows to 717K rows 28 2026/4/17 -
Experiment: Baseline CUDA Core Based Methods: cuSPARSE: NVIDIA's standard vendor
library (v12.4), used as the primary baseline. Sputnik: A SOTA sparse library designed for deep learning, optimized for CUDA cores. Tensor Core Based Methods: TCGNN-SpMM: Pioneering work bringing SpMM computation to Tensor Cores via SGT. DTC-SpMM: SOTA implementation focused on bridging the gap for SpMM with Tensor Cores Evaluate normalized speedup relative to cuSPARSE across varying dense matrix columns (N=32~256). 29 2026/4/17 -
Experiment: SpMM Performance Comparison(N=32) β’ Vs. cuSPARSE: Achieves an average
speedup of 2.1x when N=32. β’ Peak Performance: Reaches a maximum speedup of 2.9x on the PubMed dataset. β’ Vs. DTC-SpMM: Delivers an average speedup of 1.2x across all scenarios. 30 2026/4/17 -
Experiment: SpMM Performance Comparison β’ Peak performance at N=32 is
attributed to the 32 Γ 4 thread block configuration(4 warps). β’ Each warp computes 8 columns via m16n8k8, maximizing thread efficiency. β’ For larger N, redundant memory reads of π΄π‘πππ degrade relative performance. 31 2026/4/17 -
Experiment: Preprocessing Overhead Analysis β’ Comparison: Consistently the lowest overhead
across all eight datasets. β’ Scalability: On the largest dataset, BRP-SpMM is 212.9x faster than TCGNN-SpMM (CPU). β’ Speedup vs SOTA: 1.9x faster than DTC-SpMM on the Yelp dataset. β’ Scalability: As the dataset size increases, the advantage becomes more significant. 32 2026/4/17 -
Experiment: Detailed comparison of two parts β’ TC Block Dominance:
Accounts for 88.5% of non-zero elements on average. β’ Execution Time: Consumes 85.9% of total kernel execution time. β’ Edge Case: In massive datasets, the Residual Row proportion drops significantly (~5%). β’ Future Direction: Fixed window constraints (π = 4, π€ = 8) limit residual size. 33 2026/4/17 -
Experiment: L2 Cache Hit Rate β’ Average Gains: +13.2% over
cuSPARSE and +8.6% over DTC-SpMM. β’ Peak Performance: Over 20% improvement on the Yelp dataset. β’ The 128-byte aligned memory access significantly improves hardware efficiency. 34 2026/4/17 -
Experiment: Storage Analysis β’ Comparison: Memory footprint is nearly identical
to the standard COO format. β’ Requires at most 50% more space compared to the highly compressed CSR format. β’ Peak Memory Footprint during preprocessing: 10πππ§ 35 2026/4/17 -
Case Study: End-to-End GNN Training(500 epochs) β’ Experimental Setup β’
Model: 2-layer Graph Convolutional Network (GCN). β’ Frameworks: Compared against DGL, PyG, TC-GNN, and DTC-GCN. β’ Average Speedup: BRP-GCN achieves 1.13x to 1.51x speedup over all baselines. β’ Maximum Gain: Reaches 1.87x speedup over DGL on the Yelp dataset when N=128. β’ Format conversion time is included in the totals and proven negligible 36 2026/4/17 -
Conclusion Motivation & Method β’ Issue: Inefficient memory access and
underutilized Tensor Cores in high-sparsity SpMM. β’ Solution: Partition matrices into a TC Block part and a Residual Row part. Key Results β’ vs. cuSPARSE: Up to 2.9Γ (avg 2.1Γ) kernel speedup. β’ vs. SOTA (DTC-SpMM): Up to 1.8Γ (avg 1.2Γ) kernel speedup. β’ End-to-End GNN Training: Up to 1.9Γ faster in GNN training compared to DGL/PyG. Limitations & Future Work β’ The "Fixed Non-zero(π = 1)" strategy is sub-optimal for moderate sparsity (50%-80%). β’ Residual part becomes overly small in massive graphs, limiting GPU thread utilization. β’ Future Work: Needs an adaptive approach to dynamically adjust f and g parameters. 37 2026/4/17 -
Questions and Thoughts 38 2026/4/17 β’ Extra attention must be
paid to the actual memory cost during the preprocessing phase. β’ Even with 99% sparsity, local sparsity patterns can trigger excessive TC Blocks and reduce efficiency. β’ The reduction in atomic writes is less significant than claimed; β’ The primary source of improvement (BRP or reduced instructions) remains unclear. β’ For Krylov iterations, SpMM primarily appears in specialized variants such as Block-GMRES. -
References [1] Yuke Wang, Boyuan Feng, Zheng Wang, Guyue Huang,
and Yufei Ding. TC-GNN: Bridging Sparse GNN Computation and Dense Tensor Cores on GPUs. In Proceedings of the 2023 USENIX Annual Technical Conference (ATC 2023), pages 149β164. USENIX, 2023. [2] Ruibo Fan, Wei Wang, and Xiaowen Chu. DTC-SpMM: Bridging the Gap in Accelerating General Sparse Matrix Multiplication with Tensor Cores. In Proceedings of the 29th ACM International Conference on Architectural Support for Programming Languages and Operating Systems (ASPLOS 2024), pages 253β267. ACM, 2024. 39 2026/4/17