Meta、広告基盤モデル「GEM」の学習効率を倍増させる手法を公開
本文の状態
日本語全文を表示中
詳細モードで約24分の本文を読めます。
同じ出来事の情報源
この情報源を基点に整理
Meta AI Engineering
Meta は広告推薦基盤モデル GEM のトレーニング効率を倍増させ、12 ヶ月で計算能力を 4 倍に拡張したと発表し、LLM と推薦システムの特性を統合する独自のコデザイン手法を明らかにした。
AI深層分析を開く2026年8月4日 14:21
AI深層分析
キーポイント
トレーニング効率の劇的向上
Meta は GEM のエンドツーエンド(E2E)トレーニング効率を 20〜25% の MFU に引き上げ、過去 12 ヶ月で総トレーニング FLOPs を 4 倍に拡大した。
計算効率のための独自技術
Jagged Flash Attention (JFA) や MXFP8 などの混合超低精度トレーニングを推奨ワークロード向けに最適化し、最新 GPU のアーキテクチャを活用するカスタムカーネルライブラリを開発した。
スケーリング効率の革新
SM フリーのコレクティブ通信と 5D パラレル構成(2D FSDP、Expert Parallelism、Sparse Model Parallelism)を Meta の多層ネットワーク階層と共設計し、通信オーバーヘッドを削減した。
ハイブリッドアーキテクチャの課題
GEM は数兆個のスプースな埋め込みパラメータと数十億個の密なパラメータを持つハイブリッド構造であり、LLM 向けの既存インフラでは対応できない独自のトレーニング課題を抱えている。
推薦モデル学習の計算効率阻害要因
ユーザー活動履歴の可変長や非対称なアテンションパターン、メモリ束縛型演算がGPU利用率を低下させる。広告最適化タスクの数値感度の高さは、単純な低精度トレーニングによる品質劣化を防ぐ必要性を生む。
重要な引用
co-designing kernels, precision, parallelism, networking, and memory together
AI infrastructure optimized for LLM training does not directly transfer, requiring significant innovation and hardware/software co-design
Toplogy-aware 5D parallelism with Streaming Multiprocessor (SM)-free collectives
Training samples have highly variable sequence length as user activity history can vary wildly.
編集コメントを表示
編集コメント
推薦システムと LLM の境界領域における技術的ブレークスルーは、大規模モデルの実用化において極めて重要な指針となる。特に計算リソースの制約下で効率を最大化する手法は、他社の基盤モデル開発にも応用可能な示唆に富む内容である。
Source Article
元記事を日本語で読む
本文に関係しない購読案内、埋め込み通知、サイト内プロモーションは除いています。
Meta の生成型広告推薦モデル「GEM」は、Instagram や Facebook 全体で広告推薦の基盤となっているモデルですが、現在は最新世代の数千台の GPU を用いて大規模言語モデル(LLM)並みのスケールでトレーニングされています。本稿では、カーネル、精度、並列処理、ネットワーク、メモリを一体として設計(コデザイン)することで、E2E トレーニング効率を 20〜25% の Model FLOPs Utilization (MFU) に高めつつ、12 ヶ月でトレーニングに必要な計算量(FLOPs)を 4 倍に拡大した具体的な手法について解説します。
GEM のトレーニングは、推薦システムと LLM の境界領域における独自のエンジニアリング課題を抱えています。このモデルはハイブリッドアーキテクチャを採用しているだけでなく、一般的な LLM ワークロードとは異なる推薦ドメイン特有のデータ特性も備えているためです。
LLM トレーニング向けに最適化された AI インフラ(カーネル、並列処理、低精度トレーニングレシピなど)をそのまま適用することはできず、推薦モデルを効率的に LLM スケールでトレーニングするには、大幅なイノベーションとハードウェア・ソフトウェアのコデザインが不可欠です。
これらの課題に対し、計算効率の向上とスケーリング効率の向上という二つの側面からアプローチしました。
計算効率については、Jagged Flash Attention (JFA)、Generalized Dot-Product Attention (GDPA)、BlockAttention などを備えたカスタム推薦用カーネルライブラリと、MXFP8 アテンションや MLP を含む混合超低精度トレーニングを組み合わせることで実現しました。これらは推薦ワークロードに最適化され、最新世代 GPU のアーキテクチャを最大限に活用するために特別に設計されています。
スケーラビリティの効率化:トポロジー認識型 5D パラレルism と SM(Streaming Multiprocessor)を介さない集合通信
2D FSDP を用いた密なパラメータへの Expert Parallelism と、スパースパラメータ向けに完全にシャードされた 2D モデル並列性を組み合わせ、Meta の多段階ネットワーク階層と共設計することで、通信オーバーヘッドを削減しました。
その結果、GEM のエンドツーエンド(E2E)トレーニング効率を 20〜25% MFU に倍増させ、過去 12 ヶ月間の総トレーニング FLOPs を 4 倍に拡大できました。
GEM のアーキテクチャと独自なトレーニングの課題
GEM は Meta の広告システムを支える中核となるレコメンデーション基盤モデルです。そのアーキテクチャは、トリリオン単位のスパース埋め込みパラメータと数十億の密なパラメータを併せ持つハイブリッド構造となっています。トレーニングには広告コンテンツとユーザーエンゲージメントデータが用いられ、特徴量は「シーケンス特徴(例:ユーザーのアクティビティ履歴)」と「非シーケンス特徴(例:ユーザーの所在地や広告クリエイティブ表現)」の 2 つのカテゴリに分類されます。各グループに対してカスタマイズされたアテンションメカニズムが独立して適用される一方、クロスフィーチャ学習も可能になっています。

