Large language models (LLMs) can translate and modify source code, and have been shown to do so for codes of different complexity. Whether they can port a complete, production geophysical model to a different language without degrading its physics has not been established. We demonstrate that LLM-assisted code translation can preserve the physics of a complete production ocean model while moving it into a modern performance-portable form. We report our experience using an agentic LLM coding assistant, directed by domain experts, to port the FESOM2 unstructured mesh ocean--sea-ice model (about 74000 lines of core Fortran) first to C and then to C++/Kokkos for performance portability across CPUs and GPUs. We describe the practices that proved necessary, what worked and what did not, and the failure modes that we encountered. Three practices mattered most: translating in two stages that separate reproducing the numerics (Fortran to a clean C reference) from introducing parallelism (C to Kokkos); requiring a strictly literal translation in which the assistant was not permitted to ``improve'' the source; and validating each stage against an acceptance criterion suited to it. The C port reproduces the original Fortran at the level of long-term simulation statistics over five years. The Kokkos port is bit-for-bit identical to the C reference on CPU and statistically close on GPU over multi-year runs. On eddy-rich meshes up to 7.4 million surface vertices a single A100 GPU node runs 1.6--3.7 times faster than a CPU node, reaching the 1-2 simulated-years-per-day required for production integrations. The result is more than a single GPU port: by following a clear validation procedure, an LLM moved a full Fortran ocean model into another language and onto accelerators while preserving its physics in a matter of weeks.


翻译:大语言模型(LLMs)能够翻译和修改源代码,且已被证明可处理不同复杂程度的代码。然而,它们能否在保留物理过程完整性的前提下,将完整的生产级地球物理模式移植至另一种语言,此前尚未得到证实。我们证明,LLM辅助的代码翻译能保留完整生产级海洋模式的物理过程,同时将其转化为现代性能可移植形式。我们报告了在领域专家指导下,使用智能体型LLM编程助手将FESOM2非结构化网格海洋-海冰模式(约74000行核心Fortran代码)先移植至C语言,再移植至C++/Kokkos以实现跨CPU和GPU性能可移植性的实践经验。我们描述了被证明必要的实践方法、有效和无效的策略,以及遇到的失败模式。三项实践最为关键:分两阶段翻译——将再现数值计算(Fortran到纯净C参考实现)与引入并行化(C到Kokkos)分离;要求严格直译,禁止助手"优化"源代码;对每个阶段采用适配的验收标准进行验证。C移植版本在长达五年的长期模拟统计量层面复现了原始Fortran结果。Kokkos版本的CPU计算结果与C参考实现逐位一致,多年运行的GPU结果在统计上接近。在拥有高达740万表面顶点的涡旋丰富网格上,单个A100 GPU节点较CPU节点运行速度快1.6-3.7倍,达到生产集成所需的每日1-2模拟年速度。成果不仅限于单个GPU移植:通过遵循明确的验证流程,LLM在数周内将完整的Fortran海洋模式移植至另一种语言及加速器,同时保留了其物理过程。

0
下载
关闭预览

相关内容

ACM/IEEE第23届模型驱动工程语言和系统国际会议,是模型驱动软件和系统工程的首要会议系列,由ACM-SIGSOFT和IEEE-TCSE支持组织。自1998年以来,模型涵盖了建模的各个方面,从语言和方法到工具和应用程序。模特的参加者来自不同的背景,包括研究人员、学者、工程师和工业专业人士。MODELS 2019是一个论坛,参与者可以围绕建模和模型驱动的软件和系统交流前沿研究成果和创新实践经验。今年的版本将为建模社区提供进一步推进建模基础的机会,并在网络物理系统、嵌入式系统、社会技术系统、云计算、大数据、机器学习、安全、开源等新兴领域提出建模的创新应用以及可持续性。 官网链接:http://www.modelsconference.org/
扩展英语大语言模型到新语言的综述
专知会员服务
18+阅读 · 2024年8月15日
《大型语言模型代码生成》综述
专知会员服务
70+阅读 · 2024年6月4日
大语言模型简明指南
专知会员服务
143+阅读 · 2023年7月29日
学习地球科学知识理解和利用的基础语言模型
专知会员服务
30+阅读 · 2023年6月10日
绝对干货!NLP预训练模型:从transformer到albert
新智元
14+阅读 · 2019年11月10日
自然语言处理中的语言模型预训练方法
PaperWeekly
14+阅读 · 2018年10月21日
NLP通用模型诞生?一个模型搞定十大自然语言常见任务
人工智能头条
10+阅读 · 2018年6月29日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
4+阅读 · 2014年12月31日
Arxiv
26+阅读 · 2024年2月9日
Arxiv
18+阅读 · 2023年9月2日
Arxiv
21+阅读 · 2023年7月12日
Arxiv
25+阅读 · 2023年6月23日
Arxiv
12+阅读 · 2023年5月31日
VIP会员
最新内容
俄乌无人机战争的六大启示
专知会员服务
3+阅读 · 今天7:07
《无人机空中监控:通信实验洞察》
专知会员服务
2+阅读 · 今天7:05
从采集到决策:美军视角下的战术情报范式重构
《履带式无人地面战车技术发展现状》
专知会员服务
5+阅读 · 8月2日
《无人机脆弱性利用:网络空间力量的新域》
专知会员服务
5+阅读 · 8月1日
美空军如何将人工智能从战场部署至后方机关
专知会员服务
13+阅读 · 7月31日
相关基金
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
2+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
国家自然科学基金
0+阅读 · 2014年12月31日
国家自然科学基金
4+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员