Can Large Language Models Predict Parallel Code Performance?
作者: Gregory Bolet, Giorgis Georgakoudis, Harshitha Menon, Konstantinos Parasyris, Niranjan Hasabnis, Hayden Estes, Kirk W. Cameron, Gal Oren
分类: cs.DC, cs.AI, cs.PF
发布日期: 2025-05-06
备注: 5 pages, 4 figures, accepted to AI4Sys Workshop at HPDC 2025
💡 一句话要点
利用大型语言模型预测并行GPU代码性能,无需硬件剖析
🎯 匹配领域: 支柱九:具身大模型 (Embodied Foundation Models)
关键词: 大型语言模型 GPU性能预测 屋顶线模型 并行代码 零样本学习
📋 核心要点
- 现有并行GPU代码性能评估依赖硬件剖析,成本高昂且受限于硬件资源。
- 利用大型语言模型,无需硬件剖析,预测GPU代码的计算或带宽密集型特征。
- 实验表明,具有推理能力的LLM在零样本学习中能达到64%的预测准确率。
📝 摘要(中文)
准确评估并行GPU代码的性能通常需要在目标硬件上进行执行时间剖析,但由于高端GPU的访问受限,这一步骤变得越来越困难。本文探讨了大型语言模型(LLM)是否可以在不依赖硬件的情况下,为GPU性能预测提供一种替代方法。我们将该问题定义为一个屋顶线分类任务:给定GPU内核的源代码和目标GPU的硬件规格,LLM能否预测GPU内核是计算密集型还是带宽密集型?我们构建了一个包含340个GPU内核的平衡数据集,这些内核来自HeCBench基准测试,并使用CUDA和OpenMP编写,同时通过经验GPU剖析获得它们的真实标签。我们评估了LLM在四种场景下的表现:(1)可以访问内核源代码的剖析数据;(2)仅使用源代码进行零样本学习;(3)使用代码和标签对进行少量样本学习;(4)在小型自定义数据集上进行微调。结果表明,最先进的LLM对屋顶线模型有很强的理解,在提供显式剖析数据时,分类准确率达到100%。我们还发现,具有推理能力的LLM在零样本和少量样本设置中明显优于标准LLM,在没有剖析信息的情况下,在GPU源代码上的准确率高达64%。最后,我们发现LLM微调需要比我们目前可用的数据多得多。这项工作是首次使用LLM通过分类进行源代码级别的屋顶线性能预测,并说明了它们在运行时剖析不可行时指导优化工作的潜力。我们的研究结果表明,通过更好的数据集和提示策略,LLM可能成为HPC性能分析和性能可移植性的实用工具。
🔬 方法详解
问题定义:论文旨在解决并行GPU代码性能预测的问题。现有方法主要依赖于在目标硬件上进行实际运行和剖析,这不仅耗时,而且在高端GPU资源有限的情况下变得不可行。因此,需要一种无需实际硬件运行即可预测代码性能的方法。
核心思路:论文的核心思路是利用大型语言模型(LLM)的强大代码理解和推理能力,将GPU代码的性能预测问题转化为一个屋顶线分类问题。通过让LLM分析GPU内核的源代码和硬件规格,预测该内核是计算密集型还是带宽密集型。
技术框架:整体框架包括以下几个主要步骤:1)构建包含GPU内核代码及其性能标签的数据集;2)选择合适的LLM模型;3)设计不同的实验场景,包括零样本、少量样本和微调;4)评估LLM在不同场景下的性能预测准确率。数据集来自HeCBench基准测试,包含CUDA和OpenMP编写的GPU内核。
关键创新:该研究的关键创新在于首次将LLM应用于源代码级别的屋顶线性能预测。与传统的基于硬件剖析的方法不同,该方法完全依赖于LLM对代码的理解和推理能力,无需实际运行代码。
关键设计:论文设计了四种不同的实验场景,以评估LLM在不同条件下的性能。这些场景包括:1)提供内核源代码的剖析数据;2)仅使用源代码进行零样本学习;3)使用代码和标签对进行少量样本学习;4)在小型自定义数据集上进行微调。通过比较不同场景下的性能,可以评估LLM在不同程度的信息支持下的预测能力。
🖼️ 关键图片
📊 实验亮点
实验结果表明,当提供显式剖析数据时,最先进的LLM可以达到100%的分类准确率。在零样本学习中,具有推理能力的LLM在GPU源代码上的准确率高达64%,显著优于标准LLM。这些结果表明,LLM在GPU代码性能预测方面具有巨大的潜力。
🎯 应用场景
该研究成果可应用于高性能计算(HPC)领域,帮助开发者在没有目标硬件的情况下,快速评估和优化GPU代码的性能。这有助于提高代码的性能可移植性,并降低开发成本。未来,该方法有望扩展到更复杂的性能预测任务,例如预测代码在不同硬件平台上的运行时间。
📄 摘要(原文)
Accurate determination of the performance of parallel GPU code typically requires execution-time profiling on target hardware -- an increasingly prohibitive step due to limited access to high-end GPUs. This paper explores whether Large Language Models (LLMs) can offer an alternative approach for GPU performance prediction without relying on hardware. We frame the problem as a roofline classification task: given the source code of a GPU kernel and the hardware specifications of a target GPU, can an LLM predict whether the GPU kernel is compute-bound or bandwidth-bound? For this study, we build a balanced dataset of 340 GPU kernels, obtained from HeCBench benchmark and written in CUDA and OpenMP, along with their ground-truth labels obtained via empirical GPU profiling. We evaluate LLMs across four scenarios: (1) with access to profiling data of the kernel source, (2) zero-shot with source code only, (3) few-shot with code and label pairs, and (4) fine-tuned on a small custom dataset. Our results show that state-of-the-art LLMs have a strong understanding of the Roofline model, achieving 100% classification accuracy when provided with explicit profiling data. We also find that reasoning-capable LLMs significantly outperform standard LLMs in zero- and few-shot settings, achieving up to 64% accuracy on GPU source codes, without profiling information. Lastly, we find that LLM fine-tuning will require much more data than what we currently have available. This work is among the first to use LLMs for source-level roofline performance prediction via classification, and illustrates their potential to guide optimization efforts when runtime profiling is infeasible. Our findings suggest that with better datasets and prompt strategies, LLMs could become practical tools for HPC performance analysis and performance portability.