このハイブリッドアーキテクチャと推薦ドメイン特有のデータ特性との相互作用こそが、GEM のトレーニングを特に困難なものにしています。
課題 1:GPU ごとの高い利用率の実現
現在のデータセンター向け GPU とそのソフトウェアスタックは、主に大規模言語モデル(LLM)のワークロード向けに最適化されています。一方、推薦システムにおけるワークロードは、固有のデータ特性やユーザーと広告間の複雑な相互作用パターンにより、GEM 級の基盤モデルを訓練する際に高い GPU 計算利用率を達成することが極めて困難という、根本的に異なるプロファイルを持っています。
ジャガード入力(Jagged Inputs): 訓練サンプルでは、ユーザーの活動履歴が大幅に変動するため、シーケンス長が非常にばらつきます。最大長までパディングすると、計算リソースの最大 50% が無駄になります。
多様な相互作用パターンと非対称なシーケンス:自己注意機構(self-attention)は、極めて長いシーケンス(活動履歴)に対して動作しますが、注意ウィンドウは短いです。クロスアテンションは、ユーザーと広告の相互作用を学習しますが、クエリは長くキー・バリューは短い構造になります。また、プーリング多头注意機構(PMA)はユーザーの活動履歴を圧縮するため、クエリが短くキー・バリューが長い形状となります。これらの非対称な形状により、カーネル内部のパイプライン処理が計算ユニットを飽和させる効果が低下します。
メモリーバウンド型演算:MLP の埋め込み次元が小さいことや、モデルの品質と訓練の安定性を保つための各種正規化処理などにより、計算ユニットが十分に活用されません。
数値的感度:広告最適化タスク(CTR/CVR 予測)は数値の変化(例えば精度)に極めて敏感であり、安易な低精度での訓練を行うと品質が劣化するリスクが高まります。
課題 2: 数千台の GPU にわたる効率的なスケーリング
GEM のトレーニングを数千台の GPU で実行し、トリリオン規模のスプースエンベディングパラメータと数十億規模の密なパラメータを扱うには、単に規模を拡大するだけでなく、効率的なスケーリングが不可欠です。GPU を単純に増やせば、それに比例して速度が向上するわけではありません。
分散トレーニングにおける 1 ステップあたりのエンドツーエンド(E2E)レイテンシは、以下の式で決まります。
E2E Latency = Max across GPU Rank (Max(Local Compute Time, Communication Time))
ほぼ線形なスケーリングを実現するには、4 つの条件を満たす必要があります。
- 総計算時間が総通信時間を圧倒的に上回っていること。
- 通信が計算の裏側で隠蔽され、競合が生じていないこと。
- メモリ圧力による再計算が最小限に抑えられていること。
- ランク間で負荷分散が適切に行われていること。
しかし、GEM のワークロードはこれらの条件すべてを脅かします。
トリリオン規模のスプースパラメータと数十億規模の密なパラメータが、複雑な計算パターンを伴う重い通信を引き起こします。
レイヤー間でのアーキテクチャの多様性が重なり合いの窓(オーバーラップウィンドウ)を不均一にし、通信と計算のリソース競合により、通信の隠蔽は容易ではありません。
長いシーケンスと大規模な活性化値がメモリ使用量を限界まで押し上げ、効率性を損なう活性化の再計算を強いられます。
サンプルごとのジャグシーケンス(不規則な長さ)がデータ駆動型の負荷偏りを生み、ランク間でばらつきが生じます。
私たちのアプローチと効率性フレームワーク
上記のような課題に対応するため、広範な共設計の取り組みを少数の技術的なレバーに集約できるフレームワークが必要でした。トレーニングの効率性は、エンドツーエンドの MFU(モデルフロップス利用率)を通じて測定し、これは以下の 2 つの要素に分解されます:
E2E MFU = ローカル MFU(計算効率)× スケーリング比(スケーリング効率)
これらの指標は、関連しつつも異なる 2 つの最適化課題を記述するものです。
ローカル MFU(計算効率)は、単一の GPU における計算ユニットがどれだけ有効に活用されているか、つまりワークロードがハードウェアの性能限界(roofline)にどれほど近づいているかを測る指標です。これはカーネル設計や数値精度、そしてワークロードの計算パターン(データ次元やシーケンス長など)が GPU アーキテクチャ(Tensor コア、メモリ階層、ストリーミングマルチプロセッサのスケジューリングなど)にどれだけ適切にマッピングされているかによって決定されます。
スケーリング比(スケーリング効率)は、数千もの GPU に分散した際に、単一 GPU の性能がどの程度維持されるかを表します。スケーリング比が 1.0 の場合は完全な線形スケーリングを意味しますが、実際には通信オーバーヘッドや負荷の偏り、ストラングラー効果(遅延ノード)、メモリ圧力によるアクティベーション再計算などがこれを低下させます。
ローカル MFU を単独で評価するためには、モデル層を個別に単一 GPU で実行し、アクティベーション再計算や通信の影響を除いた状態で加重平均の MFU を算出します。スケーリング比は、このローカル MFU と E2E MFU の比率として導出されます。
この分解が重要なのは、計算効率とスケーリング効率を関連しつつも独立した最適化課題として扱えるためです。それぞれに専用の技術セットが存在します。
- 計算効率はカーネルレベルおよび数値精度の問題であり、その調整レバーはカーネル設計と超低精度トレーニングです。これらはどちらも GPU ごとの性能限界(roofline)の向上を目指しています。
スケーラビリティの効率化は、分散システムにおける課題です。その鍵となるのは、並列処理戦略、ネットワークトポロジーのマッピング、ネットワークの効率性、メモリ管理、そして負荷分散であり、これらはすべてシングル GPU とマルチ GPU のスループット間のギャップを埋めることを目指しています。
エンドツーエンドの MFU(モデルフロップス利用率)を最大化するには、両方の側面への対応が不可欠です。
推薦システム固有の課題に対処し、GPU の FLOPS 利用率を高めるために、私たちは最新の GPU ハードウェア向けに特別に設計・最適化されたカスタムカーネルライブラリと、超低精度トレーニングレシピを開発しました。
JFA は、不規則な入力によるパディングで発生する最大 50% に及ぶ計算資源の無駄を解消します。
BlockAttention は、モデルの品質や効率性を損なうことなく、長いユーザー履歴における自己アテンションのコストを O(L²) から O(L) に削減します。
GDPA は、FlashAttention の密な長系列という前提が成り立たなくなる GEM の多様な非対称アテンションモジュールを統合し、高速化を実現します。
MXFP8 アテンションと MLP を組み合わせることで、低精度の Tensor Core スループットを実際のエンドツーエンドの速度向上に転換しつつ、精度が敏感な CTR や CVR の目標値を低下させることなく達成します。
推薦システム向けカスタムカーネルライブラリの内部構造
Jagged Sequence Flash Attention
FlashAttention は、LLM で一般的な稠密で固定長のシーケンスを想定して設計されています。一方、推薦モデルにおけるユーザーのシーケンスは本質的に不規則(ジャグド)であり、1 サンプルあたりのトークン数は数百から数万まで幅があります。最大長にパディングすると、計算リソースの最大 50% が無駄になる可能性があります。
標準的な FlashAttention の実装では、効率的なタイル処理と並列化のためにシーケンス長が均一であると仮定しています。不規則な入力に対して単純なアプローチを採用すると、パディングによる計算リソースの浪費や、短いシーケンスが早期に完了した際に SM(ストリーミングマルチプロセッサ)がアイドル化するといった問題が発生します。そこで私たちは JFA を開発しました。これは可変長のジャグドテンソル上で直接動作するカスタム FlashAttention 実装であり、パディングのオーバーヘッドを排除しつつ、推薦システム固有の機能であるカスタムアテンションバイアスや非対称なクエリ/キー・バリュー長、効率的な逆伝播パスなどのサポートも実現しています。
JFA は 4 つの世代を経て進化し、パディングされた SDPA(スケーリングドットプロダクトアテンション)よりも遅い状態から、最新世代 GPU 上で SOTA の CUDA/Cutlass パフォーマンスに追いつくまで格差を縮めました:
ジャグド境界に対する減算方式によるマスク処理:従来の 2D マスク(無効な位置を -inf でマークする手法)は、テンソルコア以外の命令を多く消費し、実行される命令の約 28% を占めていました。これを新しい減算方式に置き換えました。具体的には、クエリとキーをゼロでマスクします(これは Tensor Memory Accelerator (TMA) が無料で処理します)。その上で余分な指数値を減算することで、数値的に等価な結果を得ながら、マスク処理によるオーバーヘッドを排除しました。
バックスワード並列化:FlashAttention の逆伝播では、dQ をシーケンスタイル間で累積する必要があり、通常は高コストなアトミック加算が行われます。複数の方式(アトミクス付きのシーケンシャル並列化、シーケンシャル並列化なし、再計算を伴うシーケンシャル並列化、dQ/dKdV の分割)を検証した結果、バッチサイズとヘッド数が大きい推薦ワークロードでは、dQ 計算を分割する非シーケンシャル並列化方式が、アトミック書き込みと冗長な再計算の両方を排除することで、21〜40% の逆伝播速度向上をもたらすことがわかりました。
ワープ専門化と永続カーネル:Triton Low-Level Extensions (TLX) へのアップグレードにより、明示的なワープ専門化、TMA の利用、そして永続カーネルのスケジューリングが可能になりました。これにより最新ハードウェアの機能を最大限に活用し、30〜100% の TFLOPS 向上を実現しました。
JFA v4 (TLX) は、生産環境でのジャグ配列(スパース性 0.5)下でも一貫した性能向上をもたらす JFA v2 と比較して 40〜140% の TFLOPS 向上を達成し、相対的なローカル MFU で 18.5%、QPS で 12% の改善に貢献しています。
一般化されたドット積アテンション (GDPA)
GEM では、自己アテンション、PMA、クロスアテンションなど、多様なアテンション様の相互作用パターンを採用しています。これらは共通の構造を持ち、2 つの行列乗算の間に要素ごとの活性化関数を挟む形ですが、ソフトマックスの代わりに GELU や SiLU などの活性化関数を使用します。これらのモジュールを最新世代 GPU 上の生産環境向け推薦システム学習ワークロードに最適化された単一の GDPA カーネルとして統合しました。
既存の FlashAttention カーネルは、LLM 向けの稠密で長いシーケンス入力を想定して設計されており、実際の運用トラフィックでは性能が大幅に低下します。現実のワークロードと合成ベンチマークの間には、2.6 倍の順方向処理速度の差があり、最悪の場合には 4 倍もの開きが生じていました。これは、短い非対称な K/V シーケンスや不規則な入力、バッチサイズが大きすぎてパイプライン占有率の前提を崩す要因によるものです。
image
image
カーネルパイプライン、スケジューリング、そして計算式を再設計し、現実のトラフィックとハードウェアの性能限界(roofline)との間のギャップを埋めました。
ソフトマックス活性化に対応しないためのパイプライン再設計:ソフトマックス補正ステージを廃止することで、4 つのワープとそのレジスタが解放されます。短い K/V シーケンスの場合、外側のループによるソフトウェアパイプライン化により、内側ループが 1〜2 回しか実行されない際に失われる性能の約 10% を回復できます。
不規則なテンソル向けのソフトレベルタイルスケジューリング:有効なタイルを CPU で事前に計算し、空のタイルは完全にスキップして、SM(ストリーミングマルチプロセッサ)間でジグザグ割り当てを行います。これにより、ワークロードの不均衡が 6 倍からほぼ平衡状態に改善されました。
ALU のみの活性化近似:GELU が依存する SFU(特殊機能ユニット)を介した tanh 関数を、6 次のテイラー展開(ALU のみ使用)に置き換えます。これは QK ノーマライゼーション(クエリ/キーの正規化)によって強制される入力範囲内であれば十分な精度を保証します。これにより、順方向と逆方向の両パスにおける SFU の競合を解消しました。
これらの最適化により、GDPA カーネルはベースラインに対して順伝播で 2 倍(1,145 BF16 TFLOPs、Tensor Core の利用率約 97%)、逆伝播で 1.6 倍の高速化を達成しました。短時間の K/V 生成設定では、Flash Attention 4 (FA4) と比較して順伝播が最大 3.5 倍に向上します。これをモデル全体に適用することで、エンドツーエンドのトレーニングスループットは 30% 以上改善されました。


