GraSS: Scalable Influence Function with Sparse Gradient Compression

Pingbang Hu, Joseph Melkonian, Weijing Tang, Han Zhao, Jiaqi W. Ma · DOI

Abstract

Data attribution—identifying which training samples most influenced a model's prediction—is a critical tool for model interpretability and debugging. However, traditional influence functions face a massive scalability wall when applied to billion-parameter models due to the $O(np)$ memory and compute requirements for per-sample gradients. We introduce GraSS (Gradient Sparsification and Sparse-projection), a framework that makes data attribution practical for large-scale models. By leveraging the natural sparsity of gradients and employing a two-stage compression approach, GraSS achieves up to a 165% speedup over previous state-of-the-art methods while maintaining high accuracy.

The Scalability Challenge in Data Attribution

When a machine learning model exhibits bias or makes an error, understanding the root cause in the training data is essential. The "influence function" is the gold standard for this task, calculating how model parameters would shift if a specific training point were removed. For Large Language Models (LLMs) with billions of parameters ($p$) and training tokens ($n$), the storage and processing of per-sample gradients is physically and financially prohibitive for most researchers.

Existing solutions typically use random projections, such as the Johnson-Lindenstrauss transform, to compress these gradients. However, the compression step itself often becomes a bottleneck because it involves dense matrix multiplications that scale with the model's parameter count.

Methodology: The GraSS Framework

GraSS addresses the computational bottleneck through a two-stage "Sparsify then Project" pipeline designed to exploit the mathematical structure of neural network gradients.

1. Sparsification (The Masking Stage)

Instead of processing all $p$ parameters, GraSS first selects a subset of dimensions ($k'$). The framework supports two masking strategies:

  • Random Mask: Dimensions are selected uniformly at random.
  • Selective Mask: A data-driven approach that optimizes a mask to retain dimensions most relevant to the resulting influence scores.

2. Sparse Projection (SJLT)

Following dimension reduction, GraSS applies a Sparse Johnson-Lindenstrauss Transform (SJLT). Unlike standard dense projections, the SJLT utilizes a projection matrix with very few non-zero entries, significantly accelerating the computation.

Conceptual diagram of the Sparse Johnson-Lindenstrauss Transform (SJLT) mapping a high-dimensional gradient vector to a lower-dimensional space.

For deep learning architectures, the authors developed FACTGRASS (Factorized GraSS). This variant exploits the Kronecker product structure of linear layers, allowing the algorithm to compute compressed gradients without ever fully materializing the massive original gradient in memory.

Experimental Evaluation

The researchers evaluated GraSS across a diverse range of tasks and scales, including MNIST (MLPs), CIFAR-2 (ResNet9), MAESTRO (Music Transformer), and WikiText (GPT2-small). To test billion-scale scalability, they applied the method to Llama-3.1-8B-Instruct evaluated on a 1-billion token subset of OpenWebText.

Key Insights and Results

Hardware-Aware Optimization

A key contribution of this work is the development of a custom SJLT CUDA kernel. Standard libraries like PyTorch often struggle with the race conditions inherent in sparse operations (where multiple threads attempt to write to the same memory location). The custom kernel resolves these issues, translating theoretical sparse speedups into real-world performance gains.

Performance and Fidelity

On the Llama-3.1-8B model, FACTGRASS achieved a 165% faster throughput during the compression step compared to LOGRA, the previous state-of-the-art. Despite this speedup, the method maintains high fidelity. Using the Linear Datamodeling Score (LDS)—a metric for how well an attribution method predicts the effect of removing data—GraSS consistently matched or outperformed dense projection methods.

Comparison of projection time and relative error between Gaussian projections and SJLT (PyTorch vs. CUDA). The top plot shows that SJLT, especially with the custom CUDA kernel, maintains near-constant projection time as the projection dimension k increases, while Gaussian projection time grows significantly. The bottom plot confirms that SJLT maintains the same relative error as dense Gaussian projections.

Conclusion and Future Work

GraSS demonstrates that gradients in modern networks are naturally sparse, particularly those using ReLU activations. By explicitly designing a compression scheme to exploit this sparsity, GraSS achieves sub-linear time complexity relative to the number of parameters.

While highly effective, the method currently has some limitations. The "Selective Mask" approach requires a one-time optimization overhead, and the framework relies on the standard assumption that data influence is additive. Future work aims to extend the factorized efficiency of FACTGRASS beyond linear layers to other architectures, such as convolutional neural networks.

Summary updated

BibTeX
@inproceedings{hu2025grass,
  author = {Pingbang Hu and Joseph Melkonian and Weijing Tang and Han Zhao and Jiaqi W. Ma},
  title = {{GraSS: Scalable Influence Function with Sparse Gradient Compression}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=o0HgWRmyY1},
}
Figure