Skip to Content
AIシステム性能エンジニアリング (Japanese Edition)
book

AIシステム性能エンジニアリング (Japanese Edition)

by Chris Fregly
November 2025
Intermediate to advanced
1060 pages
18h 47m
Japanese
O'Reilly Media, Inc.
Content preview from AIシステム性能エンジニアリング (Japanese Edition)

章14 PyTorch コンパイラ、OpenAI Triton、およびXLAバックエンド

この作品はAIを使って翻訳されている。ご意見、ご感想をお待ちしている:translation-feedback@oreilly.com

第13章では、PyTorchベースのトレーニングと推論ワークロードを最適化・調整する複数の方法について論じた。PyTorchコンパイラについて触れ、コードをほとんど変更せずにパフォーマンスを向上させるために、カーネル融合やその他のカーネルレベルのテクニックを自動化する仕組みを説明した。

本章では、TorchDynamo、Ahead-of-Time Autograd(AOT Autograd)、PrimTorch中間表現(IR)(別名PrimsまたはPrims IR)といった構成要素、ならびに TorchInductor、Accelerated Linear Algebra(XLA)、OpenAI のTriton エコシステムといったコンパイラバックエンドを含む、動的な PyTorch コンパイルスタックについて深く掘り下げる。PyTorch コンパイラスタックを図 14-1 に示す。

また、コンパイルパイプラインのデバッグツールや、マルチGPU・マルチノードクラスタでのPyTorchスケーリング用ライブラリについても扱う。さらに、torch.compile の内部動作や、動的形状・可変シーケンス長を効率的に扱う方法を探る。

さらに、PyTorchコンパイラとOpenAI Tritonエコシステムの統合についても検証する。目標は、PyTorchの柔軟なイージー実行開発体験を損なうことなく、PyTorchモデルとアプリケーションの高速化とスケーリングを実現することだ。

Diagram illustrating the components and flow of the PyTorch compiler stack, including stages like TorchDynamo, AOT Autograd, and integration with backends such as Inductor and Triton.
図14-1. PyTorchコンパイラスタックの概要

PyTorchコンパイラの深掘り

第13章で説明したように、PyTorchのtorch.compile はPyTorchコード(およびモデル)をコンパイルし、で大幅な高速化を実現する。ほとんどの場合、次のようにたった1行のコードでこれを実行できる。様々なオプションについては後述する:

compiled_model = torch.compile(model, 
  mode="max-autotune",
#  ...
) 

このセクションでは、のPyTorchコンパイルパイプラインのステップを分解する。これには、TorchDynamoによるグラフキャプチャ、AOT Autogradによる前方/後方グラフの統合最適化、PrimTorch IR、TorchInductorによるコード生成が含まれる。このパイプラインは、ターゲットGPUハードウェア向けに最適化されたカーネルを生成する役割を担っており、図14-2に示す通りである。

Diagram of the PyTorch compiler pipeline showing stages of graph acquisition, graph lowering, and graph compilation leading to optimized kernel generation for GPUs.
図14-2. PyTorch コンパイラパイプライン(出典:https://oreil.ly/55JDn

バイトコードキャプチャとグラフ抽出のためのTorchDynamo

TorchDynamo(または単にDynamo、 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

注目すべきレーダーのトレンド2026年1月 (Japanese Edition)

注目すべきレーダーのトレンド2026年1月 (Japanese Edition)

Mike Loukides

Publisher Resources

ISBN: 0642572281526