BlockAttention
GEM の自己注意機構において、中核的な効率課題は、完全なアテンションの二次コストを支払わずに長いユーザーシーケンスをスケーリングできるかどうかでした。まず、層を完全な自己注意からスライディングウィンドウ注意へ移行し、各トークンが近傍のイベントのみを対象とすることで計算複雑度を O(L²) から O(L * window) に削減しました。これにより、より長いシーケンスの実用化が可能になりました。Sliding Window Attention (SWA) カーネルは JFA においてウィンドウ外のタイルをスキップし、モデル品質指標である正規エントロピー(NE)を中立に保ちながら、長シーケンスの自己注意レイテンシを最大 68% 削減しました。
さらに、ブロックアライメントされたアテンション(block-aligned attention)の導入により構造を強化しました。GEM では安全に固定された 64 トークンのブロックを使用できるため、各 Q ブロックは対応する K/V ブロックのみを参照します。これにより、アテンション処理が独立した 64×64 の問題へと単純化されます。
この手法は、SWA(Sliding Window Attention)にまだ残っている部分ウィンドウのマスク処理やマルチタイル反復の必要性を排除し、専用の TLX カーネルによって FlashAttention が抱えるオーバーヘッド——オンラインソフトマックス補正、logsumexp による HBM トラフィック、および個別の Di プリプロセッシングなど——を完全に解消します。
RoPE(Rotary Positional Embedding)の逆伝播をアテンションのエピローグに統合することで、もう一つのメモリーバウンド型のカーネルも排除され、勾配が FP32 レジスタ内に保持されます。この結果、TLX ブロックアテンションと融合された回転位置埋め込み(fused rotary)を組み合わせた構成は、Triton によるブロックアテンションと比較して自己アテンション層の MFU(Model FLOPs Utilization)を +30.6% 向上させます。これは SWA ベースラインに対して約 +44% の改善に相当します。

