Chips & architecture · Research feature

PyGim Library Boosts Graph Neural Network Performance on Real Processing-In-Memory Systems

A new Python library, PyGim, improves graph neural network speed on real processing-in-memory hardware by reducing data movement bottlenecks.

Adapted from research by Christina Giannoula, Peiming Yang, Ivan Fernandez and colleagues.

arXiv preprint revision · 2025-04-06 · Attribution & reuse
In this article
Editorial illustration of processor die.

Editor’s introduction

The study evaluates PyGim, a graph neural network library designed for real processing-in-memory (PIM) architectures. PyGim introduces intelligent parallelization techniques and a Python API to enable hybrid execution—running compute-heavy parts on processors and memory-heavy parts in memory-centric environments. Findings highlight improved resource utilization over both CPU and GPU systems in this context, offering insights for software and hardware co-design.

Introduction

The key operators of combination are dense matrix matrix multiplications (GEMMs), while aggregation degenerates to a Sparse Matrix Matrix Multiplication (SpMM) kernel, processing the graph data that is represented as a sparse matrix. In § 2.1, we profile the GNN execution in a high-end GPU system, and find that aggregation dominates execution time and exhibits high memory intensity, while combination is compute-intensive. The compute-intensive combination fits to be executed in processor-centric systems (CPUs or GPUs). However, aggregation is significantly bottlenecked by data movement between memory and processors in such systems, since SpMM is typically memory-bandwidth-bound in CPUs and GPUs (See also § 2.1).

A promising way to alleviate the data movement cost is Processing-In-Memory (PIM) computing paradigm. PIM enables computation to be performed close to the application data by equipping memory chips with processing capabilities (in-memory processors). To provide significantly higher memory bandwidth for the in-memory processors than standard DRAM modules, manufacturers have commercialized near-bank PIM designs. Near-bank PIM memory modules tightly couple a PIM core with one (or a few) DRAM bank, exploiting bank-level parallelism to expose the high aggregated on-chip memory bandwidth of standard DRAM to processors. A real PIM system supports multiple near-bank PIM memory modules, which are connected to a CPU or GPU, henceforth referred to as Host. The UPMEM PIM architecture is the first PIM system to become commercially available. HBM-PIM and AiM are near-bank PIM systems that have been prototyped and evaluated in real systems.

A few works propose hybrid Host-PIM accelerators for GNNs. However, none of them considers real-world PIM systems. These works design new microarchitectures for near-rank PIM systems, i.e., accelerator cores are placed at each rank of memory modules. Near-rank PIM designs have not been commercialized yet, and are not always able to provide significantly higher memory bandwidth for processors than standard DRAM. In the software level, these works have simple fixed parallelization strategies for GNN aggregation in PIM cores, which would cause out-of-memory errors for medium-/large-size graphs (See § 2.3) or achieve very low performance in real near-bank PIM systems, as we show in Figs. 13 and 14 of § 4. Moreover, these works use software emulators for their evaluations (not a real PIM system), and do not describe the engineering efforts needed to deploy GNNs in their accelerators.

Our goal in this work is to efficiently map GNNs on near-bank PIM systems and quantify the potential of real PIM architectures in GNN executions. Efficiently executing GNNs in real PIM systems encounters three key challenges. 1) GNN execution has repeated compute-intensive (combination) and memory-intensive (aggregation) kernels. On the one hand, executing both types of kernels in PIM cores would incur high performance overheads in combination, since PIM cores are low-area and low-power cores with relatively low computation capabilities. On the other hand, executing combination on Host cores and aggregation on PIM cores, respectively, necessitates minimizing the overheads of passing the output result of one kernel as input to the next kernel. 2) Real-world graphs exhibit diverse characteristics, e.g., the average, min or max vertex neighboring degrees vary across different graphs. Therefore, as discussed in prior works, the execution behavior of sparse kernels, such as the SpMV/SpMM, depends on the particular characteristics of the input given, and there is no typically one-size-fits-all parallelization solution that performs best across various inputs. 3) Programming a real near-bank PIM system for a high-level application is a hard task, since software stacks for PIM systems are still in an early stage. Thus, ML programmers may need to distribute data of GNNs across thousands of DRAM banks in a fine-grained and careful way, have expertise of the PIM hardware and/or program the PIM cores using low-level APIs.

