We present the design and implementation of PolyBlocks, a modular and reusable MLIR-based compiler infrastructure for AI programming frameworks and AI chips. PolyBlocks is based on pass pipelines that compose transformations on loop nests and SSA, primarily relying on lightweight affine access analysis; the transformations are stitched together in specialized ways to realize high-performance code automatically by the use of analytical cost models and heuristics. The optimizations in these passes include multi-level tiling, fusion, on-chip scratchpad usage, mapping matmuls and convolutions to matrix units, fusing the attention layer, and several other transformations for parallelism and locality. They have been developed in a way that makes it easy to build PolyBlocks-based compilers to target new chips, reusing much of the infrastructure. PolyBlocks' design and architecture enable fully automatic code generation from high-level frameworks to low-level target-specific intrinsics. Experimental results from evaluating PolyBlocks-powered just-in-time compilation for PyTorch and JAX targeting NVIDIA GPUs show that it is able to match or outperform Torch Inductor and XLA in several cases, although the latter rely on a combination of vendor libraries and code generation. For individual operators like matmuls and convolutions, PolyBlocks-generated code is competitive with the best vendor-tuned libraries or hand-written kernels.


翻译:本文介绍了PolyBlocks的设计与实现——一个基于MLIR、模块化且可复用的编译器基础设施,适用于AI编程框架与AI芯片。PolyBlocks基于以特定方式组合循环嵌套与静态单赋值形式变换的编译过程流水线,主要依赖轻量级仿射访问分析;这些变换通过分析成本模型与启发式方法自动生成高性能代码。这些编译过程中的优化包括多级分块、融合、片上暂存器使用、将矩阵乘法与卷积映射至矩阵运算单元、注意力层融合,以及多种面向并行性与局部性的其他变换。其开发方式使得基于PolyBlocks构建面向新型芯片的编译器变得简便,同时可复用大部分基础设施。PolyBlocks的设计与架构支持从高级框架到底层目标专用内联代码的全自动代码生成。针对NVIDIA GPU的PyTorch与JAX即时编译评估实验表明,尽管Torch Inductor与XLA依赖于厂商库与代码生成的组合,PolyBlocks在多种场景下仍能匹配或超越其性能。对于矩阵乘法与卷积等独立算子,PolyBlocks生成的代码可与最优厂商调优库或手写内核相竞争。

0
下载
关闭预览

相关内容

代码(Code)是专知网的一个重要知识资料文档板块,旨在整理收录论文源代码、复现代码,经典工程代码等,便于用户查阅下载使用。
AI智能体编程:技术、挑战与机遇综述
专知会员服务
47+阅读 · 2025年8月18日
《AI新基建发展白皮书》,国家工信安全中心
专知会员服务
194+阅读 · 2021年1月23日
TensorFlow Lite指南实战《TensorFlow Lite A primer》,附48页PPT
专知会员服务
70+阅读 · 2020年1月17日
重磅!AI框架发展白皮书(2022年),44页pdf
专知
28+阅读 · 2022年2月27日
Github项目推荐 | PyTorch 中文手册 (pytorch handbook)
GitHub获赞过千:PyTorch 自然语言处理项目Top 5
新智元
12+阅读 · 2018年7月10日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
Arxiv
11+阅读 · 2023年8月28日
VIP会员
最新内容
BES:让语言模型通过双向进化搜索自我改进
专知会员服务
3+阅读 · 5月30日
以色列-美国-伊朗战争中的无人机:关键要点
专知会员服务
4+阅读 · 5月30日
《Palantir任务保障性软件安全标准(MA-S2)》
专知会员服务
10+阅读 · 5月30日
基于声学的无人机检测技术综述
专知会员服务
7+阅读 · 5月30日
《当代混合战争分析框架:俄乌战争经验教训》
战略前沿人工智能的再思考(中文)
专知会员服务
8+阅读 · 5月29日
《量化地基防空系统间接效应的博弈论方法》
专知会员服务
6+阅读 · 5月29日
相关VIP内容
相关基金
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
3+阅读 · 2015年12月31日
国家自然科学基金
0+阅读 · 2015年12月31日
国家自然科学基金
1+阅读 · 2014年12月31日
Top
微信扫码咨询专知VIP会员