騰訊混元が vLLM に HPC オプス対応
騰訊の AI モデル「混元」が開発した高性能アテンションおよび MoE バックエンド技術が vLLM に統合され、大規模モデルの推論効率が向上する。
キーポイント
vLLM と騰訊混元の技術連携
騰訊が開発した高性能アテンションおよび MoE(Mixture of Experts)バックエンドが、オープンソース推論フレームワーク vLLM に正式に統合された。
大規模モデルの推論効率向上
この統合により、特に大規模言語モデルや MoE 構造を持つモデルの推論速度とリソース効率が大幅に改善される見込みである。
高性能アテンションの実装
騰訊が最適化したアテンションアルゴリズムが vLLM に組み込まれることで、計算コストの削減とスループットの向上が実現する。
重要な引用
High-Performance Attention and MoE Backends from Tencent Hunyuan
vLLM × HPC-Ops: High-Performance Attention and MoE Backends from Tencent Hunyuan
影響分析・編集コメントを表示
影響分析
この統合は、大手テック企業が持つ高度な最適化技術をオープンソースコミュニティに還元する好例であり、業界全体における大規模モデルの実用化スピードを加速させる。特に MoE アーキテクチャの普及が進む中で、推論コストと速度のバランスを改善する重要な技術的基盤を提供する。
編集コメント
騰訊のような大手企業が持つ独自最適化技術を vLLM に提供することは、オープンソース推論フレームワークの進化にとって極めて重要です。これにより、大規模モデルをより効率的に運用する環境が整い、AI 開発現場での実用性がさらに高まると期待されます。
TL;DR
騰訊混元 AI インフラチームが開発した生産環境向けオペレータライブラリ「HPC-Ops」の、アテンションと MoE(Mixture of Experts)カーネルが、vLLM のメインブランチに正式なバックエンドとして採用されました。
両方とも NVIDIA の Hopper アーキテクチャ向けに最適化されており、特に H20 での性能が際立っています。
- アテンション: ステップごとの負荷分散型デコードスケジューラーに加え、RoPE(Rotary Positional Embedding)と QK-Norm、KV-write を融合したプロローグを実装。混合長のデコードでは、静的な split-KV スケジュールより最大 2.95 倍、FlashInfer や FlashAttention と比較しても平均で 2.25 倍の性能を発揮します。
- MoE: 完全融合型の低レイテンシ FP8 MoE パイプライン。Triton や CUTLASS を用いた実装と比較して、TP8/EP1 で平均 1.59 倍、TP1/EP8 で 1.21 倍の速度向上を達成し、出力品質は同等に保たれています。
Hy3 クラスター上で 8 台の H20 を使用したエンドツーエンドテストでは、デフォルトバックエンドと比較して TTFT(Time To First Token)が約 24%、TPOT(Time Per Output Token)が約 17% 短縮されました。
両方のバックエンドは vLLM の標準インターフェースを通じて既存の環境にプラグイン可能で、ソースコードの変更や長期維持が必要なフォークも不要です。
本記事では、HPC-Ops の概要と、これら 2 つのバックエンドがどのように設計・統合されたか、そして H20 上での実際の性能について解説します。
LLM の本番環境での推論サービスは、かつてカーネル最適化の対象だった均一で単一のバッチ処理とはもはや似ていません。実際のトラフィックは動的で長さも様々であり、モデルは MoE(混合専門家)型へと進化しコンテキスト長も伸びています。さらにエージェントワークロードがこれらの負荷をさらに高めています。この規模になると、レイテンシの多くは純粋な行列乗算のスループットだけでなく、カーネルが GPU 上でどのように作業をスケジューリングし、ステージ間でデータを移動させるかによって決定されます。
アテンションデコードでは、固定された split-KV スケジュールにより、混合バッチ内の最長リクエストで処理が停止し、短いリクエスト側では計算リソースが遊んでしまいます。MoE においては、各専門家ごとの GEMM(行列乗算)は小規模であり、従来のパイプライン方式ではトークンを専門別バッファに集約する必要があり、各ステージで起動オーバーヘッドが発生します。さらに中間データを HBM 間で移動させるコストもかかります。
vLLM はすでにコミュニティに対して高速かつ柔軟な推論エンジンを提供していますが、残されたレイテンシとスループットの問題は、アテンションカーネルと MoE カーネルがいかにしてこうした複雑で現実的なトラフィックを吸収できるかにかかっています。これが HPC-Ops が目指すところです。これは Tencent の大規模本番環境で堅牢化された演算ライブラリであり、Hy3 を運用する際と同じカーネルが、vLLM においてファーストクラスの「アテンションバックエンド」と「MoE バックエンド」として取り込まれました。
Hy3 シリーズモデルについて一言
Hy3 は、エージェント実行、コーディング、長期推論を目的とした Tencent Hunyuan の Mixture-of-Experts モデルです。295B パラメータのうち 21B をアクティブに使用することで、同規模のモデルの中で最強クラスのエージェント能力を実現しています。これはオープンソースのフラッグシップモデルよりも 2〜3 倍大きいモデルと互角の性能を持ちながら、多対話利用におけるハルシネーション(幻覚)を大幅に削減し、より信頼性の高い運用を可能にします。
内部構造では、192 のエキスパートを持つ Top-8 ルーティング、GQA アテンション(64 ヘッド、KV ヘッド 8、ヘッド次元 128)、256K のコンテキストウィンドウ、そして推測デコーディング用の 3.8B MTP レイヤーを採用しています。モデルは BF16 および FP8(Hy3-FP8)形式で提供されます。
本記事ではモデル自体について語るのではなく、その背後を支えるカーネル(計算関数)に焦点を当てます。これらについては次章で詳しく解説します。
HPC-Ops: vLLM に統合されたプロダクション向けオペレーターライブラリ
HPC-Ops は、Tencent Hunyuan AI インフラチームによって構築・維持されている、LLM 推論用のオープンソースオペレーターライブラリです。実運用におけるレイテンシとスループットを決定づけるホットパスに注力しており、アテンション、MoE、GEMM、サンプリング、正規化、そして通信と計算の融合処理などを対象としています。ネイティブで BF16 と FP8 をサポートし、推論フレームワークへ容易に組み込めるクリーンな Python API を提供しています。
これらのカーネルは、Tencent 内での Hunyuan の大規模プロダクション運用で実証済みです。今回のリリースでは、その中から 2 つが vLLM のファーストクラスバックエンドとして取り込まれました。
vLLM バックエンド | 最適化対象 | 精度 | マージ日
---|---|---|---
Attention バックエンドでは、ロードバランシングされたデコードと融合された RoPE/QK-Norm プロローグが採用されています。計算精度は BF16 または FP8 です(PR #46020)。また、MoE バックエンドでは、低レイテンシを実現する完全に融合された MoE パイプラインが実装されており、これも FP8 をサポートしています(PR #45924)。
本記事の残りの部分では、これら 2 つのバックエンドに焦点を当てます。
Attention バックエンド:動的ロードバランシングスケジューリング
課題:バッチ内での多様な長さのデコード
デコード処理において、トークン生成の各ステップでは、リクエストごとの KV キャッシュ全体に対してアテンション計算が実行されます。すでに 16K トークンのコンテキストを蓄積したリクエストは、1K トークンから始まったばかりのリクエストに比べて、およそ 16 倍の計算コストがかかります。
本番環境での推論サービスでは、出力長は予測不可能であり、連続バッチ処理によって、同じカーネル起動内で生成過程が非常に異なる段階にあるリクエストが混在します。その結果、単一のバッチ内には極めて短いシーケンスと非常に長いシーケンスが混在するのが常態となります。
既存のデコードカーネルは、KV ヘッド、リクエスト、分割された KV チャンクのインデックスをキーとして、固定された起動グリッドを通じてワークを CTAs に割り当てています。この分割度合いはすべてのリクエストで均一である必要があり、結果として二つの悪い選択肢のどちらかを選ばざるを得なくなります。
分割数を固定すれば、最長のシーケンスが全体の速度を決定します。短いリクエストを担当する CTAs はわずかな時間で完了し、その後アイドル状態になります。一方、チャンクサイズを固定すると、分割数はどのリクエストが必要とする最大値に設定されなければなりません。その結果、短いリクエストには空のチャンクでパディングが行われ、起動して作業が見つからないまま終了します。これにより、スケジューリングのスロットが無駄になります。
どちらの場合も、カーネル全体の処理時間は最も重い CTA によって決定され、他の CTAs は待機状態となり、SM のサイクルが有効活用されません。
解決策:ステップごとの負荷分散型デコードスケジューラー
HPC-Ops アテンションバックエンドは、起動時の分割ポリシーや固定グリッドに依存するのではなく、バッチ内の実際の長さ分布に適応するフラットで永続的な設計へと置き換えました。この仕組みは 3 つの段階を経て構築されています。
- アサイン。軽量なアサインカーネルは、すべての KV シーケンスを 64 トークンの均一なタイルに分割します。全ヘッドと全リクエストにわたるタイル総数を利用可能な CTAs(計算トランスファーユニット)の数で割ることで、CTA あたりの予算(バケットサイズ)を算出します。タイルは「ヘッド優先・バッチ従属」の順序で走査され、CTA のバケットへ順次充填されます。ある CTA のバケットがいっぱいになると、残りのタイルは次の CTA に溢れ出します。この仕組みにより、長いシーケンスはその長さに比例して複数の CTA に跨って処理され、短いシーケンスは数個のタイルのみで済むため、特定の CTA を独占することはありません。また、CTA あたりの最小作業負荷を設けることで、総作業量が小さい場合の過度な分割を防ぎ、チャンク数を管理可能な範囲に保ちつつ、後段の結合コストがスケジューリングによる恩恵を上回らないようにしています。生成されたタスクマップはデコードステップごとに一度計算され、そのステップ内のすべてのトランスフォーマー層で再利用されるため、オーバーヘッドは実質ゼロまで圧縮されます。
計算と結合。永続的なカーネルグリッドが実行され、各 CTA は割り当てられたタスクビンに対してループ処理を行います。CTA はタスクリプターを取得し、そのチャンクに対するアテンションを計算した上で、部分的な出力と log-sum-exp を分割バッファに書き込みます。その後、終端記号(terminator)を検出するまで次のタスクへ進みます。
グリッドが永続的であるため、タスク間の再起動オーバーヘッドやウェーブ間のアイドルギャップは発生しません。すべての SM がカーネル実行期間中常に飽和状態を維持します。最後に軽量な結合カーネルが各 (head, request) ペアのカウント数を読み取り、チャンクごとの部分結果を集約して最終的な BF16 出力を生成します。
その結果、シーケンス長の分布がいかに偏っていても、すべての CTA がほぼ等しい負荷を負い、ほぼ同時に完了します。静的スケジュールに固有なロングテールによるストールは解消され、以前はアイドル待機のために浪費されていた GPU サイクルが有効な計算に変換されます。
image動的パーティショニング:均一タイリングとバランスの取れたバケット化
融合アテンションのプロローグ
アテンション処理を実行する前に、各レイヤーでは通常、QK-Norm、RoPE、KVキャッシュへの書き込み、そして FP8 使用時にはクエリの量子化といった処理が、それぞれ独立したメモリーバウンド型のステップとして実行されます。HPC-Ops はこれらを単一の演算(HpcRopeNorm)に融合させます。融合された QKV プロジェクションから始まり、モデルの要件に従って QK-Norm と RoPE を適用し(Hy3 の場合は RoPE より先に正規化)、K と V をそのままページキャッシュへ書き込みます。FP8 使用時には、トークンごと・ヘッドごとの FP8 クエリとそのスケール値を出力するため、アテンションカーネルが再量子化する必要がありません。この単一のカーネルによって、プリフェッチ時とデコード時の両方で、各レイヤーのアテンション前処理における別々の起動や HBM への往復通信が置き換えられます。
vLLM との統合
HPC-Ops のアテンション API は、FlashAttention や FlashInfer といった既存のバックエンドと共に、ネイティブなアテンションバックエンドとして vLLM に組み込まれています。具体的には、HpcAttentionBackend が vLLM の AttentionBackend ベースクラスを継承し、標準的なバックエンド登録メカニズムを通じて登録されます。
MoE バックエンド:融合され低遅延の FP8 MoE パイプライン
課題:小規模なエキスパート GEMM とその周辺オーバーヘッド
MoE(Mixture of Experts)推論には、大きく分けて 2 つの異なる運用モードが存在します。スループットが高くバッチサイズが大きい場合、エキスパートごとの GEMM(行列積計算)は規模が大きく計算リソースがボトルネックになります。この状況では既存の実装でも十分に機能します。
一方、低レイテンシなデコード処理はその逆です。各エキスパートに割り当てられるトークンはほんの数個だけとなるため、GEMM は小規模になり、メモリ帯域がボトルネックとなります。大規模行列積計算向けに最適化されたカーネルでは、こうした形状のデータでは GPU の性能を十分に引き出せません。さらに、各エキスパートが生み出すタイル数がステップごとに変動し、その値も移り変わるため、これらの小さなタイルを GPU 上で均等に分散させることが困難です。
GEMM 周辺の処理もこの問題を複雑にします。従来の MoE パスは、トークンのルーティング、エキスパートごとのバッファへの集約、Gate-Up GEMM、活性化関数と量子化、Down GEMM、そしてトップ k の重み付けによるリダクション(トークン位置への戻し)という、複数の別々のカーネルが連鎖した構成です。このプロセスでは、行列積が始まる前に HBM 上に集約されたトークンのテンソルが一時的に作成され、各工程で独自のカーネル起動コストと中間データの HBM 往復が発生します。GEMM がすでに小規模であるデコード処理においては、これらのオーバーヘッドが GEMM 自体の処理負担と重なり合い、全体のパフォーマンスをさらに低下させます。
解決策:融合された FP8 MoE パイプライン
HPC-Ops の MoE バックエンドは、MoE パス全体のアーキテクチャを見直しました。トークンのルーティングとインデックス前処理、Gate-Up GEMM、活性化関数と量子化、Down GEMM、そしてトップ k 重み付けリダクションを、単一のコンパクトな実行パスに融合させることで、多段階設計に伴う冗長なオーバーヘッドを排除しました。
ルーティングとインデックス構築では、共有メモリを用いたカウント処理により、各トークンを専門家に割り当てて連続する出力範囲を確保します。これにより、大規模なトークンルーティングに伴うグローバルアトミック操作の負荷が大幅に軽減され、GEMM が直接参照できるルーティングインデックスとタイルごとのタスクリストが構築されます。
Gate-Up GEMM では、ルーティングインデックスを通じて元のトークンを直接読み込み、独立した gather ステップをスキップします。その後の活性化処理と FP8 量子化は別々の融合カーネルとして実行され、その出力は Down GEMM がそのまま利用します。
ワープの専門化に頼らず、まずOccupancy(リソース利用率)を最大化するアプローチを採用しています。データ転送と計算処理の両方を単一のワープグループが担当し、メモリ遅延隠蔽の仕組みを CTA 内部のソフトウェアパイプラインから、CTA 間でのハードウェアスケジューリングへとシフトさせます。これにより、SM(ストリーミングマルチプロセッサ)あたりの同時実行可能な CTA 数が増加します。すべての SM を常に満杯に保つために起動される永続グリッドがタスクリストを消費し、専門家ごとの小さく不均一なタイル群を CTAs に均等に分散させます。
PDL(Programmatic Dependent Launch)によるステージ連鎖では、各カーネルの起動を直前のカーネルの末尾と重なるように設定することで、ステージ間のアイドル時間を完全に排除します。これは最終的な top-k 加重集約に至るまで適用され、必要に応じて共有専門家の出力もこのプロセスに組み込むことができます。
これらの仕組みにより、中間データやカーネル起動がクリティカルパスから外れ、専門家ごとの計算は FP8 で実行されます。テンソル全体とブロック単位のスケーリングの両方を採用しており、ベースラインモデルと同等の出力品質を維持しています。
vLLM との統合
HPC-Ops の融合 MoE API は、DeepGEMM や Triton といった既存のバックエンドとともに、vLLM のネイティブな MoE バックエンドとして統合されています。具体的には、HPCExperts は vLLM の FusedMoEExpertsModular ベースクラスを継承し、標準的なバックエンド登録メカニズムを通じて登録されます。
vLLM での HPC-Ops バックエンドの利用方法
このガイドでは、vLLM で HPC-Ops のバックエンド(Attention および MoE)を有効にする方法を解説します。
インストール
始める前に、ソースコードから HPC-Ops をインストールしてください。
git clone https://github.com/Tencent/hpc-ops.git
cd hpc-ops
Wheel パッケージのビルドとインストール
make wheel
python3 -m pip install dist/*.whl
クイックスタート
HPC-Ops の Attention バックエンドは、現在 Hy3 シリーズ モデルのみをサポートしています。
標準的な Hy3 モデルで HPC-Ops Attention バックエンドを備えた vLLM サーバーを起動するには、以下を実行します。
vllm serve tencent/Hy3 \
--tensor-parallel-size 8 \
--attention-backend HPC_ATTN
Hy3-FP8 モデルの場合、いくつかの追加オプションが必要です。
vllm serve tencent/Hy3-FP8 \
--tensor-parallel-size 8 \
--attention-backend HPC_ATTN \
--kv-cache-dtype fp8_e4m3 \
--block-size 64
ヒント: カスタムモデルで HPC-Ops Attention バックエンドを有効にするには、モデルの forward メソッド内で rope_norm を HpcRopeNorm に置き換えてください。参考として PR #46020 をご覧ください。
HPC-Ops の MoE バックエンドは、FP8 モデルのみをサポートしています。
HPC-Ops MoE バックエンドを備えた vLLM サーバーを起動するには、以下を実行します。
vllm serve tencent/Hy3-FP8 \
--tensor-parallel-size 8 \
--moe-backend hpc
ハードウェア対応状況
HPC-Ops ベースンドは現在、NVIDIA のホッパーアーキテクチャ搭載 GPU のみでサポートされており、特に H20 で最高のパフォーマンスを発揮します。
H20 における性能
Fused MoE: HPC-Ops vs Triton / CUTLASS
Hy3 モデル構成において、HPC-Ops ベースンドを Triton および CUTLASS の各ベースンドと比較してベンチマークを行いました。TP8/EP1 と TP1/EP8 の両設定で評価した結果、バッチサイズ全体での平均では、HPC-Ops は TP8/EP1 で最良のベースンドよりも 1.59 倍、TP1/EP8 では 1.21 倍高速でした。特に低遅延デコードを支配する小~中規模のバッチサイズにおいて、最も大きな性能向上が確認されています。
Table 1: TP8 / EP1(エキスパート重みを 8 ランクにシャード)におけるバッチサイズ別の FusedMoE レイテンシ (µs)
Batch | HPC-Ops (µs) | Triton (µs) | CUTLASS (µs)
---|---|---|---
4 | 42.0 | 56.4 | 74.5
16 | 85.7 | 124.2 | 209.2
32 | 124.0 | 184.3 | 275.6
64 | 147.2 | 374.9 | 330.3
128 | 161.5 | 302.9 | 345.3
256 | 170.1 | 310.9 | 351.6
512 | 194.5 | 331.6 | 369.2
1024 | 281.4 | 652.7 | 438.3
2048 | 491.8 | 731.5 | 794.4
4096 | 872.0 | 1366.0 | 1230.7
8192 | 1695.0 | 2216.8 | 2362.9
16384 | 3241.9 | 4329.1 | 4364.4
Table 2: TP1 / EP8(エキスパートを 8 ランクにシャード)におけるバッチサイズ別の FusedMoE レイテンシ (µs)
Batch | HPC-Ops (µs) | Triton (µs) | CUTLASS (µs)
---|---|---|---
4 | 118.6 | 147.4 | 140.4
8 | 136.7 | 192.8 | 170.7
16 | 149.8 | 198.4 | 263.5
32 | 153.6 | 214.6 | 264.4
64 | 166.5 | 358.1 | 266.8
128 | 213.5 | 251.7 | 272.6
256 | 386.2 | 454.9 | 493.5
512 | 705.5 | 691.7 | 741.7
1024 | 1342.6 | 1369.1 | 1359.1
2048 | 2513.9 | 2668.7 | 2530.4
imageHPC-Ops FusedMoE on H20 — Hy3
異なる長さのバッチでのデコード:動的スケジューリングと静的スケジューリングの比較
アテンションバックエンドにおける最大の成果は、異なる長さのリクエストが混在するバッチ内でのデコード性能です。スケジューラーの影響を単独で評価するため、FP8 デコードにおいて KV 長の分布を一様から極端に偏ったものまでスウィープし、HPC-Ops の動的スケジューリングを、静的な分割-KV スケジュール、FlashInfer、そして FlashAttention と比較しました。
この結果、バッチの偏りが大きくなるほど HPC-Ops の優位性も顕著になります。小規模で一様なバッチでは性能差はほぼ同等ですが、1 件の KV 長 128K と 31 件の KV 長 4K が混在するケースでは、最大で 2.95 倍の速度向上を達成しました。これらのシナリオ全体を通じて、動的スケジューリングは FlashInfer と FlashAttention の最良の結果と比較して平均 2.25 倍高速でした。
Table 3: KV 長分布ごとのデコードレイテンシ(ms)
| Decode scenario | HPC-Ops dynamic (ms) | HPC-Ops static (ms) | FlashInfer (ms) | FlashAttention (ms) | Dynamic vs static |
|---|---|---|---|---|---|
| 64×0.5K | 0.013 | 0.013 | 0.050 | 0.025 | 1.00× |
| 64×4K | 0.033 | 0.043 | 0.221 | 0.095 | 1.32× |
| 32×0.125K + 32×4K | 0.020 | 0.033 | 0.119 | 0.053 | 1.59× |
| 2×32K + 30×4K | 0.032 | 0.056 | 0.169 | 0.094 | 1.76× |
| 1×64K + 15×4K | 0.042 | 0.097 | 0.118 | 0.065 | 2.32× |
| 1×128K + 31×4K | 0.063 | 0.186 | 0.220 | 0.097 | 2.95× |
imageDecode Attention on H20 — Hy3: dynamic vs static scheduling
アテンション:HPC-Ops と FlashAttention / Triton / FlashInfer の比較
さらに、vLLM のアテンションベンチマークを用いて、HPC-Ops アテンションバックエンドを FlashAttention、Triton、FlashInfer と比較しました。プリフィル、エクステンド、デコードの各形状において、HPC-Ops はほぼすべてのケースでこれら 3 つの中で最速と同等か、それ以上の速度を示しています。
表 4:アテンションレイテンシ(ms)の比較(FlashAttention、Triton、FlashInfer 対 HPC-Ops)
| Batch Spec | Type | Batch Size | HPC-Ops (ms) | FlashAttention (ms) | Triton (ms) | FlashInfer (ms) |
|---|---|---|---|---|---|---|
| q512 | prefill | 10 | 0.047 | 0.069 | 0.123 | 0.070 |
| q1ks2k | extend | 10 | 0.406 | 0.431 | 1.132 | 0.431 |
| q2k | prefill | 10 | 0.530 | 0.574 | 1.525 | 0.609 |
| q4k | prefill | 12 | 2.002 | 2.093 | 5.816 | 2.144 |
| q8k | prefill | 17 | 7.883 | 7.957 | 22.702 | 8.084 |
| 2q1ks4k | extend | 21 | 1.835 | 1.830 | 5.046 | 1.829 |
| 8q1s1k | decode | 80 | 0.019 | 0.031 | 0.035 | 0.021 |
| 16q1s2k | decode | 160 | 0.054 | 0.098 | 0.106 | 0.052 |
| 32q1s1k | decode | 320 | 0.057 | 0.102 | 0.080 | 0.058 |
| 64q1s4k | decode | 640 | 0.299 | 0.620 | 0.510 | 0.340 |
エンドツーエンド:8× H20 環境での Hy3 モデル評価
最後に、HPC-Ops の MoE アテンションバックエンドとアテンションバックエンドを搭載した Hy3 モデルの、エンドツーエンド(E2E)性能を NVIDIA H20 GPU 8 枚環境で vLLM デフォルトバックエンドと比較しました。すべてのテストケースにおいて、HPC-Ops バックエンドは vLLM デフォルトバックエンドを一貫して上回り、TTFT(Time to First Token:最初のトークンまでの時間)と TPOT(Token Per Output Token:出力トークンあたりの生成時間)の両方で大幅な短縮を実現しました。平均すると TTFT は約 24%、TPOT は約 17% 削減され、最大のバッチサイズでは TPOT の改善率が約 30% に達します。
表 5:異なるバッチサイズにおける TPOT(出力長 = 4K)
| バッチサイズ | ベースライン TPOT (ms) | HPC TPOT (ms) | 改善率 |
|---|---|---|---|
| 10 | 8.00 | 7.76 | +3.0% |
| 40 | 11.14 | 10.67 | +4.2% |
| 80 | 13.49 | 11.31 | +16.2% |
| 160 | 17.98 | 13.56 | +24.6% |
| 320 | 24.13 | 18.32 | +24.1% |
| 640 | 31.10 | 21.90 | +29.6% |
表 6:バッチサイズごとの TTFT(入力長 8k、チャンクプリフィル無効化、プレフィックスキャッシュ無効化)
バッチサイズ | ベースライン TTFT (ms) | HPC TTFT (ms) | 改善率
---|---|---|---
1 | 565.69 | 431.00 | +23.8%
4 | 1920.15 | 1471.43 | +23.4%
8 | 3948.22 | 3035.44 | +23.1%
16 | 7807.18 | 5885.63 | +24.6%
表 7:入力長ごとの TTFT(バッチサイズ 16、チャンクプリフィル無効化、プレフィックスキャッシュ無効化)
入力長 | ベースライン TTFT (ms) | HPC TTFT (ms) | 改善率
---|---|---|---
2k | 1792.62 | 1363.13 | +24.0%
4k | 3704.27 | 2886.40 | +22.1%
8k | 7807.12 | 5893.93 | +24.5%
次のステップ
これは、vLLM コミュニティとの長期的な協力の始まりに過ぎません。私たちは vLLM のメンテナーやコントリビューターと協力し続け、これらの機能を改善・拡張するとともに、成熟した機能は上位プロジェクトへ統合していきます。フィードバック、不具合報告、ベンチマーク結果のご提供を歓迎します。オープンで高パフォーマンスな推論の構築に、共に取り組んでいくことを楽しみにしています。
謝辞
これらのバックエンドを vLLM に実装するためにチームを超えて協力してくれた多くの人々に感謝いたします:
- Tencent Hunyuan AI Infra — HPC-Ops アテンションおよび MoE カーネルの構築・最適化を行い、vLLM のバックエンドとして貢献しました。Sethran Liu, Chase Shao, Shengy Wei, Theo Cheng, Ryann Xue, Lando Jiang, Looper Zhao, Haank Lin, Aiden Ren, Lehua Ding, Chengv Jiang, Steven Kuang, Liqi He, Kipper Gong, Reedlau Liu, Raccoon Liu, Dick Zhu。
- Tencent Network Platform Department — 通信最適化における緊密な協力に感謝します。Xuan Zhang, Haoran Zhao, Yuanyuan Gong, Yadong Liu, Jinzhu Wang, Yinben Xia, Xiang Li, Quan Wen, Zekun He.
- vLLM/Inferact — オープンなバックエンドインターフェース、レビュー、設計議論への貢献に感謝します。Kaichao You, Yongye Zhu, Yifan Qiao.
- NVIDIA — カーネルおよびパフォーマンス最適化における緊密な協力に感謝します。Yuanhang Sun, Perkz Zheng, Yuxi Chi, Jiang Shao, Jun Gu, Meng Wang, River Liu, Gary Ji, Chandler Zhou.
また、本稿の基盤となっているオープンソースカーネルコミュニティにも謝意を表します。具体的には、NVIDIA CUTLASS/CuTe、TensorRT-LLM、FlashInfer、FlashAttention、Triton などが含まれます。
原文を表示
TL;DR
The Attention and MoE kernels from HPC-Ops — the production operator library built by the Tencent Hunyuan AI Infra team — are now in vLLM main branch as first-class backends (AttentionPR #46020, MoE PR #45924). Both are optimized for NVIDIA's Hopper architecture, with the strongest results on H20:
- Attention: a per-step, load-balanced decode scheduler plus a fused RoPE + QK-Norm + KV-write prologue. On mixed-length decode, up to 2.95× over a static split-KV schedule and 2.25× on average over FlashInfer and FlashAttention.
- MoE: a fully fused, low-latency FP8 MoE pipeline. On average 1.59× at TP8 / EP1 and 1.21× at TP1 / EP8 over Triton and CUTLASS, with matched output quality.
End-to-end on Hy3 across 8× H20, the two backends together cut TTFT by about 24% and TPOT by about 17% versus the vLLM default backend.
Both plug into stock vLLM through its backend interfaces — no source changes and no long-lived fork.
This post covers three things: what HPC-Ops is, how the two upstreamed backends are designed and integrated, and how they perform on H20.
Why This Matters
Production LLM serving no longer looks like the uniform, single-turn batches most kernels were first tuned for. Real traffic is dynamic and mixed-length, models are increasingly MoE with long context, and agentic workloads push both harder. At this scale, much of the latency is decided by how well the kernels schedule work across the GPU and move data between stages, not by raw matmul throughput alone. In attention decode, a fixed split-KV schedule stalls on the longest request in a mixed batch while leaving compute idle on the short ones. In MoE, the per-expert GEMMs are small, and a conventional pipeline gathers tokens into per-expert buffers, pays launch overhead at every stage, and moves intermediates through HBM in between.
vLLM already gives the community a fast, flexible serving engine; the remaining latency and throughput come down to how well the attention and MoE kernels absorb this messy, real-world traffic. That is what HPC-Ops targets — an operator library hardened in Tencent's large-scale production serving, and the same kernels that serve Hy3 are now upstreamed into vLLM as first-class Attention and MoE backends.
A Quick Word on Hy3-series models
Hy3 is Tencent Hunyuan's Mixture-of-Experts model for agentic execution, coding, and long-horizon reasoning. Activating just 21B of its 295B parameters, it reaches some of the strongest agent capabilities in its size class — rivaling open-source flagships 2–3× larger — while substantially cutting hallucination for more reliable multi-turn use. Under the hood it uses 192 experts with top-8 routing, GQA attention (64 heads, 8 KV heads, head dim 128), a 256K context window, and a 3.8B MTP layer for speculative decoding; it ships in BF16 and FP8 (Hy3-FP8).
This post is intentionally not about the model — it is about the kernels that serve it, which we turn to next.
HPC-Ops: A Production Operator Library, Now in vLLM
HPC-Ops is an open-source operator library for LLM inference, built and maintained by the Tencent Hunyuan AI Infra team. It focuses on the hot paths that dominate real serving latency and throughput — attention, MoE, GEMM, sampling, normalization, and communication-compute fusion — with native BF16 and FP8 support and a clean Python API meant to drop into inference frameworks. The kernels are optimized for NVIDIA's Hopper architecture, with especially strong results on H20.
These kernels are proven in Tencent's own large-scale production serving of Hunyuan. In this release, two of them have been upstreamed into vLLM as first-class backends:
vLLM backendWhat it optimizesPrecisionMerged in
AttentionLoad-balanced decode + fused RoPE/QK-Norm prologueBF16 / FP8PR #46020
Fused MoEFully fused low-latency MoE pipelineFP8PR #45924
The rest of this post focuses on these two backends.
Attention Backend: Dynamic Load-Balanced Scheduling
The challenge: mixed-length decode in every batch
In decode, every token generation step runs attention over a request's full KV cache. A request that has accumulated 16K tokens of context costs roughly 16× more compute than one that just started at 1K. In production serving, output lengths are unpredictable and continuous batching keeps requests at very different stages of generation in the same kernel launch — so a single batch routinely mixes very short and very long sequences.
Existing decode kernels map work to CTAs through a fixed launch grid, keyed by KV head, request, and a split-KV chunk index — and that split-KV degree must be uniform across all requests, which forces a choice between two bad options. Fix the number of splits, and the longest sequence dominates: short-request CTAs finish in a fraction of the time and sit idle. Fix the chunk size instead, and the split count must be set to the maximum any request needs, so short requests get padded with empty chunks that launch, find no work, and exit — wasting scheduling slots. Either way, total kernel time is dictated by the heaviest CTA while the others stall, leaving SM cycles on the table.
The solution: a per-step, load-balanced decode scheduler
The HPC-Ops attention backend replaces the fixed grid with a flat, persistent design that adapts to the batch's actual length distribution rather than a launch-time split policy, built in three stages.
- Assign. A lightweight assign kernel slices every KV sequence into uniform 64-token tiles. The total tile count across all heads and requests is divided by the number of available CTAs to determine a per-CTA budget — the bucket size. Tiles are traversed in head-major, batch-minor order and filled into CTA buckets sequentially: once a CTA's bucket is full, subsequent tiles spill into the next CTA. A long sequence is therefore split across multiple CTAs in proportion to its length, while a short sequence contributes only a handful of tiles and does not monopolize a CTA. A minimum workload floor per CTA prevents over-splitting when total work is small, ensuring the number of chunks stays manageable and the downstream combine cost does not outweigh the scheduling benefit. The resulting task map is computed once per decode step and reused by every transformer layer in that step, so its overhead is amortized to near zero.
- Compute and combine. A persistent kernel grid then runs: each CTA loops over its assigned task bin, pulling a task descriptor, computing attention for that chunk, writing partial output and log-sum-exp to a split buffer, then advancing to the next task until it hits a terminator. Because the grid is persistent, there is no relaunch overhead between tasks and no idle gap between waves — every SM stays saturated for the full kernel duration. A final lightweight combine kernel reads the chunk count for each (head, request) pair and reduces the per-chunk partials into the final BF16 output.
The net effect is that all CTAs carry roughly equal workloads and finish at nearly the same time, regardless of how skewed the sequence-length distribution is. The long-tail stall inherent in static schedules is eliminated, and GPU cycles that were previously wasted on idle waiting are converted into useful compute.

A fused attention prologue
Before attention runs, each layer normally applies QK-Norm, RoPE, and a KV-cache write — plus, in FP8, a query quantization — as separate, memory-bound steps. HPC-Ops fuses them into a single op (HpcRopeNorm): starting from the fused QKV projection, it applies QK-Norm and RoPE in the model's required order (Hy3 normalizes before RoPE), writes K and V straight into the paged cache, and, in FP8, emits a per-token, per-head FP8 query with its scale so the attention kernel never re-quantizes. One kernel replaces those separate launches and their HBM round-trips on every layer's attention prologue, in both prefill and decode.
Integrating with vLLM
The HPC-Ops attention APIs are integrated into vLLM as a native attention backend, alongside existing backends such as FlashAttention and FlashInfer. Specifically, HpcAttentionBackend inherits from vLLM's AttentionBackend base class and is registered through the standard backend registration mechanism.
MoE Backend: A Fused, Low-Latency FP8 MoE Pipeline
The challenge: small expert GEMMs and the overhead around them
MoE inference has two very different regimes. At high throughput with large batches, the expert GEMMs are large and compute-bound, and existing implementations generally perform fine there. Low-latency decode is the opposite: each expert receives only a handful of tokens, so the expert GEMMs are small and memory-bound. Kernels tuned for large matmuls underfill the GPU on these shapes, and because the number of tiles each expert produces varies and shifts from step to step, those small tiles are hard to spread evenly across the GPU.
The work around the GEMMs adds to that. A conventional MoE path is a chain of separate kernels: route tokens, gather them into per-expert buffers, Gate-Up GEMM, activation and quantization, Down GEMM, and a top-k weighted reduction back to token positions. The gather materializes a gathered-token tensor in HBM before any matmul starts, and every stage pays its own kernel launch and its own HBM round-trip for intermediates. In decode, where the GEMMs are already small, all of this piles up alongside the GEMM work itself.
The solution: a fused FP8 MoE pipeline
The HPC-Ops MoE backend re-architects the whole MoE path: routing and index preprocessing, the Gate-Up GEMM, activation and quantization, the Down GEMM, and the top-k weighted reduction are fused into one compact execution path, removing the redundant overhead of a multi-stage design.
- Routing and index build. A shared-memory counting pass assigns tokens to experts with contiguous per-expert output ranges, cutting the global-atomic pressure of large-token routing, and builds the routing indices and per-tile task map that the GEMMs consume directly.
- Gate-Up GEMM. The Gate-Up GEMM reads original tokens directly through the routing index, skipping the standalone gather step. Activation and FP8 quantization then run as a separate fused kernel whose output the Down GEMM reads directly.
- Occupancy-first, without warp specialization. A single warp group handles both data movement and compute, shifting memory-latency hiding from an intra-CTA software pipeline to cross-CTA hardware scheduling and raising the number of resident CTAs per SM. A persistent grid, launched to keep every SM full, then consumes the task map and spreads the small, uneven set of per-expert tiles evenly across the CTAs.
- PDL-chained stages. Programmatic Dependent Launch overlaps each kernel launch with the tail of the previous one, erasing the bubbles between stages, all the way to the final top-k weighted reduction, which can also fold in the shared-expert output.
Together, these keep intermediates and launches off the critical path. The experts run in FP8, with both per-tensor and block-wise scaling, and match the output quality of the baselines.
Integrating with vLLM
The HPC-Ops Fused MoE APIs are integrated into vLLM as a native MoE backend, alongside existing backends such as DeepGEMM and Triton. Specifically, HPCExperts inherits from vLLM's FusedMoEExpertsModular base class and is registered through the standard backend registration mechanism.
Using HPC-Ops Backends in vLLM
This guide describes how to enable the HPC-Ops backends (Attention and MoE) in vLLM.
Install
Before getting started, install HPC-Ops from source:
Quick start
The HPC-Ops Attention backend currently supports only the Hy3-series models.
To launch a vLLM server for the standard Hy3 model with the HPC-Ops Attention backend, run:
For the Hy3-FP8 model, a few additional options are required:
Tip: To enable the HPC-Ops Attention backend for a custom model, replace rope_norm with HpcRopeNorm in the model's forward method. See PR #46020 for reference.
The HPC-Ops MoE backend supports FP8 models only.
To launch a vLLM server with the HPC-Ops MoE backend, run:
Hardware support
The HPC-Ops backends are currently supported only on NVIDIA Hopper-architecture GPUs, and deliver the best performance on the H20.
Performance on H20
Fused MoE: HPC-Ops vs Triton / CUTLASS
We benchmarked the HPC-Ops MoE backend against the Triton and CUTLASS MoE backends under the Hy3 model configuration, at both TP8 / EP1 and TP1 / EP8 settings. Averaged over batch sizes, HPC-Ops is 1.59× faster than the best baseline at TP8 / EP1 and 1.21× at TP1 / EP8, with the largest gains at the small-to-mid batch sizes that dominate low-latency decode.
Table 1: FusedMoE latency (µs) across batch sizes at TP8 / EP1 (expert weights sharded across 8 ranks)
BatchHPC-Ops (µs)Triton (µs)CUTLASS (µs)
442.056.474.5
1685.7124.2209.2
32124.0184.3275.6
64147.2374.9330.3
128161.5302.9345.3
256170.1310.9351.6
512194.5331.6369.2
1024281.4652.7438.3
2048491.8731.5794.4
4096872.01366.01230.7
81921695.02216.82362.9
163843241.94329.14364.4
Table 2: FusedMoE latency (µs) across batch sizes at TP1 / EP8 (experts sharded across 8 ranks)
BatchHPC-Ops (µs)Triton (µs)CUTLASS (µs)
4118.6147.4140.4
8136.7192.8170.7
16149.8198.4263.5
32153.6214.6264.4
64166.5358.1266.8
128213.5251.7272.6
256386.2454.9493.5
512705.5691.7741.7
10241342.61369.11359.1
20482513.92668.72530.4

Decode under mixed-length batches: dynamic vs static scheduling
The attention backend's headline win is decode over mixed-length batches. To isolate the scheduler, we sweep FP8 decode from uniform to highly skewed KV-length distributions (label A×B = A requests at KV length B) and compare HPC-Ops dynamic scheduling against a static split-KV schedule, FlashInfer, and FlashAttention. The advantage over static grows with skew, from parity on small uniform batches to 2.95× on a 1×128K + 31×4K mix. Across these cases, dynamic scheduling is on average 2.25× faster than the best of FlashInfer and FlashAttention.
Table 3: Decode latency (ms) across KV-length distributions
Decode scenarioHPC-Ops dynamic (ms)HPC-Ops static (ms)FlashInfer (ms)FlashAttention (ms)Dynamic vs static
64×0.5K0.0130.0130.0500.0251.00×
64×4K0.0330.0430.2210.0951.32×
32×0.125K + 32×4K0.0200.0330.1190.0531.59×
2×32K + 30×4K0.0320.0560.1690.0941.76×
1×64K + 15×4K0.0420.0970.1180.0652.32×
1×128K + 31×4K0.0630.1860.2200.0972.95×

Attention: HPC-Ops vs FlashAttention / Triton / FlashInfer
We further benchmarked the HPC-Ops Attention backend against FlashAttention, Triton, and FlashInfer across prefill, extend, and decode shapes, using vLLM's attention benchmark. Across these shapes, HPC-Ops is at parity with or faster than the fastest of the three in nearly every case.
Table 4: Attention latency (ms) vs FlashAttention, Triton, and FlashInfer
Batch SpecTypeBatch SizeHPC-Ops (ms)FlashAttention (ms)Triton (ms)FlashInfer (ms)
q512prefill10.0470.0690.1230.070
q1ks2kextend10.4060.4311.1320.431
q2kprefill10.5300.5741.5250.609
q4kprefill12.0022.0935.8162.144
q8kprefill17.8837.95722.7028.084
2q1ks4kextend21.8351.8305.0461.829
8q1s1kdecode80.0190.0310.0350.021
16q1s2kdecode160.0540.0980.1060.052
32q1s1kdecode320.0570.1020.0800.058
64q1s4kdecode640.2990.6200.5100.340
End-to-end: Hy3 on 8× H20
Finally, we evaluated the end-to-end (E2E) performance of the Hy3 model with the HPC-Ops MoE and Attention backends against the vLLM default backend on 8× NVIDIA H20 GPUs. Across every test case, the HPC-Ops backend consistently outperforms the vLLM default backend, delivering substantial reductions in both TTFT and TPOT. TTFT drops by about 24% on average, and TPOT by about 17% on average, growing to about 30% at the largest batch size.
Table 5: TPOT across different batch sizes (output length = 4K)
Batch SizeBaseline TPOT (ms)HPC TPOT (ms)Improvement
18.007.76+3.0%
411.1410.67+4.2%
813.4911.31+16.2%
1617.9813.56+24.6%
3224.1318.32+24.1%
6431.1021.90+29.6%
Table 6: TTFT across different batch sizes (input length = 8k, disable Chunked Prefill, disable Prefix Caching)
Batch SizeBaseline TTFT (ms)HPC TTFT (ms)Improvement
1565.69431.00+23.8%
41920.151471.43+23.4%
83948.223035.44+23.1%
167807.185885.63+24.6%
Table 7: TTFT across different input lengths (batch size = 16, disable Chunked Prefill, disable Prefix Caching)
Input LengthBaseline TTFT (ms)HPC TTFT (ms)Improvement
2k1792.621363.13+24.0%
4k3704.272886.40+22.1%
8k7807.125893.93+24.5%
What's Next
This is just the start of a longer collaboration with the vLLM community. We'll keep working with vLLM maintainers and contributors to improve and extend these capabilities and to upstream further work as it matures. Feedback, issues, and benchmarks are very welcome, and we look forward to building open, high-performance inference together.
Acknowledgements
We would like to thank the many people across teams who worked together to bring these backends to vLLM:
- Tencent Hunyuan AI Infra — for building and optimizing the HPC-Ops Attention and MoE kernels and contributing them to vLLM as backends. Sethran Liu, Chase Shao, Shengy Wei, Theo Cheng, Ryann Xue, Lando Jiang, Looper Zhao, Haank Lin, Aiden Ren, Lehua Ding, Chengv Jiang, Steven Kuang, Liqi He, Kipper Gong, Reedlau Liu, Raccoon Liu, Dick Zhu.
- Tencent Network Platform Department — for the close collaboration on communication optimization. Xuan Zhang, Haoran Zhao, Yuanyuan Gong, Yadong Liu, Jinzhu Wang, Yinben Xia, Xiang Li, Quan Wen, Zekun He.
- vLLM/Inferact — for the open backend interfaces, reviews, and design discussions. Kaichao You, Yongye Zhu, Yifan Qiao.
- NVIDIA — for the close collaboration on kernel and performance optimization. Yuanhang Sun, Perkz Zheng, Yuxi Chi, Jiang Shao, Jun Gu, Meng Wang, River Liu, Gary Ji, Chandler Zhou.
We also thank the broader open-source kernel community whose work this builds on and measures against, including NVIDIA CUTLASS/CuTe, TensorRT-LLM, FlashInfer, FlashAttention, and Triton.
関連記事
今日のまとめ
AI日報で今日の重要ニュースをまとめ読み