Learning Performance-Improving Code Edits

Fuente: arXiv
Guardado en:
Detalles Bibliográficos
Autores principales: Shypula, Alexander, Madaan, Aman, Zeng, Yimeng, Alon, Uri, Gardner, Jacob, Hashemi, Milad, Neubig, Graham, Ranganathan, Parthasarathy, Bastani, Osbert, Yazdanbakhsh, Amir
Formato: Preprint
Publicado: 2023
Materias:
Acceso en línea:
Etiquetas: Agregar Etiqueta
Sin Etiquetas, Sea el primero en etiquetar este registro!
_version_ 1866911854843920384
author Shypula, Alexander
Madaan, Aman
Zeng, Yimeng
Alon, Uri
Gardner, Jacob
Hashemi, Milad
Neubig, Graham
Ranganathan, Parthasarathy
Bastani, Osbert
Yazdanbakhsh, Amir
author_facet Shypula, Alexander
Madaan, Aman
Zeng, Yimeng
Alon, Uri
Gardner, Jacob
Hashemi, Milad
Neubig, Graham
Ranganathan, Parthasarathy
Bastani, Osbert
Yazdanbakhsh, Amir
contents With the decline of Moore's law, optimizing program performance has become a major focus of software research. However, high-level optimizations such as API and algorithm changes remain elusive due to the difficulty of understanding the semantics of code. Simultaneously, pretrained large language models (LLMs) have demonstrated strong capabilities at solving a wide range of programming tasks. To that end, we introduce a framework for adapting LLMs to high-level program optimization. First, we curate a dataset of performance-improving edits made by human programmers of over 77,000 competitive C++ programming submission pairs, accompanied by extensive unit tests. A major challenge is the significant variability of measuring performance on commodity hardware, which can lead to spurious "improvements." To isolate and reliably evaluate the impact of program optimizations, we design an environment based on the gem5 full system simulator, the de facto simulator used in academia and industry. Next, we propose a broad range of adaptation strategies for code optimization; for prompting, these include retrieval-based few-shot prompting and chain-of-thought, and for finetuning, these include performance-conditioned generation and synthetic data augmentation based on self-play. A combination of these techniques achieves a mean speedup of 6.86 with eight generations, higher than average optimizations from individual programmers (3.66). Using our model's fastest generations, we set a new upper limit on the fastest speedup possible for our dataset at 9.64 compared to using the fastest human submissions available (9.56).
format Preprint
id arxiv_https___arxiv_org_abs_2302_07867
institution arXiv
publishDate 2023
record_format arxiv
spellingShingle Learning Performance-Improving Code Edits
Shypula, Alexander
Madaan, Aman
Zeng, Yimeng
Alon, Uri
Gardner, Jacob
Hashemi, Milad
Neubig, Graham
Ranganathan, Parthasarathy
Bastani, Osbert
Yazdanbakhsh, Amir
Software Engineering
Artificial Intelligence
Machine Learning
Performance
With the decline of Moore's law, optimizing program performance has become a major focus of software research. However, high-level optimizations such as API and algorithm changes remain elusive due to the difficulty of understanding the semantics of code. Simultaneously, pretrained large language models (LLMs) have demonstrated strong capabilities at solving a wide range of programming tasks. To that end, we introduce a framework for adapting LLMs to high-level program optimization. First, we curate a dataset of performance-improving edits made by human programmers of over 77,000 competitive C++ programming submission pairs, accompanied by extensive unit tests. A major challenge is the significant variability of measuring performance on commodity hardware, which can lead to spurious "improvements." To isolate and reliably evaluate the impact of program optimizations, we design an environment based on the gem5 full system simulator, the de facto simulator used in academia and industry. Next, we propose a broad range of adaptation strategies for code optimization; for prompting, these include retrieval-based few-shot prompting and chain-of-thought, and for finetuning, these include performance-conditioned generation and synthetic data augmentation based on self-play. A combination of these techniques achieves a mean speedup of 6.86 with eight generations, higher than average optimizations from individual programmers (3.66). Using our model's fastest generations, we set a new upper limit on the fastest speedup possible for our dataset at 9.64 compared to using the fastest human submissions available (9.56).
title Learning Performance-Improving Code Edits
topic Software Engineering
Artificial Intelligence
Machine Learning
Performance
url https://arxiv.org/abs/2302.07867