用小模型+智能代理优化射电天文代码,节能又高效
Enhancing SLMs for Sustainable Code Optimization in Radio-Astronomy

- 用小语言模型结合智能代理和编译器反馈提升代码生成质量
- 多采样策略让小模型性能媲美大模型,计算资源减少40%以上
- 适合需要节能优化的科学计算团队,尤其适用于硬件加速迁移
大型语言模型(LLMs)可生成并优化复杂代码。本文研究其在大规模科学领域,特别是射电天文学中的应用与可持续性。随着LOFAR望远镜升级,观测范围和数据处理量大幅增加,计算需求预计增长40倍。这要求现有软件严格优化并广泛采用硬件加速器,但代码库庞大,优化任务艰巨。为实现可持续发展,需在不增加能耗的前提下完成优化。因此,我们提出使用小语言模型(SLMs)替代能耗高的大模型。通过引入智能代理机制,采用多采样生成策略和编译器反馈闭环,显著提升代码生成质量。实验表明,多采样SLM在资源更少的情况下表现可匹敌甚至超越单次生成的大模型;编译器反馈使所有测试模型持续改进。该方法具备通用性,支持检索增强生成(RAG)及静态、动态分析工具集成。
原文摘要 · Abstract (English)
Recent Large Language Models (LLMs) can produce and optimize complex code. We investigate the use of LLMs to generate and optimize code for large-scale sciences, focusing on radio astronomy and sustainability. The LOFAR telescope is currently being upgraded, significantly increasing the sky area observed, while simultaneously processing more data faster. However, this is expected to increase the computational requirements 40-fold. This upgrade thus critically depends on rigorous performance optimization of existing software and widespread adoption of accelerators. The code base is very large, making this a daunting task. We therefore investigate and demonstrate an AI-driven approach meant to assist developers in evaluating and optimizing their code, including porting to hardware accelerators. The LOFAR community is committed to sustainable solutions, and needs to achieve these improvements without increasing the energy budget. We thus need to optimize existing codes or port them to accelerators, while making sure that the optimization process itself is also energy efficient. This poses a challenge, since LLMs are energy-intensive. We therefore propose to use Small Language Models (SLMs) instead to limit environmental impact. In this paper, we show how to enhance SLMs through the use of agentic AI. We extend the SLMs in two ways to improve code generation quality and performance: first with a multi-sampling generation strategy and second with incorporating compiler feedback. We demonstrate that multi-sampling SLMs can match or surpass larger single-generation models with fewer computational resources and that feeding compiler output back into the SLMs leads to consistent improvements across all tested models. Our approach is generic, and can also use Retrieval Augmented Generation (RAG) as well as static and dynamic analysis tools in the code generation pipeline.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。