MPI-RICAL: Data-Driven MPI Distributed Parallelism Assistance with Transformers

Nadav Schneider, Tal Kadosh, Niranjan Hasabnis, Timothy Mattson, Yuval Pinter, Gal Oren · DOI · OpenReview

TL;DR

This paper introduces MPI-RICAL, a novel AI-powered tool that assists developers in writing distributed memory parallel code for scientific applications using MPI. By leveraging Transformer models trained on a new corpus of MPI code, MPI-RICAL can suggest correct MPI functions and their placement within existing serial code, significantly easing the complex task of domain decomposition.

What Problem Does This Paper Address?

Computational science relies heavily on supercomputers to simulate complex phenomena, which in turn requires efficient parallelization of code. The Message Passing Interface (MPI) is the de facto standard for distributed memory parallelism. However, manually parallelizing code, especially with techniques like domain decomposition (where data is split across processors), is notoriously challenging, error-prone, and requires deep understanding of both the code and MPI. Existing tools primarily focus on shared-memory parallelism or translating from other parallel paradigms (like OpenMP) to MPI, leaving a gap for assisting developers in converting serial code to MPI-based distributed memory parallel code, particularly for domain decomposition tasks.

Methods

The core of MPI-RICAL is a Transformer-based language model, specifically a fine-tuned version of SPT-Code. This model is trained to perform a "code translation" task: given a C code snippet without MPI functions, it predicts the MPI functions that should be inserted and their correct locations.

The process involves:

  1. Preprocessing: The input code is converted into a linearized Abstract Syntax Tree (AST) representation called X-SBT. This representation captures structural information efficiently.
  2. Transformer Architecture: The model uses a bidirectional encoder to process the input code and its X-SBT representation, and an auto-regressive decoder to generate the output code with predicted MPI functions.
  3. Training: The model is trained in a supervised manner, learning to map MPI-function-free code to its MPI-parallelized counterpart.

Datasets

The paper introduces MPICodeCorpus, a novel, publicly available corpus of MPI-based parallel programs. This corpus was created by mining over 16,500 GitHub repositories, specifically targeting C files containing "MPI" in their metadata. After applying inclusion/exclusion criteria (e.g., parsability, code length limits), approximately 25,000 C programs were selected.

For training, the MPICodeCorpus was processed into input-output pairs: the input is the original MPI code with MPI function calls removed, and the output is the original MPI code with functions and their correct locations. The model was also pre-trained on the CodeSearchNet dataset, which contains code in various languages.

Key Insights and Ideas

  • Leveraging LLMs for Code Parallelization: The paper demonstrates that large language models, particularly Transformer architectures, can be effectively adapted for the complex task of suggesting MPI parallelization constructs, moving beyond simple code completion.
  • The Importance of Context and Location: Simply suggesting MPI functions isn't enough; their correct placement within the code is crucial for functional parallel programs. MPI-RICAL explicitly addresses both aspects.
  • MPICodeCorpus as a Foundational Resource: The creation of a large, publicly available corpus of MPI-based parallel programs is a significant contribution, enabling future research and development in this area.
  • Domain Decomposition as a Key Challenge: The paper highlights domain decomposition as a particularly difficult aspect of MPI programming, and MPI-RICAL aims to alleviate this specific pain point.

Key Results

MPI-RICAL achieved strong performance on its test set:

  • MPICodeCorpus Test Set: An M-F1 score of 0.87, M-Precision of 0.85, and M-Recall of 0.89.
  • Numerical Computations Benchmark: On a set of 11 carefully selected and compiled MPI programs with domain decomposition, MPI-RICAL achieved an M-F1 score of 0.91, M-Precision of 0.98, and M-Recall of 0.86. This indicates high accuracy in suggesting correct MPI functions and their locations for real-world scientific applications.

Limitations and Future Work

The authors acknowledge several limitations and suggest future directions:

  • Code Length Restriction: The current dataset creation process excluded programs longer than 320 tokens (approximately 50 lines) due to hardware limitations. Future work aims to train on complete codes without this restriction, which will likely require significant hardware upgrades or advanced training techniques like continual learning.
  • Language Pre-training: The model was pre-trained on Java and Python. Future work suggests that pre-training on C code might improve performance.
  • Structural Code Changes: The current evaluation focuses on function calls and their locations, but not on broader structural code changes that might be necessary for effective MPI parallelization. Future research will explore measuring the accuracy of generated MPI function arguments and overall MPI code structure.
  • IDE Integration: While the paper positions MPI-RICAL as an IDE assistant, further work is needed to fully integrate and optimize it for real-time developer assistance.

Summary updated

BibTeX
@inproceedings{schneider2023mpi,
  author = {Nadav Schneider and Tal Kadosh and Niranjan Hasabnis and Timothy Mattson and Yuval Pinter and Gal Oren},
  title = {{MPI-RICAL: Data-Driven MPI Distributed Parallelism Assistance with Transformers}},
  booktitle = {Workshops @ SC},
  year = {2023},
  doi = {10.1145/3624062.3624063},
}
Figure