混合超低精度トレーニング(Mixed Ultra-Low-Precision Training)
GPU において、精度を下げること自体が Tensor core のスループット向上に直結します。最新世代の GPU では、FP8 は FP16 と比較してピーク FLOPS が 2 倍、FP4 は 4 倍となります。次世代 GPU では、低精度のピーク FLOPS がさらに急速に増加すると予想されています。ハードウェアベンダーが FP16 よりも低精度の FLOPS をより速く拡張している現状を踏まえると、低精度トレーニングの価値はますます高まっています。
しかし、品質の低下を招かずに低精度トレーニングを実現すること、すなわち数値的な安定性と量子化オーバーヘッドの両方を解決することは、業界全体が直面する課題です。私たちは、数値的安定性を強化した MXFP8 アテンションと MLP を開発し、この二つの課題を同時に解決しました。
低精度フラッシュアテンション
最新の GPU が低精度に対応するネイティブ機能を活用し、順伝播と逆伝播の両方で FA4 カーネルにエンドツーエンドの MXFP8 ブロックスケール MMA(行列乗算)を追加拡張しました。主な課題は、低精度のアテンションが単なるデータ型の置き換えではない点にあります。GEMM(一般行列乗算)ごとに K 次元に沿ってスケールファクターを生成し、FA4 がすでに TMEM(テンソルメモリ)の容量を最大限に使用しているにもかかわらず、共有メモリ(SMEM)や TMEM を経由してステージングする必要があります。また、ソフトマックス P や逆伝播 dS などの中間計算もオンラインで行う必要があります。
モジュールレベルで Tensor Core の高速化効果を維持するために、量子化は上位の正規化カーネルと投影カーネルに統合されました。これにより、FP8 アクティベーションと Tensor Core に適したスケールレイアウトを直接生成し、追加の BF16 グローバルメモリ転送を回避しています。GEM の不規則なレコメンデーションワークロードでは、FP8 データはパディングされていない位置に留まり、TMA に対してコンパクトなスケールファクターのみが散乱・パディングされます。これにより、モデル品質の低下を導入することなく、MXFP8 ブロックスケール MMA サポートを実用的なエンドツーエンドのアテンション高速化へと結びつけることに成功しました。

