NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Automatic Parallelization of Python Programs for Distributed Heterogeneous Computing

Jun Shirako, Akihiro Hayashi, Sri Raj Paul, Alexey Tumanov, Vivek Sarkar

Introduction

In the realm of high-performance computing (HPC), a significant "ninja gap" persists between the productivity of high-level languages and the performance of low-level implementations. Domain scientists—biologists, physicists, and data scientists—overwhelmingly prefer Python for its ease of use and rich ecosystem. However, Python is inherently sequential and often struggles to utilize modern hardware like GPUs or distributed clusters effectively.

To achieve high performance, developers are typically forced to rewrite their code using complex frameworks such as MPI for distributed memory, CUDA for GPU acceleration, or specialized Domain Specific Languages (DSLs) like Halide. These tools require "ninja-level" expertise in computer architecture. While libraries like NumPy provide a performance boost, they operate as fixed interfaces that cannot optimize across multiple function calls or automatically manage data movement between heterogeneous devices. This paper introduces AutoMPHC, a compiler framework designed to bridge this gap by automating the transformation of sequential Python code into optimized, parallel programs for distributed heterogeneous environments.

The AutoMPHC Framework

AutoMPHC employs a multi-stage optimization pipeline that transforms standard Python code into a high-performance distributed application. The framework's architecture is built on five key pillars:

1. Type-Driven AOT Transformation

The system utilizes standard Python type hints (e.g., data: ndarray) as metadata for the compiler. In cases where hints are absent, AutoMPHC employs a profiler (MonkeyType) to infer types. This allows for "ahead-of-time" (AOT) compilation, which is essential for generating efficient machine code before the program execution begins.

2. Multi-Versioning and Runtime Checks

Because Python is a dynamic language, a single optimized version of a function may not be valid for all possible inputs. AutoMPHC generates multiple versions of the code and implements a runtime "decision tree." This tree performs two critical checks:

  • Legality Check: Does the actual data type at runtime match the optimized version?
  • Profitability Check: Is the dataset large enough to justify the overhead of parallelization and data transfer?

3. Unified Polyhedral Optimization

The core innovation of AutoMPHC is its extension of the polyhedral framework—a mathematical abstraction for representing nested loops. The system treats both explicit Python for loops and implicit loops within NumPy operators (such as np.dot or np.sum) as a unified representation. This allows the compiler to perform sophisticated loop fusion and tiling across library boundaries, significantly reducing data movement and improving cache locality.

4. Ray Integration for Distributed Scaling

For distributed execution, AutoMPHC integrates with the Ray runtime. Ray handles the complexities of task scheduling across cluster nodes and manages a distributed "Object Store." By leveraging Ray’s immutable object store, AutoMPHC avoids the expensive synchronization protocols common in MPI, facilitating smoother scaling on heterogeneous clusters.

5. Automated Heterogeneous Execution

The framework automatically identifies code blocks suitable for GPU execution. It performs on-the-fly conversion of NumPy calls to CuPy (a GPU-accelerated library), handling the necessary data transfers between the host CPU and the GPU device without manual intervention.

Experimental Evaluation

The researchers evaluated AutoMPHC using two primary benchmarks: PolyBench-Python, a suite of 15 standard numerical kernels, and STAP (Space-Time Adaptive Processing), a real-world radar signal processing application used to test large-scale distributed performance.

Single-Node Performance

In single-node tests using PolyBench, AutoMPHC significantly outperformed standard NumPy. For kernels such as correlation and covariance, the framework achieved speedups ranging from 8.7x to 212.4x. These gains are primarily attributed to the framework's ability to "look inside" NumPy calls and fuse operations that would otherwise be executed sequentially.

Distributed Scaling on Supercomputers

The STAP application served as a stress test for the system’s scalability on the OLCF Summit supercomputer. Running on 24 nodes (utilizing 144 GPUs), AutoMPHC achieved a staggering 20,000x speedup compared to sequential Python. Furthermore, the system reached a throughput of 44.58 cubes/second, successfully meeting the real-time processing requirement of 33.3 cubes/second—a feat previously impossible using standard Python implementations.

Conclusion and Future Work

AutoMPHC demonstrates that it is possible to achieve supercomputer-level performance without sacrificing the productivity of the Python ecosystem. By breaking the "library wall" and treating NumPy operations as optimizable mathematical units, the framework provides a path for domain scientists to utilize massive GPU clusters transparently.

Future work will focus on refining the granularity of GPU execution decisions, moving from an "all-or-nothing" approach to per-array decision-making. Additionally, the authors plan to explore hybrid code generation (Python-to-C++) and more sophisticated offline profiling to further enhance the runtime profitability heuristics.

Summary updated

BibTeX
@inproceedings{shirako2022automatic,
  author = {Jun Shirako and Akihiro Hayashi and Sri Raj Paul and Alexey Tumanov and Vivek Sarkar},
  title = {{Automatic Parallelization of Python Programs for Distributed Heterogeneous Computing}},
  booktitle = {Euro-Par},
  year = {2022},
}
Figure