2025/09/17 by Savini Kashmira, Kashmira, Savini, Jayanaka Dantanarayana +12 · 1 voice · 1 citation
Computer Science · #Call graph #Code refactoring #Compiler #Control flow #Control flow graph #Data-flow analysis #Graph #Graph rewriting #Model-Driven Software Engineering Techniques #Natural Language Processing Techniques #Python (programming language) #Software Testing and Debugging Techniques #Source code #cs.LG #cs.PL #cs.SE
paper · pdf · doi:10.48550/arxiv.2509.16248
published in arXiv (Cornell University) (Cornell University)
openalex publication_date 2025/09/17 · arxiv published 2025/09/17 · openalex created_date 2025/10/10 · arxiv updated 2026/06/29 · openalex updated_date 2026/08/01
This paper presents GraphMend, a compiler technique that automatically fixes FX graph breaks in PyTorch 2 programs. Although PyTorch 2 introduced TorchDynamo and TorchInductor to enable just-in-time graph compilation, certain code patterns still cause graph breaks that force execution to fall back to Python eager mode, introducing costly CPU-GPU synchronization and reducing optimization opportunities. Our investigation of 195 Hugging Face models reveals that 13.8% of models exhibit graph breaks. GraphMend automatically eliminates fixable breaks through source-level program analysis and transformations. It analyzes AST-level program structure to identify graph-break patterns and applies transformations only when their semantic preservation can be statically established. These transformations enable PyTorch to capture larger, uninterrupted FX graphs without manual refactoring by developers. We evaluate GraphMend on all 27 models found to exhibit graph breaks in our investigation. GraphMend eliminates 107 of 147 graph breaks (73%), fully fixing all breaks in 21 models. In our experiments on NVIDIA GPUs, GraphMend achieves up to 26x cold-start speedup, 5x on average, and up to 1.39x steady-state forward pass speedup. These results demonstrate that semantics-aware source-level analysis and transformation are effective complements to PyTorch's dynamic JIT compilation pipeline, substantially improving both usability and performance.