Accelerating Mini-batch HGNN Training by Reducing CUDA Kernels

Meng Wu, Jingkai Qiu, Mingyu Yan, Wenming Li, Yang Zhang, Zhimin Zhang, Xiaochun Ye, Dongrui Fan · DOI

Abstract

Heterogeneous Graph Neural Networks (HGNNs) are essential for modeling complex, multi-typed relationships in graph-structured data. However, their training efficiency on modern GPUs is often hampered by the high overhead of launching numerous small CUDA kernels for diverse relation types. This paper presents HiFuse, an optimization framework designed for PyTorch Geometric (PyG) that accelerates HGNN training by reorganizing data layouts, merging kernels, and offloading control-intensive tasks to the CPU. Experimental results demonstrate that HiFuse achieves up to a 3.04x speedup and significantly reduces kernel launch overhead across standard benchmarks.

Introduction

Heterogeneous Graph Neural Networks (HGNNs) extend standard GNNs by incorporating multiple types of nodes and edges, making them ideal for complex domains such as academic citation networks, recommendation systems, and bioinformatics. Despite their modeling power, training HGNNs is computationally expensive. Current frameworks like PyTorch Geometric (PyG) often suffer from low GPU utilization during mini-batch training.

The primary bottleneck is a "death by a thousand cuts" scenario: because each relationship type in an HGNN typically requires its own set of CUDA kernels, a high number of relations leads to a massive volume of short-lived, memory-bound kernels. The time spent on kernel launch overhead often exceeds the actual computation time, leaving the GPU underutilized and stalling the training pipeline.

The HiFuse Framework

HiFuse addresses these inefficiencies through two primary strategies: optimizing data locality through reorganization and merging, and balancing the workload between the CPU and GPU via asynchronous pipelining.

1. Data Reorganization and Kernel Merging

Standard GNN implementations often store vertex features using a "Vertex Index First" approach, which mixes different node types in memory. HiFuse introduces a Vertex Type First reorganization. By ensuring that features of the same type are stored contiguously, the framework enables coalesced memory access, which is significantly more efficient for GPU architectures.

Building on this reorganization, HiFuse implements Kernel Merging. Instead of launching individual scatter/gather kernels for every distinct relation type, HiFuse merges smaller feature matrices into larger, unified tensors. This allows a single, high-throughput kernel to process multiple relations simultaneously, drastically reducing the total number of kernel launches and mitigating the overhead associated with small-scale operations.

2. Workflow Offloading and Asynchronous Pipelining

Graph construction tasks—such as selecting specific edges for semantic graphs—involve complex integer logic and branching. These tasks are "control-intensive," making them poorly suited for the SIMT (Single Instruction, Multiple Threads) architecture of GPUs. HiFuse offloads these graph construction stages to the CPU, which is better equipped for such logic.

To prevent the CPU from becoming a bottleneck, HiFuse employs an Asynchronous Pipeline using OpenMP for multi-threading and asynchronous CUDA streams. This architecture allows the CPU to prepare the graph structure for the next mini-batch while the GPU is concurrently performing the forward and backward passes on the current batch. This overlap ensures that both processors remain active, eliminating idle time.

Experimental Evaluation

The researchers evaluated HiFuse using two prominent HGNN models, RGCN and RGAT, across four benchmark datasets: aifb (AF), bgs (BG), mutag (MT), and am (AM). The datasets ranged from approximately 7,000 nodes to 1.88 million nodes, with relation counts varying between 50 and 122.

Key Results

  • Training Speedup: HiFuse achieved an average speedup of 2.38x over the baseline PyG implementation, with a peak performance improvement of 3.04x.
  • Kernel Reduction: The framework successfully reduced the total number of CUDA kernels by 43.6% to 73.2%, depending on the dataset and model complexity.
  • Throughput Improvements: By optimizing data locality, the memory throughput for neighbor aggregation—the most computationally expensive phase of GNN training—improved by up to 14x. Specifically, the throughput of the critical 'scatter' kernel saw improvements of up to 136x due to the "Vertex Type First" layout.
  • Resource Utilization: The asynchronous pipeline resulted in a more balanced CPU-to-GPU execution ratio, indicating that the framework effectively maximized the hardware's potential.

Discussion and Insights

The success of HiFuse highlights several critical insights for deep learning systems research. First, in the context of HGNNs, locality is paramount. Shifting from index-based to type-based data layouts provides massive gains in memory efficiency. Second, the results underscore the importance of hardware specialization; by recognizing that graph sampling and construction are "GPU-hostile" but "control-friendly," HiFuse demonstrates that offloading to the CPU is often more efficient than forcing all tasks onto the GPU.

Limitations and Future Work

While HiFuse provides substantial gains on single-node systems, several areas remain for future exploration:

  • Multi-GPU Scaling: Future research is needed to determine how kernel merging and offloading strategies interact with inter-GPU communication bottlenecks in distributed settings.
  • Dynamic Graphs: The current optimizations are tailored for static or semi-static graph structures during mini-batching. Adapting these techniques for rapidly evolving dynamic graphs presents a significant engineering challenge.
  • Framework Integration: While HiFuse is designed for PyG, full integration into the upstream codebase would require broader support for edge cases and diverse GNN architectures beyond RGCN and RGAT.

Conclusion

HiFuse offers a robust solution to the kernel launch bottleneck in HGNN training. By combining intelligent data reorganization with a balanced CPU-GPU pipeline, it provides a significant performance boost for researchers and practitioners working with complex, heterogeneous datasets.

Summary updated

BibTeX
@inproceedings{wu2024accelerating,
  author = {Meng Wu and Jingkai Qiu and Mingyu Yan and Wenming Li and Yang Zhang and Zhimin Zhang and Xiaochun Ye and Dongrui Fan},
  title = {{Accelerating Mini-batch HGNN Training by Reducing CUDA Kernels}},
  booktitle = {ICA3PP},
  year = {2024},
  doi = {10.1007/978-981-96-1542-1\_17},
}
Figure