NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Sparse Graph Neural Networks with Scikit-Network

Simon Delarue, Thomas BonaldComplex Networks 2023

This paper introduces a new Graph Neural Network (GNN) module for the Scikit-network Python library. While most GNN frameworks rely on dense tensor operations optimized for GPUs, this work advocates for a "sparse-first" approach. By leveraging sparse matrix representations for both graph structures and node features, the authors demonstrate that GNNs can be trained efficiently on large real-world datasets using standard CPU resources and minimal memory.

The "Memory Wall" in Graph Learning

Real-world graphs—like social networks or web crawls—are massive but incredibly sparse. However, dominant GNN libraries like PyTorch Geometric (PyG) and Deep Graph Library (DGL) are built on top of deep learning frameworks designed for dense tensors.

This creates a "memory wall." To process large graphs in these frameworks, users often have to resort to complex workarounds like neighborhood sampling or mini-batching, which add architectural complexity. Without these tricks, standard GNN implementations frequently trigger Out-of-Memory (OOM) errors on typical hardware. The authors tackle this by asking: Can we build a GNN framework that treats sparsity as a first-class citizen?

Methods: A Sparse-First Architecture

The core of the implementation is the use of SciPy’s Compressed Sparse Row (CSR) format for both the adjacency matrix ($A$) and the feature matrix ($X$). The authors implement a layer-wise propagation rule that adapts to the data's density:

  1. Layer 0 (Sparse-to-Sparse): Since input features (like word counts) are often sparse, the first layer uses Sparse-Matrix-Sparse-Matrix multiplication (SpMSpM).
  2. Hidden Layers (Sparse-to-Dense): As data passes through the network, representations become dense. For these stages, the library switches to Sparse-Matrix-Dense-Matrix multiplication (SpMM).
  3. API Design: Following the scikit-learn philosophy, the module uses a simple .fit_predict() interface, making GNNs as accessible as standard clustering or ranking algorithms.

The Sweet Spot of Sparsity

A key insight of the research is identifying the specific conditions where sparse implementations outperform dense-optimized frameworks. The authors found a clear threshold (density $\approx 10^{-3}$). Once a graph's density drops below this point, the sparse matrix approach becomes significantly more efficient than dense tensor methods.

Computation time vs. Density: sknetwork becomes the most efficient option as graph density decreases below 10^-3.

Key Results and Benchmarks

The researchers evaluated their implementation on three real-world datasets: Wikivitals, Wikivitals+, and OGBN-arxiv. Benchmarks were conducted on a standard MacBook (M1 Pro, 16GB RAM) against DGL and PyG:

  • Memory Efficiency: On the OGBN-arxiv dataset (169k nodes), both DGL and PyG failed with Out-of-Memory (OOM) errors during full-graph training. scikit-network completed the task in approximately 60 seconds.
  • Speed: On the Wikivitals+ dataset, scikit-network was nearly 4x faster than DGL (632s vs 2396s).
  • Scaling: As shown in the performance benchmarks, the computation time for scikit-network scales more gracefully as the number of nodes increases, provided the graph remains sparse.
Computation time vs. Number of Nodes: sknetwork maintains lower overhead compared to DGL and PyG as graph size increases.

Conclusion

By relying solely on NumPy and SciPy, the library removes the need for specialized CUDA installations or high-end GPUs. It proves that for many graph tasks, a well-optimized CPU implementation is faster and more robust than a GPU implementation struggling with memory overhead. While currently focused on GCN-style layers, the authors plan to extend the module to include attention mechanisms and a wider variety of optimizers.

Summary updated

BibTeX
@inproceedings{delarue2023sparse,
  author = {Simon Delarue and Thomas Bonald},
  title = {{Sparse Graph Neural Networks with Scikit-Network}},
  booktitle = {Complex Networks},
  year = {2023},
  doi = {10.1007/978-3-031-53468-3\_2},
}
Figure