PyGim co-designs a Cooperative Acceleration (CoA) model with a novel Parallelism Fusion (PaF) method. CoA runs heterogeneous kernels to the best-fit underlying hardware: the processor-centric Host (CPU/GPU) system executes the compute-intensive GNN combination, and the memory-centric PIM system executes the memory-intensive aggregation. PaF serves a dual purpose: it (i) strives a balance between computation and data transfer costs in GNN aggregation executed in PIM cores, minimizing the overheads of passing the output result of combination as input to aggregation, and vice versa, and (ii) provides various parallelization techniques to cover many real-world graphs with diverse characteristics. Specifically, in GNN aggregation, we enable three parallelism levels on the hardware PIM side and, at each level, we provide different parallelization techniques on the software side. 1) We group the available PIM cores of the system in clusters, and design edge- and feature-level parallelism across PIM clusters. 2) We enable vertex- or edge-level parallelism across cores within PIM cluster. 3) We employ either vertex- or edge-level parallelism across threads within a PIM core. The technique of the first parallelism level reduces data transfer overheads to/from PIM memory modules, thus reducing costs when passing the output of one GNN kernel as input to the next one. The techniques of the second and third parallelism levels enable load balancing schemes that provide high compute balance across low-power PIM cores and across threads of a PIM core. PaF enables various GNN aggregation configurations and load balancing strategies, by configuring the number of PIM cores per cluster, vertex- or edge-level parallelism within a PIM cluster or within a PIM core, such that to efficiently support diverse real-world graphs.

Processing-In-Memory (PIM) Systems

In our evaluation, we use UPMEM PIM, the first PIM system that has been commercialized on real hardware. UPMEM PIM uses 2D DRAM arrays and combines them with general-purpose cores, called DPUs, on the same chip. Each PIM-enabled module has two ranks (devices), each rank has 8 chips, and each chip has 8 DPUs. Each DPU is tightly coupled to a DRAM bank, has a 14-stage pipeline, and supports multiple threads (up to 24), called tasklets.

DPUs have a 32-bit RISC-style general-purpose instruction set, and natively support in hardware 32-bit integer addition/subtraction and 8-bit/16-bit multiplication. More complex operations, e.g., 32-bit integer multiplication/division, and floating-point operations are software emulated. Each DPU has access to its own (1) 64MB DRAM bank, called MRAM, (2) 24KB instruction memory, and (3) 64KB scratchpad memory, called WRAM. The Host CPU can access the MRAM banks to copy input data (from main memory to MRAM, i.e., CPU-DPU) and retrieve results (from MRAM to main memory, i.e., DPU-CPU). The CPU-DPU/DPU-CPU transfers can be performed in parallel across multiple MRAM banks, if the size of data transferred from/to all MRAM banks is the same. There is no direct communication channel between DPUs, and inter-DPU communication takes place via the Host.

Prior PIM-Based GNN Accelerators

A few prior works propose hardware accelerators for GNN aggregation; however, they do not consider real-world PIM systems. They target near-rank PIM systems that have not been developed as proof-of-concept silicon yet, and typically provide lower memory bandwidth than near-bank PIM systems, which have already been commercialized. Moreover, these prior works focus on the ASIC design of the processing units, and implement simple parallelization strategies at the software level, which have been evaluated in software simulators (instead of a real system). Specifically, these works do not comprehensively evaluate the performance overheads of transferring data to/from PIM memory modules (i.e., Host-PIM and PIM-Host data transfer costs).

PyGim Tuner

PyGim’s PaF is designed to support various parallelization and load balancing strategies to efficiently cover various real-world graphs: as shown in prior works, the execution behavior of sparse kernels that process input data with diverse characteristics, such as the SpMM of GNN aggregation that processes real-world graphs with varying neighboring degrees, diameters etc, depends on the particular characteristics of the input. Therefore, to enable high performance by adapting the PaF strategy to the particular graph’s characteristics and avoid programmer’s intervention, we integrate in PyGim a lightweight tuner that selects the aggregation configuration to be used: the user selects the compression format (CSR/COO), and then the tuner predicts the best-performing aggregation configuration, i.e., the sparse and dense partitions, the groups per device, the selection of vertex- or edge-level parallelism across cores of a PIM cluster and across threads of a PIM core.

