[論文レビュー] A Deep Learning Based Cost Model for Automatic Code Optimization
この論文は、Tiramisuコンパイラでコード変換を適用した全プログラムからの速度向上を予測するディープラーニングベースのコストモデルを提示し、平均絶対誤差率約16%を達成し、過度な特徴工学なしで競争力の自動最適化を可能にする。
Enabling compilers to automatically optimize code has been a longstanding goal for the compiler community. Efficiently solving this problem requires using precise cost models. These models predict whether applying a sequence of code transformations reduces the execution time of the program. Building an analytical cost model to do so is hard in modern x86 architectures due to the complexity of the microarchitecture. In this paper, we present a novel deep learning based cost model for automatic code optimization. This model was integrated in a search method and implemented in the Tiramisu compiler to select the best code transformations. The input of the proposed model is a set of simple features representing the unoptimized code and a sequence of code transformations. The model predicts the speedup expected when the code transformations are applied. Unlike previous models, the proposed one works on full programs and does not rely on any heavy feature engineering. The proposed model has only 16% of mean absolute percentage error in predicting speedups on full programs. The proposed model enables Tiramisu to automatically find code transformations that match or are better than state-of-the-art compilers without requiring the same level of heavy feature engineering required by those compilers.
研究の動機と目的
- モチベーション: learnt cost models を用いて変換探索を導くことにより、コンパイラのコード最適化を自動化する。
- 特徴工学を過度に行わず、全プログラムに対する深層学習回帰モデルを開発する。
- モデルを探索戦略と統合し、高性能なコード変換を自動的に特定できるようにする。
- 実ベンチマークにおいて最先端モデルおよびベースラインと比較して、精度と有効性を評価する。
提案手法
- ランダムなTiramisuプログラムと有効な変換列を生成し、実際のスピードアップを測定するデータ生成器を構築する。
- ループネスト、代入、変換を含むコンパクトなASTベースの計算ベクトルでプログラムを表現する。
- 計算埋め込み、再帰的なループ埋め込みユニット(2つのLSTM+融合)、回帰層を組み合わせたハイブリッドニューラルアーキテクチャを提案し、スピードアップを予測する。
- PyTorchとAdamWを用いてMAPEを最小化するようモデルを訓練する。
- 学習済みモデルを木探索の目的関数として用い、Beam SearchとMonte Carlo Tree Searchを組み合わせて、モデルの不確実性を考慮しつつコード変換列を探索する。
- Halideベースのコストモデルと比較し、探索時間と最終パフォーマンスのトレードオフや精度を分析する。
実験結果
リサーチクエスチョン
- RQ1CPUコンテキストの全プログラムに適用されたコード変換の列から、ディープラーニングモデルは速度向上を予測できるか?
- RQ2全プログラムで過度なハンドエンジニアリング特徴を避けることで、予測精度やランキング品質が低下するか、または保たれるか?
- RQ3学習済みモデルは現実的なベンチマークで高性能な変換列を発見するためにBeam SearchおよびMCTSをどれほど効果的に導けるか?
- RQ4提案モデルは精度と自動最適化の促進においてHalideのコストモデルと比較してどうか?
主な発見
- テストセットでの速度向上予測のMAPEは16%。
- 予測される速度向上/ランクと測定値の間にPearson相関0.90、Spearman相関0.95。
- このモデルによりTiramisuが複数のベンチマークで最先端コンパイラと同等以上の変換を自動的に見つけられる。
- コストモデルを用いたBeam Searchは、検索時間を大幅に短縮し、最終的な性能の低下は控えめ(平均約15%)。
- MCTSを用いた場合、モデルの不確実性をよりうまく扱い、競争力のある結果を得られる一方で一部のベンチマークで改善が見られる。
この論文を読む
Nubintのビューアで原文を開き、読みながら気になる箇所をすぐに質問できます。
Nubintでこの論文を読むこのレビューはAIが論文の原文をもとに作成しました。引用する前に原文をご確認ください。