独自の要件を満たすため、カーネルレベルで3つの新技術を導入しました。
TMEM スケールファクターの配置:元の FA4 はアキュムレータ用に 512 カラム分の TMEM をすべて使用しており、ブロックスケールのファクターを格納する余地がありませんでした。これを解決するため、一時的に未使用となっている TMEM 領域とスケールファクターを重ね合わせます(例:S(i) スケールファクターを S(1-i) アキュムレータ領域に配置)。これにより、既存の GEMM レイテンシの背後に隠れる単一の軽量バリアが必要となるだけで済みます。
オンザフライ P から MXFP8 への変換:ソフトマックス出力(P)は、ソフトマックスワープ内でインプレースで MXFP8 に量子化されます。これにより、ソフトマックス正規化のために既に計算された行最大値を再利用し、冗長なリダクションを回避できます。スケールファクターは、高コストな log2/round/clamp 演算ではなく、最適化された PTX ビット操作シーケンスから導出されます。
ブロックごとの量子化:[32, 32] の正方形量子化を採用し、redux.sync.max.abs.f32 ワープワイドリダクションを通じて 32×32 ブロックごとに1つのスケールファクターを計算します。これにより量子化が転置不変となり、各テンソルは一度だけ量子化されます。これは逆伝播パスにおいて、転置された Q,K 値が必要となる場合に特に有用です。
Meta 内部の電力制限付き最新世代 GPU で測定した GEM 代表形状では、MXFP8 を使用することで順伝播カーネルで 1.3 倍以上、逆伝播カーネルで 1.5 倍以上の高速化を達成しました。


量子化のオーバーヘッドをどう処理するか
量子化によるオーバーヘッドは主に、モデルのパラメータ(重み)と中間テンソル(活性化値)の 2 つに起因します。これを単純な方法で処理すると、追加されるキャストやスケーリング、データ転送が低精度 Tensor コアによる計算速度向上を相殺してしまう恐れがあります。
重みにおける量子化:Fully Sharded Data Parallel (FSDP) シャード単位での対応
事前全結合シャード量子化:FSDP の全結合(all-gather)処理の前に、各ランクのローカルなシャードを個別に量子化します。これにより、量子化コストを複数のランクで分散でき、すべてのランクで集約された重みを毎回再量子化する必要がなくなります。
量子化された FSDP 通信:BF16(バイナリ浮動小数点 16 ビット)ではなく低精度のペイロードを通信することで、全結合処理のデータ量を減らし、遅延を短縮します。これにより、量子化によるオーバーヘッドがさらに相殺されます。
活性化値における量子化:カーネル融合
線形モジュール:追加の量子化ステップに伴うカーネル起動や HBM(ハイバンド幅メモリ)へのアクセスを避けるため、活性化値の量子化を直前の正規化処理に統合しました(PreNorm 融合)。
アテンションモジュール:PreNorm 融合に加え、量子化を直前の投影層にも統合しています。これにより、アテンションカーネルは追加の量子化ステップを経ずに、直接低精度の活性化値を消費できます。

数値的安定性の確保
量子化誤差や外れ値、丸めバイアスにより、特に勾配計算において低精度トレーニングが数値的に不安定になるリスクがあります。これらに対処するために以下の手法を採用しました。
外れ値の緩和:
低精度量子化の前段階として、ランダム・ハダマート変換を適用し、外れ値の拡散と分布の平滑化を行いました。
レシピチューニング(微細な制御):
決定論的な丸めバイアスを排除するため、確率的丸めを採用しました。
スキップまたは高精度な重み勾配(WGrad): 活性化値や勾配がより深刻な外れ値を示すことが確認されたため、WGrad の一部をスキップするか、あるいは高精度処理を行うことでモデルの品質を大幅に向上させることができました。
混合精度:
最も効果的な箇所(例えば大規模な行列積演算など)では極低精度を使用し、量子化の影響を受けやすい後段のレイヤーなどでは BF16 にフォールバックしています。
原文を表示
Meta’s Generative Ads Recommendation Model (GEM), the foundation model behind ads recommendations across Instagram and Facebook, now trains at LLM scale on several thousand of the latest-generation GPUs. This post goes into the details on how we achieved: doubling end-to-end (E2E) training efficiency to 20–25% Model FLOPs Utilization (MFU) while scaling training FLOPs 4x in 12 months, by co-designing kernels, precision, parallelism, networking, and memory together.
Training GEM presents unique engineering challenges at the intersection of recommendation systems and LLMs as the model combines a hybrid architecture plus recommendations-domain data properties that are unlike typical LLM workloads.
AI infrastructure optimized for LLM training (kernels, parallelism, low precision recipes etc.) does not directly transfer, requiring significant innovation and hardware/software co-design to reach LLM-scale training for recommendation models efficiently.
We tackled these challenges through complementary compute efficiency and scaling efficiency innovations:
Compute efficiency: Achieved through a customized recommendation kernel library — Jagged Flash Attention (JFA), Generalized Dot-Product Attention (GDPA), BlockAttention, etc. — and mixed ultra-low precision training (including MXFP8 attention and MLP) optimized for recommendation workloads, purpose-built to exploit latest generation GPU’s architecture.
Scaling efficiency: Topology-aware 5D parallelism with Streaming Multiprocessor (SM)-free collectives — 2D FSDP + Expert Parallelism for dense parameters, combined with Fully Sharded 2D Model Parallelism for sparse parameters — co-designed with Meta’s multi-tiered network hierarchy to reduce communication overhead.
The results: we doubled GEM’s E2E training efficiency to 20-25% MFU while scaling total training FLOPs 4x over the past 12 months.
GEM’s Architecture And Its Unique Training Challenges
GEM is the central recommendations foundation model behind Meta’s ads system. It has a hybrid architecture with trillions of sparse embedding parameters and billions of dense parameters. GEM is trained on ad content and user engagement data with two categories of features: sequence features (e.g., user activity history) and non-sequence features (e.g., user location, ad creative representation). Customized attention mechanisms are applied to each group independently, while also enabling cross-feature learning.