Alg. 1 presents a brief description of the PyGim tuner which iterates over all possible aggregation configurations and predicts the best-performing configuration. Specifically, the tuner iterates over all divisors of the available PIM devices in the system (line 5), creates 1, 2, or 4 clusters per PIM device, and it computes the number of dense partitions (line 7). If the number of dense partitions is larger than the hidden size, this configuration is not valid and is omitted (lines 9). Otherwise, the tuner iterates over the possible load balance strategies within the PIM cluster (line 10) and within the PIM core (line 11). For each current configuration, the tuner estimates the performance using the described analytical models (line 12), and keeps the lowest estimated execution time and its corresponding configuration in local variables (lines 13-15). When the tuner has examined all possible configurations, it returns the estimated best-performing configuration (line 16).

PyGim API and Integration

Combination comprises a small neural network, thus PyGim leverages existing optimized ML kernels from PyTorch to execute the corresponding ML operators of GNN combination on Host cores. We integrate PyGim with PyTorch, as we explain in the next paragraph. Note that although we only have access to a CPU-PIM system for our evaluations, PyGim can support GPU-PIM GNN executions (GPU-PIM systems that are expected to be available in the market) by leveraging PyTorch’s supported backends (CPU and GPU).

To interact with PIM devices (e.g., Host-PIM/ PIM-Host transfers) in aggregation, Host code needs to be implemented. The Host code implements (developed in C language) the parallelization approaches and the corresponding data partitioning schemes proposed in § 3.2, when loading the graph into PIM-enabled memory modules (pre-processing step). The kernel code that PIM cores are running is implemented using the UPMEM PIM interface, since this is the only commercially available real PIM system. This interface is also written using the C language, and it can be easily ported to other PIM systems with similar interfaces to UPMEM. We create a PIM backend for PIM aggregation and expose this software runtime as a handy Python API so that programmers can easily use it via a high-level programming interface. We combine our Python-like API with PyTorch to enable efficient CoA execution. PyGim’s PIM aggregation can be also easily integrated to other ML frameworks, such as TensorFlow, Keras, MXNet and Caffe.

Alg. 2 presents an example of GCN inference with PyGim. Programmers need to (i) allocate PIM devices (line 15), (ii) load graph data into PIM-enabled memory (lines 17-19), (iii) create a GNN model (lines 21-25), and (iv) run GNN inference by configuring aggregation and combination to be executed on the PIM cores (line 9) and Host cores (line 11), respectively. The allocated PIM resources are released, when the program exits.

Methodology

System. We use the UPMEM PIM architecture, a real-world PIM system. The system consists of a Host CPU (2-socket Intel Xeon with 8-cores each and a total of 32 threads at 2.10 GHz), standard DDR4 memory (128 GB), and 16 PIM DIMMs of 2 ranks (124.5 GB and 1992 PIM cores at 350 MHz), each rank has 64 cores. There are 56 faulty cores in the evaluated system that cannot be used, but they do not affect the correctness of our results (they are not used in our experiments).

Models and Datasets. We evaluate the GCN, GIN and SAGE models. The multiplication of floating point data types is software emulated in the UPMEM PIM system. Thus, we present detailed evaluations with 32-bit integer (int32) data type, since it has the same byte width with 32-bit float (fp32), its arithmetic operations are more effectively supported in UPMEM PIM hardware, and provides high accuracy (having int32 for both computation and memory representation results to less than 1% accuracy drop in all models and datasets over fp32 using the quantization scheme of Ctranslate2 ). Quantization is orthogonal to our optimizations, and we expect that future PIM systems (e.g., HBM-PIM) will provide native floating-point arithmetic support or optimized quantization schemes will provide high accuracy with fixed-precision data types. We evaluate real-world sparse matrices from the Sparse Matrix Suite Collection, when using one PIM core and one PIM cluster, and present large-scale experiments with three real-world graph datasets: ogbn-proteins, Reddit and AmazonProducts. See also Appendix A.7 for detailed matrix and graph dataset characteristics.

