PyGraph: Robust Compiler Support for CUDA Graphs in PyTorch

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Ghosh, Abhishek, Nayak, Ajay, Panwar, Ashish, Basu, Arkaprava
Format: Preprint
Published: 2025
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866912783910567936
author Ghosh, Abhishek
Nayak, Ajay
Panwar, Ashish
Basu, Arkaprava
author_facet Ghosh, Abhishek
Nayak, Ajay
Panwar, Ashish
Basu, Arkaprava
contents Machine learning (ML) workloads launch hundreds to thousands of short-running GPU kernels per iteration. With GPU compute throughput growing rapidly, CPU-side launch latency of kernels is emerging as a bottleneck. CUDA Graphs promise to address this by replaying a set of kernels with a single dispatch of the graph, removing per-kernel launch costs. However, CUDA Graphs remain surprisingly difficult to deploy correctly and efficiently. We present PyGraph - a compiler framework to maximize the coverage and benefits of CUDA Graphs for ML workloads. It introduces three novel optimizations: it applies automatic code transformations to make ML applications amenable to CUDA Graphs; it eliminates the parameter copy overheads for kernels executing in CUDA Graphs, and it selectively deploys CUDA Graphs guided by a cost-benefit analysis. For 25 ML workloads from TorchBench, HuggingFace, and TIMM, PyGraph more than doubles the benefit from deploying CUDA Graph compared to the most popular and widely used ML compiler, PyTorch2. PyGraph is built atop PyTorch2's compilation framework and requires no programmer intervention.
format Preprint
id arxiv_https___arxiv_org_abs_2503_19779
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle PyGraph: Robust Compiler Support for CUDA Graphs in PyTorch
Ghosh, Abhishek
Nayak, Ajay
Panwar, Ashish
Basu, Arkaprava
Machine Learning
Machine learning (ML) workloads launch hundreds to thousands of short-running GPU kernels per iteration. With GPU compute throughput growing rapidly, CPU-side launch latency of kernels is emerging as a bottleneck. CUDA Graphs promise to address this by replaying a set of kernels with a single dispatch of the graph, removing per-kernel launch costs. However, CUDA Graphs remain surprisingly difficult to deploy correctly and efficiently. We present PyGraph - a compiler framework to maximize the coverage and benefits of CUDA Graphs for ML workloads. It introduces three novel optimizations: it applies automatic code transformations to make ML applications amenable to CUDA Graphs; it eliminates the parameter copy overheads for kernels executing in CUDA Graphs, and it selectively deploys CUDA Graphs guided by a cost-benefit analysis. For 25 ML workloads from TorchBench, HuggingFace, and TIMM, PyGraph more than doubles the benefit from deploying CUDA Graph compared to the most popular and widely used ML compiler, PyTorch2. PyGraph is built atop PyTorch2's compilation framework and requires no programmer intervention.
title PyGraph: Robust Compiler Support for CUDA Graphs in PyTorch
topic Machine Learning
url https://arxiv.org/abs/2503.19779