The interplay between this hybrid architecture and rec-domain data properties is what makes GEM’s training uniquely challenging.
Challenge 1: Achieving High Per-GPU Utilization
Today’s data center GPUs and their software stacks are mostly optimized for LLM workloads, whereas recommendation workloads have a fundamentally different profile due to unique data characteristics and rich user & ads signal interaction patterns that make it extremely difficult to achieve high GPU compute utilization for training a foundational recommendation model of GEM’s size.
Jagged Inputs: Training samples have highly variable sequence length as user activity history can vary wildly. Padding to max length would waste up to 50% compute.
Diverse interaction patterns and asymmetric sequences: Self-attention operates on extremely long sequences (activity history) but short attention window; cross-attention learns user x ads interaction with long queries but short key/value; pooled multi-head attention (PMA) compress user activity history, resulting in short queries but long key/value. These asymmetric shapes make intra kernel pipelining less effective to saturate compute units.
Memory-bound operations: e.g., small embedding dimension for MLP and various normalizations for model quality and training stability leave compute units underutilized.
Numerical sensitivity: Ads optimization tasks (CTR/CVR prediction) are highly sensitive to numerical change (e.g., precision), making naïve low-precision training prone to quality regression.
Challenge 2: Scaling Efficiently Across Thousands of GPUs
Training GEM across thousands of GPUs with trillions of sparse embedding parameters and billions of dense parameters requires scaling efficiently, not just scaling up. Simply adding more GPUs does not translate to proportional speedup. In distributed training, E2E latency per training step is determined by:
E2E Latency = Max across GPU Rank (Max(Local Compute Time, Communication Time))
Near-linear scaling requires four conditions:
Total compute time >> total communication time.
Communication hidden behind compute without contention.
Minimal recomputation from memory pressure.
Good load balancing across ranks.
GEM’s workload threatens every one of these:
O(Trillion) sparse parameters and O(Billion) dense parameters drive heavy communication with mixed compute patterns.
Architecture diversity across layers makes overlap windows uneven; resource contention between communication and computation makes hiding communication non-trivial.
Long sequences with large activations push memory usage toward its limit, forcing activation recomputation that erodes efficiency.
Jagged sequences across samples create data-driven load skew that varies across ranks.
Our Approach and Efficiency Framework
Given the challenges outlined above, we needed a framework that turned a sprawling co-design effort into a small number of technical levers. We measure training efficiency through E2E MFU, which decomposes into two factors:
E2E MFU = Local MFU (compute efficiency) × Scaling Ratio (scaling efficiency)
These factors describe two related but distinct optimization problems.
Local MFU (compute efficiency) measures how well a single GPU’s compute units are utilized — how close the workload runs to the hardware roofline. It is determined by kernel design, numerical precision, and how well the workload’s compute patterns (data dimensions, sequence lengths) map onto GPU architecture (Tensor cores, memory hierarchy, streaming multiprocessor scheduling).
Scaling Ratio (scaling efficiency) measures how much single-GPU performance is retained when distributing across thousands of GPUs. A scaling ratio of 1.0 means perfect linear scaling; in practice, communication overhead, load imbalance, straggler effects, and activation recomputation from memory pressure all erode it.
To isolate local MFU, we run model layers individually on a single GPU and compute a weighted average MFU without activation recomputation or communication exposure. The scaling ratio is derived as the ratio between local and E2E MFU.
This decomposition matters because it lets us treat compute efficiency and scaling efficiency as related but distinct optimization problems, each with its own dedicated set of techniques:
Compute efficiency is a kernel-level and numerical-precision problem. The levers are kernel design and ultra-low-precision training — both targeting the per-GPU roofline.
Scaling efficiency is a distributed-systems problem. The levers are parallelism strategy, network topology mapping, networking efficiency, memory management, and load balancing — all targeting the gap between single-GPU and multi-GPU throughput.
Both must be addressed to maximize end-to-end MFU.
Optimizing Compute Efficiency With Recommendation Kernels and Ultra-Low-Precision Training
To address the recommendations-system-specific challenges mentioned above and push up GPU FLOPS utilization, we built a custom kernel library and an ultra-low-precision training recipe custom-built and optimized for recommendation workloads on the latest GPU hardware.
JFA — eliminates the up-to-50% compute waste from padding jagged inputs.
BlockAttention — reduces long user-history self-attention cost from O(L²) to O(L) while preserving model quality and efficiency
GDPA — unifies and accelerates GEM’s diverse, asymmetric attention modules where FlashAttention’s dense long-sequence assumptions break down
MXFP8 attention + MLP — turns lower-precision Tensor Core throughput into real end-to-end speedups without regressing precision-sensitive CTR/CVR objectives
Inside the Customized Kernel Library for Recommendation
Jagged Sequence Flash Attention
FlashAttention is designed for dense, fixed-length sequences common in LLMs. In recommendation models, user sequences are inherently jagged — varying from hundreds to tens of thousands of tokens per sample — and padding to max length could waste up to 50% of compute.
Standard FlashAttention implementations assume uniform sequence lengths for efficient tiling and parallelization; with jagged inputs, naive approaches either pad (wasting compute) or leave SMs idle when short sequences finish early. We developed JFA, a custom FlashAttention implementation that operates directly on variable-length jagged tensors, eliminating padding overhead while supporting rec-specific features such as custom attention biases, asymmetric query/key-value lengths, and efficient backward passes.
We evolved JFA through four generations, progressively closing the gap from being slower than padded SDPA (scaled dot-product attention) to matching SOTA CUDA/Cutlass performance on latest-generation GPUs:
Jagged masking via subtraction scheme: Traditional 2D masking for jagged boundaries (marking invalid positions with -inf) consumes significant non-tensor-core instructions (~28% of executed instructions). We replaced this with a novel subtraction scheme — masking Query/Key with zeros (which the Tensor Memory Accelerator (TMA) does for free) and subtracting the extra exponents — producing numerically equivalent results without the masking overhead.
Backward parallelization: FlashAttention’s backward pass requires accumulating dQ across sequence tiles, typically via costly atomic adds. We explored multiple schemes (seq-parallel with atomics, no seq-parallel, seq-parallel with recompute, split dQ/dKdV) and found that for rec workloads with high batch x heads, a non-seq-parallel scheme with split dQ computation delivers 21-40% backward speedup by eliminating both atomic writes and redundant recomputation.
Warp specialization and persistent kernels: Upgrading to Triton Low-Level Extensions (TLX) enabled explicit warp specialization, along with use of TMA, and persistent kernel scheduling — unlocking 30-100% TFLOPS improvement by leveraging the latest hardware feature.
JFA v4 (TLX) achieves 40-140% TFLOPS improvement over JFA v2, which delivers consistent gains under production jagged distributions (sparsity 0.5), contributing to 18.5% relative local MFU gain and 12% QPS gain.
Generalized Dot-Product Attention (GDPA)
GEM uses diverse attention-like interaction patterns — self-attention, PMA, and cross-attention — that share a common structure: two matrix multiplications with an element-wise activation in between, but replace softmax with activations like GELU or SiLU. We unify these modules under a single GDPA kernel optimized for production RecSys training workloads on latest generation GPUs.
Existing FlashAttention kernels are designed for LLM-style dense, long-sequence inputs and perform poorly under real production traffic. We observed a 2.6x forward performance gap and up to 4x worst-case gap between real-world workloads and synthetic benchmarks driven by short/asymmetric K/V sequences, jagged inputs, and large batch sizes that break pipeline occupancy assumptions.
image
image
We redesigned the kernel pipeline, scheduling, and math to close the performance gap between real-world traffic and hardware roofline.
Pipeline redesign for non-softmax activations: Eliminating the softmax correction stage frees four warps and their registers. For short K/V sequences, outer-loop software pipelining recovers ~10% performance lost by inner-loop pipelining when the inner loop runs only 1–2 iterations.
Software-level tile scheduling for jagged tensors: precompute valid tiles on CPU, skip empty tiles entirely, and apply zigzag assignment across SMs — reducing workload skew from 6x to near-balanced.
ALU-only activation approximation: Replace GELU’s SFU-bound tanh with a 6th-order Taylor expansion (ALU-only), accurate within the bounded input range enforced by QK-norm (query/key normalization). Eliminates SFU contention in both forward and backward passes.
With these optimizations, the optimized GDPA kernel achieves 2x forward speedup (1,145 BF16 TFLOPs, ~97% Tensor Core utilization) and 1.6x backward speedup over baseline. Under short K/V production settings, it achieves up to 3.5x forward speedup over Flash Attention 4 (FA4). Applied across the full model, these kernels deliver over 30% end-to-end training throughput improvement.


