What is Structured sparsity?

Sparsity in which zero weights follow a fixed pattern; 2:4 sparsity, with two zeros in every four weights, lets matrix units that support it skip the multiplications by zero and compute faster.

Field: AI Hardware & Software Stack

Japanese name: 構造化スパース

Difference from scattered zeros

A state in which many of the weights are 0 is called sparse. When the positions of the zeros follow no rule, it is unstructured sparsity. In that case the position of each nonzero value has to be recorded one by one. Because the positions are irregular, an arithmetic unit cannot read the data in a fixed sequence. Even with many zeros, an ordinary matrix unit gains little speed. Structured sparsity puts a rule on where the zeros go, so that hardware can handle them easily.

How 2:4 sparsity works

In 2:4 sparsity, every four consecutive weights form a group. At least two in each group are set to 0. Eight weights, for example, form 2 groups, with at most 2 × 2 = 4 nonzero values. What is stored is two values per group and a small piece of information giving their positions within the group. Every group has the same shape, so the arithmetic unit can process them in a fixed sequence. A matrix unit that supports this format skips the multiplications by 0, so it can compute faster than with a dense matrix.

How it is made, and other structures

In many cases the starting point is a trained dense model. In each group, the weights with less influence are chosen and set to 0 to give the 2:4 pattern. The model is then retrained with the zero positions kept, to recover accuracy. Because the placement of zeros is constrained, accuracy can be harder to keep than with unstructured sparsity of the same ratio. Removing whole channels or filters is also a kind of structured sparsity. It leaves smaller dense matrices, so it speeds up even arithmetic units with no special support.

Try it: questions about Structured sparsity

Which describes the 2:4 structured sparsity supported by GPU matrix units?

  1. AWeights are grouped in fours with two zeros in each group; this fixed pattern lets matrix units skip zeros for up to about 2× speedup
  2. BTwo of every four weights are chosen at random each time
  3. CMatrices are split into 2 × 4 blocks for computation
Show answer and explanation

Answer: A. Weights are grouped in fours with two zeros in each group; this fixed pattern lets matrix units skip zeros for up to about 2× speedup

With 2:4 sparsity, training or fine-tuning ensures that at least two of every four consecutive weights are zero. Only the two non-zero values and a small index of their positions need storing, so memory shrinks, and matrix units skip the zero multiplications for up to about twice the speed. The fixed pattern makes hardware acceleration practical where scattered sparsity is difficult.

FAQ

If half the weights are 0, does any kind of sparsity run faster?

No. The gain applies to a fixed pattern such as 2:4 on a matrix unit that supports it. Even then, the speed of the whole model also depends on things such as memory bandwidth.

How is it related to pruning?

Pruning is the operation of setting weights to 0, and sparsity is the resulting state. Choosing the weights so that the zeros form a fixed pattern gives structured sparsity. Choosing them freely gives unstructured sparsity.

Books on AI Hardware & Software Stack Ad

As an Amazon Associate I earn from qualifying purchases.

This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.

Back to the glossary