Back to projects

Santiago Segovia · Project studies

Technical project reportCompleted

Sparse Matrix Research

Santiago Segovia

August 2025 - December 2025

Technologies — MATLAB

View source on GitHub

Abstract

Investigated random, banded, and block sparsity in MATLAB to examine how matrix structure affects computational cost and predictive accuracy in an arithmetic model motivated by encrypted machine learning inference.

Research Overview

This research investigates matrix sparsity as a means of reducing computation associated with privacy-preserving machine learning inference. Matrix operations combine many weighted contributions, but a contribution with a zero weight can be omitted when the implementation explicitly exploits that structure. Sparsification therefore changes the workload by selectively removing entries from the matrix used in computation.

The central research question is how the amount and arrangement of retained information influence the balance between computational efficiency and predictive accuracy. The study is motivated by encrypted inference, where arithmetic can be particularly costly, and examines this trade-off through MATLAB experiments and custom arithmetic. Conclusions must remain tied to the evaluated arithmetic model rather than being interpreted automatically as measurements of a deployed encrypted inference system.

Sparsity Patterns

The study compares random, banded, and block sparsity. Random sparsity distributes retained entries across the matrix without requiring them to occupy a contiguous region. Banded sparsity retains entries near the main diagonal, imposing a relationship between row and column proximity. Block sparsity retains selected groups of entries, producing larger regions of structured connectivity.

These patterns separate two aspects of sparsification: how many values remain and where those values occur. Matrices with equal nonzero counts can preserve different relationships and therefore produce different predictive behavior. Their computational behavior may also differ because regular groups of retained values can be processed differently from scattered entries. The comparison treats sparsity as a structural design choice rather than a single percentage of removed weights.

Experimental Approach

MATLAB was used to construct sparse candidates and evaluate their computational and predictive behavior under the project's custom arithmetic. Each candidate represents a particular selection of retained matrix entries. The nonzero count, nnz(Ws), measures the number of active entries in a sparse candidate Ws; relative to the full matrix size, it also provides a direct description of the degree of sparsification.

For a matrix with m rows and n columns, the zero fraction can be expressed as 1 − nnz(Ws)/(m × n). This describes the stored pattern, but it does not by itself establish an equivalent runtime reduction. The experiments consider computational measurements alongside accuracy so that reductions in arithmetic are interpreted in relation to their effect on the task being evaluated.

Interpreting the Trade-Off

Increasing sparsity can reduce the number of weighted contributions evaluated, but can also remove information that supports accurate predictions. The meaningful question is therefore whether a reduction in computational cost justifies the associated change in accuracy. A highly sparse candidate may be unattractive if its predictions deteriorate substantially, while a less sparse candidate may preserve useful behavior at a lower cost than the original matrix.

A Pareto perspective helps express this comparison: a candidate is dominated if another achieves at least as much accuracy at no greater cost and improves at least one of those objectives. This is an interpretation framework rather than a claim of a unique optimum. Arithmetic savings and measured runtime must also be separated, since representation, indexing, and processing overhead affect how efficiently the implementation can exploit zeros.

Lessons and Significance

The project highlights that computational optimization depends on preserving useful structure while removing unnecessary work. The location of retained entries can matter as much as their number, particularly when a sparsity pattern changes which relationships the computation is able to represent. This connects matrix design directly to the quality of the resulting predictions.

A second lesson concerns the scope of performance claims. Fewer nonzero entries demonstrate a smaller active matrix representation, and fewer evaluated operations demonstrate arithmetic savings, but neither alone proves an equivalent speedup in encrypted execution. The contribution is an experimental framework for comparing sparsity patterns and their efficiency–accuracy trade-offs under the chosen computational model.