エージェント支援による SGLang の開発(18 分読了)
本文の状態
日本語全文を表示中
詳細モードで約43分の本文を読めます。
同じ出来事の情報源
この情報源を基点に整理
TLDR AI
SGLang チームは、エージェントワークフローを再利用可能な SKILL.md ファイルやベンチマーク契約、レビューループ、本番環境のデバッグプレイブックに変換する方法を明らかにした。これにより、実行・テスト・レビュー可能な手順的エンジニアリング知識としてのエージェント価値が強調された。
Source Article
元記事を日本語で読む
本文に関係しない購読案内、埋め込み通知、サイト内プロモーションは除いています。
SGLang の開発は、もはや単なるコードの修正にとどまらなくなっています。現在では、同じリポジトリが LLM サービング、分散ランタイム、GPU カーネル、拡散パイプライン、モデル固有の実行パス、そして本番環境でのインシデント対応までをカバーしています。
かつては、これらのワークフローの多くが開発者個人の記憶に依存していました。特定のモデルの起動方法やプロファイルトレースの読み方、CUDA クラッシュ時のデバッグで最初に確認すべきログ、パフォーマンス改善 PR に含めるべきベンチマークなどです。しかし、エージェントツールの成熟に伴い、こうした経験知を SKILL.md ファイル、スクリプト、ベンチマーク契約、レビューループとして実行可能な形に変換できるようになっています。
SGLang のエージェント開発においては、LLM および拡散モデルの両方に対応する一連のスキルが既に確立されています:
- SGLang `.claude/skills` は SGLang リポジトリ内部で管理されており、CUDA クラッシュのデバッグ、カーネル統合、テスト、CI、プロファイリング、本番環境でのトリアージ、ソースツリー規約など、リポジトリレベルの開発ワークフローを網羅しています。
- SGLang diffusion `.claude/skills` は拡散モデル固有のワークフローに焦点を当てており、新しい拡散モデルの追加、デノイズパスのベンチマークとプロファイリング、パフォーマンスオプションのチューニング、量子化パイプラインの検証などを含みます。
「BBuf/AI-Infra-Auto-Driven-SKILLS」リポジトリでは、クロスフレームワークのサービングベンチマーク、キャパシティプランニング、プロファイルとパイプライン分析、モデル計算シミュレーション、SGLang 向けの手動レビュー、本番環境でのインシデント対応、SGLang やその他のオープンソース推論フレームワークにおける SOTA ループ、そしてモデル PR の履歴管理などについて取り上げています。
「kernel-design-agents」は KDA プロジェクトであり、MLSys 2026 FlashInfer Kernel Contest で優勝したソリューションです。
「BBuf/KDA-Pilot」では、KDA スタイルのエージェントカーネルワークフローを SGLang に適用しています。公開されている B200 の拡散サマリーは現在、10 の SGLang カーネルタスクを追跡しています。表のほとんどの行は KDA-Pilot の公開ベンチマーク台帳から来ていますが、「residual_gate_add」については、元のタスクベースラインが変更された後にマージされた SGLang 統合 PR で報告された B200 の高速化率が使用されています。KDA-Pilot に由来する作業は現在、3 つの SGLang 統合 PR に反映されています。
これらを総合すると、これらの取り組みは同じ方向を指し示しています。エージェントが持つ価値は、実行可能な手順や再現可能な実験、検証可能な証拠といった手続的エンジニアリング知識から生まれるのです。
1. TL;DR
- エージェントが最も有用なのは、SGLang において明確に定義されたワークフローに沿って作業を継続できる場合です。ベンチマーク測定、プロファイリング、カーネル API のログ取得、拡散パイプラインの追加、本番環境でのインシデント再現、そして SOTA ループはすべてスキルとしてエンコード可能です。
SGLang スキルとは、実行可能な開発手順のことです。debug-cuda-crash、sglang-diffusion-benchmark-profile、そして llm-torch-profiler-analysis といったスキルにおいて重要なのは、事前チェック、失敗時の強制停止ポイント、成果物の契約条件、再現コマンド、そして結果のフォーマットです。
パフォーマンス改善においては、プロファイルによるエビデンスが中心となります。SGLang のプロファイラー・スキルは、固定されたカーネル表、オーバーラップの機会を示す表、および融合パターンの表を生成します。KDA-Pilot はこれを拡張し、同じ ABI を持つベースラインと候補の比較、実際のワークロードへの適用、正しさの確認ゲート、NCU(NVIDIA Compute Profiler)によるエビデンス、そして形状ごとの結果を取り入れています。
長期的な最適化は、すでに「ループ・エンジニアリング」へと移行しつつあります。SGLang の SOTA(State-of-the-Art)パフォーマンス・ループでは、「SOTA を追う」という行為を、公平なベンチマーク、ギャップの判断、プロファイリング、パッチ適用、再検証というステップに分解しています。Humanize/RLCR は外部レビューを追加し、Codex Goal は同様のループをより低い調整コストで実行できます。
レビューの重要性も増しています。エージェントはより多くの実験を実行できるようになりましたが、同時に「ありそうに見える」変更も多数生成するため、慎重なレビューが必要となります。開発者たちは次第に、問題の定義、エビデンスの選定、ワークフローの設計、そして結果が生産環境向けとして準備ができているかの判断を自ら行うようになっています。
2. なぜ SGLang はエージェント支援型開発に適しているのか
SGLang は、LLM およびマルチモーダルモデル向けの高性能なサービングフレームワークです。モデルファミリーやハードウェアパスが拡大するにつれ、開発現場ではいくつかの recurring な問題が顕在化しています:
LLM の処理パスは複雑です。パフォーマンスの問題一つが、Python ランタイム、スケジューラ、CUDA グラフ、Triton/CUDA カーネル、FlashInfer/FlashAttention、分散集合演算、そしてモデル固有のラッパーにまたがる可能性があります。
Diffusion モデルの処理パスも同様です。デノイズ処理が遅くなる要因には、パイプラインやステージの分割、DiT ブロック、アテンションバックエンド、torch.compile によるグラフ断絶、CFG/SP の並列化、VAE、あるいはカスタム融合カーネルなどが考えられます。
検証には多大なコストがかかります。多くの変更は、H100、H200、B200、RTX 5090 といった実機上で、実際のモデルとワークロードを用いてテストする必要があります。ローカルでの単体テストだけでは不十分です。
プロファイリング結果を手動で再利用するのは困難です。一つのトレースには数百ものカーネル起動が含まれており、Perfetto を人手で読み解くのは容易ではありません。その過程では、カーネルと Python ソースコードの対応関係を見逃したり、プリフェッチ(prefill)とデコードを混同したりするリスクがあります。
開発者はプロファイラ出力を読み込むうちにノウハウを蓄積します。「どのカーネル名がモデルロジックに対応するか」「どのような起動パターンがグラフ断絶を示唆するか」「NCCL/アテンション/MLP のレイアウトで何が正常か」といった知見です。しかし、その知識が特定の一人の頭の中だけで完結している限り、次のタスクではそれを再利用することはできません。
パフォーマンスの結論は、文脈に大きく依存します。GPU の種類や形状、バッチサイズ、並列処理の設定、精度、バックエンド、コンパイル状態など、あらゆる要素が結果を変化させます。単体のマイクロベンチマークだけでは、実際のモデルレベルでのメリットを証明することは難しく、固定された負荷条件下でスループット、レイテンシ、メモリ使用量、精度、安定性を繰り返し検証する、エンドツーエンドの長時間実行テストプロセスが必要です。このプロセスは手間と時間を要します。
これらの課題には、エージェントが自然に適合します。サーバーの起動、ワークロードの修正、トレースの収集、プロファイル行の選別、テストの追加、実験結果の記録など、すべての作業には明確な入力と出力があり、スクリプト化や反復実行に適しています。開発者が定義すべきは境界線です。同じベンチマーク設定、同じプロファイル解釈ルール、同じ精度ゲート、そしてエージェントがコードの変更を停止する条件です。
ここで議論しているエージェントは、エンジニアリングワークフローによって制約された実行エンジンです。繰り返される SGLang の開発手順はスキルとして捉えられ、エージェントに反復実行、証拠収集、状態追跡を任せることができます。開発者は依然として目標の定義、証拠の評価、変更が実際のサービングパスに含まれるべきかのレビューを担当します。
3. プロンプトエンジニアリングから SKILL へ:プロトコルと例
SGLang フレームワークにおいて、有用なスキルは少なくとも以下の問いに答えられるものでなければなりません:
| 質問 | 習得すべきスキル |
|---|---|
| 使用タイミング | トリガーシナリオ、対応モデル、対応ハードウェア、および不可避のケース |
| 開始方法 | 事前チェック、環境変数、リポジトリの状態、依存関係の確認、およびモデル設定 |
| 検証方法 | ベンチマークコマンド、プロファイルコマンド、テストエントリーポイント、および精度ゲート |
| 判断基準 | 出力テーブル、失敗モード、優先順位、リスクカテゴリ、およびフォールバック条件 |
| 納品方法 | アーティファクトディレクトリ、結果スキーマ、PR 説明文、再現コマンド、およびレビュー要件 |
SGLang エージェント関連のスキルは、異なるレイヤーにまたがっています。ソースコードへの直接変更に関わるものとしては、デバッグやテストの実施、拡散モデルの追加、ベンチマークおよびプロファイルワークフローの構築などが挙げられます。一方、クロスフレームワーク間のベンチマーク、キャパシティプランニング、計算リソースのシミュレーション、本番環境でのインシデント対応、プルリクエストの最適化に関する知見、人間によるレビュープロセス、そして Humanize や RLCR といったより高レベルなワークフローを支援するスキルも含まれます。
3.1 Current Skill Stack
現在、SGLang エージェント関連で一般的に使用されているスキルは、以下のグループに分類されます。
| レイヤー | 代表的なスキル / プロジェクト | 解決する課題 |
|---|---|---|
| CUDA クラッシュ | `debug-cuda-crash` | カスタム演算子やカーネル API の境界付近での入力を記録し、例外をキャッチしてダンプを取得することで、一時的なクラッシュをオフラインで分析可能なサンプルに変換します |
| LLM ベンチマーク | `llm-serving-auto-benchmark` | SGLang および他の OpenAI 互換推論スタック全体で、公平かつ制限付きの再開可能なサービングベンチマーク検索を実行します |
| キャパシティプランニング | `llm-serving-capacity-planner` | SGLang および他の推論フレームワークの起動ログを解析し、重みメモリ、KV キャッシュ予算、CUDA グラフオーバーヘッド、リクエストキャパシティ、および OOM 負荷について説明します |
| トレーストリアージ | `llm-torch-profiler-analysis` | 固定されたカーネル、オーバーラップの機会、および融合パターンのテーブルを生成し、カーネルを Python ソースコードにマッピングします。同じ統一ワークフローは AI-Infra にも存在し、クロスフレームワークでの利用が可能です |
| パイプライン/レイヤー分析 | `llm-pipeline-analysis` | torch プロファイラトレースを順次パス、レイヤー、およびカーネルフローにスライスして、定常状態のパス、ボトルネックとなるレイヤタイプの種類、および Perfetto の時間範囲を特定します |
| モデル計算シミュレーション | `model-compute-simulation` | LLM 向けの演算子レベルの計算テンプレートを構築し、テンソル形状、FLOPs、MFU、カーネルから演算へのマッピング、および並列化に関する仮定シナリオを推定します |
| Diffusion ベンチマーク/プロファイル | `sglang-diffusion-benchmark-profile` | デノイズレイテンシ、パフォーマンスダンプ、および torch プロファイラトレースをキャプチャし、同時に実行が実際にネイティブの SGLang Diffusion バックエンドを使用していることを最初に確認します |
| Diffusion モデルの追加 | `sglang-diffusion-add-model` | Diffusers または参照パイプラインから新しい Diffusion モデルを、SGLang のパイプライン/ステージ/モデル/構成構造に追加します |
| Diffusion パフォーマンスチューニング | `sglang-diffusion-performance` | torch.compile、ウォームアップ、SP/CFG 並列化、オフロード、アテンションバックエンド、および量子化などのパフォーマンス設定を選択します |
| 本番環境トリアージ | `sglang-prod-incident-triage` | ライブサーバーバンドルを収集し、失敗したリクエストを保存して再生した後、集中的なクラッシュ/ハング/プロファイルツールへルーティングします |
| SGLang レビュー / PR 履歴 | `sglang-humanize-review` および `model-pr-history-knowledge` | 実際のメンテナーの議論パターンに対して SGLang パッチをレビューし、PR 駆動型のモデル進化履歴を変更されたソースコードに密接に保持します |
| SGLang SOTA パフォーマンスループ (Loop Engineering) | `sglang-sota-humanize-loop` | まず、SGLang を要求されたオープンソース推論フレームワークと比較し、その後、ギャップの判断、プロファイリング、パッチ適用、再検証を Humanize/RLCR ループに組み込みます |
見落としがちな手順を実行可能なプロトコルに変換し、ワークフローの起動、再開、レビューを可能にします。
3.2 最近の最適化とワークフロー例
以下の事例は、直近でマージされた SGLang の PR に基づいています。表では、ベンチマークやプロファイリング、ローカライズ、コード変更、テスト、再検証といった、一連のエンジニアリングプロセス全体に焦点を当てています。
| ケース | 結果 | 重要なポイント |
|---|---|---|
| ルーターにおける長文コンテキストのトークン化重複排除、SGLang PR #28744 | DeepSeek-V4-Flash デプロイメントにおいて、60k/125k トークンのプロンプトでのアイドル時の TTFT がそれぞれ約 29% / 41% 低下。60k トークン負荷下では TTFT が 34%–49% 低下 | エージェントがキャッシュ対応ルーティング、チャットエンコーダーの整合性、エンジン側の input_ids フォールバック、およびプロキシボディ構築を統合的に処理し、ルーターとエンジンでのトークン化の重複を回避 |
| Qwen3-Next FlashInfer による allreduce 融合、SGLang PR #22664 | H100 TP=4 環境で、リクエストスループットが 5.49 req/s から 9.41 req/s に向上(約 +71.4%)。平均 TTFT は 456.24 ms から 167.54 ms に低下 | これはプロファイル駆動型の LLM 集合演算最適化であり、非融合のクロスデバイスリダクションがプリフィルを支配していた。融合された allreduce パスは MMLU/GSM8K の精度チェックで検証済み |
| Cohere2Moe NVFP4 融合 MoE パス、SGLang PR #27401 | CohereLabs/command-a-plus-05-2026-w4a4 を 1x B300 で実行。チャットで前回の SGLang デフォルトより +26%、要約で +21% スループットが向上し、同環境での他のオープンソース推論フレームワークをそれぞれ +4.1% / +6.8% 上回った | この変更によりルーティングセマンティクスが完成し、既存の flashinfer_trtllm NVFP4 融合 MoE カーネルを実際のモデルパスで正しく使用可能となった。GSM8K/MMLU の検証も実施 |
| Kimi Delta Attention CuteDSL プリフィルカーネル(SM100)、SGLang PR #27488 | moonshotai/Kimi-Linear-48B-A3B-Instruct において、B200 での Delta Attention プリフィルが Triton より 1.08x–1.52x 高速化。GSM8K のスコアは 0.915 から 0.920 に向上し、現実的なゲート値に対応する新規回帰テストを追加 | このカーネルタスクでは、モデルのゲート分布、数値オーバーフロー、ホストオーバヘッド、実モデルでの精度、およびユニットテストを網羅し、最適化がマージ可能となるまで対応 |
| スペクトルプログレッシブ拡散、SGLang PR #27524 | RTX A6000 環境での報告によると、FLUX.1, FLUX.2, Z-Image, Wan, Qwen-Image のノイズ除去速度がそれぞれ 1.63x, 1.77x, 2.07x, 2.32x, 1.6x 向上 | これは拡散側のシステム最適化であり、初期のノイズ除去は低い潜在解像度で実行され、高周波の詳細が重要となる段階で GPU DCT アップサンプリングにより完全解像度を復元 |
| LTX-2 VAE デコードのチャネルラスト 3D、SGLang PR #27431 | LTX-2 のデコードステージが 5.41 s から 3.84 s に改善(約 1.41x)。ピーク確保メモリは 71.81 GiB から 62.12 GiB に減少し、約 9.7 GiB の節約 | プロファイルにより Conv3d とレイアウト変換がボトルネックと特定されたため、因果パディングでメモリフォーマットを維持し、ローダーポリシーを単一 GPU 向け LTX-2 に接続する修正を実施 |
これらの例では、エージェントは主にワークフローの執行を通じて貢献します。具体的には、ベンチマークの実行、プロファイルの読み込み、Python ソースコードの特定、コードの変更、テストの追加、再検証、PR 記述の準備などです。スキルがなければ、多くの手順で手動でのリマインドが必要になります。しかし、これらがスキルとしてエンコードされれば、ワークフローを繰り返すことははるかに容易になります。
4. プロファイリング、レビュー、ループエンジニアリング
SGLang のパフォーマンス改善においてよくある間違いは、実行時間の合計値だけを見たり、Perfetto を数分間開いて直感で「どこかを融合させるべきだ」と判断したりすることです。これはエージェントにとって特に危険です。視覚的にホットなカーネルを真のボトルネックと誤認する可能性が高いためです。
実際には、2 つのプロファイリングスキルが組み合わせて使われることが一般的です。llm-torch-profiler-analysis は最初のトレースの選別を担当し、グローバルなプロファイル情報を 3 つの固定されたテーブルに変換します。
Kernel Table: 各ステージごとの GPU 時間のシェア率、起動回数、カーネルカテゴリを要約し、可能な限りカーネルを Python ソースコードや CPU オペレーションにマッピングします。
Overlap Opportunity Table:排他的・非表示時間の共有、依存リスク、カーネルカテゴリを用いて、残りの重複可能性や余裕を特定します。
Fuse Pattern Table:SGLang やその他のオープンソース推論フレームワーク、カーネルライブラリにおける融合・重複パスのソースに裏打ちされたパターンカタログとトレースを比較します。
これらの表は、最初の質問群への回答となります。具体的には、どの処理段階とカーネルがどれだけの GPU 時間を消費し、それらが Python のどの行に対応するか、そして学習すべき既存の融合(fuse)や重なり(overlap)の経路が存在するかどうかです。SGLang が他の推論フレームワークに比べて劣っている場合、コード変更を開始する前にプロファイラー表がその差の原因を説明してくれるはずです。
次のステップは llm-pipeline-analysis です。グローバルなボトルネックが特定された後でも、それがどのフォワードパスや層タイプ、そしてカーネルフローに属するのかを知る必要があります。この手法では Chrome トレースの JSON ファイルとモデルの config.json を読み込み、層境界を定義するアンカーカーネルを用いてトレースデータをフォワードパスと層に分割します。その結果、より深い分析のための複数の表が生成されます。
「フォワードパスのサマリー」では、コールドスタートと定常状態を明確に分離し、ウォームアップが最適化の目標にならないようにしています。
「レイヤーごとのタイムライン」では、各層における実時間(wall time)、合計継続時間、および MLA、MoE、GEMM、NCCL、MHC、Hadamard といったカテゴリ別の割合を報告します。 (原文の技術表記: Forward pass summary、Per-layer timeline)
レイヤークラスターの統計情報:特に、compress_ratios を持つ NSA/ハイブリッドアテンションモデルなど、層構造が交互に切り替わるモデルにおいて有用です。このようなモデルでは、C4_LIGHT、C128_HEAVY、HASH、またはその他の層タイプがレイテンシを支配することがあります。 (原文の技術表記: Layer cluster statistics)
- 「計算フロー表」: 代表的なレイヤーを具体的なカーネルフローに展開し、ホットネス(頻度)、相対タイムスタンプ、入力次元情報を付与することで、Perfetto への戻り作業が容易になります。 (原文の技術表記:
Compute flow table)
プロファイリング分析は、したがって2段階のプロセスとなります。まず llm-torch-profiler-analysis が完全なトレース内の主要な競合を特定します。次に llm-pipeline-analysis が、定常状態の順方向パスや代表的な層、具体的なカーネルフローに基づいて問題を具体化します。
最初のステップでは直感に頼って方向性を選ぶことを避け、2つ目のステップではモデル構造内の層タイプごとの違いを見落としながら1つのグローバルホットカーネルを凝視するのを防ぎます。
4.1 Humanize/RLCR: ループへの外部レビューの追加
人間による支援は、長期にわたるタスクにおける状態管理とレビューを可能にします。SGLang のパフォーマンス向上のような高リスクな課題では、通常、一度の実装で完了することはなく、ベンチマーク、プロファイリング、パッチ適用、元への戻し、方向転換、再検証といった多くの試行錯誤のサイクルを経ることになります。
Humanize はこのプロセスを2つのステージに分割します。まず最初のステージとして humanize-gen-plan を実行し、ドラフト要件から構造化された plan.md を生成します。これには、ゴールの説明、受容基準、正負のテストケース、パス境界、マイルストーン、実装上の注意点が含まれます。
- RLCR ループを次に実行します。
humanize-rlcrはplan.mdからループを開始し、各ラウンドで Claude Code が.humanize/rlcr//round--prompt.mdを読み込み、実装とコミット、サマリーの作成を行います。その後、Codex Review が状態ファイルやサマリー、Git のクリーンliness、レビュー結果、未解決の質問、最大反復条件、その他のゲートを確認します。「タスク完了」という単なる宣言だけではループを終了させることはできません。
この仕組みは、SGLang の SOTA パフォーマンスループにおける実行と検証の基盤となります。Claude Code はベンチマークの実行、プロファイルの読み込み、SGLang コードの変更、そして再検証を行います。Codex Review では、各ラウンド終了時にエビデンス、状態、リスクを確認します。これは PR 化されるタスクや、サービングの正しさに影響を与えるタスク、あるいは数日間にわたる複数回の実験を要するタスクに特に適しています。
実際には、エージェントがいきなり実装に飛び込まないよう、コマンドの実行順序は明示的に指定する必要があります。
1. Write a task draft under artifact_root/draft.md.
2. Run humanize-gen-plan to generate artifact_root/plan.md.
3. Start humanize-rlcr from artifact_root/plan.md.
4. Keep all decisions, summaries, and review state in the local Humanize workspace.
4.2 SGLang SOTA パフォーマンスループ(ループエンジニアリング)
単一のスキルで一つのタスクを安定させることは可能です。しかし、十数回の実験ラウンドを経ると、新たな問題が浮き彫りになります。「どの候補が最良か」「どの方向性がすでに失敗したのか」「直前の NCU レポートは何を示しているか」「ベンチマークは依然としてベースラインと整合しているか」「いつ停止すべきか」といった問いです。これらの状態情報は、チャットのコンテキスト内にのみ存在させておくことはできません。
SGLang SOTA パフォーマンスループとは、Humanize/RLCR を基盤としたループエンジニアリングのワークフローです。ここでいう「SOTA(State of the Art)」とは、固定された実験条件下における最良の再現可能な結果を指します。具体的には、同一モデル、同一ハードウェア、同一 GPU 数、同一精度、同一ワークロード、同一 SLA、同一フレームワークコミット、そして同一サービングパラメータという条件です。このループが問うのは、SGLang がこれらの条件下で現在の最良の再現可能な結果に到達できるかどうかです。
図 1: SGLang の SOTA パフォーマンスループ。まず固定された公平なベンチマークで再現可能なベースラインを確立します。その後のギャップ判定、プロファイリング、パイプライン分析、パッチ適用、再検証は「Humanize/RLCR ループ」によって駆動されます。
SGLang の SOTA パフォーマンスループには、以下のステージが含まれます。
- 目標範囲を定義する。例えば
Qwen/Qwen3-Next-80B-A3B-Instruct-FP8モデルを、シングルノード構成の B200 グラフィックボード 2 枚(FP8)で実行し、SGLang の TP=2 と設定します。比較対象は、同じ 2 GPU という予算制約下で動作するオープンソース推論フレームワークです。
- まず公平な検索を実行する。SGLang にパッチを適用する前に、同じ負荷とリソース予算の下で、SGLang および各要求されたオープンソース推論フレームワークに対して、最も再現性のある実行コマンドを探します。
- ギャップを判定する。もし SGLang が既に同等かそれ以上の性能を示す場合は、その完了証拠を記録します。一方、閾値を超える遅れが継続している場合は、プロファイリングフェーズへ進みます。
- プロファイルでギャップの理由を解明する。安易にコード変更を行うのではなく、まずカーネルテーブル、パイプラインテーブル、オーバーラップ/融合テーブルを作成し、必要に応じて NCU レポートも生成します。
- 証拠に基づいたパスのみをパッチ適用する。具体的には、ハイブリッドアテンション、Mamba/GDN、ラディックスキャッシュ、ターゲット検証、CUDA グラフ、MoE/EP、量子化カーネル、あるいはモデルラッパーなどが対象となります。
- 同じ負荷で再検証を行う。各ラウンドでは、ベンチマーク結果、プロファイルデータ、精度、失敗した試行、環境情報、およびクリーンアップアクションを記録します。
2 枚の B200 GPU を使用して Qwen/Qwen3-Next-80B-A3B-Instruct-FP8 のようなモデルをターゲットとする場合、ループ処理が重要になります。ベンチマーク結果やプロファイルトレース、失敗したパッチ、中間的な結論はすべて、同一のモデル・ハードウェア・ワークロード・フレームワークコミットに紐付けられる必要があるからです。もしこうしたタスクを独立した多数のプロンプトに分割してしまうと、「どのコマンドがどの結果を生んだか」や「後続のプロファイルが元のベースラインと一致しているか」といった情報が失われやすくなります。証拠とレビューを伴うループを採用することで、各ラウンド間で条件の整合性を保つことができます。
4.3 Codex Goal: より低コストなループ実装
前述の SGLang SOTA Performance Loop は、Claude Code がベンチマーク・プロファイリング・パッチ適用・再検証を実行し、Codex Review が各ラウンド終了時にチェックを行うという 2 役構成を採用しています。これは本格的な PR 作業には適していますが、1 ラウンドごとに実行モデルとレビューモデルの両方を使用するため、コストと待機時間が嵩む課題があります。
一方、「Codex Goal」は別の実装アプローチです。「公平なベンチマーク → ギャップ判定 → プロファイリング → パッチ適用 → 再検証 → アーティファクト台帳」という一連の工程を永続的な Goal に記述しておけば、実行モデルとレビューモデルという 2 役構成を必要とせず、単一の Codex Goal で実行・自己チェック・再検証を一貫して担うことが可能になります。ただし、SGLang SOTA Performance Loop の中核となる制約は維持されます。すなわち、固定されたワークロード、証拠に基づくパッチ適用、同一の実験条件下での再検証、そして各ラウンド終了後のアーティファクトマニフェスト更新です。
両アプローチの違いは以下の通りです:
| 次元 | Humanize/RLCR SOTA ループ | Codex の目標 |
|---|---|---|
| 実行 | Claude Code が実装と実験を処理し、Codex Review が各ラウンドを検証する | 1 つの Codex 目標が継続的に実行され、自己検証および再検証を行う |
| 状態の保存場所 | 計画、プロンプト、サマリー、および検証結果は .humanize/rlcr/... 以下に格納される | 現在の目標スレッドとマニフェスト/証拠は artifact_root 以下に格納される |
| 検証方法 | ストップフック、Codex Review、および git/状態/スキーマチェック | 目標レベルの自己検証、アーティファクト契約、および人間のスポットチェック |
| コスト | 2 つのモデル役割が参加するため、各ラウンドのコストが増加する | 実行と検証を 1 つの目標で担うため、コストが削減される |
| 主なリスク | ループ設定が複雑になり、各ラウンドの待機時間が長くなる | 明確なハードストップ条件がない場合、目標の逸脱または早期完了が発生する可能性 |
以下は、AI-Infra-Auto-Driven-SKILLS/prompts から抜粋した、2x B200 モデルの最適化プロンプト例です。
Humanize/RLCR バージョン:
Use the sglang-sota-humanize-loop workflow.
Task:
Optimize SGLang serving performance for Qwen/Qwen3-Next-80B-A3B-Instruct-FP8
on a single node with 2 NVIDIA B200 GPUs, FP8 precision, and initial SGLang
TP=2. SGLang should match or exceed the best reproducible result from the
requested open-source inference frameworks under the same 2-GPU budget, workload, SLA,
model, precision, and environment constraints.
Required workflow:
1. Create a draft task document under artifact_root.
2. Run humanize-gen-plan to turn the draft into a structured plan.md.
3. Start humanize-rlcr from that plan.md in the Claude Code session.
4. Keep benchmark, profile, patch, and revalidation decisions inside the same
Humanize workspace.
Evidence and safety requirements:
- Before patching, run a fair bounded search for SGLang and the requested open-source inference framework set.
- Check relevant open PRs in sgl-project/sglang and BBuf/sglang before choosing
the SGLang baseline.
- If SGLang is behind by more than 1%, profile before patching.
- Prioritize evidence around hybrid attention, Mamba/GDN, radix cache, target
verify, and CUDA graph.
- Record benchmark commands, profile artifacts, failed attempts, and cleanup
evidence for every round.
- Patch only evidence-supported SGLang code paths.
- If a PR is needed, push/open it only against BBuf/sglang and include benchmark,
GSM8K, and full MMLU accuracy tables.
artifact_root:
/workspace/sglang-agent-artifacts/b200_qwen3_next_80b_a3b_instruct_fp8_sota_humanize
Codex Goal バージョン:
/goal Keep optimizing SGLang serving for
`Qwen/Qwen3-Next-80B-A3B-Instruct-FP8` on a single node with 2 NVIDIA B200
GPUs until SGLang matches or exceeds the best reproducible result from the
requested open-source inference frameworks under the same 2-GPU budget, FP8 precision,
workload, SLA, model, and environment constraints. The current Codex Goal is the loop: fixed fair
benchmarking, gap decision, profiling, pipeline analysis, evidence-backed
patching, revalidation, final report, and optional PR preparation all happen
inside this Goal. Completion requires benchmark evidence, profile evidence when
SGLang was behind, correctness/accuracy evidence, a final artifact manifest,
and no regression in environment safety constraints.
model_id: Qwen/Qwen3-Next-80B-A3B-Instruct-FP8
root_dir: /workspace
target_hardware: single-node 2x NVIDIA B200
minimum_gpu_count: 2
precision_quantization: FP8
initial_deployment: SGLang TP=2
artifact_root:
/workspace/sglang-agent-artifacts/b200_qwen3_next_80b_a3b_instruct_fp8_sota_goal
Requirements:
- Use the current Codex Goal as the only persistent loop.
- Before patching, run a fair bounded search for SGLang and the requested
open-source inference frameworks under the same 2-GPU budget.
- If SGLang is behind by more than 1%, profile in the same Goal, then use
llm-torch-profiler-analysis, llm-pipeline-analysis, and ncu-report-skill when
needed before patching.
- Focus on hybrid attention, Mamba/GDN, radix cache, target verify, and CUDA graph.
- Update the artifact manifest, benchmark evidence, profile evidence, failed
attempts, and next-step decision after every round.
- Stop and report a blocker if resources are unavailable, evidence is
untrustworthy, the budget is exhausted, or no defensible next patch exists.
Goal 版では、ベンチマーク、プロファイル、精度、および成果物の要件はそのまま維持されます。異なる点は、実行とレビューが一つの永続的な目標に統合されていることです。明確なハードストップ条件を設けることで、オーケストレーションの手間を減らしつつ、SGLang の SOTA パフォーマンスループを同等に実現できます。
5. KDA ベースの CUDA カーネル最適化(SGLang システム向け)
LLM や拡散モデルレベルの最適化を超えて、カーネル最適化にはより厳しいスケーリング課題が存在します。ハードウェアやワークロードに依存しない「唯一最良」のカーネルは存在しません。同じ演算子でも、H100、H200、B200、B300 といった異なる GPU アーキテクチャでは最適な実装が異なります。また、モデルアーキテクチャの違いはテンソル形状やレイアウト制約に影響し、サービスワークロードの変化はバッチサイズ、シーケンス長、精度フォーマット、ラッパーのオーバーヘッド、同期動作、フォールバックパスなどを変化させます。
実務的には、検索空間はハードウェア、モデル、ワークロードの定義を掛け合わせた直積(カルテシアン積)となります。
これは組み合わせ最適化の負荷を生み出します。各候補カーネルに対して、開発者は代表的な実稼働データを抽出し、同じ ABI を持つハネスを構築し、A/B 測定を実行し、形状ごとの正しさを確認し、NCU メトリクスを読み込み、どの形状に専門化が必要かを判断し、最終的に実際の SGLang パスで再検証する必要があります。ハードウェア・モデル・ワークロードの組み合わせごとにこれを手動で行うのはコストがかかります。しかしこれは、人間が不変条件を定義し最終パスを検証する限りにおいて、エージェントが得意とする反復的で証拠に基づく作業の典型でもあります。
ただし、エージェントに CUDA を直接書かせることは、ベンチマーク報酬のハッキングにつながりやすいものです。具体的には、ベンチマーク自体を変更したり、軽量なラッパーを使ったり、ベースラインでは使用していない高速数学演算を有効化したり、特定の形状のみを最適化してしまったり、数値的意味論を破綻させたり、実際の SGLang パスで何の改善も得られない結果を生んだりするリスクがあります。
KDA-Pilot は、カーネル最適化を分離されたタスクに分割することで、エージェントが SGLang リポジトリ全体を自由に改変できないようにしています:
- ワークロードは実際の SGLang 拡散モデルから取得されます。まず 20 の拡散モデルを実行し、実際のカーネルメタデータを要約します。
- ベースラインはアップストリームの SGLang メインブランチからコピーされ、ソースの系譜が記録されます。
- ベースラインと候補は、同じローカル ABI と同じビルド/エクスポートパスを使用する必要があります。
- ベンチマークでは、固定された実稼働データ行を用い、A/B 交互実行を行い、CUDA イベントまたは壁時計タイマーで計測します。
正しさの検証には、本番環境での動作確認、標準的な回帰テストグリッドの実行、NaN や Inf のチェック、出力の汚染(ポイズン)検出、そしてフォールバック契約の遵守が含まれます。
各イテレーションでは、タスクプロンプト、ベンチマークのエビデンス、KernelWiki、ncu-report-skill を更新します。
形状に特化したディスパッチは許可されていますが、それぞれのバケットについては、その適用条件、処理パス、レイテンシ、およびフォールバック手順を文書化しておく必要があります。
具体的なスナップショットを示すことで、規模感を把握しやすくなります。現在公開されている KDA-Pilot B200 の拡散サマリーでは、10 件の SGLang カーネルタスクが追跡されています。KDA-Pilot の台帳には、ほとんどの行で安定した数値的な B200 の証拠があり、壁面幾何平均の速度向上率は
抽出された生産用行において、性能は 1.1341 倍から 2.7499 倍に向上しました。residual_gate_add 行では 1.11 倍の改善が確認され、これはマージされた上流側の LTX-2.3 B200 の結果と一致しています。 (原文の技術表記: 1.1341x、2.7499x、1.11x)
2026 年 6 月 27 日現在、KDA-Pilot から派生した 3 つの最適化が SGLang の本流(upstream)にマージされました。1 つ目は SGLang PR #27392 で、Qwen-Image-2512 向けの B200 ネイティブ拡散モデルにおけるノーマル化スケールシフトの CUDA 高速パスです。その週後半にはさらに 2 つが追加され、SGLang PR #29281 は Cosmos3 VAE の因果的 Conv3D カット/パッドコピーパスに対応し、SGLang PR #29361 は LTX-2.3 のリジューアルゲート更新パスを扱っています。
| アップストリーム PR | ターゲットパス | カーネルレベルのエビデンス | モデルパスのエビデンス |
|---|---|---|---|
| #27392 | Qwen-Image norm-scale-shift | プロファイラーの寄与度分析で、ターゲットカーネルグループが 1.279x 改善 | B200 1 台あたり、両側で 5 つのインターリーブ実行を行った結果、フルリクエスト速度が 1.125x、デノイズウォール速度が 1.130x 向上 |
| #29281 | Cosmos3 causal Conv3D cat/pad | B200 の加重カーネルグループが、トレースされた VAE デコード呼び出し全体で 10.621 ms から 5.240 ms(2.03x)に改善 | Cosmos3-Nano T2V で torch.compile を有効にした結果、E2E 時間の中央値が 181.521 ms から 177.687 ms(1.021x)に改善 |
| #29361 | LTX-2.3 residual-gate update | 大規模 B200 の LTX-2.3 行が、既存の Triton パスに対して 1.108x から 1.130x 改善し、隣接する拡散行では最大 2.587x | LTX-2.3 HQ T2V で、E2E 時間が 46644.08 ms から 45198.37 ms(1.032x)に改善 |
重要なのは、個々のカーネルの性能向上がそのまま大規模なエンドツーエンドの成果に直結するわけではないという点です。むしろ、KDA-Pilot が提供した証拠パッケージ——固定された生産環境での実行結果、正しさの検証ゲート、同じ ABI 条件での比較、プロファイラーによる詳細な寄与分析、そして実モデルを用いたチェック——が、単なる孤立したベンチマークから、レビュー可能な SGLang のサービングパスへとカーネルタスクを移行させる鍵となります。
図 2:KDA-Pilot によって最適化された、10 の追跡対象 SGLang 拡散カーネルタスクにおける B200 の証拠データ。ほとんどの行は KDA-Pilot による壁面時間(wall time)の幾何平均速度向上を示しています。ここでいう壁面時間には、Python のディスパッチ、ラッパーのオーバーヘッド、カーネル起動、そして cuda.synchronize() を通じて可視化される同期オーバーヘッドが含まれており、純粋なカーネルデバイスの実行時間よりも、実際の呼び出しパスに近い値となっています。
| カーネルタスク | B200 の実証データ | 主要な最適化の方向性 |
|---|---|---|
qknorm_rope | 1.1341x | RoPE 共用ステージング、Q/Kの再利用、大規模行向け高速パス |
norm_infer | 1.3523x | Warp-row RMS、タイル化された永続型 RMS、8B/16B ベクトルパス |
rotary_embedding | 1.4912x | 128-bit ベクトル I/O、cos/sin のホイスティング、LTX2 ブロックマッチング |
cutedsl_norm_tanh_mul_add | 1.4953x | 行不変数値の数学演算ホイスティング、起動バウンズ調整、正確な tanh 計算 |
cutedsl_norm_scale_shift | 1.3201x | 演算子クラスディスパッチ、16B/32B ベクトル、2 段階分散計算 |
fuse_scale_shift | 2.7499x | rowgrid/flatvec/exact-C パス、キャッシュヒント、1 段階リダクション |
group_norm_silu | 2.3118x | 分割グループ統計、チャンネルラスト直接パス、大規模行向けフォールバック |
attention_concat_copy | 1.30x | 単一起動領域コピー、ピッチ付き 16B ブロック収集、厳格なレイアウト/デバイス拒否 |
causal_conv3d_cat_pad | 2.06x | フラットチャンキング、16B ベクトル化ストア、ストライド対応フォールバック、ビット単位正確なゲート |
residual_gate_add | 1.11x | 1 段階 CUDA 融合、ピン留め GPU の正しさ、SGLang PR #29361 B200 Triton-row 再ベンチマーク |
このチャートとタスクリストは、実験設定を念頭に置いて読む必要があります。これらは抽出された実データに基づくカーネルとタスクの速度向上率を示すものであり、モデル全体のエンドツーエンドでの性能向上を報告しているわけではありませんが、依然として有用な情報です。ベースライン、ワークロード、正しさの確認、プロファイリング、レビュー体制が整った上であれば、エージェントは実際のフレームワーク用カーネルに対して、レビュー可能な漸進的な改善を生み出すことが可能になります。
KDA-Pilot の実験から得られた 2 つのルールは、今後も守るべきです。
- ベンチマーク報酬のハッキング余地を残さないこと。ベースラインと候補が異なる ABI や高速数学設定、あるいは異なるラッパーパスを使用している場合、結果は信頼できなくなります。また、結果を見てからベンチマークの形状セットを変更する(例えば、候補の方が遅い形状を削除するなど)という共通の問題にも注意が必要です。そのような結果は使用すべきではありません。
- ルーフラインに近いバケットでは、実行不可またはフォールバックの判断を許容すること。優れたカーネル最適化タスクとは、エージェントがすべての形状で勝利することを強要するものではありませんです。巨大な連続バケットや帯域幅制限に既に近いパスにおいては、複雑さを増すよりも、フォールバックとして記録する方が望ましい場合があります。
6. 実践ルール
- エージェントを開始する前にタスクの範囲を明確に定義すること。「SGLang の最適化」は広すぎます。代わりに、「2x B200 環境で
1000->1000および8000->1000の固定ワークロード下、Qwen/Qwen3-Next-80B-A3B-Instruct-FP8に対して別のオープンソース推論フレームワークと同等の性能を出すこと」のように、実行可能な目標を設定すべきです。
ベンチマークの結果を分析する前に、まず評価用ワークロードの固定化を確認してください。結果が判明した後に負荷条件が変わってしまうと、エージェントが意図せずして「解きやすい問題」に対して最適化を行ってしまうリスクがあります。SOTA ループでも KDA-Pilot でも、パッチ適用前には必ず固定されたワークロードを使用しています。
NCU の解析結果は、対象カーネルの計算特性に合わせて解釈する必要があります。メモリーバウンド型のカーネルであれば、DRAM や L2 のスループット、ロード/ストアの効率性、そしてメモリーパイプの利用率に注目します。一方、GEMM やアテンション演算など計算バウンド型の場合は、Tensor Core の利用率、SM の稼働状況、実行可能なワープ数、および主要なストール要因を確認しましょう。小規模でレイテンシがボトルネックとなるカーネルでは、起動回数、カーネルごとの実行時間、同期ポイント、そして融合の機会がないかチェックします。単なるトレース画面のスクリーンショットだけでは不十分です。次のコード変更には、具体的な数値指標による裏付けが必要です。
信頼できるプロファイルを得るためには、バックエンドとフォールバックの条件を必ず確認してください。LLM の実行中にアテンションバックエンドが静かに切り替わったり、CUDA グラフが無効化されたり、ベンチマーク時とは異なるラッパーパスを経由したりしている場合、そのトレースは本来の対象となるサービングパスを記述したものとは言えません。拡散モデルにおいても同様で、ログに「diffusers」バックエンドへのフォールバックが記録されていれば、それはネイティブな SGLang 拡散の根拠として使用できません。こうした停止条件(ハードストップ)は、スキル定義の中に明記しておくべきです。
カーネル最適化を行う際は、ABI、ラッパー、コンパイルフラグを統一することが必須です。特に候補となる実装が、意図せずして軽量なパスへ逸脱しないよう注意し、--use_fast_math の設定は片側だけ有効にするような不整合があってはいけません。
レビューの重要性は以前にも増して高まっています。エージェントが作成する PR は増加しますが、同時に巧妙なミスも生み出す可能性があります。SGLang のような高性能システムにおけるレビューでは、形状やデータ型、分散実行、CUDA グラフの動作、フォールバック挙動、精度、サービング API、メトリクス、ベンチマーク設定など、多角的に検証する必要があります。
エージェント時代の SGLang 開発において、エンジニアがシステムから排除されるわけではありません。より現実的な変化は、開発者体験をワークフローに組み込み、反復的な実行をエージェントに任せる一方で、判断、設計、レビューといった重要な役割を人間が残すことにあります。浮いた時間は、より困難なパフォーマンス課題やモデルパスの最適化、プロダクション環境の安定性向上に充てるか、あるいはエージェントワークフロー自体の改善に回せます。オープンソースの推論フレームワークにとって、こうしたインフラへの持続的な投資は極めて価値があります。
7. Acknowledgments
SGLang エージェントスキルの構築に貢献した SGLang チームメンバーとコントリビューターの方々に感謝します:Xiaoyu Zhang (BBuf)、Lianmin Zheng、Liangsheng Yin、Ke Bao、fzyzcjy、Kangyan Zhou、DarkSharpness、Mick、Alison Shao、Baizhou Zhang、Bingxu Chen、Cheng Wan、Ratish P、shuwenn、ykcai-daniel、Yuhao Yang、Artem Savkin。
KDA チームの方々に感謝します:Dongyun Zou、Ligeng Zhu、Sihao Liu、Junxian Guo、Yixin Dong、Zijian Zhang、Hao Kang、Song Bian。
Humanize チームとコントリビューターの方々に感謝します:Sihao Liu、Ligeng Zhu、Zijian Zhang、Zenus Zhang、shinan6、DYZhang、Chao Liu、Zhou Yaoyang、gyy0592、AcrossForest、Emin、Qiming Chu、jiaxiaoyu、tastynoob、zhenwei。
8. References
SGLang の GitHub リポジトリ
SGLang の .claude/skills
SGLang Diffusion 用の .claude/skills
AI-Infra-Auto-Driven-SKILLS
AI-Infra-Auto-Driven-SKILLS のプロンプト
Kernel Design Agents (KDA)
KernelWiki skill
ncu-report-skill
KDA-Pilot
SGLang Diffusion 高度な最適化(LMSYS Blog)
OpenAI Codex プロンプティング:ゴールモード
Humanize
原文を表示
SGLang development increasingly goes beyond isolated code changes. The same repository now spans LLM serving, distributed runtime, GPU kernels, diffusion pipelines, model-specific execution paths, and production incident handling. In the past, many of these workflows depended on individual developer memory: how to launch a certain model, how to read a profile trace, which log to add first when debugging a CUDA crash, or which benchmarks a performance PR should include. As agent tools mature, this experience can be turned into executable SKILL.md files, scripts, benchmark contracts, and review loops.
Around SGLang agent development, a set of skills has already emerged for both LLM and diffusion work:
- SGLang .claude/skills is maintained inside the SGLang repository and captures repo-level development workflows such as CUDA crash debugging, kernel integration, tests, CI, profiling, production triage, and source-tree conventions.
- SGLang diffusion .claude/skills focuses on diffusion-specific workflows, including adding new diffusion models, benchmarking and profiling denoise paths, tuning performance options, and validating quantized pipelines.
- BBuf/AI-Infra-Auto-Driven-SKILLS covers cross-framework serving benchmarks, capacity planning, profile and pipeline analysis, model compute simulation, SGLang human-style review, production incident triage, SOTA loops for SGLang and other open-source inference frameworks, and model PR history.
- kernel-design-agents is the KDA project and the winning solution for the MLSys 2026 FlashInfer Kernel Contest.
- BBuf/KDA-Pilot applies KDA-style agent kernel workflows to SGLang. Its public B200 diffusion summary now tracks 10 SGLang kernel tasks. Most rows come from KDA-Pilot's public benchmark ledger, while residual_gate_add uses the B200 speedup reported by the merged SGLang integration PR after the original task baseline moved. KDA-Pilot-derived work has now landed in three SGLang integration PRs.
Viewed together, these efforts point to the same direction: the value of agents comes from procedural engineering knowledge, including executable steps, reproducible experiments, and reviewable evidence.
1. TL;DR
- Agents are most useful in SGLang when they can keep moving along a well-defined workflow. Benchmarking, profiling, kernel API logging, adding diffusion pipelines, production incident replay, and SOTA loops can all be encoded as skills.
- An SGLang skill is an executable development procedure. In debug-cuda-crash, sglang-diffusion-benchmark-profile, and llm-torch-profiler-analysis, the important content is preflight checks, hard failure gates, artifact contracts, reproduction commands, and result formats.
- Profile evidence is central to performance work. The SGLang profiler skills produce fixed kernel tables, overlap-opportunity tables, and fuse-pattern tables. KDA-Pilot extends this into same-ABI baseline/candidate comparison, real workloads, correctness gates, NCU evidence, and per-shape results.
- Long-running optimization has started to move into Loop Engineering. The SGLang SOTA Performance Loop decomposes "chasing SOTA" into fair benchmarking, gap decision, profiling, patching, and revalidation. Humanize/RLCR adds external review, while Codex Goal can run the same loop with lower coordination overhead.
- Review becomes more important. Agents can run more experiments, but they also generate more changes that look plausible and still need careful review. Developers increasingly define problems, choose evidence, design workflows, and decide whether results are ready for production paths.
2. Why SGLang Is a Good Fit for Agent-Assisted Development
SGLang is a high-performance serving framework for LLMs and multimodal models. As model families and hardware paths expand, several recurring problems show up in development:
- LLM paths are complex. A single performance issue may cross the Python runtime, scheduler, CUDA graph, Triton/CUDA kernels, FlashInfer/FlashAttention, distributed collectives, and model-specific wrappers.
- Diffusion paths are also complex. A slower denoise pass may involve pipeline/stage partitioning, DiT blocks, attention backends, torch.compile graph breaks, CFG/SP parallelism, VAE, or custom fused kernels.
- Validation is expensive. Many changes must be tested on real models and real workloads on H100, H200, B200, or RTX 5090. Local unit tests alone are not enough.
- Profiles are hard to reuse manually. A single trace may contain hundreds of kernel launches. Reading Perfetto by hand can miss kernel-to-Python-source mappings and can easily mix up prefill and decode. Developers accumulate know-how while reading profiler output, such as which kernel names map to which model logic, which launch patterns suggest graph breaks, and which NCCL/attention/MLP layouts are normal. If that knowledge remains only in one person's head, the next task cannot reuse it.
- Performance conclusions depend heavily on context. GPU type, shape, batch size, parallelism, precision, backend, and compile state can all change the result. An isolated microbenchmark often cannot prove real model-level benefit, so an end-to-end long-running test process is needed to repeatedly validate throughput, latency, memory, accuracy, and stability under fixed workloads. That process is both labor-intensive and time-consuming.
These problems are a natural fit for agents. Launching servers, fixing workloads, collecting traces, triaging profile rows, adding tests, and recording experiment results all have clear inputs and outputs and are well suited to scripting and repeated execution. Developers need to define the boundaries: the same benchmark setup, the same profile interpretation rules, the same accuracy gates, and the conditions under which the agent should stop changing code.
The agent discussed here is therefore an executor constrained by engineering workflows. Repeated SGLang development procedures can be captured as skills, letting the agent handle repetitive execution, evidence collection, and state tracking. Developers remain responsible for defining goals, judging evidence, and reviewing whether a change belongs in the real serving path.
3. From Prompt Engineering to SKILL: Protocols and Examples
In the SGLang framework, a useful skill should at least answer the following questions:
| Question | What the skill should capture |
|---|---|
| When to use it | Trigger scenarios, supported models, supported hardware, and hard-stop cases |
| How to start | Preflight checks, environment variables, repository state, dependency checks, and model configuration |
| How to validate | Benchmark commands, profile commands, test entry points, and accuracy gates |
| How to decide | Output tables, failure modes, priorities, risk categories, and fallback conditions |
| How to deliver | Artifact directories, result schemas, PR descriptions, reproduction commands, and review requirements |
SGLang agent-related skills cover different layers. Some are close to source changes, such as debugging, testing, adding diffusion models, and benchmark/profile workflows. Others target cross-framework benchmarking, capacity planning, compute simulation, production incident triage, PR optimization knowledge, SGLang human-style review, and higher-level workflows such as Humanize/RLCR.
3.1 Current Skill Stack
The commonly used SGLang agent-related skills fall into the following groups.
| Layer | Representative skill / project | Problem it solves |
|---|---|---|
| CUDA crash | `debug-cuda-crash` | Records inputs, exceptions, and dumps around custom op/kernel API boundaries, turning transient crashes into samples that can be analyzed offline |
| LLM benchmark | `llm-serving-auto-benchmark` | Runs fair, bounded, resumable serving benchmark search across SGLang and other OpenAI-compatible inference stacks |
| Capacity planning | `llm-serving-capacity-planner` | Parses SGLang and other inference-framework startup logs to explain weight memory, KV cache budget, CUDA graph overhead, request capacity, and OOM pressure |
| Trace triage | `llm-torch-profiler-analysis` | Produces fixed kernel, overlap-opportunity, and fuse-pattern tables, and maps kernels back to Python source; the same unified workflow also lives in AI-Infra for cross-framework use |
| Pipeline/layer analysis | `llm-pipeline-analysis` | Slices torch profiler traces into forward passes, layers, and kernel flows to locate steady-state passes, bottleneck layer types, and Perfetto time ranges |
| Model compute simulation | `model-compute-simulation` | Builds operator-level compute templates for LLMs and estimates tensor shapes, FLOPs, MFU, kernel-to-op mapping, and parallelism what-ifs |
| Diffusion benchmark/profile | `sglang-diffusion-benchmark-profile` | Captures denoise latency, perf dumps, and torch profiler traces, while first checking that execution is actually using the native SGLang diffusion backend |
| Add diffusion model | `sglang-diffusion-add-model` | Adds a new diffusion model from a Diffusers/reference pipeline into the SGLang pipeline/stage/model/config structure |
| Diffusion performance tuning | `sglang-diffusion-performance` | Chooses performance settings such as torch.compile, warmup, SP/CFG parallelism, offload, attention backend, and quantization |
| Production triage | `sglang-prod-incident-triage` | Collects live-server bundles, saves failing requests, replays them, and then routes to focused crash/hang/profile tools |
| SGLang review / PR history | `sglang-humanize-review` and `model-pr-history-knowledge` | Reviews SGLang patches against real maintainer discussion patterns and keeps PR-driven model evolution histories close to the changed source |
| SGLang SOTA Performance Loop (Loop Engineering) | `sglang-sota-humanize-loop` | First compares SGLang fairly against the requested open-source inference frameworks, then puts gap decision, profiling, patching, and revalidation into a Humanize/RLCR loop |
These entries turn easy-to-miss steps into executable protocols so the workflow can run, resume, and be reviewed.
3.2 Recent Optimization and Workflow Examples
The following examples come from recently merged SGLang PRs. The table focuses on the full engineering path: benchmarking, profiling, localization, code changes, tests, and revalidation.
| Case | Result | Key point |
|---|---|---|
| Router long-context tokenization deduplication, SGLang PR #28744 | On a DeepSeek-V4-Flash deployment, idle TTFT for 60k/125k-token prompts dropped by about 29% / 41%; under 60k-token load, TTFT dropped by 34%–49% | The agent handled cache-aware routing, chat-encoder parity, engine-side input_ids fallback, and proxy body construction together, avoiding duplicate tokenization in the router and engine |
| Qwen3-Next FlashInfer allreduce fusion, SGLang PR #22664 | On H100 TP=4, request throughput improved from 5.49 req/s to 9.41 req/s, about +71.4%; mean TTFT dropped from 456.24 ms to 167.54 ms | This is a profile-driven LLM collective optimization: unfused cross-device reduce dominated prefill, and the fused allreduce path was validated with MMLU/GSM8K accuracy checks |
| Cohere2Moe NVFP4 fused-MoE path, SGLang PR #27401 | For CohereLabs/command-a-plus-05-2026-w4a4 on 1x B300, request throughput improved over the previous SGLang default by +26% on chat and +21% on summarization, and beat another open-source inference framework in that setup by +4.1% / +6.8% | The change completed the routing semantics so the existing flashinfer_trtllm NVFP4 fused-MoE kernel could be used correctly in the real model path, with GSM8K/MMLU checks |
| Kimi Delta Attention CuteDSL prefill kernel on SM100, SGLang PR #27488 | For moonshotai/Kimi-Linear-48B-A3B-Instruct, Delta Attention prefill on B200 became 1.08x–1.52x faster than Triton; GSM8K moved from 0.915 to 0.920, with a new regression test for realistic gate magnitudes | This kernel task had to cover the model's gate distribution, numerical overflow, host overhead, real-model accuracy, and unit tests before the optimization was ready to merge |
| Spectral Progressive Diffusion, SGLang PR #27524 | Denoising speedups for FLUX.1, FLUX.2, Z-Image, Wan, and Qwen-Image reached 1.63x, 1.77x, 2.07x, 2.32x, and 1.6x respectively in the reported RTX A6000 setup | This is a diffusion-side system optimization: early denoising runs at lower latent resolution, then GPU DCT upsampling restores full resolution when high-frequency details start to matter |
| LTX-2 VAE decode channels-last-3d, SGLang PR #27431 | The LTX-2 decode stage improved from 5.41 s to 3.84 s, about 1.41x; peak reserved memory dropped from 71.81 GiB to 62.12 GiB, saving about 9.7 GiB | The profile pointed to Conv3d and layout conversion, so the fix preserved memory format in causal padding and connected the loader policy to single-GPU LTX-2 |
In these examples, the agent mainly contributes by executing the workflow: running benchmarks, reading profiles, locating Python source, changing code, adding tests, revalidating, and preparing PR descriptions. Without skills, many steps rely on manual reminders. Once encoded as skills, the workflow becomes much easier to repeat.
4. Profiling, Review, and Loop Engineering
A common mistake in SGLang performance work is to look only at total runtime, or to open Perfetto for a few minutes and decide by intuition that something "should be fused." This is even riskier for agents, because they can easily mistake a visually hot kernel for the real bottleneck.
In practice, two profiler skills are usually used together. llm-torch-profiler-analysis handles the first layer of trace triage and turns a global profile into three fixed tables:
- Kernel Table: summarizes GPU time share, launch count, and kernel category by stage, and maps kernels back to Python source and CPU ops when possible.
- Overlap Opportunity Table: uses exclusive/hidden time share, dependency risk, and kernel category to identify remaining overlap or headroom.
- Fuse Pattern Table: compares the trace against a source-backed pattern catalog of fusion/overlap paths in SGLang, other open-source inference frameworks, and kernel libraries.
These tables answer the first set of questions: which stage and which kernel take how much GPU time, which Python line they map to, and whether there is an existing fuse/overlap path to learn from. If SGLang trails another inference framework, the profiler table should explain the gap before any code change starts.
The next step is llm-pipeline-analysis. Once global hotspots are known, we still need to know which forward pass, layer type, and kernel flow they belong to. This skill reads Chrome trace JSON and the model config.json, uses layer-boundary anchor kernels to split the trace into forward passes and layers, and then produces several tables for deeper analysis:
- Forward pass summary: separates cold-start from steady-state so warmup does not become the optimization target.
- Per-layer timeline: reports wall time, sum duration, and the share of categories such as MLA, MoE, GEMM, NCCL, MHC, and Hadamard for each layer.
- Layer cluster statistics: especially useful for models with alternating layer structures, such as NSA/hybrid-attention models with compress_ratios, where C4_LIGHT, C128_HEAVY, HASH, or other layer types may dominate latency.
- Compute flow table: expands representative layers into concrete kernel flows with hotness, relative timestamps, and input dimensions, making it easy to jump back into Perfetto.
Profile analysis therefore becomes a two-step process. First, llm-torch-profiler-analysis identifies the main conflict in the full trace. Then, llm-pipeline-analysis grounds the problem in steady-state forward passes, representative layers, and concrete kernel flows. The first step avoids choosing a direction by intuition. The second avoids staring at one global hot kernel while missing layer-type differences in the model structure.
4.1 Humanize/RLCR: Adding External Review to the Loop
Humanize addresses state and review in long-running tasks. A high-risk SGLang performance task usually does not finish in one implementation pass. It may go through many rounds of benchmarking, profiling, patching, reverting, changing direction, and validating again. Humanize splits this process into two stages:
- Run gen-plan first. humanize-gen-plan turns a draft requirement into a structured plan.md containing the goal description, acceptance criteria, positive/negative tests, path boundaries, milestones, and implementation notes.
- Run the RLCR loop next. humanize-rlcr starts the loop from plan.md. In each round, Claude Code reads .humanize/rlcr/<timestamp>/round-<N>-prompt.md, implements, commits, and writes a summary. Codex Review then checks state files, summaries, git cleanliness, review results, open questions, max-iteration conditions, and other gates. A single sentence claiming "task complete" is not enough to exit the loop.
This mechanism provides the execution and review foundation for the SGLang SOTA Performance Loop. Claude Code runs benchmarks, reads profiles, changes SGLang code, and revalidates. Codex Review checks evidence, state, and risk at the end of each round. It is a good fit for tasks that will become PRs, affect serving correctness, or require multi-day, multi-round experiments.
In practice, the command order should be explicit so the agent does not jump directly into implementation:
1. Write a task draft under artifact_root/draft.md.
2. Run humanize-gen-plan to generate artifact_root/plan.md.
3. Start humanize-rlcr from artifact_root/plan.md.
4. Keep all decisions, summaries, and review state in the local Humanize workspace.
4.2 SGLang SOTA Performance Loop (Loop Engineering)
A single skill can stabilize one task. After a dozen rounds of experiments, however, another problem appears: which candidate is best, which directions have already failed, what the previous NCU report showed, whether the benchmark still matches the baseline, and when to stop. This state cannot live only in chat context.
The SGLang SOTA Performance Loop is a Loop Engineering workflow built on Humanize/RLCR. Here, SOTA means the best reproducible result under fixed experimental conditions: the same model, hardware, GPU count, precision, workload, SLA, framework commit, and serving parameters. The question is whether SGLang can reach the current best reproducible result under those conditions.
Figure 1: SGLang SOTA Performance Loop. A fixed fair benchmark first establishes a reproducible baseline. The subsequent gap decision, profiling, pipeline analysis, patching, and revalidation are driven by the Humanize/RLCR loop.
A full SGLang SOTA Performance Loop contains the following stages:
- Define the target boundary. For example, Qwen/Qwen3-Next-80B-A3B-Instruct-FP8, single-node 2x B200, FP8, SGLang TP=2, and comparison against the requested open-source inference frameworks under the same 2-GPU budget.
- Run fair search first. Before patching SGLang, search for the best reproducible commands for SGLang and each requested open-source inference framework under the same workload and resource budget.
- Decide the gap. If SGLang already matches or leads, record completion evidence. If it is consistently behind by more than the threshold, move to profiling.
- Use profiles to explain the gap. Do not rush into code changes. First produce kernel tables, pipeline tables, overlap/fuse tables, and NCU reports when needed.
- Patch only evidence-supported paths, such as hybrid attention, Mamba/GDN, radix cache, target verify, CUDA graph, MoE/EP, quant kernels, or model wrappers.
- Revalidate on the same workload. Every round records benchmarks, profiles, accuracy, failed attempts, environment information, and cleanup actions.
For a target such as Qwen/Qwen3-Next-80B-A3B-Instruct-FP8 on 2x B200, the loop matters because benchmark results, profile traces, failed patches, and intermediate conclusions all need to stay attached to the same model, hardware, workload, and framework commits. If this type of task is split into many independent prompts, it is easy to lose which command produced which result or whether a later profile still matches the original baseline. A loop with evidence and review keeps conditions aligned across rounds.
4.3 Codex Goal: A Lower-Cost Loop Implementation
The SGLang SOTA Performance Loop above uses a two-role setup: Claude Code executes benchmarks, profiling, patching, and revalidation, while Codex Review checks each round at the end. This setup is suitable for serious PR work, but every round consumes both an execution model and a review model, increasing cost and waiting time.
Codex Goal offers another implementation. Once "fair benchmark -> gap decision -> profile -> patch -> revalidate -> artifact ledger" is written into a persistent Goal, a single Codex Goal can carry execution, self-checking, and revalidation without the two-role execution/review setup. The core constraints of the SGLang SOTA Performance Loop remain: fixed workload, evidence-driven patches, revalidation under the same experimental conditions, and artifact manifest updates after every round.
The two approaches differ as follows:
| Dimension | Humanize/RLCR SOTA Loop | Codex Goal |
|---|---|---|
| Execution | Claude Code handles implementation and experiments; Codex Review reviews each round | One Codex Goal continuously executes, self-checks, and revalidates |
| State location | Plan, prompt, summary, and review results under .humanize/rlcr/... | Current Goal thread plus manifest/evidence under artifact_root |
| Review method | Stop hook, Codex Review, and git/state/schema checks | Goal-level self-checks, artifact contracts, and human spot checks |
| Cost | Two model roles participate, so each round costs more | One Goal carries both execution and checks, reducing cost |
| Main risk | More complex loop setup and longer waits per round | Goal drift or premature completion unless hard-stop conditions are explicit |
Below is a 2x B200 model optimization prompt example from AI-Infra-Auto-Driven-SKILLS/prompts.
Humanize/RLCR version:
Use the sglang-sota-humanize-loop workflow.
Task:
Optimize SGLang serving performance for Qwen/Qwen3-Next-80B-A3B-Instruct-FP8
on a single node with 2 NVIDIA B200 GPUs, FP8 precision, and initial SGLang
TP=2. SGLang should match or exceed the best reproducible result from the
requested open-source inference frameworks under the same 2-GPU budget, workload, SLA,
model, precision, and environment constraints.
Required workflow:
1. Create a draft task document under artifact_root.
2. Run humanize-gen-plan to turn the draft into a structured plan.md.
3. Start humanize-rlcr from that plan.md in the Claude Code session.
4. Keep benchmark, profile, patch, and revalidation decisions inside the same
Humanize workspace.
Evidence and safety requirements:
- Before patching, run a fair bounded search for SGLang and the requested open-source inference framework set.
- Check relevant open PRs in sgl-project/sglang and BBuf/sglang before choosing
the SGLang baseline.
- If SGLang is behind by more than 1%, profile before patching.
- Prioritize evidence around hybrid attention, Mamba/GDN, radix cache, target
verify, and CUDA graph.
- Record benchmark commands, profile artifacts, failed attempts, and cleanup
evidence for every round.
- Patch only evidence-supported SGLang code paths.
- If a PR is needed, push/open it only against BBuf/sglang and include benchmark,
GSM8K, and full MMLU accuracy tables.
artifact_root:
/workspace/sglang-agent-artifacts/b200_qwen3_next_80b_a3b_instruct_fp8_sota_humanize
Codex Goal version:
/goal Keep optimizing SGLang serving for
`Qwen/Qwen3-Next-80B-A3B-Instruct-FP8` on a single node with 2 NVIDIA B200
GPUs until SGLang matches or exceeds the best reproducible result from the
requested open-source inference frameworks under the same 2-GPU budget, FP8 precision,
workload, SLA, model, and environment constraints. The current Codex Goal is the loop: fixed fair
benchmarking, gap decision, profiling, pipeline analysis, evidence-backed
patching, revalidation, final report, and optional PR preparation all happen
inside this Goal. Completion requires benchmark evidence, profile evidence when
SGLang was behind, correctness/accuracy evidence, a final artifact manifest,
and no regression in environment safety constraints.
model_id: Qwen/Qwen3-Next-80B-A3B-Instruct-FP8
root_dir: /workspace
target_hardware: single-node 2x NVIDIA B200
minimum_gpu_count: 2
precision_quantization: FP8
initial_deployment: SGLang TP=2
artifact_root:
/workspace/sglang-agent-artifacts/b200_qwen3_next_80b_a3b_instruct_fp8_sota_goal
Requirements:
- Use the current Codex Goal as the only persistent loop.
- Before patching, run a fair bounded search for SGLang and the requested
open-source inference frameworks under the same 2-GPU budget.
- If SGLang is behind by more than 1%, profile in the same Goal, then use
llm-torch-profiler-analysis, llm-pipeline-analysis, and ncu-report-skill when
needed before patching.
- Focus on hybrid attention, Mamba/GDN, radix cache, target verify, and CUDA graph.
- Update the artifact manifest, benchmark evidence, profile evidence, failed
attempts, and next-step decision after every round.
- Stop and report a blocker if resources are unavailable, evidence is
untrustworthy, the budget is exhausted, or no defensible next patch exists.
The Goal version preserves the same benchmark, profile, accuracy, and artifact requirements. The difference is that execution and review are folded into one persistent target. With clear hard-stop conditions, it can carry the same SGLang SOTA Performance Loop with less orchestration.
5. KDA-Based CUDA Kernel Optimization for SGLang Systems
Beyond model-level optimization for LLMs and diffusion, kernel optimization has a harsher scaling problem. There is no single best kernel independent of hardware and workload. The same operator can prefer different implementations on H100, H200, B200, or B300; different model architectures expose different tensor shapes and layout constraints; and serving workloads change batch size, sequence length, precision format, wrapper overhead, synchronization behavior, and fallback paths. In practice, the search space is a Cartesian product of hardware, model, and workload definitions.
This creates a combinatorial optimization burden. For each candidate kernel, a developer needs to extract representative production rows, build a same-ABI harness, run A/B measurements, check correctness across shape buckets, read NCU metrics, decide whether a bucket deserves specialization, and then revalidate in the real SGLang path. Doing this by hand for every hardware/model/workload combination is expensive. It is also exactly the kind of repetitive, evidence-heavy workflow that agents are good at, as long as humans define the invariants and review the final path.
Asking an agent to write CUDA directly, however, can easily lead to benchmark reward hacking: changing the benchmark, using a lighter wrapper, enabling fast math that the baseline does not use, optimizing only one shape, breaking numerical semantics, or producing no gain in the real SGLang path.
KDA-Pilot separates kernel optimization into isolated tasks so the agent does not freely modify the whole SGLang repository:
- Workloads come from real SGLang diffusion models. The process first runs 20 diffusion models and summarizes actual kernel metadata.
- The baseline is copied from upstream SGLang main, with source lineage recorded.
- Baseline and candidate must use the same local ABI and the same build/export path.
- Benchmarks use fixed production rows, A/B interleaving, and CUDA event or wall timing.
- Correctness covers production rows, a canonical regression grid, NaN/Inf checks, poison output checks, and fallback contracts.
- Each iteration refreshes the task prompt, benchmark evidence, KernelWiki, and ncu-report-skill.
- Shape-specialized dispatch is allowed, but each bucket must document its condition, path, latency, and fallback.
A concrete snapshot makes the scale easier to see. The public KDA-Pilot B200 diffusion summary currently lists 10 tracked SGLang kernel tasks. Most rows have stable numeric B200 evidence in the KDA-Pilot ledger, with wall-geomean speedups ranging from 1.1341x to 2.7499x on extracted production rows. The residual_gate_add row is shown at 1.11x, matching the merged upstream LTX-2.3 B200 result.
As of June 27, 2026, three KDA-Pilot-derived optimizations have landed upstream in SGLang. The first was SGLang PR #27392, a B200 native diffusion norm-scale-shift CUDA fast path for Qwen-Image-2512. Two more landed later that week: SGLang PR #29281 for the Cosmos3 VAE causal Conv3D cat/pad copy path, and SGLang PR #29361 for the LTX-2.3 residual-gate update path.
| Upstream PR | Target path | Kernel-level evidence | Model-path evidence |
|---|---|---|---|
| #27392 | Qwen-Image norm-scale-shift | Target kernel group improved by 1.279x in profiler attribution | On one B200, five interleaved runs per side showed 1.125x full-request speedup and 1.130x denoise-wall speedup |
| #29281 | Cosmos3 causal Conv3D cat/pad | B200 weighted kernel group improved from 10.621 ms to 5.240 ms, or 2.03x, across traced VAE decode calls | With torch.compile enabled on Cosmos3-Nano T2V, median E2E time improved from 181.521 ms to 177.687 ms, or 1.021x |
| #29361 | LTX-2.3 residual-gate update | Large B200 LTX-2.3 rows improved 1.108x to 1.130x over the existing Triton path, with neighboring diffusion rows up to 2.587x | On LTX-2.3 HQ T2V, E2E time improved from 46644.08 ms to 45198.37 ms, or 1.032x |
The key takeaway is not that every standalone kernel win becomes a large end-to-end win. It is that the same KDA-Pilot evidence package -- fixed production rows, correctness gates, same-ABI comparisons, profiler attribution, and real-model checks -- can move a kernel task from an isolated benchmark into a reviewable SGLang serving path.
Figure 2: B200 evidence for 10 tracked SGLang diffusion kernel tasks optimized by KDA-Pilot. Most rows report KDA-Pilot wall-geomean speedup; wall time includes Python dispatch, wrapper overhead, kernel launch, and synchronization overhead visible through cuda.synchronize(), which is closer to the real call path than pure kernel device time.
| Kernel task | B200 evidence | Main optimization direction |
|---|---|---|
qknorm_rope | 1.1341x | Shared RoPE staging, Q/K reuse, large-row fast path |
norm_infer | 1.3523x | Warp-row RMS, tiled persistent RMS, 8B/16B vector path |
rotary_embedding | 1.4912x | 128-bit vector I/O, cos/sin hoisting, LTX2 block matching |
cutedsl_norm_tanh_mul_add | 1.4953x | Row-invariant math hoisting, launch-bounds tuning, exact tanh |
cutedsl_norm_scale_shift | 1.3201x | Operand-class dispatch, 16B/32B vectors, two-pass variance |
fuse_scale_shift | 2.7499x | rowgrid/flatvec/exact-C paths, cache hints, one-pass reduction |
group_norm_silu | 2.3118x | Split-group stats, channels-last direct path, fallback for giant rows |
attention_concat_copy | 1.30x | Single-launch region copy, pitched 16B block gather, strict layout/device rejection |
causal_conv3d_cat_pad | 2.06x | Flat chunking, 16B vectorized stores, stride-aware fallback, bitwise-exact gate |
residual_gate_add | 1.11x | One-pass CUDA fusion, pinned-GPU correctness, SGLang PR #29361 B200 Triton-row re-benchmark |
The chart and task table should be read with the experimental setting in mind: they report kernel-task speedups on extracted production rows, not full model end-to-end gains. They are still useful. Once baseline, workload, correctness, profiling, and review are fixed, agents can produce reviewable incremental improvements on real framework kernels.
Two rules from the KDA-Pilot experiments are worth keeping:
- Do not leave room for benchmark reward hacking. Results become unreliable when baseline and candidate use different ABIs, different fast-math settings, or different wrapper paths. Another common issue is changing the benchmark shape set after seeing the results, for example removing shapes where the candidate is slower. Such results should not be used.
- Buckets close to the Roofline should allow no-go or fallback decisions. A good kernel optimization task should not force the agent to win every shape. For giant contiguous buckets or paths already close to the bandwidth limit, recording a fallback may be better than adding more complexity.
6. Practice Rules
- Define the task boundary before starting the agent.
"Optimize SGLang" is too broad. "Match another open-source inference framework for Qwen/Qwen3-Next-80B-A3B-Instruct-FP8 on 2x B200 under fixed 1000->1000 and 8000->1000 workloads" is an executable target.
- Fix the benchmark before reading profiles.
If the workload can change after results are known, the agent may accidentally optimize an easier problem. Both the SOTA loop and KDA-Pilot put fixed workloads before patching.
- Interpret NCU results according to the kernel's compute characteristics.
For memory-bound kernels, focus on DRAM/L2 throughput, load/store efficiency, and memory pipe utilization. For compute-bound GEMM/attention kernels, focus on Tensor Core utilization, SM busy, eligible warps, and the main stall reasons. For small latency-bound kernels, check launch count, per-kernel duration, synchronization points, and possible fusion opportunities. A single trace screenshot is not enough; the next code change should be supported by specific metrics.
- Check backend and fallback gates before trusting a profile.
If an LLM run silently switches attention backend, disables CUDA graph, or takes a wrapper path different from the benchmarked one, the trace is no longer describing the target serving path. The same rule applies to diffusion: if logs show fallback to the diffusers backend, that trace cannot be used as evidence for native SGLang diffusion. These hard-stop conditions should live in the skill.
- Kernel optimization must use the same ABI, wrapper, and compile flags.
In particular, the candidate should not silently take a lighter path, and --use_fast_math should not be enabled on only one side.
- Review matters more than before.
Agents can create more PRs, and they can also create more plausible mistakes. Review for a high-performance system like SGLang needs to check shape, dtype, distributed execution, CUDA graph behavior, fallback behavior, accuracy, serving APIs, metrics, and benchmark setup.
Agent-era SGLang development will not remove developers from the system. The more realistic change is to write developer experience into workflows, hand repetitive execution to agents, and leave judgment, design, and review to people. The saved time can go into harder performance problems, model paths, and production stability, or back into improving the agent workflow itself. For an open-source inference framework, this kind of infrastructure is worth sustained investment.
7. Acknowledgments
We thank the SGLang Team members and contributors who helped build the SGLang agent skills: Xiaoyu Zhang (BBuf), Lianmin Zheng, Liangsheng Yin, Ke Bao, fzyzcjy, Kangyan Zhou, DarkSharpness, Mick, Alison Shao, Baizhou Zhang, Bingxu Chen, Cheng Wan, Ratish P, shuwenn, ykcai-daniel, Yuhao Yang, and Artem Savkin.
We thank the KDA team: Dongyun Zou, Ligeng Zhu, Sihao Liu, Junxian Guo, Yixin Dong, Zijian Zhang, Hao Kang, and Song Bian.
We thank the Humanize team and contributors: Sihao Liu, Ligeng Zhu, Zijian Zhang, Zenus Zhang, shinan6, DYZhang, Chao Liu, Zhou Yaoyang, gyy0592, AcrossForest, Emin, Qiming Chu, jiaxiaoyu, tastynoob, and zhenwei.
8. References
- SGLang GitHub Repository
- SGLang .claude/skills
- SGLang diffusion .claude/skills
- AI-Infra-Auto-Driven-SKILLS
- AI-Infra-Auto-Driven-SKILLS prompts
- Kernel Design Agents (KDA)
- KernelWiki skill
- ncu-report-skill
- KDA-Pilot
- SGLang Diffusion Advanced Optimizations, LMSYS Blog
- OpenAI Codex Prompting: Goal mode
- Humanize
関連記事
今日のまとめ
AIデイリーブリーフで今日の重要ニュースをまとめ読み