HPC-Ops、SGLang に統合され推論性能向上
本文の状態
日本語全文を表示中
詳細モードで約34分の本文を読めます。
同じ出来事の情報源
この情報源を基点に整理
LMSYS Blog
Tencent Hunyuan の HPC-Ops が SGLang に統合され、Hy3 モデルの TPOT 最大 48.8% 削減が期待される。
Continue in AI NEW LAB
このニュースを、実務の判断につなげる
AI NEW LABで、試したことや先に確認したい条件を共有できます。まずはログインなしで読めます。
AI NEW LABで論点を見るAI深層分析を開く2026年8月8日 02:28
AI深層分析
キーポイント
HPC-Ops の SGLang 統合と実用化
騰訊が自社大規模運用で検証済みの HPC-Ops ライブラリ(Dynamic Attention、Fused MoE など)をオープンソースの SGLang メインブランチに統合し、コミュニティへの提供を開始した。
NVIDIA H20 における性能向上
HPC-Ops のアテンション機能は H20 で静的スケジューリング比で最大 2.95 倍、既存最良手法比でも平均 2.25 倍の高速化を実現し、Router GEMM は FP32 cuBLAS に対して最大 3.22 倍の速度向上を示した。
MoE カーネルとエンドツーエンド推論
HPC-Ops の MoE 実装は Hy3 モデルで SGLang や vLLM ベースラインを上回る高速化を達成し、8×H20 環境での TPOT(Time Per Output Token)を最大 48.8% 削減する効果を確認した。
FP8 精度と H200 検証結果
Qwen3 や Hy3 モデルを用いた H200 環境での検証では、FP8 KV キャッシュや LongCat-Flash カーネルの統合により、スループットや速度で FlashAttention や Triton を上回る結果が得られた。
混合長デコードにおけるアテンション負荷の不均一性
デコード時、各トークンはリクエストの全 KV キャッシュにアテンションするため、KV 作業量は生シーケンス長に比例して増大する。プロダクション環境ではバッチ内で短いキャッシュと数万トークンの長いシークエンスが混在し、静的な分割スケジューリングでは負荷偏りや空のスロット発生という問題が生じる。
重要な引用
Its core operators, including Dynamic Attention and Fused MoE, play a critical role in Hunyuan's online inference, reducing TPOT of Hy3 model by up to 48.8%.
HPC-Ops dynamic scheduling reaches 2.95× over its static split-KV schedule and is on average 2.25× faster than the best of FlashInfer and FlashAttention in each measured case.
On 8× H20 with Hy3-FP8, enabling HPC-Ops Attention and MoE together reduces TPOT by 15.1–48.8% at batch sizes 4–64.
A request with 16K cached tokens therefore carries roughly 16× the KV work of one with 1K.
編集コメントを表示
編集コメント
騰訊が自社の大規模運用で成功した最適化技術をオープンソースへ還元する姿勢は、業界全体の推論効率向上に寄与する重要な一歩である。SGLang との統合により、これらの技術がより広範な開発者や組織によって即座に検証・利用可能になった点は特筆すべき成果と言える。
Source Article
元記事を日本語で読む
本文に関係しない購読案内、埋め込み通知、サイト内プロモーションは除いています。
「HPC-Ops」(https://github.com/Tencent/hpc-ops) は、Tencent の大規模な本番環境で運用されている LLM 推論向けのオープンソース演算ライブラリです。このライブラリの核となる Dynamic Attention や Fused MoE といった演算子は、Hunyuan のオンライン推論において極めて重要な役割を果たしており、Hy3 モデルの TPOT を最大 48.8% 削減することに貢献しています。現在、HPC-Ops の Attention、Router GEMM、MoE は SGLang のメインブランチに統合され、本番環境で実証済みの最適化技術がオープンソースの推論コミュニティへ提供されるようになりました。
この記事では、HPC-Ops における重要な演算子 3 つの設計と、それらが SGLang とどのように連携しているかについて解説します。さらに、NVIDIA H20 での演算ベンチマークと推論結果、ならびに H200 での検証結果も紹介します。これらの統合は NVIDIA の Hopper アーキテクチャ(SM90)向け GPU を対象としており、Qwen3、Hy3、LongCat の各ワークロードで検証済みです。
ハイライト
- Attention: H20 において、HPC-Ops の動的スケジューリングは静的な split-KV スケジュールと比較して2.95 倍の性能を発揮し、測定されたすべてのケースで FlashInfer や FlashAttention の最良値よりも平均2.25 倍高速です。アップストリームの H200 検証では、FP8 KV キャッシュを採用した Hy3-FP8 パスが FlashAttention を上回り、出力スループットを3.7–5.9%向上させました。
- Router GEMM: H20 において、HPC-Ops は FP32 の cuBLAS よりも1.30–3.22 倍高速です。また、FP32 cuBLAS との絶対誤差最大値は0.00177であり、TF32 cuBLAS の0.06464と比較して精度が格段に高いことが示されています。アップストリームの H200 LongCat-Flash カーネル検証では、既存の FP32 パスに対して4.31 倍の高速化を実現しました。
MoE: H20 上、HPC-Ops は Hy3 ベンチマークにおいて、SGLang と vLLM の最良のベースラインと比較して、TP8/EP1 で平均バッチあたりの速度向上率 1.08 倍、TP1/EP8 で 1.21 倍 を達成しました。また、Qwen3/H200 カーネルベンチマークでは、8 トークン処理で Triton の最大 4.21 倍 に達しています。
エンドツーエンドのサービス提供: 8×H20 で Hy3-FP8 を使用し、HPC-Ops Attention と MoE を同時に有効化すると、バッチサイズ 4〜64 で TPOT(Time Per Output Token)が 15.1–48.8% 短縮され、バッチサイズ 4〜16 で TTFT(Time To First Token)が 3.3–6.0% 短縮されます。また、8×H20 で LongCat-Flash-Lite-FP8 を使用し、HPC-Ops Router GEMM を有効化すると、バッチサイズ 4〜64 で入力スループットが 5.5–6.1% 向上します。
アテンション、ルーティング、エキスパート:MoE モデルサービスにおける 3 つのホットパス
本番環境での MoE サービス提供は、単独で測定されたカーネルベンチマークの均一なワークロードとは大きく異なります。同じレイテンシ敏感経路内で、長さの異なるアテンション処理、精度に敏感なルーティング、そしてスパースなエキスパート実行が組み合わさるためです。特に長文コンテキスト、複数回の対話、エージェント型ワークロードでは、生きている KV(Key-Value)ペアの長さの分布がさらに広がります。したがって、サービスパフォーマンスは行列乗算のスループットだけでなく、ワークロードのバランス、数値的忠実度、オーバーヘッド制御にも依存します。
これらの制約は、MoE モデルのサービスにおける 3 つのパフォーマンスが重要な局面で顕在化します。
デコード中、アテンション処理量は各リクエストのライブ KV 長さに比例して増加するため、混合された長さのバッチを扱うことは負荷分散の問題となります。ラウター GEMM はトップ k 選択に使用されるスコアを生成しますが、数値のわずかな変化がエキスパートの選択結果を変えてしまいます。選ばれたエキスパートは、小さく不均一なトークングループを処理するため、メタデータ構築やトークンの移動、中間ストレージ、起動オーバーヘッドなどが、エキスパート GEMM 自体の処理コストに匹敵するほどになることがあります。
HPC-Ops は、各局面に対応した専用オペレーターで解決します。アテンションにはワークロードを認識したスケジューリングを、ラウター GEMM には精度を意識した定式化を採用し、MoE には統合パイプラインを実装して、独立した gather 処理を排除するとともに起動と中間トラフィックの削減を実現しています。
これらオペレーターは、SGLang のサービスランタイムにネイティブバックエンドおよびディスパッチインターフェースを通じて統合されています。以下では、各オペレーターの設計について解説します。
Attention: 混合長デコードのための負荷分散
デコード中、新しいトークンごとにリクエストの KV キャッシュ全体に対してアテンション計算が行われるため、処理量はライブなシーケンス長さに比例して増加します。16K のキャッシュトークンを保持するリクエストは、1K のリクエストに比べて約 16 倍の KV 処理量を要します。
本番環境ではプロンプトと出力の長さのばらつきが大きく、連続バッチ化により生成プロセスの異なる複数のリクエストを同じ起動で処理するため、短い KV キャッシュと数万トークン規模の長いシーケンスが混在したバッチが日常的に発生します。
静的な split-KV スケジューリングは、KV ヘッド、リクエスト、および KV チャンクに対して固定された起動グリッドに作業をマッピングし、バッチ全体で共有される単一のパーティショニングポリシーを採用します。この静的なアプローチには主に 2 つの方針がありますが、どちらも混合長のバッチ処理では性能を発揮できません。
1 つ目は分割数を固定する方式です。これでは長めのリクエストが非常に重いチャンクとなり、短めのリクエストを処理する CTA(Cooperative Thread Array)は早期に完了する一方、数少ない長時間実行される CTA がカーネルの尾部時間を決定してしまいます。
2 つ目はチャンクサイズを固定する方式です。この場合、グリッドは最長のリクエストに対応できる十分な分割数を確保する必要があり、結果として短めのリクエストには空またはほぼ空のチャンクが割り当てられます。しかし、これらもスケジュール上のスロットを消費してしまうため、非効率が生じます。
つまり、前者は作業量の偏りを生み出し、後者は存在しない作業をスケジューリングすることになります。
Scheduling around live KV work
HPC-Ops は、リクエストごとの静的な分割を置き換え、バッチの実際の長さ分布に応じて KV タイルを CTAs 間で動的にバランスさせる永続的なカーネルを採用しています。各デコードバッチに対して、アサインメントカーネルは生きている KV の長さを基にグローバルなタスマップを構築します。具体的には、すべてのシーケンスを均一な 64 トークン分のタイルにスライスし、全ヘッドと全リクエストにわたるタイル数を合計して、永続的な CTAs の数で割ります。これにより、各 CTA に割り当てるタイル数の上限(バジェット)が設定されます。アサインメントカーネルは、このバジェットまで各 CTA のビンにタイルを埋め尽くし、それを超えた分は次の CTA へ溢出させます。その結果、長いシーケンスはその長さに比例して複数の CTA にまたがり、短いシーケンスは実際に保有するタイル数だけしか貢献しません。また、総作業量が小さい場合の過剰な分割を防ぐために最小作業量の下限を設け、後段の結合処理のコストを抑えています。このタスマップは、デバイス側のシーケンス長からデコードステップごとに一度生成され、Transformer レイヤー全体で再利用されるため、そのコストは分散されます。
実行時には、各 CTA が割り当てられたバインを処理し終えます。各ディスクリプタに対して、1 つ以上の連続する KV タイルを対象にアテンション計算を行い、ログ和指数統計を含む部分的な出力を書き出します。同じ CTA はバインが空になるまで次のディスクリプタへ継続して処理を進めます。各 CTA が生成するのは特定の要求に対する部分結果の一部のみであるため、最終的な結合カーネルは実際のチャンク数とヘッド数を要求ごとに読み取り、正しいグローバルソフトマックス正規化の下でそれらを統合します。バインサイズがほぼ均等であることが保証されているため、CTA は概ね同時に完了し、一部の非常に長いリクエストによって生じるはずのカーネルの尾部(遅延)を排除できます。
融合されたアテンション前処理
Hy3 FP8 において、HPC-Ops は QKV プロジェクション後にアテンションの前処理を融合します。具体的には、RoPE の適用前に QK-Norm を実行し、Q をトークンごと・ヘッドごとのスケール付きで FP8 に出力します。また、K と V は直接ページ化された FP8 キャッシュに書き込まれます。量子化された Q とそのスケールはそのままメインのアテンションカーネルへ渡され、再量子化を不要とします。この融合パスにより、中間テンソルとその関連する HBM への往復転送、およびプレフィルとデコードの両方で発生する別個のカーネル起動が排除されます。
Router GEMM: ルーティング精度とスループットのバランス
Router の精度は、MoE モデルの品質に直接影響を及ぼします。各 MoE レイヤーにおいて、Router は隠れ状態を専門家のスコアへ投影し、そのスコアに対してトップ k 選択を行うことで、実際に実行する専門家を選定します。k 番目と (k+1) 番目の専門家のスコア差が小さい場合があるため、この投影演算の算術精度が、正しい専門家が選ばれるかどうかを決定づけます。
Router の精度を維持するためには、隠れ状態が BF16 で処理されている場合でも、一部の生産環境向けモデルでは FP32 形式で Router の重みを保持しています。これらの重みを BF16 にキャストすれば BF16 Tensor Core のスループットは向上しますが、トップ k の判断をひっくり返す可能性のある下位ビットの情報が失われてしまいます。一方、FP32 での GEMM を完全に実行すればすべての重み精度が保たれますが、その分、Tensor Core のスループットは低下します。
精度を意識した BF16 定式化
HPC-Ops は、FP32 重みを 2 つの BF16 コンポーネントに分解することでこの課題を解決します。まず、直接切り捨てて BF16 の高次部 Whigh を抽出し、スケーリングされた残差 (W−Whigh)×256 から第 2 の BF16 コンポーネント Wlow を作成します。元の重みは W≈Whigh+Wlow/256 と近似されるため、行列積計算は 2 つの BF16 GEMM に分割され、低次部の有効桁寄与を復元するためにスケール補正を加えて結果を結合します。
単一のカーネルが 2 つの BF16 乗算を実行します。アクティベーションタイルは共有メモリから一度読み込まれ、両方の部分結果は FP32 レジスタに蓄積されます。エピローグで 1/256 のスケールを適用し、最終的な FP32 ルータースコアをグローバルメモリへ書き出します。この方式により、主要な演算を BF16 Tensor Core で実行しながらも、精度は完全な FP32 GEMM に近い値を維持できます。
フレームワーク側では、モデル読み込み時に分解された重みペアをキャッシュし、リクエスト間や CUDA グラフの再実行時にもこれを再利用します。形状に応じたディスパッチが、測定されたクロスオーバーポイントで HPC-Ops カーネルとデフォルトパスの切り替えを行います。そのポイント以下では、2 つの乗算によるオーバーヘッドが Tensor Core の性能向上を上回るため、単一の FP32 パスの方が高速になります。
MoE: reducing overhead around small expert GEMMs
デコード処理では、MoE レイヤー内の各エキスパートが受け取るトークンはほんのわずかです。その結果生じるエキスパートごとの行列積(GEMM)は小規模でメモリーバウンドとなり、GPU の SM(ストリームマルチプロセッサ)もこれらの形状では十分に活用されません。さらに問題が悪化するのは負荷不均衡の影響です。各エキスパートにルーティングされるトークン数はエキスパート間で異なり、ステップごとに変動するため、こうした小さく不均一なタイルを利用可能な SM 上に均等に分散させることが困難になります。
エキスパート GEMM そのものだけでなく、それを囲む処理も大きなオーバーヘッドをもたらします。従来の MoE パスは、ルーティング、トークンを各エキスパート用バッファに集約する Gather 操作、Gate-Up GEMM、活性化と量子化、Down GEMM、そしてトップ k の重み付けによる還元(Token 位置への戻し)といった個別のカーネルを連鎖させています。Gather ステップでは行列積が始まる前に HBM にフルサイズのトークンテンソルが展開され、その後の各段階でも中間データのために独自のカーネル起動と HBM への往復が発生します。GEMM が小規模な場合、こうした周囲のオーバーヘッドがステージ全体の所要時間の大きな割合を占めてしまいます。
低遅延指向の融合 MoE パイプライン
バッチサイズが小さい推論においては、HPC-Ops の MoE バックエンドが、タスクマップ駆動型の永続的なエキスパート GEMM を中核に据えた低遅延パイプラインで、ルーティングとインデックス前処理、Gate-Up、活性化と再量子化、Down、そしてトップ k 重み付け還元を一貫して調整します。
ルーティングとインデックス構築。選択された上位 k 個のエキスパート ID から出発し、共有メモリを用いたカウント処理がトークンとエキスパートの割り当てを整理して、各エキスパートごとの連続した出力範囲を作成します。これにより、グローバルなアトミック操作の負荷が軽減され、永続的なエキスパート GEMM が直接消費するルーティングインデックスとタイルごとのタスマップが構築されます。
ゲートアップと活性化。Gate-Up GEMM は、ルーティングインデックスを通じて元のトークンを直接読み込み、独立した gather 処理とその追加の HBM トラフィックをスキップします。SiLU-and-mul と FP8 の再量子化は単一の融合カーネルとして実行され、その出力は Down GEMM が直接読み取ります。
ウォープ専門化なしのoccupancy優先。データ転送と行列計算の両方を単一のウォープグループが処理し、生産者と消費者を別々のグループに割り当てる従来の手法とは異なります。これにより CTA のレジデンシーが向上し、メモリレイテンシの隠蔽が CTA 内のソフトウェアパイプラインから、CTA を跨ぐハードウェアスケジューリングへと移行します。永続グリッドはこれらのタスマップを消費し、小さく不均一なエキスパートタイルを SM 全体に分散させます。
PDL 連鎖ステージ。Programmatic Dependent Launch は、各下流カーネルの起動を直前のステージの末尾とオーバーラップさせることで、Gate-Up、活性化、Down、そして最終的な上位 k 個の重み付けリダクション(エキスパート出力をトークン順序に戻す処理)全体にわたるギャップを削減します。
これらの最適化により、クリティカルパス上の中間トラフィックとカーネル起動オーバーヘッドが大幅に削減されます。
HPC-Ops カーネルから SGLang へ
SGLang のネイティブバックエンドとディスパッチインターフェースを通じて、HPC-Ops は既存のサービングランタイムの状態に直接アクセスしながらも、独立してメンテナンスされるオペレーターライブラリとして機能します。アテンションは追加レイアウト変換なしでページ化された KV ストレージとライブなデバイス側のシーケンスメタデータを消費し、Router GEMM はリクエスト間および CUDA グラフの再実行を通じて事前処理済みの重みとワークスペースを再利用します。また MoE は SGLang のエキスパート ID とパーティションに従い、追加のリマッピングを行わずに動作します。これらの統合により、各オペレーターの意図されたデータパスが維持されつつ、SGLang の既存の実行モデルに適合しています。
これら 3 つの統合されたオペレーターパスは以下の通りです:
| HPC-Ops オペレーター | 最適化対象 | 精度 | アップストリーム PR |
|---|---|---|---|
| Attention | 負荷分散された混合長デコード、および融合された QK-Norm、RoPE、量子化、KV 書き込みプロローグ | BF16 アクティベーション; BF16 または FP8 E4M3 KV キャッシュ | #30540, #32304 |
| Router GEMM | BF16 Tensor Cores を使用しつつ FP32 重み情報を保持する、精度対応のルーター射影 | BF16 アクティベーション × FP32 重み → FP32 スコア | #30247, #31943 |
| MoE | 小規模かつ不均一なエキスパート GEMM 周辺の低オーバーヘッド実行 | BF16 ヒ든状態; FP8 E4M3 エキスパート重み | #30541 |
はじめに
本ガイドでは、SGLang で HPC-Ops のアテンション演算子、ルーター GEMM、MoE 演算子をどのように使用するかを解説します。
インストール
ソースコードから HPC-Ops をインストールするには、以下の手順に従ってください。
git clone https://github.com/Tencent/hpc-ops.git
cd hpc-ops
make wheel
python3 -m pip install dist/*.whl
HPC-Ops は、SGLang の公式 x86_64 開発イメージ(lmsysorg/sglang:dev または CUDA 12.9 用の lmsysorg/sglang:dev-cu12)に既に含まれています。そのため、これらのイメージを使用する場合は個別のインストールは不要です。
アテンションと MoE
SGLang では、Attention と MoE は独立したバックエンドオプションとして扱われ、Qwen3 や Hy3 といった対応モデルでは個別に、あるいは同時に有効化できます。以下の例では、両方の HPC-Ops バックエンドを有効にしつつ、FP8 KV キャッシュを用いた Attention パスを選択しています。
python3 -m sglang.launch_server \
--model tencent/Hy3-FP8 \
--tp-size 8 \
--attention-backend hpc_ops \
--kv-cache-dtype fp8_e4m3 \
--page-size 64 \
--moe-runner-backend hpc_ops
BF16 の KV キャッシュを使用する場合は --kv-cache-dtype fp8_e4m3 を省略してください。また、HPC-Ops オペレータを 1 つだけ利用したい場合は、対応するバックエンドオプションのみを指定すればよいです。
Router GEMM
SGLang における HPC-Ops Router GEMM は、BF16 Tensor Cores で行列計算を実行する際にも、FP32 の Router 重みから低次の情報を保持します。この統合パスは LongCat-Flash Chat および Lite で検証済みであり、対応するモデルや Router の形状に対して自動的に選択されます。
HPC-Ops をインストールすれば、標準的な LongCat-Flash の起動でこれを利用できます:
python3 -m sglang.launch_server \
--model meituan-longcat/LongCat-Flash-Lite-FP8
パフォーマンス評価
HPC-Ops バックエンドは現在、NVIDIA の Hopper アーキテクチャ搭載 GPU をサポートしており、特に H20 上で最高のパフォーマンスを発揮します。以下の評価では、H20 における演算子ベンチマーク、8 基の H20 を用いた SGLang のエンドツーエンド推論サービス、および上位リポジトリである SGLang のプルリクエストで報告されている H200 の結果を網羅しています。
H20 演算子ベンチマーク
Attention(アテンション)機能
アテンションスケジューラの最大の利点は、ミックスド・レングス・デコードにおいて顕著に現れます。これは、同じバッチ内のリクエスト間で KV キャッシュの長さが大きく異なるケースです。評価では、均一な分布から極端に偏った分布に至るまでの FP8 形式の KV キャッシュデコードをテストしました。表における「A×B」は、KV 長が B のリクエストが A 個あることを意味します。
スケジューリング効果のみを抽出して比較するため、HPC-Ops の動的スケジューリングと静的な split-KV 方式を対比させました。さらに、FlashInfer と FlashAttention も追加のベンチマークとして含めています。その結果、動的スケジュールによる性能向上は偏りの度合いに比例して大きくなり、均一な「64×0.5K」バッチでは両者の差がほぼ同等だったのに対し、「1×128K + 31×4K」という混合構成では 2.95 倍 の高速化を達成しました。全 6 つのケースを通じて、動的スケジューリングは各ケースにおける FlashInfer と FlashAttention の最速値と比較して、平均で 2.25 倍 も高速でした。
*表 1: H20 上の KV 長分布ごとのデコードレイテンシ。数値が小さいほど優れています。*
| デコードシナリオ | HPC-Ops ダイナミック | HPC-Ops スティック | FlashInfer | FlashAttention | ダイナミック対スティック |
|---|---|---|---|---|---|
| 64×0.5K | 0.013 ms | 0.013 ms | 0.050 ms | 0.025 ms | 1.00× |
| 64×4K | 0.033 ms | 0.043 ms | 0.221 ms | 0.095 ms | 1.32× |
| 32×0.125K + 32×4K | 0.020 ms | 0.033 ms | 0.119 ms | 0.053 ms | 1.59× |
| 2×32K + 30×4K | 0.032 ms | 0.056 ms | 0.169 ms | 0.094 ms | 1.76× |
| 1×64K + 15×4K | 0.042 ms | 0.097 ms | 0.118 ms | 0.065 ms | 2.32× |
| 1×128K + 31×4K | 0.063 ms | 0.186 ms | 0.220 ms | 0.097 ms | 2.95× |

Router GEMM.
まず、Router GEMM の評価を行いました。一般的な K=4096, N=192 のスウィープテストを実施した結果、HPC-Ops は FP32 版の cuBLAS よりも 1.30~3.22 倍高速で、TF32 版の cuBLAS よりも 1.25~1.78 倍高速でした。数値的な基準として FP32 版の cuBLAS を用いた場合、最大絶対誤差は 0.00177 以下に抑えられ、TF32 の 0.06464 と比較して精度が格段に優れています。
*Table 2: BF16 × FP32 Router GEMM latency at K = 4096, N = 192 on H20. Lower is better.*
| M | HPC-Ops | FP32 cuBLAS | TF32 cuBLAS | FP32 に対する速度向上率 | TF32 に対する速度向上率 |
|---|---|---|---|---|---|
| 1 | 11.200 µs | 14.576 µs | 14.048 µs | 1.30× | 1.25× |
| 16 | 11.744 µs | 23.808 µs | 18.752 µs | 2.03× | 1.60× |
| 48 | 12.144 µs | 31.008 µs | 20.064 µs | 2.55× | 1.65× |
| 96 | 13.904 µs | 31.760 µs | 24.720 µs | 2.28× | 1.78× |
| 208 | 17.088 µs | 39.280 µs | 28.928 µs | 2.30× | 1.69× |
| 512 | 26.992 µs | 86.976 µs | 44.736 µs | 3.22× | 1.66× |
| 1024 | 50.640 µs | 110.480 µs | 68.544 µs | 2.18× | 1.35× |
| 2048 | 76.688 µs | 198.576 µs | 100.800 µs | 2.59× | 1.31× |
| 4096 | 141.120 µs | 403.728 µs | 205.760 µs | 2.86× | 1.46× |

次に、LongCat-Flash で採用されている 2 つの Router 形状を再検証しました。SGLang のモデル認識型ディスパッチ範囲内において、HPC-Ops は Chat 形状で 1.06–2.83 倍、Lite 形状で 1.09–2.46 倍の高速化を実現し、SGLang のデフォルト設定を上回りました。
*表 3: H20 上での SGLang ディスパッチ範囲における LongCat-Flash Router GEMM のレイテンシ。数値が小さいほど優れています。*
| M | Chat デフォルト | Chat HPC-Ops | 高速化率 | Lite デフォルト | Lite HPC-Ops | 高速化率 |
|---|---|---|---|---|---|---|
| 64 | 39.19 µs | 37.01 µs | 1.06× | — | — | — |
| 128 | 74.18 µs | 59.36 µs | 1.25× | 25.83 µs | 23.72 µs | 1.09× |
| 256 | 100.03 µs | 82.47 µs | 1.21× | 41.87 µs | 34.01 µs | 1.23× |
| 512 | 190.37 µs | 141.73 µs | 1.34× | 71.89 µs | 41.95 µs | 1.71× |
| 1024 | 380.68 µs | 207.00 µs | 1.84× | 108.64 µs | 74.09 µs | 1.47× |
| 2048 | 961.15 µs | 339.04 µs | 2.83× | 235.81 µs | 106.81 µs | 2.21× |
| 4096 | 1469.70 µs | 670.14 µs | 2.19× | 423.52 µs | 172.44 µs | 2.46× |
| 8192 | 2881.00 µs | 1333.84 µs | 2.16× | 835.22 µs | 339.66 µs | 2.46× |

*図 3: SGLang のディスパッチ範囲における、LongCat-Chat(左)と Lite(右)の形状での Router GEMM レイテンシ。数値が小さいほど優れています。
MoE (Mixture of Experts)
MoE モデルについては、TP8 / EP1 および TP1 / EP8 の Hy3 形状において、SGLang、vLLM Triton、vLLM CUTLASS と比較し、融合演算全体のベンチマークを行いました。各行で 3 つのベースライン中最も低いレイテンシを基準にすると、HPC-Ops は TP8 / EP1 で平均バッチあたりの速度向上率 1.08 倍、TP1 / EP8 で 1.21 倍 を達成しました。特に低遅延デコードで一般的である小〜中規模のバッチサイズにおいて、最も大きな改善が見られました。
*表 4: H20 における Hy3 MoE のレイテンシ(TP8 / EP1)。数値が小さいほど優れています。*
| バッチサイズ | HPC-Ops | SGLang | vLLM Triton | vLLM CUTLASS | 最良値との速度向上率 |
|---|---|---|---|---|---|
| 16 | 85.7 µs | 88.6 µs | 124.2 µs | 209.2 µs | 1.03× |
| 32 | 124.0 µs | 137.2 µs | 184.3 µs | 275.6 µs | 1.11× |
| 64 | 147.2 µs | 164.4 µs | 374.9 µs | 330.3 µs | 1.12× |
| 128 | 161.5 µs | 179.9 µs | 302.9 µs | 345.3 µs | 1.11× |
| 256 | 170.1 µs | 191.5 µs | 310.9 µs | 351.6 µs | 1.13× |
| 512 | 194.5 µs | 230.1 µs | 331.6 µs | 369.2 µs | 1.18× |
| 1024 | 281.4 µs | 300.5 µs | 652.7 µs | 438.3 µs | 1.07× |
| 2048 | 491.8 µs | 522.5 µs | 731.5 µs | 794.4 µs | 1.06× |
| 4096 | 872.0 µs | 899.2 µs | 1366.0 µs | 1230.7 µs | 1.03× |
| 8192 | 1695.0 µs | 1712.7 µs | 2216.8 µs | 2362.9 µs | 1.01× |
| 16384 | 3241.9 µs | 3257.1 µs | 4329.1 µs | 4364.4 µs | 1.00× |
表 5:H20 上での Hy3 MoE のレイテンシ(TP1 / EP8)。数値が小さいほど優れています。
| バッチサイズ | HPC-Ops | SGLang | vLLM Triton | vLLM CUTLASS | 最良値との速度向上率 |
|---|---|---|---|---|---|
| 4 | 118.6 µs | 183.1 µs | 147.4 µs | 140.4 µs | 1.18× |
| 8 | 136.7 µs | 231.5 µs | 192.8 µs | 170.7 µs | 1.25× |
| 16 | 149.8 µs | 234.2 µs | 198.4 µs | 263.5 µs | 1.32× |
| 32 | 153.6 µs | 475.3 µs | 214.6 µs | 264.4 µs | 1.40× |
| 64 | 166.5 µs | 477.3 µs | 358.1 µs | 266.8 µs | 1.60× |
| 128 | 213.5 µs | 482.3 µs | 251.7 µs | 272.6 µs | 1.18× |
| 256 | 386.2 µs | 494.3 µs | 454.9 µs | 493.5 µs | 1.18× |
| 512 | 705.5 µs | 970.7 µs | 691.7 µs | 741.7 µs | 0.98× |
| 1024 | 1342.6 µs | 1476.8 µs | 1369.1 µs | 1359.1 µs | 1.01× |
| 2048 | 2513.9 µs | 2871.2 µs | 2668.7 µs | 2530.4 µs | 1.01× |

*Figure 4: TP8 / EP1 と TP1 / EP8 の構成における Hy3 モデルの MoE レイテンシ。数値が小さいほど優れています。
H200 オペレータ検証
先行するプルリクエストには、H200 サービングの結果も含まれており、性能向上がホッパー(Hopper)アーキテクチャの GPU 全体に通用することが確認されています。
*Table 6: 先行する SGLang のプルリクエストで報告されたオペレータ検証結果。*
| オペレーター | アップストリーム検証ワークロード | 比較対象 | 結果 |
|---|---|---|---|
| FP8 Attention | Hy3-FP8 with FP8 KV cache; mixed-length decode | HPC-Ops dynamic scheduling vs. HPC-Ops static split-KV | 出力スループット +2.0%; 総スループット +2.0%; メディアン TTFT −5.3% |
| BF16 Attention | Qwen3 with BF16 KV cache; mixed-length decode | HPC-Ops dynamic scheduling vs. HPC-Ops static split-KV | 出力スループット +3.0%; 平均 E2E レイテンシ −2.8%; 平均 TPOT −2.8% |
| Router GEMM | LongCat-Flash Chat and Lite router shapes | HPC-Ops Router GEMM vs. SGLang default | カーネルの高速化: 1.56–4.31× |
| MoE | Qwen3 FP8 MoE workloads from 1 to 4,096 tokens | HPC-Ops MoE vs. SGLang Triton fused experts | カーネルの高速化: 0.89–4.21× |
エンドツーエンドのパフォーマンス
エンドツーエンドの評価は、8 枚の NVIDIA H20 GPU を用いて、対応するデフォルトの実装である SGLang と比較して行われました。Hy3-FP8 モデルでは TP8(Tensor Parallelism 8)かつ FP8 KV キャッシュを有効化した環境で、HPC-Ops のアテンションと MoE(Mixture of Experts)機能を同時に有効化することによる、サービス全体の性能への影響を測定しました。一方、LongCat-Flash-Lite-FP8 モデルでは Router GEMM のみを対象に評価を行いました。また、SGLang 公式のプルリクエストで報告されている H200 を用いたサービス検証の結果も併せてまとめました。
Hy3-FP8: アテンションと MoE
入力長 8K、出力長 4K の条件下では、HPC-Ops によりバッチサイズ 1 で TPOT(Time Per Output Token)が 3.3% 短縮されました。バッチサイズを 4 から 64 に広げると、この短縮効果は 15.1% から 48.8% に拡大します。
*Table 7: FP8 KV キャッシュと HPC-Ops アテンション、MoE を同時に有効化した場合の Hy3-FP8 の TPOT。数値が小さいほど優れています。*
| バッチサイズ | SGLang デフォルト | HPC-Ops | 改善率 |
|---|---|---|---|
| 1 | 7.56 ms | 7.31 ms | 3.3% |
| 4 | 11.10 ms | 9.42 ms | 15.1% |
| 8 | 14.29 ms | 10.76 ms | 24.7% |
| 16 | 22.90 ms | 13.09 ms | 42.8% |
| 32 | 35.33 ms | 18.09 ms | 48.8% |
| 64 | 40.70 ms | 23.81 ms | 41.5% |
8K の入力において、HPC-Ops はバッチサイズ 1〜16 で TTFT を3.3–9.0% 改善します。
*表 8: 8K 入力の FP8 KV キャッシュを用いた Hy3-FP8 の TTFT。数値が正の場合は、レイテンシの低下を意味します。*
| バッチサイズ | SGLang デフォルト | HPC-Ops | 改善率 |
|---|---|---|---|
| 1 | 460.67 ms | 419.43 ms | 9.0% |
| 4 | 1612.47 ms | 1533.66 ms | 4.9% |
| 8 | 3210.93 ms | 3018.68 ms | 6.0% |
| 16 | 5810.53 ms | 5619.48 ms | 3.3% |
バッチサイズ 16 の条件下で、チャンクドプリフィルとプレフィックスキャッシュを無効化し、入力長を 2K から 8K にわたってスウィープしました。その結果、HPC-Ops はすべての入力長において TTFT を 2.3–8.9% 改善しました。
*表 9: バッチサイズ 16 における FP8 KV キャッシュの有効化時の Hy3-FP8 の TTFT(入力長別)。数値が正の場合はレイテンシの低下を意味します。
| 入力長 | SGLang デフォルト | HPC-Ops | 改善率 |
|---|---|---|---|
| 2K | 1509.98 ms | 1375.95 ms | 8.9% |
| 4K | 2779.46 ms | 2715.18 ms | 2.3% |
| 8K | 5810.53 ms | 5619.48 ms | 3.3% |
LongCat-Flash-Lite-FP8:Router GEMM
Router GEMM の評価は、1,024 トークンの入力と 128 トークンの出力を想定して個別に行われました。バッチサイズが 1 の場合、スループットはほぼ同等で 0.5% の改善にとどまりますが、バッチサイズが 4 から 64 の範囲では 5.5〜6.1%の向上が見られました。
*表 10:HPC-Ops Router GEMM を用いた LongCat-Flash-Lite-FP8 の入力スループット。数値が高いほど優れています。*
| バッチサイズ | SGLang デフォルト | HPC-Ops Router GEMM | 改善率 |
|---|---|---|---|
| 1 | 16,612.11 tok/s | 16,695.77 tok/s | 0.5% |
| 4 | 54,466.27 tok/s | 57,810.27 tok/s | 6.1% |
| 8 | 60,425.93 tok/s | 63,833.96 tok/s | 5.6% |
| 16 | 61,995.23 tok/s | 65,539.10 tok/s | 5.7% |
| 32 | 62,833.85 tok/s | 66,306.52 tok/s | 5.5% |
| 64 | 62,841.93 tok/s | 66,422.92 tok/s | 5.7% |

*図 5:SGLang のエンドツーエンド結果。上段の 3 つの Hy3-FP8 パネルは、HPC-Ops アテンションと MoE を同時に有効化し、FP8 KV キャッシュを使用しています。下段右のパネルは Router GEMM に特化した評価です。
H200 サービング検証
先行するプルリクエストでは、SGLang のサービングループに統合された演算子が H200 上でも動作することを確認しました。これは主要なターゲットである H20 のチューニングを超え、モデルレベルでの統合チェックを提供しています。
*表 11:先行する SGLang プルリクエストで報告されたモデルレベルのサービング検証結果*
| 演算子 | アップストリーム検証ワークロード | 比較対象 | 結果 |
|---|---|---|---|
| Attention | Hy3-FP8 with FP8 KV cache serving workloads | HPC-Ops Attention vs. FlashAttention | 出力スループット: +3.7–5.9% |
| Router GEMM | LongCat-Flash Lite prefill serving workloads | HPC-Ops Router GEMM vs. SGLang default | 入力スループット: +2.8–5.4% |
| MoE | Qwen3 and Hy3 FP8 MoE serving workloads | HPC-Ops MoE vs. SGLang default | 出力スループット: Qwen3 は同等から +2.7%; Hy3 −4.2% to +6.3% |
数値精度とモデルレベルの忠実性についても、上位ブランチへの統合検証を行いました。BF16 と FP8 の両方でアテンションテストに合格し、Hy3 の FP8 によるグリーディ推論結果は BF16 パスのトークン単位で完全に一致しました。また、Router GEMM は FP32 リファレンスとの比較でも問題なく、グリーディ出力も保持されています。
Qwen3 における HPC-Ops の MoE パスは、Triton との FP32 に対する誤差評価において、コサイン類似度が 0.99974、最大相対誤差が 0.024 という結果を示しました。詳細な設定とケース別の結果は、上位ブランチの PR で確認できます。
What's next
今回の取り組みは、HPC-Ops と SGLang コミュニティによる広範な協力の一部です。今後は SGLang のメンテナーやコントリビューターと連携し、これらの演算子をさらに改善・拡張するとともに、成熟した HPC-Ops の機能を順次上位ブランチへ統合していきます。フィードバック、不具合報告、ベンチマーク結果のご提供を歓迎します。オープンかつ高パフォーマンスな LLM 推論の発展に、一緒に取り組んでいきましょう。
Acknowledgments
これらの演算子を SGLang に実装するために尽力いただいた多くのチームメンバーに感謝いたします:
- Tencent Hunyuan AI Infra — HPC-Ops のアテンション、Router GEMM、MoE 演算子の構築と最適化を行い、SGLang へ貢献いただきました。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。
オープンソースのバックエンドインターフェース、レビュー、設計議論への貢献に感謝します。SGLang の Xiaoyu Zhang (BBuf)、Xinyuan Tong、Ke Bao、そして SGLang チーム全員。
カーネルとパフォーマンス最適化における密接な協力に感謝します。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 などが含まれます。
原文を表示
HPC-Ops is an open-source operator library for LLM inference, deployed in Tencent's large-scale production serving. Its core operators, including Dynamic Attention and Fused MoE, play a critical role in Hunyuan's online inference, reducing TPOT of Hy3 model by up to 48.8%. HPC-Ops Attention, Router GEMM, and MoE are now integrated into SGLang's main branch, bringing these production-proven optimizations to the open-source serving community.
In this blog, we introduce the design of three important operators in HPC-Ops and their integration with SGLang. We then present operator benchmarks and serving results on H20 together with the H200 validation results. The integrations target NVIDIA Hopper GPUs (SM90) and have been validated with Qwen3, Hy3, and LongCat workloads.
Highlights
- Attention: On H20, HPC-Ops dynamic scheduling reaches 2.95× over its static split-KV schedule and is on average 2.25× faster than the best of FlashInfer and FlashAttention in each measured case. In upstream H200 validation, the integrated Hy3-FP8 path with FP8 KV cache improves output throughput by 3.7–5.9% over FlashAttention.
- Router GEMM: On H20, HPC-Ops is 1.30–3.22× faster than FP32 cuBLAS, while its maximum absolute error relative to FP32 cuBLAS is 0.00177, versus 0.06464 for TF32 cuBLAS. In the upstream H200 LongCat-Flash kernel validation, it delivers a 4.31× speedup over the existing FP32 path.
- MoE: On H20, HPC-Ops delivers mean per-batch speedups of 1.08× at TP8 / EP1 and 1.21× at TP1 / EP8 over the best of the SGLang and vLLM baselines on Hy3. In the upstream Qwen3/H200 kernel benchmark, it reaches up to 4.21× over Triton at eight tokens.
- End-to-end serving: On 8× H20 with Hy3-FP8, enabling HPC-Ops Attention and MoE together reduces TPOT by 15.1–48.8% at batch sizes 4–64 and TTFT by 3.3–6.0% at batch sizes 4–16. On 8× H20 with LongCat-Flash-Lite-FP8, enabling HPC-Ops Router GEMM improves input throughput by 5.5–6.1% at batch sizes 4–64.
Attention, routing, and experts: three hot paths in MoE model serving
Production MoE serving rarely resembles the uniform workloads measured in isolated kernel benchmarks. It combines mixed-length Attention work, precision-sensitive routing, and sparse expert execution within the same latency-sensitive path; long-context, multi-turn, and agentic workloads further widen the distribution of live KV lengths. Serving performance therefore depends not only on raw matrix-multiplication throughput, but also on workload balance, numerical fidelity, and overhead control.
These constraints surface in three performance-critical stages of MoE model serving. During decode, Attention work scales with each request's live KV length, making mixed-length batches a load-balancing problem. Router GEMM produces the scores used for top-k selection, where small numerical changes can alter expert choices. The selected experts then process small and uneven token groups, allowing metadata construction, token movement, intermediate storage, and launch overhead to rival the expert GEMMs themselves.
HPC-Ops addresses each stage with a dedicated operator: workload-aware scheduling for Attention, a precision-aware formulation for Router GEMM, and a fused pipeline for MoE that eliminates the standalone gather and reduces launch and intermediate traffic. The upstream integration pairs these operators with SGLang's serving runtime through its native backend and dispatch interfaces. The following sections explain how each operator is designed.
Attention: load balancing for mixed-length decode
During decode, each new token attends over the request's full KV cache, so Attention work scales with the live sequence length. A request with 16K cached tokens therefore carries roughly 16× the KV work of one with 1K. In production, prompt and output lengths vary widely, and continuous batching places requests at different stages of generation in the same launch; a batch therefore routinely mixes short KV caches with sequences tens of thousands of tokens long.
A static split-KV schedule maps work to a fixed launch grid over KV heads, requests, and KV chunks, with one partitioning policy shared across the batch. A static split-KV scheduler generally follows one of two policies, neither of which performs well for mixed-length batches. (1) Fix the split count, and long requests produce much heavier chunks: short-request CTAs finish early while a few long-running CTAs determine the kernel tail. (2) Fix the chunk size instead, and the grid must reserve enough splits for the longest request, leaving shorter requests with empty or nearly empty chunks that still consume scheduling slots. One policy creates uneven work; the other schedules nonexistent work.
Scheduling around live KV work
HPC-Ops replaces the static per-request split with a persistent kernel that dynamically balances KV tiles across CTAs according to the batch's actual length distribution. For each decode batch, an assign kernel builds a global task map from live KV lengths: it slices every sequence into uniform 64-token tiles, sums the tile count across all heads and requests, and divides the total by the number of persistent CTAs to set a per-CTA tile budget. The assignment kernel fills each CTA's bin up to that budget before spilling into the next, so long sequences span multiple CTAs in proportion to their length while short sequences contribute only the tiles they actually have. A minimum-work floor prevents over-partitioning when total work is small, keeping the downstream combine inexpensive. The task map is generated once per decode step from device-side sequence lengths and reused across Transformer layers, amortizing its cost.
At execution time, each CTA drains its assigned bin. For every descriptor, it computes Attention over one or more contiguous KV tiles and writes a partial output with its log-sum-exp statistic; the same resident CTA continues to the next descriptor until its bin is empty. Because each CTA produces only a subset of the partials for a given request, a final combine kernel reads the actual chunk count per request and head and merges the partials under the correct global softmax normalization. The near-equal bin sizes ensure that CTAs finish at roughly the same time, eliminating the kernel tail that a few unusually long requests would otherwise cause.
A fused attention prologue
For Hy3 FP8, HPC-Ops fuses the Attention prologue after the QKV projection: it applies QK-Norm before RoPE, emits Q in FP8 with a per-token, per-head scale, and writes K and V directly into the paged FP8 cache. It passes the quantized Q and its scale directly to the main Attention kernel, avoiding requantization. The fused path eliminates intermediate tensors and their associated HBM round-trips and separate kernel launches in both prefill and decode.
Router GEMM: balancing routing precision and throughput
Router precision directly affects MoE model quality. At each MoE layer, the router projects hidden states into expert scores, and a top-k selection over these scores determines which experts execute. The score differences between the k-th and (k+1)-th expert can be small, so the arithmetic precision of this projection determines whether the correct experts are selected.
To preserve router precision, some production models retain FP32 router weights even when hidden states are BF16. Casting those weights to BF16 enables BF16 Tensor Core throughput but discards low-order mantissa bits that can flip a top-k decision. A full FP32 GEMM preserves all weight precision, but with lower Tensor Core throughput.
A precision-aware BF16 formulation
HPC-Ops resolves this by decomposing the FP32 weight into two BF16 components. It extracts a BF16 high part WhighW_{\mathrm{high}} by direct truncation, then forms a second BF16 component from the scaled residual (W−Whigh)×256(W - W_{\mathrm{high}}) \times 256. The original weight is approximated as W≈Whigh+Wlow/256W \approx W_{\mathrm{high}} + W_{\mathrm{low}} / 256, so the matrix product becomes two BF16 GEMMs whose results are combined with a scale correction to recover the low-order mantissa contribution. A single kernel executes both BF16 multiplications: it loads activation tiles once from shared memory, accumulates both partial results in FP32 registers, applies the 1/2561/256 scaling in the epilogue, and writes the final FP32 router scores to global memory. This formulation recovers precision close to a full FP32 GEMM while running the main arithmetic on BF16 Tensor Cores.
On the framework side, SGLang caches the decomposed weight pair at model load time and reuses it across requests and CUDA graph replays. A shape-aware dispatch selects between the HPC-Ops kernel and the default path at measured crossover points. Below these points, the single FP32 path is faster because the two-product overhead exceeds the Tensor Core gain.
MoE: reducing overhead around small expert GEMMs
During decode, each expert in an MoE layer receives only a handful of tokens. The resulting expert GEMMs are small and memory-bound, and the GPU's SMs are underutilized at these shapes. The problem is compounded by load imbalance: the number of tokens routed to each expert varies across experts and shifts from step to step, making it difficult to spread these small, uneven tiles evenly across the available SMs.
Beyond the expert GEMMs themselves, the operations surrounding them introduce substantial overhead. A conventional MoE path chains separate kernels for routing, gathering tokens into per-expert buffers, Gate-Up GEMM, activation and quantization, Down GEMM, and top-k weighted reduction back to token positions. The gather step materializes a full token tensor in HBM before any matmul begins, and each subsequent stage pays its own kernel launch and HBM round-trip for intermediates. When the GEMMs are small, this surrounding overhead consumes a comparable fraction of the stage's wall time.
A fused, latency-oriented MoE pipeline
For low-batch-size inference, the HPC-Ops MoE backend coordinates routing and index preprocessing, Gate-Up, activation and requantization, Down, and top-k weighted reduction in a low-latency pipeline built around task-map-driven persistent expert GEMMs.
- Routing and index build. Starting from the selected top-k expert IDs, a shared-memory counting pass organizes token–expert assignments into contiguous per-expert output ranges, reducing global atomic pressure and building the routing indices and per-tile task maps consumed directly by the persistent expert GEMMs.
- Gate-Up and activation. The Gate-Up GEMM reads original tokens directly through the routing indices, skipping the standalone gather and its extra HBM traffic. SiLU-and-mul and FP8 requantization then run as one fused kernel whose output the Down GEMM reads directly.
- Occupancy-first, without warp specialization. A single warp group handles both data movement and matrix math rather than reserving separate producer and consumer groups. This raises CTA residency and shifts memory-latency hiding from an intra-CTA software pipeline to cross-CTA hardware scheduling. Persistent grids then consume these task maps and spread the small, uneven expert tiles across the SMs.
- PDL-chained stages. Programmatic Dependent Launch overlaps each downstream kernel launch with the tail of the preceding stage, reducing gaps across Gate-Up, activation, Down, and the final top-k weighted reduction, which restores expert outputs to token order.
Together, these optimizations reduce intermediate traffic and kernel-launch overhead on the critical path.
From HPC-Ops kernels to SGLang
Through SGLang's native backend and dispatch interfaces, HPC-Ops operates directly on the serving runtime's existing state while remaining an independently maintained operator library. Attention consumes paged KV storage and live device-side sequence metadata without an additional layout conversion; Router GEMM reuses preprocessed weights and workspace across requests and CUDA graph replays; and MoE follows SGLang's expert IDs and partitions without additional remapping. These integrations preserve each operator's intended data path while fitting SGLang's existing execution model.
The three integrated operator paths are summarized below:
| HPC-Ops operator | What it optimizes | Precision | Upstream PRs |
|---|---|---|---|
| Attention | Load-balanced mixed-length decode and a fused QK-Norm, RoPE, quantization, and KV-write prologue | BF16 activations; BF16 or FP8 E4M3 KV cache | #30540, #32304 |
| Router GEMM | Precision-aware router projection using BF16 Tensor Cores while retaining FP32 weight information | BF16 activations × FP32 weights → FP32 scores | #30247, #31943 |
| MoE | Low-overhead execution around small and uneven expert GEMMs | BF16 hidden states; FP8 E4M3 expert weights | #30541 |
Getting started
This guide describes how to use the HPC-Ops Attention, Router GEMM, and MoE operators in SGLang.
Install
To install HPC-Ops from source:
git clone https://github.com/Tencent/hpc-ops.git
cd hpc-ops
make wheel
python3 -m pip install dist/*.whl
HPC-Ops is already included in SGLang's official x86_64 development images (lmsysorg/sglang:dev, or lmsysorg/sglang:dev-cu12 for CUDA 12.9), so no separate installation is required when using these images.
Attention and MoE
Attention and MoE are independent backend choices in SGLang and can be enabled separately or together for compatible models such as Qwen3 and Hy3. The following example selects both HPC-Ops backends and enables the FP8 KV-cache Attention path:
python3 -m sglang.launch_server \
--model tencent/Hy3-FP8 \
--tp-size 8 \
--attention-backend hpc_ops \
--kv-cache-dtype fp8_e4m3 \
--page-size 64 \
--moe-runner-backend hpc_ops
For BF16 KV cache, omit --kv-cache-dtype fp8_e4m3. To use only one HPC-Ops operator, specify only the corresponding backend option.
Router GEMM
In SGLang, HPC-Ops Router GEMM retains low-order information from FP32 router weights while executing the matrix math on BF16 Tensor Cores. The integrated path has been validated on LongCat-Flash Chat and Lite and is selected automatically for supported model and router shapes. Once HPC-Ops is installed, a standard LongCat-Flash launch can use it:
python3 -m sglang.launch_server \
--model meituan-longcat/LongCat-Flash-Lite-FP8
Performance evaluation
The HPC-Ops backends currently support NVIDIA Hopper-architecture GPUs and deliver their best performance on H20. The evaluation below covers operator benchmarks on H20, end-to-end SGLang serving on 8× H20, and the H200 results reported in the upstream SGLang pull requests.
H20 operator benchmarks
Attention.
The Attention scheduler's headline benefit appears in mixed-length decode, where requests in the same batch can have very different KV-cache lengths. We evaluate FP8 KV-cache decode from uniform to highly skewed distributions; in the table, A×B denotes A requests with KV length B. To isolate the scheduling effect, we compare HPC-Ops dynamic scheduling with its static split-KV counterpart, while FlashInfer and FlashAttention provide additional baselines. The dynamic-vs-static gain grows with skew, from parity on the uniform 64×0.5K batch to 2.95× on the 1×128K + 31×4K mix. Across all six cases, dynamic scheduling is on average 2.25× faster than the best of FlashInfer and FlashAttention in each case.
*Table 1: Decode latency across KV-length distributions on H20. Lower is better.*
| Decode scenario | HPC-Ops dynamic | HPC-Ops static | FlashInfer | FlashAttention | Dynamic vs. static |
|---|---|---|---|---|---|
| 64×0.5K | 0.013 ms | 0.013 ms | 0.050 ms | 0.025 ms | 1.00× |
| 64×4K | 0.033 ms | 0.043 ms | 0.221 ms | 0.095 ms | 1.32× |
| 32×0.125K + 32×4K | 0.020 ms | 0.033 ms | 0.119 ms | 0.053 ms | 1.59× |
| 2×32K + 30×4K | 0.032 ms | 0.056 ms | 0.169 ms | 0.094 ms | 1.76× |
| 1×64K + 15×4K | 0.042 ms | 0.097 ms | 0.118 ms | 0.065 ms | 2.32× |
| 1×128K + 31×4K | 0.063 ms | 0.186 ms | 0.220 ms | 0.097 ms | 2.95× |

Router GEMM.
We evaluate Router GEMM first with a generic K=4096,N=192K = 4096, N = 192 sweep. Across the measured M values, HPC-Ops is 1.30–3.22× faster than FP32 cuBLAS and 1.25–1.78× faster than TF32 cuBLAS. Using FP32 cuBLAS as the numerical reference, the maximum absolute error remains at or below 0.00177, compared with 0.06464 for TF32.
*Table 2: BF16 × FP32 Router GEMM latency at K = 4096, N = 192 on H20. Lower is better.*
| M | HPC-Ops | FP32 cuBLAS | TF32 cuBLAS | Speedup vs. FP32 | Speedup vs. TF32 |
|---|---|---|---|---|---|
| 1 | 11.200 µs | 14.576 µs | 14.048 µs | 1.30× | 1.25× |
| 16 | 11.744 µs | 23.808 µs | 18.752 µs | 2.03× | 1.60× |
| 48 | 12.144 µs | 31.008 µs | 20.064 µs | 2.55× | 1.65× |
| 96 | 13.904 µs | 31.760 µs | 24.720 µs | 2.28× | 1.78× |
| 208 | 17.088 µs | 39.280 µs | 28.928 µs | 2.30× | 1.69× |
| 512 | 26.992 µs | 86.976 µs | 44.736 µs | 3.22× | 1.66× |
| 1024 | 50.640 µs | 110.480 µs | 68.544 µs | 2.18× | 1.35× |
| 2048 | 76.688 µs | 198.576 µs | 100.800 µs | 2.59× | 1.31× |
| 4096 | 141.120 µs | 403.728 µs | 205.760 µs | 2.86× | 1.46× |

We then retest the two router shapes used by LongCat-Flash. Within SGLang's model-aware dispatch ranges, HPC-Ops delivers 1.06–2.83× speedup for the Chat shape and 1.09–2.46× for the Lite shape over the SGLang default.
*Table 3: LongCat-Flash Router GEMM latency over the SGLang dispatch ranges on H20. Lower is better.*
| M | Chat default | Chat HPC-Ops | Speedup | Lite default | Lite HPC-Ops | Speedup |
|---|---|---|---|---|---|---|
| 64 | 39.19 µs | 37.01 µs | 1.06× | — | — | — |
| 128 | 74.18 µs | 59.36 µs | 1.25× | 25.83 µs | 23.72 µs | 1.09× |
| 256 | 100.03 µs | 82.47 µs | 1.21× | 41.87 µs | 34.01 µs | 1.23× |
| 512 | 190.37 µs | 141.73 µs | 1.34× | 71.89 µs | 41.95 µs | 1.71× |
| 1024 | 380.68 µs | 207.00 µs | 1.84× | 108.64 µs | 74.09 µs | 1.47× |
| 2048 | 961.15 µs | 339.04 µs | 2.83× | 235.81 µs | 106.81 µs | 2.21× |
| 4096 | 1469.70 µs | 670.14 µs | 2.19× | 423.52 µs | 172.44 µs | 2.46× |
| 8192 | 2881.00 µs | 1333.84 µs | 2.16× | 835.22 µs | 339.66 µs | 2.46× |

MoE.
For MoE, we benchmark the full fused operation under Hy3 shapes at TP8 / EP1 and TP1 / EP8 against SGLang, vLLM Triton, and vLLM CUTLASS. Taking the lowest latency among the three baselines in each row, HPC-Ops delivers a mean per-batch speedup of 1.08× at TP8 / EP1 and 1.21× at TP1 / EP8, with the largest gains at the small-to-mid batch sizes common in low-latency decode.
*Table 4: Hy3 MoE latency at TP8 / EP1 on H20. Lower is better.*
| Batch | HPC-Ops | SGLang | vLLM Triton | vLLM CUTLASS | Speedup vs. best |
|---|---|---|---|---|---|
| 16 | 85.7 µs | 88.6 µs | 124.2 µs | 209.2 µs | 1.03× |
| 32 | 124.0 µs | 137.2 µs | 184.3 µs | 275.6 µs | 1.11× |
| 64 | 147.2 µs | 164.4 µs | 374.9 µs | 330.3 µs | 1.12× |
| 128 | 161.5 µs | 179.9 µs | 302.9 µs | 345.3 µs | 1.11× |
| 256 | 170.1 µs | 191.5 µs | 310.9 µs | 351.6 µs | 1.13× |
| 512 | 194.5 µs | 230.1 µs | 331.6 µs | 369.2 µs | 1.18× |
| 1024 | 281.4 µs | 300.5 µs | 652.7 µs | 438.3 µs | 1.07× |
| 2048 | 491.8 µs | 522.5 µs | 731.5 µs | 794.4 µs | 1.06× |
| 4096 | 872.0 µs | 899.2 µs | 1366.0 µs | 1230.7 µs | 1.03× |
| 8192 | 1695.0 µs | 1712.7 µs | 2216.8 µs | 2362.9 µs | 1.01× |
| 16384 | 3241.9 µs | 3257.1 µs | 4329.1 µs | 4364.4 µs | 1.00× |
*Table 5: Hy3 MoE latency at TP1 / EP8 on H20. Lower is better.*
| Batch | HPC-Ops | SGLang | vLLM Triton | vLLM CUTLASS | Speedup vs. best |
|---|---|---|---|---|---|
| 4 | 118.6 µs | 183.1 µs | 147.4 µs | 140.4 µs | 1.18× |
| 8 | 136.7 µs | 231.5 µs | 192.8 µs | 170.7 µs | 1.25× |
| 16 | 149.8 µs | 234.2 µs | 198.4 µs | 263.5 µs | 1.32× |
| 32 | 153.6 µs | 475.3 µs | 214.6 µs | 264.4 µs | 1.40× |
| 64 | 166.5 µs | 477.3 µs | 358.1 µs | 266.8 µs | 1.60× |
| 128 | 213.5 µs | 482.3 µs | 251.7 µs | 272.6 µs | 1.18× |
| 256 | 386.2 µs | 494.3 µs | 454.9 µs | 493.5 µs | 1.18× |
| 512 | 705.5 µs | 970.7 µs | 691.7 µs | 741.7 µs | 0.98× |
| 1024 | 1342.6 µs | 1476.8 µs | 1369.1 µs | 1359.1 µs | 1.01× |
| 2048 | 2513.9 µs | 2871.2 µs | 2668.7 µs | 2530.4 µs | 1.01× |

H200 operator validation
The upstream PRs also include H200 serving results, confirming that the performance gains generalize across Hopper GPUs.
*Table 6: Operator validation reported in the upstream SGLang pull requests.*
| Operator | Upstream validation workload | Comparison | Result |
|---|---|---|---|
| FP8 Attention | Hy3-FP8 with FP8 KV cache; mixed-length decode | HPC-Ops dynamic scheduling vs. HPC-Ops static split-KV | Output throughput +2.0%; total throughput +2.0%; median TTFT −5.3% |
| BF16 Attention | Qwen3 with BF16 KV cache; mixed-length decode | HPC-Ops dynamic scheduling vs. HPC-Ops static split-KV | Output throughput +3.0%; mean E2E latency −2.8%; mean TPOT −2.8% |
| Router GEMM | LongCat-Flash Chat and Lite router shapes | HPC-Ops Router GEMM vs. SGLang default | Kernel speedup: 1.56–4.31× |
| MoE | Qwen3 FP8 MoE workloads from 1 to 4,096 tokens | HPC-Ops MoE vs. SGLang Triton fused experts | Kernel speedup: 0.89–4.21× |
End-to-end performance
The end-to-end evaluation runs on 8× NVIDIA H20 GPUs against the corresponding default SGLang implementations. On Hy3-FP8 at TP8 with FP8 KV cache, we measure the combined serving impact by enabling HPC-Ops Attention and MoE together. On LongCat-Flash-Lite-FP8, only Router GEMM is measured. We also summarize the H200 serving validation reported in the upstream SGLang pull requests.
Hy3-FP8: Attention and MoE.
With an 8K input and 4K output, HPC-Ops reduces TPOT by 3.3% at batch size 1. Across batch sizes 4–64, the reduction grows to 15.1–48.8%.
*Table 7: Hy3-FP8 TPOT with FP8 KV cache and HPC-Ops Attention and MoE enabled together. Lower is better.*
| Batch | SGLang default | HPC-Ops | Improvement |
|---|---|---|---|
| 1 | 7.56 ms | 7.31 ms | 3.3% |
| 4 | 11.10 ms | 9.42 ms | 15.1% |
| 8 | 14.29 ms | 10.76 ms | 24.7% |
| 16 | 22.90 ms | 13.09 ms | 42.8% |
| 32 | 35.33 ms | 18.09 ms | 48.8% |
| 64 | 40.70 ms | 23.81 ms | 41.5% |
With an 8K input, HPC-Ops improves TTFT by 3.3–9.0% across batch sizes 1–16.
*Table 8: Hy3-FP8 TTFT with FP8 KV cache for an 8K input. Positive improvements mean lower latency.*
| Batch | SGLang default | HPC-Ops | Improvement |
|---|---|---|---|
| 1 | 460.67 ms | 419.43 ms | 9.0% |
| 4 | 1612.47 ms | 1533.66 ms | 4.9% |
| 8 | 3210.93 ms | 3018.68 ms | 6.0% |
| 16 | 5810.53 ms | 5619.48 ms | 3.3% |
At batch size 16, we also sweep the input length from 2K to 8K with chunked prefill and prefix caching disabled. HPC-Ops improves TTFT by 2.3–8.9% across the three input lengths.
*Table 9: Hy3-FP8 TTFT with FP8 KV cache across input lengths at batch size 16. Positive improvements mean lower latency.*
| Input length | SGLang default | HPC-Ops | Improvement |
|---|---|---|---|
| 2K | 1509.98 ms | 1375.95 ms | 8.9% |
| 4K | 2779.46 ms | 2715.18 ms | 2.3% |
| 8K | 5810.53 ms | 5619.48 ms | 3.3% |
LongCat-Flash-Lite-FP8: Router GEMM.
Router GEMM is evaluated separately with a 1,024-token input and a 128-token output. Input throughput remains near parity at batch size 1, with a 0.5% improvement, and improves by 5.5–6.1% across batch sizes 4–64.
*Table 10: LongCat-Flash-Lite-FP8 input throughput with HPC-Ops Router GEMM. Higher is better.*
| Batch | SGLang default | HPC-Ops Router GEMM | Improvement |
|---|---|---|---|
| 1 | 16,612.11 tok/s | 16,695.77 tok/s | 0.5% |
| 4 | 54,466.27 tok/s | 57,810.27 tok/s | 6.1% |
| 8 | 60,425.93 tok/s | 63,833.96 tok/s | 5.6% |
| 16 | 61,995.23 tok/s | 65,539.10 tok/s | 5.7% |
| 32 | 62,833.85 tok/s | 66,306.52 tok/s | 5.5% |
| 64 | 62,841.93 tok/s | 66,422.92 tok/s | 5.7% |

H200 serving validation
The upstream pull requests also evaluated the integrated operators in the SGLang serving loop on H200, providing a model-level integration check beyond the primary H20 tuning target.
*Table 11: Model-level serving validation reported in the upstream SGLang pull requests.*
| Operator | Upstream validation workload | Comparison | Result |
|---|---|---|---|
| Attention | Hy3-FP8 with FP8 KV cache serving workloads | HPC-Ops Attention vs. FlashAttention | Output throughput: +3.7–5.9% |
| Router GEMM | LongCat-Flash Lite prefill serving workloads | HPC-Ops Router GEMM vs. SGLang default | Input throughput: +2.8–5.4% |
| MoE | Qwen3 and Hy3 FP8 MoE serving workloads | HPC-Ops MoE vs. SGLang default | Output throughput: Qwen3 from parity to +2.7%; Hy3 −4.2% to +6.3% |
The upstream integrations were also checked for numerical and model-level fidelity. Attention tests passed across BF16 and FP8, and the evaluated Hy3 FP8 greedy outputs matched the BF16 path token for token. Router GEMM passed comparisons against the FP32 reference and preserved greedy outputs. For Qwen3, the HPC-Ops MoE path matched Triton's error against FP32, with a cosine similarity of 0.99974 and a maximum relative error of 0.024. Full configurations and per-case results are available in the upstream PRs.
What's next
This work is part of a broader collaboration between HPC-Ops and the SGLang community. We will continue working with SGLang maintainers and contributors to improve and extend these operators and upstream additional HPC-Ops capabilities as they mature. Feedback, issues, and benchmarks are very welcome, and we look forward to advancing open, high-performance LLM inference together.
Acknowledgments
We would like to thank the many people across teams who worked together to bring these operators to SGLang:
- Tencent Hunyuan AI Infra — for building and optimizing the HPC-Ops Attention, Router GEMM, and MoE operators and contributing them to SGLang. 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.
- SGLang — for the open backend interfaces, reviews, and design discussions. Xiaoyu Zhang (BBuf), Xinyuan Tong, Ke Bao, and the entire SGLang team.
- 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デイリーブリーフで今日の重要ニュースをまとめ読み