TSENOR: Highly-Efficient Algorithm for Finding Transposable N:M Sparse Masks

Xiang Meng, Mehdi Makni, Rahul Mazumder

Abstract

Modern hardware acceleration for Large Language Models (LLMs) often relies on N:M sparsity, a structured pruning technique where $N$ out of every $M$ consecutive weights are non-zero. While effective for the forward pass, standard N:M sparsity fails to maintain its structure upon transposition, creating a bottleneck during the backward pass of training. This paper introduces TSENOR (Transposable N:M Sparsity with ENtropy regularization and Optimized Rounding), a GPU-parallelized algorithm that reformulates the search for transposable masks as an optimal transport problem. TSENOR achieves a 100x to 300x speedup over existing solvers, enabling the application of high-dimensional transposable patterns (e.g., 16:32) to billion-parameter models like LLaMA 3.2 with negligible accuracy loss.

Introduction

As Large Language Models (LLMs) continue to scale, the demand for computational efficiency has led to the adoption of structured sparsity. N:M sparsity has emerged as a preferred format because it provides a middle ground between the flexibility of unstructured pruning and the hardware-friendliness of block sparsity. Specifically, NVIDIA’s Tensor Cores provide direct hardware support for 2:4 sparsity, offering significant throughput gains.

However, a critical limitation persists: standard N:M sparsity is typically defined along a single dimension (rows). During the training process, the backward pass requires the transpose of the weight matrix ($W^T$) to calculate gradients. A matrix that is N:M sparse along its rows is almost never N:M sparse along its columns. Consequently, the backward pass cannot leverage hardware acceleration, leaving the training process bottlenecked. Finding a "transposable" mask—one that satisfies N:M constraints in both the original and transposed orientations—is a complex combinatorial problem that has previously been computationally prohibitive for large-scale models.

The TSENOR Algorithm

TSENOR addresses this challenge by transforming the discrete combinatorial search into a continuous optimization problem. The methodology consists of three primary stages:

1. Optimal Transport Reformulation

The authors observe that finding the optimal transposable mask is mathematically equivalent to a "capacitated optimal transport" problem. By relaxing the binary constraint (where a mask element is either 0 or 1) into fractional values between 0 and 1, the problem becomes differentiable and more manageable.

2. Entropy Regularization and Dykstra’s Algorithm

To solve the relaxed problem at scale, TSENOR introduces an entropy regularization term, similar to the Sinkhorn algorithm used in optimal transport. This allows the use of Dykstra’s algorithm, which iteratively projects the solution onto row, column, and capacity constraints. Because this process consists primarily of matrix-vector multiplications, it is highly amenable to GPU acceleration. This implementation allows TSENOR to process millions of weight blocks simultaneously using standard PyTorch operations without requiring custom CUDA kernels.

Since the optimization produces fractional values, a two-step rounding process converts them back to a binary mask:

  • Greedy Selection: The algorithm iteratively selects the largest fractional values that satisfy the N:M constraints.
  • Local Search: A swap-based refinement identifies "unsaturated" rows and columns, performing element swaps to maximize the total weight magnitude preserved by the final mask.

Experimental Results

Computational Efficiency

TSENOR demonstrates massive performance gains over existing methods. It is 100x to 300x faster than traditional optimal solvers, such as Network Flow, and significantly outperforms general-purpose GPU linear programming solvers like cuPDLP. Despite this speed, the masks generated by TSENOR maintain high quality, with only a 1-10% relative error compared to theoretical optimal masks.

LLM Performance and the "M" Factor

The researchers evaluated TSENOR using the LLaMA 3.2 family (1B, 3B, and 8B parameters) across benchmarks including WikiText2, C4, and various zero-shot reasoning tasks (PIQA, ARC, Hellaswag). A key insight from the study is the importance of the "M" value. While 2:4 and 16:32 both represent 50% sparsity, the larger 16:32 pattern allows for significantly better preservation of model accuracy.

TSENOR is the first algorithm to make these larger patterns computationally feasible for LLMs. Results show that LLaMA 3.2-8B with 16:32 transposable sparsity performs nearly identically to its non-transposable counterpart and actually outperforms standard 2:4 sparse models.

Hardware Implications

By enabling transposable patterns, TSENOR allows for hardware acceleration in both the forward and backward passes. At 75% sparsity, these patterns enable a 3.3x speedup in matrix operations. While current hardware is primarily optimized for 2:4 patterns, the success of 16:32 patterns suggests a path forward for future hardware designs or specialized kernels (such as nmSPMM) to achieve even greater efficiency.

Conclusion

TSENOR provides a scalable solution to the transposable N:M sparsity problem, removing a major bottleneck in sparse LLM training. By leveraging optimal transport and GPU parallelism, it enables the use of high-performance sparse patterns that were previously too expensive to compute. Future work will focus on integrating these masks into end-to-end training pipelines to fully realize the potential of transposable sparsity from scratch.

Summary updated

BibTeX
@inproceedings{meng2025tsenor,
  author = {Xiang Meng and Mehdi Makni and Rahul Mazumder},
  title = {{TSENOR: Highly-Efficient Algorithm for Finding Transposable N:M Sparse Masks}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=o2agVeHrW4},
}
Figure