BlockAttention
For GEM self-attention, the core efficiency challenge was scaling long user sequences without paying the quadratic cost of full attention. We first moved the layer from full self-attention to sliding-window attention, limiting each token to nearby events and reducing complexity from O(L2) to O(L * window). This made longer sequences practical. The Sliding Window Attention (SWA) kernel skipped off-window tiles in JFA and reduced long-sequence self-attention latency by up to 68% with neutral NE (normalized entropy, a model-quality metric).
We then pushed the structure further with block-aligned attention. Since GEM could safely use fixed 64-token blocks, each Q block only attends to its corresponding K/V block, turning attention into independent 64×64 problems. This removes the partial-window masking and multi-tile iteration still present in SWA, and lets a dedicated TLX kernel eliminate FlashAttention overheads such as online softmax correction, logsumexp HBM traffic, and separate Di preprocessing.
Fusing RoPE backward into the attention epilogue removes another memory-bound kernel and keeps gradients in FP32 registers. Together, TLX block attention + fused rotary improves self-attention layer MFU by +30.6% over Triton block attention, or roughly +44% over the SWA baseline.

Mixed Ultra-Low-Precision Training
On a GPU, lower precision directly translates to higher Tensor core throughput. For the latest generation GPU, FP8 delivers 2x peak FLOPS over FP16, and FP4 delivers 4x. We expect the peak FLOPS of low precision to increase faster in next-generation GPUs. This makes low-precision training increasingly attractive as hardware vendors scale low-precision FLOPS faster than FP16.
However, making low-precision training work without quality regression — addressing both numerical stability and quantization overhead — remains an industry-wide challenge. We developed MXFP8 Attention and MLP with numerical stability enhancement, which addressed both training stability and quantization overhead.
Low Precision Flash Attention
We extended the FA4 kernel with end-to-end MXFP8 blockscaled MMA for both forward and backward passes leveraging latest generation GPUs’ native support for low precision. The main challenge is that low precision attention is not just a datatype swap. Scale factors must be generated along each GEMM’s (General Matrix Multiplications) K dimension, staged through shared memory (SMEM) / tensor memory (TMEM) despite FA4’s already full TMEM footprint, and computed online for intermediates such as softmax P and backward dS.
To make the Tensor core speedup survive at module level, quantization was fused into upstream normalization and projection kernels, emitting FP8 activations and tensor-core-friendly scale layouts directly while avoiding extra BF16 global-memory traffic. For GEM’s jagged recommendation workloads, FP8 data stays at unpadded positions and only compact scale factors are scattered/padded for TMA. This turns MXFP8 block-scaled MMA support into practical E2E attention speedups without introducing model quality regressions.

