A 1000×1000 weight matrix is stored densely in fp16 (2 bytes per number). To store an unstructured-pruned copy in CSR (compressed sparse row) format you keep, for each non-zero, its fp16 value (2 bytes) and its column index (int32, 4 bytes), plus one int32 row pointer per row plus one. How many bytes does the sparse copy use at 80% and 95% sparsity, and at what sparsity does it break even with the dense copy?

ML systems and evaluation, Model compression
Level L2 Elementary. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can count the real memory cost of sparse storage, including index overhead, and see why moderate unstructured sparsity saves less than it seems.

Key idea

Every non-zero in CSR costs a value plus an index, here 2+4=6 bytes, three times the 2 bytes of one dense fp16 entry. So CSR beats dense only when the fraction of non-zeros is below 2/6=1/3, that is, above about 67% sparsity.

Steps

  1. Start with the concept question `unstructured-vs-structured-pruning`; this is its numerical side. Dense size: 1000×1000×2=2,000,000 bytes.
  2. At 80% sparsity the number of non-zeros is 0.2×106=200,000. Values and column indices cost 200,000×6=1,200,000 bytes. Row pointers cost 1001×4=4,004 bytes. Total 1,204,004 bytes, about 60% of the dense size.
  3. At 95% sparsity there are 50,000 non-zeros: 50,000×6=300,000 bytes plus 4,004 gives 304,004 bytes, about 15% of the dense size.
  4. Break-even: with density δ (fraction of non-zeros), sparse size ≈6δ×106 and dense size 2×106. Setting them equal gives δ=1/3, so sparsity =2/3≈67%. At 50% sparsity CSR needs about 3,004,004 bytes, more than the dense copy.
  5. Speed is a separate matter. Saving memory does not make a GPU faster, since irregular index lookups prevent the dense matrix-multiply hardware from being used well. Hardware-friendly patterns such as 2:4 sparsity (keep 2 of every 4 values) store 2 values plus small 2-bit position codes, about 4.5 bytes per 4 weights against 8 bytes dense, with a regular layout the hardware can use.

Common mistakes

How long your answer should be

Half a page; about 3 minutes, with the three byte counts and the break-even.

Read this

Previous in ML systems and evaluation: How do you monitor a deployed ML (machine learning) model when ground-truth labels arrive weeks late or never arrive at all?
Next in ML systems and evaluation: How do accuracy, F1 score and ROC-AUC compare as evaluation metrics for a binary classifier, and when is each appropriate, considering threshold dependence, class imbalance and whether each measures ranking quality or decision quality (use a small confusion-matrix example)?