PyTorch 2.12 リリースのハイライト(7 分読了)
PyTorch 2.12 は、CUDA Graph の制御フロー対応や MX 量子化サポートなど、大規模モデルの推論・学習効率を飛躍的に高める実装最適化機能を多数追加した重要なリリースである。
キーポイント
CUDA Graph の高度化と制御フロー対応
torch.cond を含む動的な制御フローが CUDA Graph でキャプチャー・再生可能になり、XPU や外部バックエンドとの統合も強化された。
量子化フォーマット拡張とモデル圧縮
torch.export.save がマイクロスケーリング(MX)量子化フォーマットをサポートし、極めて効率的なモデルの完全エクスポートが可能になった。
最適化器と計算ライブラリの高速化
Adagrad に fused=True が追加され単一カーネル実装へ統合され、linalg.eigh の CUDA 実行速度が最大 100 倍向上した。
ROCm ユーザー向けの機能強化
ROCm ユーザー向けに拡張可能なメモリセグメントや rocSHMEM、FlexAttention パイプラインングが導入された。
CUDA におけるバッチ処理固有値分解の劇的な高速化
cuSolver ベンドの更新により、linalg.eigh のパフォーマンスが最大 100 倍向上し、科学計算や機械学習ワークロードでの効率が大幅に改善されました。
ハードウェア非依存なグラフキャプチャ API の新設
torch.accelerator.Graph が導入され、CUDA、XPU、およびアウトオブツリーバックエンド間でグラフのキャプチャとリプレイを統一的に扱えるようになりました。
マイクロスケーリング量子化フォーマットのサポート追加
torch.export.save が Microscaling (MX) 量子化形式に対応し、大規模モデルやエッジ環境向けに圧縮されたモデルのフルエクスポートが可能になりました。
影響分析・編集コメントを表示
影響分析
このリリースは、PyTorch が単なる研究ツールから、大規模モデルのトレーニングと推論を効率的に実行できる本格的な生産プラットフォームへと進化していることを示す重要なマイルストーンです。特に CUDA Graph の制御フロー対応や量子化サポートの強化は、コスト削減とレイテンシ低減を求める企業にとって即座に適用可能な価値を持つ技術的飛躍と言えます。
編集コメント
今回のアップデートは、特に大規模モデルの推論効率化と、多様なハードウェア(NVIDIA GPU, Intel XPU など)での一貫したパフォーマンス発揮において、開発者の負担を劇的に減らす内容となっています。
**
Featured projects
-
PyTorch® 2.12 のリリースを発表できることを嬉しく思います (release notes)!
PyTorch 2.12 リリースには、以下の主要な変更が含まれています:
- CUDA におけるバッチ処理された linalg.eigh が、更新された cuSolver バックエンドの選択により最大で 100 倍高速化されました
- 新しい torch.accelerator.Graph API は、CUDA、XPU、およびアウトオブツリーバックエンド間でグラフキャプチャとリプレイを統一しました
- torch.export.save は now Microscaling (MX) 量子化フォーマットをサポートし、積極的な圧縮モデルの完全なエクスポートを可能にしました
- Adagrad が now fused=True をサポートし、Adam、AdamW、SGD とともに単一カーネル最適化実装に参加しました
- torch.cond コントロールフローは、CUDA Graphs 内でキャプチャおよびリプレイできるようになりました
- ROCm ユーザーは、拡張可能なメモリセグメント、rocSHMEM 対称メモリ集合体、FlexAttention パイプラインングの恩恵を受けます
今回のリリースには、PyTorch 2.11 から 457 名の貢献者による 2,926 のコミットが含まれています。私たちの献身的なコミュニティの皆様に心から感謝申し上げます。いつも通り、これらの新機能をお試しいただき、2.12 の改善に向けて問題点を報告していただくことをお勧めします。PyTorch 2 シリーズの始め方に関する詳細は、Getting Started ページをご覧ください。
ご質問はありますか?5 月 20 日(水)午前 10 時(太平洋標準時)に、パネルディスカッショナーの Joe Spisak 氏、Andrey Talman 氏、Alban Desmaison 氏と司会者の Chris Gottbrath 氏によるライブ Q&A にご参加ください。リリースの概要を簡単に説明し、皆様のご質問にお答えします。今すぐ登録する
2.x シリーズを通じて、PyTorch は研究ファーストのフレームワークから、大規模な生産環境でのトレーニングと推論のための統一されたハードウェア非依存プラットフォームへと進化を遂げてきました。PyTorch 2.10 では、クロスバックエンドのパフォーマンスプリミティブと TorchScript の正式な非推奨化により基盤を整えました。PyTorch 2.11 では、分散トレーニングのための微分可能なコレクティブ(collectives)、次世代 GPU 向けの FlashAttention-4、そしてより広範なエクスポート対応により、その基盤を拡張しました。
PyTorch 2.12 はこの方向性を継続します:新しいデバイス非依存の torch.accelerator.Graph API が、CUDA、XPU、およびアウトオブツリーバックエンド間でグラフキャプチャとリプレイを統一し、バッチ処理された固有値分解(eigendecomposition)は最大で 100 倍高速化され、torch.export では、 aggressively compressed models を展開するためのマイクロスケーリング量子化形式(Microscaling quantization formats)がサポートされます。これらのリリースを通じて、PyTorch はバックエンド間でより高速になり、AI イノベーションを可能にし続ける中で、利用可能なプラットフォームの幅も広がっています。
パフォーマンス機能
CUDA におけるバッチ処理された固有値分解(linalg.eigh)が最大で 100 倍高速化**
CUDA における linalg.eigh のバックエンド選択が大幅に改修されました。従来の MAGMA バックエンドは廃止され、cuSolver に置き換えられました(Grayson Derossi による PR #174619)。また、Johannes Z による PR #175403 で、cuSolver のディスパッチヒューリスティックが更新され、syevj_batched が無条件で使用されるようになりました。バッチ化された対称/エルミート固有値問題において、これは前バージョンと比較して最大 100 倍の高速化を実現し、CuPy との間で長年存在していた性能格差を解消しました。**
以前は PyTorch が各行列求解を非効率的に個別にディスパッチしていたため数分かかっていたワークロードも、cuSolver の syevj_batched カーネル(多数の小型・中型行列を単一の GPU 操作として処理するように設計されたもの)を使用することで、秒単位で実行可能になりました。これらの性能向上は、バッチ化された行列の固有値分解に依存する科学計算や機械学習のワークロードにおいて特に重要です。(ドキュメント内の使用例:example usage in the doc)
融合型 Adagrad オプティマイザ **
Adagrad オプティマイザは now fused=True をサポートするようになりました。これにより、各操作ごとに別々のカーネルを起動するのではなく、オプティマイザのステップ全体が単一の CUDA カーネル内で実行されます。これによってカーネル起動のオーバーヘッドとメモリアクセス量が削減されました。Adagrad は、Adam、AdamW、SGD に続き、融合型バリアントを提供するようになりました。基盤となる CUDA カーネルは @MeetThePatel 氏により 2.11 サイクル中に貢献され(PR #159008)、Python フロントエンドがユーザーに公開される形での実装は Jane Xu 氏によって 2.12 で完成されました(PR #177672)。
ハードウェア間でのコンパイルとエクスポート
torch.accelerator.Graph: デバイス非依存アクセラレーターグラフキャプチャおよびストリーム API
torch.accelerator.Graph は、torch.xpu.XPUGraph などのバックエンド固有の実装に対する統一された抽象化を提供する、グラフキャプチャとリプレイのための新しいデバイス非依存 API です。各バックエンドは、軽量な GraphImplInterface を通じて独自の実装を登録することができ、バックエンドの自律性を維持しつつ、一貫したユーザー向け API を実現します。
これに伴い、c10::Stream および torch.Stream は now is_capturing() メソッドを公開するようになり、デバイス固有の is_current_stream_capturing に代わり、バックエンド非依存な代替手段を提供しています。ストリームコンテキストマネージャーの再入問題も修正されました。これらの変更により、ストリームおよびグラフ管理におけるクロスバックエンド間の整合性が実現され、XPU バックエンドに対する初期サポートが提供されるとともに、PrivateUse1 を介してアウトオブツリー(外部)バックエンドへの拡張性も確保されています。
Guangye Yu 氏 (Intel) によって 6 つの PR にわたって貢献され、C++ インターフェース (PR #171269) と Python フロントエンド (PR #171285) を基盤としています。(ドキュストリング内の使用例)
torch.export がマイクロスケーリング (MX) 量子化フォーマットをサポートするようになりました
モデルが研究から本番環境へ移行する際、torch.export は PyTorch モデルをデプロイ用にシリアライズするための標準的なパスです。しかし、Microscaling (MX) 量子化を使用するモデルは、これまでエクスポートできませんでした。これは、MX フォーマット(MXFP4, MXFP6, MXFP8)で共有ブロックスケール指数として使用される float8_e8m0fnu データ型を torch.export.save が処理していなかったためです。
PyTorch 2.12 では、torch.export.save と torch.export.load がこのデータ型を持つテンソルのシリアライズとデシリアライズを正しく行うようになり、Microscaling 量子化を活用するモデルの完全なエクスポートからデプロイまでのワークフローが阻害されなくなりました。これは、大規模言語モデルをコスト制約のある環境やエッジ環境にデプロイするチームにとって特に重要です。そこでは積極的な量子化が不可欠です。ARM の Chizkiyahu Raful 氏による寄稿 (PR #176270)。
CUDA Graph 内での torch.cond を用いた制御フローのキャプチャ
torch.cond を使用した制御フロー領域を、CUDA Graphs の一部としてキャプチャして再生できるようになりました。以前はデータ依存型の制御フローにより分岐が CPU で評価されるため、CUDA グラフツリーへのフォールバックを余儀なくされていました。CUDA 12.4 の条件付き IF ノードを活用することで、torch.cond の分岐は単一のグラフキャプチャ内で完全に GPU 上で評価されるようになりました。**
これは、Daniel Galvez と Ting-Yang Kuei(NVIDIA)によって貢献されたものであり(PR #168912)、Paul Zhang(Meta)によって Inductor の順序付けサポートが追加されました(PR #179457)。現在、この機能は eager および cudagraphs バックエンドで動作しますが、Inductor への対応は今後のリリースを予定しています。
XPU 向けの FMA ベースの addcdiv 低減化
Inductor は now、addcdiv 演算に対して融合乗算加算(FMA: fused multiply-add)命令を使用し、Triton カーネル融合の利点を維持しながら、eager CUDA 実行とビット単位の数値整合性を達成しています。
addcdiv は、Adam、AdamW、RMSprop など多くのオプティマイザ更新ルールの核心に位置する融合演算(結果 = input + value × (tensor1 / tensor2))です。以前は、Inductor の低減化が個別の乗算および除算命令を使用していたため、eager モードと比較して小さな浮動小数点丸め誤差が生じていました。これらの違いは数千回のトレーニングステップにわたって蓄積し、コンパイルされたモデルが数値的に同一の結果を生成していることを検証することが困難になっていました。
これはまず Michael Lazos(Meta)によって CUDA 向けに実装され(PR #174912)、その後 Guangye Yu(Intel)によって XPU へ拡張されました(PR #176163)。これにより、Intel GPU 上のいくつかの数値的正しさの問題が修正されました。オプティマイザを多用するトレーニングループで torch.compile を使用するユーザーは、NVIDIA および Intel のハードウェアの両方で、数値的な再現性を犠牲にすることなくコンパイルされたパフォーマンスを得ることができます。
分散トレーニング
カスタム演算における ProcessGroup サポート
カスタム演算子は、呼び出し側がグローバルレジストリで文字列グループ名に変換して検索する必要がある代わりに、ProcessGroup オブジェクトを直接引数として受け取れるようになりました。すべての c10d 機能的集合演算 (all_reduce, reduce_scatter など) は、ProcessGroup オブジェクトを直接受け取ることも、文字列名を受け取ることもできるよう更新されました。Aaron Orenstein (Meta) による寄稿 (PR #172795)。
マルチ GPU/マルチノードプロファイリングの改善
PyTorch Profiler Events API は now、フロー ID、フロータイプ、アクティビティタイプ、未完了イベント、Python 関数イベントを公開するようになりました。これにより events() が Chrome trace JSON 出力と同等になり、より豊富なプログラムによる事後分析が可能になります。さらに、新しい seq_num フィールドを使用して、ランク間の NCCL 集合トレースを相関させることが可能になりました。同じ集合に参加するすべてのランクは、プロセスグループ内で同じシーケンス番号を共有します。これらの変更により、複数の GPU およびノードにわたる分散トレーニングのパフォーマンスデバッグのためのツールが大幅に改善されました。API の拡張は Ryan Zhang (Meta) によるもの (PR #177888)、NCCL seq_num の追加は Marvin Dsouza (Meta) によるものです (PR #177148)。
FlightRecorder: ncclx + gloo バックエンド
FlightRecorder のトレース解析機能は、既存の nccl および xccl バックエンドに加え、ncclx と gloo バックエンドもサポートするようになりました。これにより、より広範な集合通信バックエンドにわたる分散通信のトレーシングが可能になります。さらに、FlightRecorder は以前は追跡されていなかった torchcomms 操作(例:all_gather_single, reduce_scatter_v, barrier)も認識できるようになりました。また、複数のプロセスグループが同時に FlightRecorder のシングルトンにアクセスした際に無限ループを引き起こす可能性があった競合状態の問題も、今回のサイクルで修正されました。バックエンドの許可リスト追加は Lily Janjigian (Meta) 氏によるもの(PR #180268)、torchcomms 操作サポートは Tushar Jain 氏によるものです(PR #178359)。
プラットフォーム関連アップデート
CUDA
CUDA Graph カーネル注釈
torch.cuda.graph は now、enable_annotations という kwarg を受け付けるようになりました。これにより、キャプチャされた CUDA グラフ内の個々のカーネルに注釈メタデータ(例:集合演算の名前、プロセスグループ、メッセージサイズなど)が注入されます。コンパニオンポストプロセッシングスクリプト(python -m torch.cuda._annotate_cuda_graph_trace)でトレーサーを後処理した後、これらの注釈はトレースにマージされます。これらの注釈は Perfetto/Chrome プロファイラーのトレースに表示され、再生されたグラフ内の各カーネルが何を行っているかを理解することが大幅に容易になります。Shangdi Yu (Meta) 氏による寄稿(PR #179768)。
CUDA Green コンテキストワークキュー制限
CUDA Green Contexts で、ワークキューの制限を指定できるようになり、GPU リソースの分割に対するより細かな制御が可能になりました。この実験的機能により、ユーザーはグリーンコンテキスト内の並行する作業提出数を制限でき、複数の同時実行ワークロード間でのリソース共有をより予測可能にできます。Matthias Jouanneaux (NVIDIA) による寄稿 (PR #177242)。
ROCm
ROCm: 拡張可能なセグメント
AMD GPU (ROCm >= 7.02) では、PyTorch のキャッシュアロケータにおいて拡張可能なメモリセグメントがサポートされるようになりました。これは、仮想メモリ API を介して動的に割り当てを拡大することでメモリの断片化を削減する CUDA の機能と同等です。Prachi Gupta (AMD) による追加 (PR #173330)。
ROCm: rocSHMEM サポート
rocSHMEM サポートにより、対称メモリ集合演算 (torch.ops.symm_mem.*) が AMD GPU で利用可能になりました。これは、NVSHMEM ベースのオンGPU 通信プリミティブ — ポイントツーポイント、ブロードキャスト、オール・トゥー・オール、および MoE 指向の 2D AllToAllv を含む — を ROCm に移植したものです。rocSHMEM の実装では、NVSHMEM と rocSHMEM の間の API およびワープサイズの差異を処理するために、専用のコンパイルユニットが使用されています。Prachi Gupta による寄稿 (PR #173518)。
ROCm: hipSPARSELt および FP8 半構造化スパース性
hipSPARSELt は、ROCm >= 7.12 における PyTorch ビルドでデフォルトで有効化され、AMD GPU に対して半構造化(2:4)スパース性サポートをもたらしました。FP8 (float8_e4m3fn) 入力も、MI350X (gfx950) 上で hipSPARSELt を介して FP32 出力とともにサポートされるようになりました。これにより、以前は CUDA のみに限定されていた torch._cslt_sparse_mm スパース性加速パスが利用可能になります。hipSPARSELt の有効化は rraminen (AMD) によって行われました(PR #170852)、FP8 半構造化スパース性の追加は Benji Beck (Meta) によって行われました(PR #179310)。
ROCm: Inductor FlexAttention パイプライン処理
AMD GPU 上の FlexAttention は、Triton バックエンドで二段階パイプライン処理を使用するようになり、MI350X 上で因果関係(causal)、アルバイブ(alibi)、スライディングウィンドウなど、さまざまなアテンションパターンと形状において 5-26% の速度向上を実現しました。これは、より効率的なメモリー・計算のオーバーラップを解放する単一の設定変更(num_stages=1 から 2)によるものです。nithinsubbiah によって貢献されました(PR #176676)。
Apple MPS
MPS: Metal-4 オフラインシェーダーコンパイル
Apple Silicon のバイナリホイールは、macOS 26 で metal-4 標準に基づいて事前コンパイルされた Metal-4 シェーダーを同梱するようになりました。これにより、初回実行時のランタイムシェーダーコンパイルのオーバーヘッドが排除され、MPS ワークロードの起動レイテンシが削減されます。また、事前にコンパイルされた .metallib バイナリを直接読み込むための補完 API (torch._C._mps_loadMetalllib) も追加され、Triton Apple MPS バックエンドのコンパイル時 metallib ワークフローをサポートしています。Isalia20 (Irakli Salia) によって貢献されました(PR #179378)。
非推奨および破壊的変更
Distributed: Planned Breaking Changes for torchcomms
torchcomms を PyTorch Distributed に直接統合し、誰もがすぐにその恩恵を受けられるように取り組んできました。今後のリリース(2.13 以降)では、torchcomms をデフォルトで使用する予定であり、これには ProcessGroup の動作に関するいくつかの破壊的変更が含まれます。これらの変更がほとんどのモデルで自動的に機能し、エコシステム内の互換性問題を修正することを目指していますが、それでも一部のモデルには影響が生じます。
torchcomms はまだ改良中ですが、現在すぐに使用可能であり、新しい API、フォールトトレランス(耐障害性)、ウィンドウ機能、スケーラビリティ、デバッグ機能へのアクセスを得ることができます。始めるには、pip install torchcomms を実行し、TORCH_DISTRIBUTED_USE_TORCHCOMMS=1 を設定してください。
詳細については https://github.com/meta-pytorch/torchcomms をご覧ください。
主な変更点:
- 即時初期化:dist.init_process_group 内ですべての ProcessGroup/通信子を即時に初期化するよう要求し、単一のバックエンドデバイスのみをサポートします。つまり、初期化時にデバイスを指定する必要があります。
- P2P 操作:各 ProcessGroup/通信子が基盤となる通信子と 1:1 で対応するように目指しています。これにより、同じグループまたはストリームで発行された P2P 操作が並行して実行されることは保証されなくなります。並行して実行する P2P 操作には、バッチ API または別のグループ/通信子の使用が必要です。
- torchcomms の依存関係:PyTorch Distributed に対して torchcomms を必須パッケージ化し、既存の c10d::Backends を非推奨として、より現代的な単一の通信定義に置き換える計画です。
torchcomms の統合は PyTorch Distributed チームが主導しており、2.12 では基盤整備が行われています。これには Yifan Mao 氏によるバックエンドラッパーのリファクタリング(PR #177157)と、Tushar Jain 氏による FlightRecorder の統合(PR #175270)が含まれます。
Torchscript は非推奨となりました
Torchscript は 2.10 で非推奨となり、jit trace および script API を置き換えるには torch.export を使用し、組み込みランタイムを置き換えるには Executorch を使用する必要があります。詳細については、PTC からのこの講演をご覧ください。
CUDA 12.8 Wheel の非推奨
PyTorch 2.12 から、CUDA 12.8 のバイナリ Wheel は非推奨となり、標準リリースマトリクスの一部として公開されなくなります。デフォルトの Wheel は CUDA 13.0(PyPI から pip install torch で入手可能)のままです。また、CUDA 13.2 が実験的ビルドとして追加されました。
Pascal や Volta などの古いアーキテクチャで動作しているユーザーは、このリリースでもサポートされている CUDA 12.6 Wheel に切り替えるべきです。Blackwell などの新しい GPU で動作しているユーザーは、CUDA 13.0 以上の Wheel を使用する必要があります。なお、これには NVIDIA ドライバーのアップグレード(Linux では 580.65.06、Windows では 580.88)が必要です。
原文を表示
**
Featured projects
-
We are excited to announce the release of PyTorch® 2.12 (release notes)!
The PyTorch 2.12 release features the following changes:
- Batched linalg.eigh on CUDA is up to 100x faster due to updated cuSolver backend selection
- New torch.accelerator.Graph API unifies graph capture and replay across CUDA, XPU, and out-of-tree backends
- torch.export.save now supports Microscaling (MX) quantization formats, enabling full export of aggressively compressed models
- Adagrad now supports fused=True, joining Adam, AdamW, and SGD with a single-kernel optimizer implementation
- torch.cond control flow can now be captured and replayed inside CUDA Graphs
- ROCm users gain expandable memory segments, rocSHMEM symmetric memory collectives, and FlexAttention pipelining
This release is composed of 2,926 commits from 457 contributors since PyTorch 2.11. We want to sincerely thank our dedicated community for your contributions. As always, we encourage you to try these out and report any issues as we improve 2.12. More information about how to get started with the PyTorch 2-series can be found at our Getting Started page.
Have questions? Join us on Wednesday, May 20 at 10 am PST for a live Q&A with panelists Joe Spisak, Andrey Talman, and Alban Desmaison, and moderator Chris Gottbrath. We will provide a brief overview of the release and answer your questions live. Register now.
Throughout the 2.x series, PyTorch has been evolving from a research-first framework into a unified, hardware-agnostic platform for production training and inference at scale. PyTorch 2.10laid the groundwork with cross-backend performance primitives and the formal deprecation of TorchScript. PyTorch 2.11 expanded that foundation with differentiable collectives for distributed training, FlashAttention-4 on next-generation GPUs, and broader export coverage.
PyTorch 2.12 continues this direction: a new device-agnostic torch.accelerator.Graph API unifies graph capture and replay across CUDA, XPU, and out-of-tree backends; batched eigenvalue decomposition is up to 100x faster; and torch.export now supports Microscaling quantization formats for deploying aggressively compressed models. Across these releases, PyTorch is becoming faster across backends and usable in a wider variety of platforms as it continues to enable AI innovation.
Performance Features
Up to 100x faster batched eigendecomposition on CUDA (linalg.eigh)**
The backend selection for linalg.eigh on CUDA has been overhauled. The legacy MAGMA backend was deprecated in favor of cuSolver (PR #174619 by Grayson Derossi), and the cuSolver dispatch heuristics were updated to use syevj_batched unconditionally (PR #175403 by Johannes Z). For batched symmetric/Hermitian eigenvalue problems, this yields up to 100x speedups over the previous release, resolving longstanding performance gaps with CuPy. **
Workloads which previously took minutes (because PyTorch was inefficiently dispatching each matrix solve individually) now run in seconds by using cuSolver’s syevj_batched kernel, which is designed to process many small/medium matrices as a single GPU operation. These gains are especially relevant for scientific computing and machine learning workloads that rely on eigendecompositions of batched matrices. (example usage in the doc)
Fused Adagrad optimizer **
The Adagrad optimizer now supports fused=True, performing the entire optimizer step in a single CUDA kernel rather than launching separate kernels for each operation. This reduces kernel launch overhead and memory traffic. Adagrad joins Adam, AdamW, and SGD in offering a fused variant. The underlying CUDA kernel was contributed by @MeetThePatel in the 2.11 cycle (PR #159008), with the Python frontend exposing it to users finalized by Jane Xu in 2.12 (PR #177672).
Compilation and export across hardware
torch.accelerator.Graph: Device Agnostic Accelerator Graph Capture and Stream API
torch.accelerator.Graph is a new device-agnostic API for graph capture and replay, providing a unified abstraction over backend-specific implementations such as torch.xpu.XPUGraph. Each backend can register its own implementation through a lightweight GraphImplInterface, preserving backend autonomy while enabling a consistent user-facing API. **
Alongside this, c10::Stream and torch. Stream now exposes an is_capturing() method, replacing the device-specific is_current_stream_capturing with a backend-agnostic alternative. Stream context manager reentrance was also fixed. Together, these changes bring cross-backend parity to stream and graph management, with initial support for the XPU backend and extensibility to out-of-tree backends via PrivateUse1.
Contributed by Guangye Yu (Intel) across six PRs, anchored by the C++ interface (PR #171269) and Python frontend (PR #171285). (usage example in docstring)
torch.export now supports Microscaling (MX) quantization formats**
As models move from research to production, torch.export is the standard path for serializing PyTorch models for deployment. However, models using Microscaling (MX) quantization — an increasingly popular technique for reducing model size and inference cost — could not previously be exported because torch.export.save did not handle the float8_e8m0fnu dtype used as the shared block-scale exponent in MX formats (MXFP4, MXFP6, MXFP8).
In PyTorch 2.12, torch.export.save and torch.export.load now correctly serialize and deserialize tensors with this dtype, unblocking the full export-to-deployment workflow for models leveraging Microscaling quantization. This is particularly relevant for teams deploying large language models to cost-constrained or edge environments where aggressive quantization is essential. Contributed by Chizkiyahu Raful (ARM) (PR #176270).
Capture Control flow with torch.cond within CUDA Graph
Control-flow regions using torch.cond can now be captured and replayed as part of CUDA Graphs. Previously, data-dependent control flow forced fallback to CUDA graph trees because branching was evaluated on the CPU. By leveraging CUDA 12.4’s conditional IF nodes, torch.cond branches are now evaluated entirely on the GPU within a single graph capture. **
This was contributed by Daniel Galvez and Ting-Yang Kuei (NVIDIA) (PR #168912), with Inductor ordering support added by Paul Zhang (Meta) (PR #179457). This currently works with the eager and cudagraphs backends; Inductor support is planned for a future release.
FMA-based addcdiv lowering for XPU**
Inductor now uses fused multiply-add (FMA) instructions for addcdiv operations, achieving bitwise numerical parity with eager CUDA execution while preserving Triton kernel fusion benefits.
addcdiv is a fused arithmetic operation (result = input + value × (tensor1 / tensor2)) that sits at the heart of many optimizer update rules, including Adam, AdamW, and RMSprop. Previously, Inductor’s lowering used separate multiply and divide instructions, introducing small floating-point rounding differences compared to eager mode. These differences accumulate over thousands of training steps, making it difficult to validate that compiled models produce numerically identical results.
This was first implemented for CUDA by Michael Lazos (Meta) (PR #174912), then extended to XPU by Guangye Yu (Intel) (PR #176163), fixing several numerical correctness issues on Intel GPUs. Anyone using torch.compile with optimizer-heavy training loops now gets compiled performance without sacrificing numerical reproducibility — on both NVIDIA and Intel hardware.
Distributed Training
ProcessGroup support in custom ops
Custom operators can now accept ProcessGroup objects directly as arguments rather than requiring callers to convert them to string group names and looking them up in a global registry. All c10d functional collective ops (all_reduce, reduce_scatter, etc) have been updated to accept both ProcessGroup objects directly and the string names. Contributed by Aaron Orenstein (Meta) (PR #172795).
Multi-GPU/multi-node profiling improvements
PyTorch Profiler Events API now exposes flow IDs, flow types, activity types, unfinished events, and Python function events — bringing events() to parity with the Chrome trace JSON output and enabling richer programmatic post-hoc analysis. In addition it is now possible to correlate NCCL collective traces across ranks using a new seq_num field – all ranks participating in the same collective share the same sequence number within a process group. Together these changes significantly improve the tooling for debugging distributed training performance across multiple GPUs and nodes. API enrichment by Ryan Zhang (Meta) (PR #177888) and NCCL seq_num added by Marvin Dsouza (Meta) (PR #177148).
FlightRecorder: ncclx + gloo Backends
FlightRecorder’s trace analyzer now supports ncclx and gloo backends alongside the existing nccl and xccl backends, enabling distributed communication tracing across a broader set of collective backends. Additionally, FlightRecorder now recognizes torchcomms operations (e.g., all_gather_single, reduce_scatter_v, barrier) that were previously untracked. A race condition that could cause an infinite loop when multiple process groups concurrently accessed the FlightRecorder singleton was also fixed in this cycle. Backend allowlist added by Lily Janjigian (Meta) (PR #180268), with torchcomms operation support by Tushar Jain (PR #178359).
Platform Related Updates
CUDA
CUDA Graph kernel annotations
torch.cuda.graph now accepts an enable_annotations kwarg that injects annotation metadata (e.g., collective op names, process groups, message sizes) into individual kernels within captured CUDA graphs. After post-processing tracer with a companion post-processing script (python -m torch.cuda._annotate_cuda_graph_trace) annotations are merged into traces. These annotations appear in Perfetto/Chrome profiler traces, making it significantly easier to understand what each kernel in a replayed graph is doing. Contributed by Shangdi Yu (Meta) (PR #179768).
CUDA Green Context workqueue limit
CUDA Green Contexts now support specifying a workqueue limit, giving finer-grained control over GPU resource partitioning. This experimental feature allows users to constrain the number of concurrent work submissions within a green context, enabling more predictable resource sharing across concurrent workloads. Contributed by Matthias Jouanneaux (NVIDIA) (PR #177242).
ROCm
ROCm: Expandable segments
AMD GPUs (ROCm >= 7.02) now support expandable memory segments in PyTorch’s caching allocator, matching the CUDA feature that reduces memory fragmentation by dynamically growing allocations via virtual memory APIs. Added by Prachi Gupta (AMD) (PR #173330)
ROCm: rocSHMEM support
rocSHMEM support enables symmetric memory collective operations (torch.ops.symm_mem.*) on AMD GPUs, porting the NVSHMEM-based on-GPU communication primitives — including point-to-point, broadcast, all-to-all, and MoE-oriented 2D AllToAllv — to ROCm. The rocSHMEM implementation uses a dedicated compilation unit to handle API and warp-size differences between NVSHMEM and rocSHMEM. Contributed by Prachi Gupta (PR #173518).
ROCm: hipSPARSELt and FP8 semi-structured sparsity
hipSPARSELt is now enabled by default in PyTorch builds on ROCm >= 7.12, bringing semi-structured (2:4) sparsity support to AMD GPUs. FP8 (float8_e4m3fn) inputs are also now supported through hipSPARSELt on MI350X (gfx950), with FP32 output. This enables the same torch._cslt_sparse_mm sparsity acceleration path that was previously CUDA-only. hipSPARSELt enabled by rraminen (AMD) (PR #170852), with FP8 semi-structured sparsity added by Benji Beck (Meta) (PR #179310).
ROCm: Inductor FlexAttention pipelining
FlexAttention on AMD GPUs now uses two-stage pipelining in the Triton backend, delivering 5-26% speedups across a range of attention patterns (causal, alibi, sliding window) and shapes on MI350X. This was a one-line configuration change (num_stages=1 to 2) that unlocks more efficient memory-compute overlap. Contributed by nithinsubbiah (PR #176676).
Apple MPS
MPS: Metal-4 offline shader compilation
Apple Silicon binary wheels now ship with ahead-of-time-compiled Metal-4 shaders, built on macOS 26 with the metal-4 standard. This eliminates the runtime shader compilation overhead on first run, reducing startup latency for MPS workloads. A companion API (torch._C._mps_loadMetalllib) was also added for loading pre-compiled .metallib blobs directly, supporting the Triton Apple MPS backend’s compile-time metallib workflow. Contributed by Isalia20 (Irakli Salia) (PR #179378).
Deprecations and Breaking Changes
Distributed: Planned Breaking Changes for torchcomms
We’ve been working hard on integrating torchcomms directly into PyTorch Distributed so everyone can get the benefits out of the box. In an upcoming release (2.13+) we’re planning on using torchcomms by default, which includes some breaking changes to how ProcessGroups operate. We aim to make these changes work automatically for most models and fix any incompatibilities in the ecosystem, but nevertheless, some models will be impacted.
We’re still polishing torchcomms but you can use it right now and get access to the new APIs, fault tolerance, window, scalability, and debuggability features. To get started, pip install torchcomms and set TORCH_DISTRIBUTED_USE_TORCHCOMMS=1.
See https://github.com/meta-pytorch/torchcomms for more details.
Key changes:
- Eager Initialization: We will require all ProcessGroup/communicators to be eagerly initialized during dist.init_process_group and only support a single backend device. This means that the device will have to be specified during initialization.
- P2P operations: We aim to make each ProcessGroup/communicator match 1:1 with the underlying communicator. This means that P2P operations issued on the same group/stream will not be guaranteed to run concurrently. Concurrent P2P operations will be required to use the batch APIs or a separate group/communicator.
- torchcomms dependency: We plan to make torchcomms a required package for PyTorch Distributed and deprecate the existing c10d::Backends in favor of a single, more modern communication definition.
The torchcomms integration is being led by the PyTorch Distributed team, with groundwork in 2.12, including backend wrapper refactoring by Yifan Mao (PR #177157) and FlightRecorder integration by Tushar Jain (PR #175270).
Torchscript is now Deprecated
Torchscript was deprecated in 2.10 and torch.export should be used to replace the jit trace and script APIs, and Executorch should be used to replace the embedded runtime. For more details, see this talkfrom PTC.
Deprecation of the CUDA 12.8 Wheel
Starting with PyTorch 2.12, the CUDA 12.8 binary wheel is deprecated and will no longer be published as part of the standard release matrix. The default wheel remains CUDA 13.0 (via pip install torch from PyPI), and CUDA 13.2 has been added as an experimental build.
Users running on older architectures (e.g., Pascal, Volta) should switch to the CUDA 12.6 wheel, which remains supported in this release. Users running on newer GPUs (e.g., Blackwell) should use the CUDA 13.0+ wheels; note that this requires an NVIDIA driver upgrade to 580.65.06 (Linux) or 580.88 (Windows).
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み