arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2302.11405cs.LGcs.AI
收藏

ML驱动的MLIR硬件成本模型

ML-driven Hardware Cost Model for MLIR

Intel(英特尔公司)

Dibyendu Das, Sandya Mannarswamy

摘要:

在早期优化过程中,编译器必须预测机器相关的特性,如执行单元利用率,寄存器溢出数量,延迟,吞吐量等,以生成更好的代码。通常,编译器中会内置一个手写的静态/分析硬件成本模型。然而,随着深度学习编译器的发展,对更复杂和更多样的预测的需求变得更加明显,这些编译器需要优化卷积图。这样的编译器通常在降低到传统LLVM-IR之前采用更高级别的MLIR形式作为IR表示。在这样的场景中,静态/分析成本模型是麻烦的并且容易出错,因为操作码表示非常高级别的代数/算术运算。因此,我们为高级MLIR开发了一个基于机器学习的成本模型,它可以预测不同的目标变量,如CPU/GPU/xPU利用率,执行的指令,寄存器使用率等。通过将传入的MLIR视为文本输入和NLP模型,我们可以应用现代NLP研究中的知名技术来帮助更准确地预测硬件特性。我们希望这种精确的ML驱动的硬件成本模型能够指导我们的深度学习编译器进行图级优化,包括算子融合、本地内存分配、内核调度等,以及许多内核级优化,如循环交换、LICM和展开。我们报告了在高级MLIR上开发此类模型的早期工作进展结果,这些MLIR表示由Pytorch/Tensorflow类框架以及仿射等较低级别的方言发出的低流图。我们发现,这些模型可以提供合理的良好估计与各种硬件特性的兴趣,可以是一个去到机制,在未来的硬件成本建模的低误差范围。

英文摘要:

During early optimization passes, compilers must make predictions for machine-dependent characteristics such as execution unit utilization, number of register spills, latency, throughput etc. to generate better code. Often a hand-written static/analytical hardware cost model is built into the compiler. However, the need for more sophisticated and varied predictions has become more pronounced with the development of deep learning compilers which need to optimize dataflow graphs. Such compilers usually employ a much higher level MLIR form as an IR representation before lowering to traditional LLVM-IR. A static/analytical cost model in such a scenario is cumbersome and error prone as the opcodes represent very high level algebraic/arithmetic operations. Hence, we develop a machine learning-based cost model for high-level MLIR which can predict different target variables of interest such as CPU/GPU/xPU utilization, instructions executed, register usage etc. By considering the incoming MLIR as a text input a la NLP models we can apply well-known techniques from modern NLP research to help predict hardware characteristics more accurately. We expect such precise ML-driven hardware cost models to guide our deep learning compiler in graph level optimizations around operator fusion, local memory allocation, kernel scheduling etc. as well as in many kernel-level optimizations such as loop interchange, LICM and unroll. We report early work-in -progress results of developing such models on high-level MLIR representing dataflow graphs emitted by Pytorch/Tensorflow-like frameworks as well as lower-level dialects like affine. We show that these models can provide reasonably good estimates with low error bounds for various hardware characteristics of interest and can be a go-to mechanism for hardware cost modelling in the future.

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

↑