arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2603.13640cs.LGcs.SE
收藏

SemRep:基于代码变换的生成式代码表示学习

SemRep: Generative Code Representation Learning with Code Transformations

The University of Chicago(芝加哥大学);Columbia University(哥伦比亚大学);Microsoft(微软公司)

Weichen Li, Jiamin Song, Bogdan Alexandru Stoica, Arav Dhoot, Gabriel Ryan, Shengyu Fu, Kexin Pei

AI总结:

SemRep通过生成式代码表示学习提升代码变换效果,利用语义保持变换作为中间表示,实现更准确的语义推理和更高效的代码优化。

摘要:

代码变换是软件开发过程中的基础能力,其有效性依赖于构建高质量的代码表示来表征输入代码的语义并指导变换。现有方法将代码变换视为端到端学习任务,使用于语义推理的表示构建隐含在模型权重中或依赖于刚性的编译器级抽象。我们提出了SemRep,一种通过生成式代码表示学习提升代码变换效果的框架。我们的关键见解是利用语义保持变换作为中间表示,这既作为生成式中期训练任务,也作为后续特定指令代码变换的指导。在通用代码编辑和优化任务(例如GPU内核优化)中,SemRep在严格相同的训练预算下,比广泛微调的基线在正确性上高出6.9%,性能高1.1倍,泛化性高13.9%,鲁棒性高6.7%。通过探索多样化的代码变换,SemRep特别适用于进化搜索。结合进化编码代理,SemRep发现685B更大权重基线无法发现的优化,同时以25%更低的推理计算量实现相同性能。

英文摘要:

Code transformation is a foundational capability in the software development process, where its effectiveness relies on constructing a high-quality code representation to characterize the input code semantics and guide the transformation. Existing approaches treat code transformation as an end-to-end learning task, leaving the construction of the representation needed for semantic reasoning implicit in model weights or relying on rigid compiler-level abstractions. We present SemRep, a framework that improves code transformation through generative code representation learning. Our key insight is to employ the semantics-preserving transformations as the intermediate representation, which serves as both a generative mid-training task and the guidance for subsequent instruction-specific code transformations. Across general code editing and optimization tasks (e.g., GPU kernel optimization), SemRep outperforms the extensively finetuned baselines with strictly the same training budget by 6.9% in correctness, 1.1x in performance, 13.9% in generalization, and 6.7% in robustness. With the improved exploration of diverse code transformations, SemRep is particularly amenable to evolutionary search. Combined with an evolutionary coding agent, SemRep finds optimizations that 685B larger-weight baselines fail to discover while achieving the same performance with 25% less inference compute.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