Table of Contents
Fetching ...

pyGinkgo: A Sparse Linear Algebra Operator Framework for Python

Keshvi Tuteja, Gregor Olenik, Roman Mishchuk, Yu-Hsiang Tsai, Markus Götz, Achim Streit, Hartwig Anzt, Charlotte Debus

TL;DR

pyGinkgo addresses the Python gap in high-performance sparse linear algebra by wrapping the Ginkgo C++ backend with pybind11 to provide a Pythonic, NumPy/PyTorch-compatible interface, across CUDA, HIP, and OpenMP backends. The framework combines a minimal C++ core with Python dispatchers and a pure-Python layer for extensible algorithms, enabling SpMV and iterative solvers with low overhead. Empirical results show pyGinkgo outperforms major Python libraries (SciPy, CuPy, PyTorch, TensorFlow) on SpMV and achieves competitive or superior solver performance, while maintaining proximity to native Ginkgo on diverse hardware (NVIDIA, AMD) and scaling well with problem size. The work demonstrates pyGinkgo as a practical and portable backend for sparse ML and scientific workflows, with plans to extend solvers (e.g., Rayleigh-Ritz) and integrate additional kernels (e.g., convolution) to broaden applicability.

Abstract

Sparse linear algebra is a cornerstone of many scientific computing and machine learning applications. Python has become a popular choice for these applications due to its simplicity and ease of use. Yet high performance sparse kernels in Python remain limited in functionality, especially on modern CPU and GPU architectures. We present pyGinkgo, a lightweight and Pythonic interface to the Ginkgo library, offering high-performance sparse linear algebra support with platform portability across CUDA, HIP, and OpenMP backends. pyGinkgo bridges the gap between high-performance C++ backends and Python usability by exposing Ginkgo's capabilities via Pybind11 and a NumPy and PyTorch compatible interface. We benchmark pyGinkgo's performance against state-of-the-art Python libraries including SciPy, CuPy, PyTorch, and TensorFlow. Results across hardware from different vendors demonstrate that pyGinkgo consistently outperforms existing Python tools in both sparse matrix vector (SpMV) product and iterative solver performance, while maintaining performance parity with native Ginkgo C++ code. Our work positions pyGinkgo as a compelling backend for sparse machine learning models and scientific workflows.

pyGinkgo: A Sparse Linear Algebra Operator Framework for Python

TL;DR

pyGinkgo addresses the Python gap in high-performance sparse linear algebra by wrapping the Ginkgo C++ backend with pybind11 to provide a Pythonic, NumPy/PyTorch-compatible interface, across CUDA, HIP, and OpenMP backends. The framework combines a minimal C++ core with Python dispatchers and a pure-Python layer for extensible algorithms, enabling SpMV and iterative solvers with low overhead. Empirical results show pyGinkgo outperforms major Python libraries (SciPy, CuPy, PyTorch, TensorFlow) on SpMV and achieves competitive or superior solver performance, while maintaining proximity to native Ginkgo on diverse hardware (NVIDIA, AMD) and scaling well with problem size. The work demonstrates pyGinkgo as a practical and portable backend for sparse ML and scientific workflows, with plans to extend solvers (e.g., Rayleigh-Ritz) and integrate additional kernels (e.g., convolution) to broaden applicability.

Abstract

Sparse linear algebra is a cornerstone of many scientific computing and machine learning applications. Python has become a popular choice for these applications due to its simplicity and ease of use. Yet high performance sparse kernels in Python remain limited in functionality, especially on modern CPU and GPU architectures. We present pyGinkgo, a lightweight and Pythonic interface to the Ginkgo library, offering high-performance sparse linear algebra support with platform portability across CUDA, HIP, and OpenMP backends. pyGinkgo bridges the gap between high-performance C++ backends and Python usability by exposing Ginkgo's capabilities via Pybind11 and a NumPy and PyTorch compatible interface. We benchmark pyGinkgo's performance against state-of-the-art Python libraries including SciPy, CuPy, PyTorch, and TensorFlow. Results across hardware from different vendors demonstrate that pyGinkgo consistently outperforms existing Python tools in both sparse matrix vector (SpMV) product and iterative solver performance, while maintaining performance parity with native Ginkgo C++ code. Our work positions pyGinkgo as a compelling backend for sparse machine learning models and scientific workflows.

Paper Structure

This paper contains 25 sections, 2 equations, 5 figures, 2 tables.

Figures (5)

  • Figure 1: Overview of pyGinkgo
  • Figure 2: Overview of Solver Bindings
  • Figure 3: SpMV and solver performance on different architectures
  • Figure 4: Variation of Speedup relative to SciPy for representative matrices on GPU and CPU
  • Figure 5: Performance difference and time difference analysis relative to native Ginkgo implementation for SpMV on NVIDIA A100 and AMD Instinct MI100 accelerators for CSR and COO matrix formats