To meet our unique requirements we had to develop three new innovations at the kernel level:
TMEM scale factor placement: The original FA4 fully utilized 512-column TMEM for accumulators, leaving no room for block-scale factors. We solve this by overlapping scale factors with temporarily-unused TMEM regions (e.g., placing S(i) scale factors in the S(1-i) accumulator region), requiring only one additional lightweight barrier that is hidden behind existing GEMM latency.
Online P-to-MXFP8 conversion: Softmax output (P) is quantized to MXFP8 in-place within the softmax warp, reusing the row-max already computed for softmax normalization to avoid redundant reductions. Scale factors are derived via optimized PTX bit-manipulation sequences instead of expensive log2/round/clamp operations.
Block-wise Quantization: We use [32, 32] square quantization computing one scale factor per 32×32 block via redux.sync.max.abs.f32 warp-wide reduction — making quantization transpose-invariant so each tensor is quantized only once. This is useful for the backward pass, where transposed Q,K values are needed.
On GEM representative shapes, measured on Meta internal power capped latest generation GPU, we achieved >1.3x speedup for the forward kernel with MXFP8. For the backward kernel, we achieved >1.5x speedup with MXFP8.
image
image
Handling Quantization Overhead
Quantization overhead mainly comes from two sources, model parameters (weights) and intermediate tensors (activations). If handled naively, the extra casting, scaling, and data movement can offset the compute speedup from low-precision Tensor cores.
Weight – quantization on Fully Sharded Data Parallel (FSDP) shard
Pre-all-gather shard quantization: quantize each rank’s local shard before FSDP all-gather to amortize the quantization cost across ranks, this avoids re-quantizing the fully gathered weight on every rank.
Quantized FSDP communication: communicate low-precision payloads (vs. BF16) to reduce all-gather volume and cut all-gather latency which further neutralizes the quantization overhead.
Activation – kernel fusion
Linear modules: Instead of doing a separate quantization step with extra kernel launch + HBM traffic, we fused activation quantization into the preceding normalization (PreNorm fusion) to avoid the overhead.
Attention modules: In addition to PreNorm fusion, we also fused quantization into the preceding projection so the attention kernel consumes low-precision activations directly with no extra quantization step.

Addressing Numerical Stability
Quantization errors, outliers, and rounding bias can make low-precision training numerically fragile, especially for gradient computation. We addressed these challenges with:
Outlier mitigation:
We applied Random Hadamard Transforms spread outliers and smooth distributions prior to low precision quantization.
Recipe tuning (fine-grained controls):
We used stochastic rounding to eliminate deterministic rounding bias.
Skipping / higher-precision weight-gradient (WGrad): We observed activations and gradients can exhibit more severe outlier behavior; selectively skipping WGrad or using higher precision can materially improve model quality.
Mixed precision:
We use ultra low precision where it will have the most benefit (e.g., large GEMMs) and fall back to BF16 (e.g., later layers in the model are more sensitive to quantizati
AI算出
技術分析ainew評価高い
Meta が GEM モデルの学習効率を倍増させた具体的な技術的アプローチ(カーネル設計、混合精度トレーニング、並列処理戦略)を詳細に解説しており、AI/ML エンジニアリングの実践的な価値が高い記事です。ただし、日本企業や日本市場特有の情報ではなく、一般的な技術知見であるため日本の関連性は低めです。
6つの評価軸を見る
- AI関連度
- 100
- 情報源の信頼性
- 100
- 新規性
- 75
- 調べる価値
- 75
- 重複の少なさ
- 100
- 日本での有用性
- 25
News to Guide
ニュースの次に確認する
発表内容を、現在の料金や仕様と照らし合わせられる関連ガイドです。
今日のまとめ
AIデイリーブリーフで今日の重要ニュースをまとめ読み