Within PIM Core Analysis

We draw three findings. First, all schemes scale up to 16 threads, because the PIM core pipeline is fully utilized after 16 threads. In wing_nodal with 16 threads, only one thread processes many more edges than the rest, thus RV slightly scales to 24 threads (by 0.09%), because it exhibits better compute balance across threads. Second, int32 data type provides at least one order of magnitude better performance than fp32 data type. The UPMEM PIM core does not support in hardware floating-point operations, while they are software emulated using integer arithmetic units. Thus, fp32 SpMM achieves much lower performance than int32 SpMM due to the excessive amount of computations. Third, RV provides worse performance than other schemes, since balancing the vertices across threads incurs high edge (non-zero element) imbalance, thus causing high disparity in the amount of computations performed across threads (high compute imbalance).

To our knowledge, our work is the first to design an ML library and tuner for GNN executions on near-bank PIM systems, propose efficient GNN aggregation schemes tailored for such systems, and extensively characterize GNNs on the first real-world PIM system. We briefly discuss prior work.

PIM-Based Accelerators. A few works design PIM-based GNN accelerators. Their custom microarchitecture designs for host and PIM cores are orthogonal to PyGim software library. These works target near-rank PIM architectures and use simulators for their evaluations. PyGim targets near-bank PIM systems, which typically provide much larger memory bandwidth than near-rank PIMs, and evaluates GNNs on a real system. Finally, implementing the software data mappings of these works to near-bank PIM systems would cause out-of-memory errors (See § 2.3) or would be inefficient: as shown in our evaluations, PyGim significantly outperforms the best-performing strategy of GraNDe. Li et al. design a tool to explore PIM design configurations (e.g., near-DIMM, near-rank, near-bank) for different application scenarios, which is orthogonal to our work. A few works propose in-storage PIM designs that sample the large graphs inside the disk (SSDs) to reduce the amount of graph data sent from disk to host CPU/GPU cores. These works can work synergistically with ours: PyGim can be used to efficiently process the produced smaller graph in DRAM. Finally, a few works design custom PIM-based architectures for large language models, however they do not support GNNs and the SpMM kernel.

System Support and Software for PIM Systems. Prior works design optimized linear algebra, graph processing, database, array iterators, ML training, bioinformatics, and image processing kernels for PIM systems. The closest work to ours is SparseP, that is an efficient SpMV library for PIM systems. We use the best-performing SparseP kernel in GNNs, show that it has worse performance and energy efficiency than PyGim. A few works propose efficient communication collectives for future PIM systems. Moreover, a few works discuss scalability issues and hardware limitations of real near-bank PIM systems, and propose architectural features for future PIM systems. These prior works are orthogonal to PyGim: PyGim can be used in their proposed future PIM designs and/or leverage optimized communication collectives to enable high efficiency in GNN executions.

GNNs and SpMM in Commodity Systems. Prior works optimize GNNs and SpMM on CPUs, GPUs by leveraging the shared memory model of CPUs/GPUs and deep cache hierarchies (on-chip caches). Their optimizations cannot be applied in PIM systems, that have a distributed memory model and shallow cache hierarchy. Prior works optimize GNNs and SpMM on CPU-GPU, multi-CPU/multi-GPU systems by minimizing communication costs among cores, and/or overlapping computation with communication. However, real PIM systems may not support direct communication among PIM cores, and there are no real PIM systems that can overlap computation with communication across on PIM cores. Thus, well-tuned GNN and SpMM kernels for distributed processor-centric systems either cannot be directly applied in PIM systems, or their fine-grained inter-PIM-core communication (e.g., implemented over Host) would cause high performance overheads.

Custom Accelerators for GNNs and SpMM. Prior works propose custom hardware accelerators for GNNs and SpMM, but they target processor-centric systems with low available memory bandwidth. Instead, PyGim provides software-level optimizations for GNNs, and targets memory-centric PIM systems.