エージェント支援による SGLang の開発(18 分読了)
SGLang プロジェクトが、LLM サービングやカーネル設計などの複雑な開発ワークフローを「SKILL.md」形式のスキルとして構造化し、AI エージェントによる実行可能な自動化を実現する新たな開発パラダイムを示している。
キーポイント
暗黙知の形式化と自動化
従来の開発者個人の記憶に依存していた CUDA クラッシュ対応やプロファイリングなどのワークフローを、実行可能な「SKILL.md」ファイルとして標準化し、エージェントが自律的に処理できるようにした。
専門分野別スキルの構築
SGLang のコア開発、拡散モデル(diffusion)のワークフロー、クロスフレームワークベンチマーク、およびカーネル設計(KDA)に特化したエージェントスキルセットをそれぞれ独立して整備・運用している。
実証された成果と統合
KDA-Pilot などのプロジェクトを通じて生成された改善案が実際に SGLang のマージ済み PR に反映され、B200 環境での拡散タスクなど具体的なパフォーマンス向上実績を上げている。
再現性と検証可能性の重視
エージェントによる開発プロセスにおいて、手順の明確化、実験の再現性、そしてレビュー可能な証拠(evidence)の蓄積が価値の核心であると位置付けている。
SGLang エージェントスキルの階層構造
エージェントスキルは、デバッグやベンチマークなどのソースコードに近い低レベル作業から、クロスフレームワーク比較や生産環境のインシデント対応など高レベルなワークフローまで多層的に構成されている。
エージェント活用時の標準化された質問枠組み
スキルの効果的な運用には、「いつ使うか」「どのように開始し、検証し、判断し、納品するか」という5つの主要な問いに対する具体的なチェックリストと出力要件が定義されている。
スキルベースの自動化ワークフロー
CUDA クラッシュやベンチマーク、容量計画など、複雑なインフラ課題を解決するための具体的な「スキル」が定義され、実行可能で再開可能なプロトコルとして実装されています。
重要な引用
As agent tools mature, this experience can be turned into executable SKILL.md files, scripts, benchmark contracts, and review loops.
The value of agents comes from procedural engineering knowledge, including executable steps, reproducible experiments, and reviewable evidence.
Agents are most useful in SGLang when they can keep moving along a well-defined workflow.
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.
These entries turn easy-to-miss steps into executable protocols so the workflow can run, resume, and be reviewed.
影響分析・編集コメントを表示
影響分析
この記事は、AI インフラ開発における「人間中心の暗黙知」から「エージェント中心の形式化された知識」への転換点を示しており、大規模なオープンソースプロジェクトの維持・拡張性を劇的に高める可能性を秘めています。特に、複雑なハードウェア最適化やトラブルシューティング領域での自動化成功事例は、今後の AI エージェント開発ツールチェーンの標準的なあり方を定義する重要な指標となります。
編集コメント
SGLang プロジェクトが示す「SKILL.md」による開発プロセスの形式化は、単なるツールの進化を超え、AI インフラ開発そのもののパラダイムシフトを示唆しています。特に複雑なハードウェア最適化領域でのエージェント活用実績は、今後の業界標準として注目すべき動きです。
SGLang の開発は、もはや孤立したコード変更の域を超えつつあります。同じリポジトリには、LLM サービング、分散ランタイム、GPU カーネル、拡散パイプライン、モデル固有の実行パス、そして本番環境でのインシデント対応など、多岐にわたる要素が含まれるようになりました。かつてはこれらのワークフローの多くが個々の開発者の記憶に依存していました:特定のモデルを起動する方法、プロファイルトレースを読み取る方法、CUDA クラッシュをデバッグする際に最初にどのログを追加すべきか、あるいはパフォーマンス PR に含めるべきベンチマークは何かといったことです。エージェントツールの成熟に伴い、こうした経験則を実行可能な SKILL.md ファイル、スクリプト、ベンチマーク契約、そしてレビューループへと変換することが可能になっています。
SGLang エージェント開発の周辺では、LLM および拡散ワークロードの両方に対して、すでに一連のスキルセットが確立されています:
- SGLang の .claude/skills は SGLang リポジトリ内部で維持管理されており、CUDA クラッシュのデバッグ、カーネル統合、テスト、CI、プロファイリング、本番環境でのトリアージ、ソースツリー規約など、リポジトリレベルの開発ワークフローを網羅しています。
- SGLang 拡散用の .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(要約)
- エージェントが最も有用なのは、明確に定義されたワークフローに沿って継続的に動作できる場合です。ベンチマーク測定、プロファイリング、カーネル API ログの取得、拡散パイプラインの追加、本番環境インシデントの再生、SOTA(State-of-the-Art)ループなどはすべてスキルとしてエンコード可能です。
- SGLang におけるスキルとは、実行可能な開発手順のことです。debug-cuda-crash、sglang-diffusion-benchmark-profile、llm-torch-profiler-analysis においては、事前チェック、堅牢な失敗ゲート、アーティファクト契約、再現コマンド、結果フォーマットが重要な要素となります。
- プロファイリング証拠はパフォーマンス作業の中心です。SGLang プロファイラーのスキルは、固定されたカーネルテーブル、オーバーラップ機会のテーブル、および融合パターンのテーブルを生成します。KDA-Pilot はこれを、同じ ABI ベースラインと候補の比較、実際のワークロード、正しさのゲート、NCU 証拠、形状ごとの結果へと拡張しています。
- 長期にわたる最適化は、ループエンジニアリングへと移行し始めています。SGLang の SOTA(State-of-the-Art)パフォーマンスループは、「SOTA を追う」ことを、公平なベンチマーク、ギャップの判断、プロファイリング、パッチ適用、再検証という段階に分解します。Humanize/RLCR は外部レビューを追加し、Codex Goal はより低い調整オーバーヘッドで同じループを実行できます。
- 査読(レビュー)の重要性が高まっています。エージェントはより多くの実験を実行できますが、同時に、妥当に見えるが依然として慎重なレビューを必要とする変更も生成します。開発者はますます、問題の定義、証拠の選択、ワークフローの設計、そして結果が生産環境パスに適合するかどうかの決定を行います。
2. なぜ SGLang がエージェント支援開発に適しているか
SGLang は、LLM(大規模言語モデル)およびマルチモーダルモデル向けの高性能なサービングフレームワークです。モデルファミリーとハードウェアパスが拡大するにつれ、開発においていくつかの recurring な問題が発生します。
- LLM のパスは複雑です。単一の性能問題は、Python ランタイム、スケジューラ、CUDA グラフ、Triton/CUDA カーネル、FlashInfer/FlashAttention、分散コレッティブ(collectives)、およびモデル固有のラッパーを横断する可能性があります。
- Diffusion パスも複雑です。低速のデノイズパスには、パイプライン/ステージ分割、DiT ブロック、アテンションバックエンド、torch.compile グラフブレイク、CFG/SP 並列化、VAE、またはカスタム融合カーネルが含まれる場合があります。
- バリデーションは高コストです。多くの変更は、H100、H200、B200、または RTX 5090 上の実際のモデルと実際のワークロードでテストする必要があります。ローカルのユニットテストだけでは不十分です。
- プロファイルの再利用は手動では困難です。単一のトレースには数百個のカーネル起動が含まれる可能性があります。Perfetto を人手で読むと、カーネルから Python ソースへのマッピングを見逃したり、prefill と decode を混同したりするリスクがあります。開発者はプロファイラー出力を読み込むことでノウハウを蓄積します。例えば、どのカーネル名がどのモデルロジックに対応するか、どの起動パターンがグラフブレイクを示唆するか、そして NCCL/アテンション/MLP のレイアウトが標準的であるかなどです。その知識が一人の頭の中だけに留まっている場合、次のタスクではそれを再利用できません。
- パフォーマンスに関する結論は文脈に大きく依存します。GPU タイプ、形状、バッチサイズ、並列化方式、精度、バックエンド、コンパイル状態などはすべて結果を変化させます。孤立したマイクロベンチマークだけでは、実際のモデルレベルでの恩恵を証明できないため、固定されたワークロード下でスループット、レイテンシ、メモリ使用量、精度、安定性を繰り返し検証するためのエンドツーエンドの長時間実行テストプロセスが必要です。このプロセスは労働集約的であり、時間がかかります。
これらの問題はエージェントにとって自然な適性を持っています。サーバーの起動、ワークロードの修正、トレースの収集、プロファイル行の選別、テストの追加、実験結果の記録などは、明確な入力と出力を持ち、スクリプト化や反復実行に非常に適しています。開発者が定義すべきは境界線です。同じベンチマーク設定、同じプロファイル解釈ルール、同じ精度ゲート、そしてエージェントがコードの変更を停止する条件です。
ここで議論されているエージェントは、エンジニアリングワークフローによって制約された実行役です。反復的な SGLang 開発手順はスキルとして捉えることができ、これによりエージェントが反復的な実行、証拠の収集、状態の追跡を担当できるようになります。開発者は依然として目標の定義、証拠の評価、変更が実際のサービングパスに属するかどうかのレビューという責任を負います。
3. プロンプトエンジニアリングから SKILL へ:プロトコルと例
SGLang フレームワークにおいて、有用なスキルは少なくとも以下の問いに答えなければなりません:
質問 | スキルが捉えるべき内容
---|---
いつ使用するか | トリガーシナリオ、サポート対象モデル、サポート対象ハードウェア、および強制停止ケース
どのように開始するか | プレフライトチェック、環境変数、リポジトリの状態、依存関係のチェック、モデル設定
どのように検証するか | ベンチマークコマンド、プロファイルコマンド、テストエントリーポイント、精度ゲート
どのように判断するか | 出力テーブル、失敗モード、優先順位、リスクカテゴリ、フォールバック条件
必ず JSON 形式で返してください。translation フィールドのみ。他のフィールド (technical_terms 等) は一切追加しないこと — 余計なフィールドを書こうとして本文翻訳がトークン上限で打ち切られる事故を防ぐため:
{"translation": "これらの問題はエージェントにとって自然な適性を持っています。サーバーの起動、ワークロードの修正、トレースの収集、プロファイル行の選別、テストの追加、実験結果の記録などは、明確な入力と出力を持ち、スクリプト化や反復実行に非常に適しています。開発者が定義すべきは境界線です。同じベンチマーク設定、同じプロファイル解釈ルール、同じ精度ゲート、そしてエージェントがコードの変更を停止する条件です。
ここで議論されているエージェントは、エンジニアリングワークフローによって制約された実行役です。反復的な SGLang 開発手順はスキルとして捉えることができ、これによりエージェントが反復的な実行、証拠の収集、状態の追跡を担当できるようになります。開発者は依然として目標の定義、証拠の評価、変更が実際のサービングパスに属するかどうかのレビューという責任を負います。
3. プロンプトエンジニアリングから SKILL へ:プロトコルと例
SGLang フレームワークにおいて、有用なスキルは少なくとも以下の問いに答えなければなりません:
質問 | スキルが捉えるべき内容
---|---
いつ使用するか | トリガーシナリオ、サポート対象モデル、サポート対象ハードウェア、および強制停止ケース
どのように開始するか | プレフライトチェック、環境変数、リポジトリの状態、依存関係のチェック、モデル設定
どのように検証するか | ベンチマークコマンド、プロファイルコマンド、テストエントリーポイント、精度ゲート
どのように判断するか | 出力テーブル、失敗モード、優先順位、リスクカテゴリ、フォールバック条件"}
成果物ディレクトリ、結果スキーマ、PR 説明、再現コマンド、およびレビュー要件をどのように提供するか
SGLang エージェント関連のスキルは異なるレイヤーにまたがっています。デバッグ、テスト、拡散モデルの追加、ベンチマーク/プロファイルワークフローなど、ソースコードの変更に近いものもあれば、クロスフレームワークベンチマーク、キャパシティプランニング、計算シミュレーション、本番環境インシデントのトリアージ、PR 最適化に関する知識、SGLang の人間によるレビュースタイル、そして Humanize や RLCR といったより高レベルなワークフローを対象とするものもあります。
3.1 現在のスキルスタック
一般的に使用される SGLang エージェント関連のスキルは、以下のグループに分類されます。
レイヤー | 代表的なスキル/プロジェクト | 解決する問題
---|---|---
CUDA クラッシュ|debug-cuda-crash|カスタムオペレーションやカーネル API の境界付近での入力、例外、ダンプを記録し、一時的なクラッシュをオフラインで分析可能なサンプルに変換します
LLM ベンチマーク|llm-serving-auto-benchmark|SGLang および他の OpenAI 互換推論スタック全体で、公平かつ制限付き、再開可能なサービングベンチマーク検索を実行します
キャパシティプランニング|llm-serving-capacity-planner|SGLang および他の推論フレームワークの起動ログを解析し、重みメモリ、KV キャッシュ予算、CUDA グラフオーバーヘッド、リクエストキャパシティ、および OOM(Out Of Memory)負荷について説明します
Trace triagellm-torch-profiler-analysis は、修正済みのカーネル、重なり合いの機会、融合パターンのテーブルを生成し、カーネルを Python ソースコードにマッピングします。同じ統一されたワークフローは AI-Infra にも存在し、クロスフレームワークでの利用が可能です。
Pipeline/layer analysisllm-pipeline-analysis は、torch profiler のトレースを順方向パス、レイヤー、カーネルフローにスライスし、定常状態のパス、ボトルネックとなるレイヤータイプ、Perfetto の時間範囲を特定します。
Model compute simulationmodel-compute-simulation は、LLM 向けの演算子レベルの計算テンプレートを作成し、テンソル形状、FLOPs(浮動小数点演算数)、MFU(モデル利用率)、カーネルと演算子のマッピング、並列化に関する「もしも」シナリオを推定します。
Diffusion benchmark/profilesglang-diffusion-benchmark-profile は、ノイズ除去のレイテンシ、パフォーマンスダンプ、torch profiler のトレースをキャプチャします。その際、実行が実際にネイティブの SGLang Diffusion バックエンドを使用していることを最初に確認します。
拡散モデルの追加 sglang-diffusion-add-model Diffusers/reference パイプラインから新しい拡散モデルを SGLang のパイプライン/ステージ/モデル/構成構造に追加します
拡散モデルのパフォーマンスチューニング sglang-diffusion-performance torch.compile、ウォームアップ、SP/CFG 並列化、オフロード、アテンションバックエンド、量子化などのパフォーマンス設定を選択します
本番環境のトリアージ sglang-prod-incident-triage 実行サーバーバンドルを収集し、失敗したリクエストを保存して再生し、その後、集中的なクラッシュ/ハング/プロファイリングツールへルーティングします
SGLang のレビュー / PR 履歴 sglang-humanize-review および model-pr-history-knowledge 実際のメンテナーの議論パターンに対して SGLang のパッチをレビューし、変更されたソースコードに近い位置で PR ドライブ型のモデル進化履歴を保持します
SGLang SOTA Performance Loop (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% 低下
| エージェントはキャッシュ対応ルーティング、チャットエンコーダーの整合性、エンジン側の入力 ID フォールバック、プロキシボディ構築を統合的に処理し、ルーターとエンジンでのトークン化の重複を回避しました
Qwen3-Next FlashInfer allreduce fusion、SGLang PR #22664 H100 TP=4 の環境で、リクエストスループットが 5.49 req/s から 9.41 req/s に向上し、約 +71.4% の改善となりました。また、平均 TTFT(Time To First Token)は 456.24 ms から 167.54 ms に低下しました。これはプロファイル駆動型の LLM コレクティブ最適化であり、融合されていないクロスデバイスリダクションがプリフィルを支配していた状況に対し、融合された allreduce パスが MMLU/GSM8K の精度チェックを通じて検証されました。
Cohere2Moe NVFP4 fused-MoE path、SGLang PR #27401 1x B300 上で CohereLabs/command-a-plus-05-2026-w4a4 を実行した結果、チャット処理ではリクエストスループットが以前の SGLang デフォルトより +26%、要約処理では +21% 向上しました。また、同環境における他のオープンソース推論フレームワークと比較しても、それぞれ +4.1% / +6.8% の性能差で上回りました。この変更によりルーティングセマンティクスが完成し、既存の flashinfer_trtllm NVFP4 fused-MoE カーネルを実際のモデルパス内で正しく利用できるようになりました。GSM8K/MMLU による検証も完了しています。
Kimi Delta Attention CuteDSL prefill kernel on SM100、SGLang PR #27488 moonshotai/Kimi-Linear-48B-A3B-Instruct において、B200 上での Delta Attention プリフィルは Triton よりも 1.08 倍〜1.52 倍高速化されました。GSM8K のスコアは 0.915 から 0.920 に向上し、現実的なゲート値に対応する新たな回帰テストが追加されました。このカーネルタスクでは、モデルのゲート分布、数値オーバーフロー、ホストオーバーヘッド、実モデルにおける精度、およびユニットテストを網羅的にカバーした上でなければ、最適化のマージは完了しませんでした。
スペクトルプログレッシブ拡散、SGLang PR #27524 における FLUX.1、FLUX.2、Z-Image、Wan、Qwen-Image のノイズ除去速度向上は、報告された RTX A6000 環境においてそれぞれ 1.63 倍、1.77 倍、2.07 倍、2.32 倍、1.6 倍に達しました。これは拡散側のシステム最適化であり、初期のノイズ除去は低い潜在解像度で実行され、高周波の詳細が重要となる段階で GPU DCT(離散コサイン変換)によるアップサンプリングがフル解像度を復元します。
LTX-2 VAE のデコードチャンネルを末尾に配置する 3D 処理、SGLang PR #27431 では、LTX-2 のデコード段階が 5.41 秒から 3.84 秒へ改善され、約 1.41 倍の高速化を達成しました。また、ピーク確保メモリは 71.81 GiB から 62.12 GiB に減少し、約 9.7 GiB の節約となりました。プロファイリング結果から Conv3d(3 次元畳み込み)とレイアウト変換がボトルネックであることが判明したため、修正では因果パディングにおけるメモリフォーマットを保持し、ローダーポリシーを単一 GPU 向け LTX-2 に接続しました。
これらの例において、エージェントは主にワークフローの実行に貢献しています。具体的には、ベンチマークの実行、プロファイルの読み取り、Python ソースコードの特定、コードの変更、テストの追加、再検証、および PR(プルリクエスト)の説明書の準備です。スキルがなければ多くの工程で手動での指示が必要となりますが、これらがスキルとしてエンコードされることで、ワークフローを繰り返すことがはるかに容易になります。
4. プロファイリング、レビュー、ループエンジニアリング
SGLang のパフォーマンス最適化における一般的な誤りは、総実行時間のみを参照したり、Perfetto を数分間開いて直感で「何かを融合させるべきだ」と判断することです。これはエージェントにおいては特に危険であり、視覚的にホットなカーネルが実際のボトルネックであると誤認しやすいからです。
実際には、通常 2 つのプロファイリングスキルを組み合わせて使用します。llm-torch-profiler-analysis はトレースの最初の層のトリアージを担当し、グローバルプロファイルを 3 つの固定テーブルに変換します:
- カーネルテーブル:ステージごとの GPU 時間シェア、起動回数、カーネルカテゴリを要約し、可能な限りカーネルを Python ソースコードや CPU オペレーションにマッピングします。
- オーバーラップ機会テーブル:排他的/隠れた時間シェア、依存関係リスク、およびカーネルカテゴリを用いて、残りのオーバーラップ余地または余裕を特定します。
- 融合パターンテーブル:SGLang、他のオープンソース推論フレームワーク、およびカーネルライブラリにおける融合・オーバーラップパスのソースコードに裏打ちされたパターンカタログとトレースを比較します。
これらのテーブルは最初の質問群に対する回答を提供します。すなわち、どのステージとどのカーネルがどれだけの GPU 時間を消費しているのか、それらがどの Python ラインに対応するのか、そして学習可能な既存の融合・オーバーラップパスが存在するかどうかです。SGLang が他の推論フレームワークに劣っている場合、コード変更を開始する前にプロファイラーテーブルがその差を説明すべきです。
次のステップは llm-pipeline-analysis です。グローバルなホットスポットが分かっても、それらがどのフォワードパス、レイヤータイプ、カーネルフローに属するのかを知る必要があります。このスキルは Chrome トレース JSON とモデルの config.json を読み込み、レイヤー境界を定義するアンカーカーネルを用いてトレースをフォワードパスとレイヤーに分割し、より深い分析のための複数のテーブルを生成します:
- フォワードパスサマリー: コールドスタートと定常状態を分離し、ウォームアップが最適化のターゲットにならないようにします。
- レイヤー別タイムライン: 各レイヤーについて壁時計時間、合計継続時間、および MLA、MoE、GEMM、NCCL、MHC、Hadamard などのカテゴリの割合を報告します。
- レイヤークラスタ統計: 特に compress_ratios を持つ NSA/ハイブリッドアテンションモデルなど、交互にレイヤー構造が変化するモデルにおいて有用です。このような場合、C4_LIGHT、C128_HEAVY、HASH、または他のレイヤータイプがレイテンシを支配することがあります。
- 計算フローテーブル: 代表的なレイヤーを、ホットネス、相対タイムスタンプ、入力次元を含む具体的なカーネルフローに展開し、Perfetto に簡単に戻れるようにします。
したがって、プロファイル分析は 2 つのステップからなるプロセスとなります。まず llm-torch-profiler-analysis が全体のトレースにおける主要な競合を特定します。次に llm-pipeline-analysis が問題を定常状態のフォワードパス、代表的なレイヤー、具体的なカーネルフローに位置づけます。最初のステップは直感による方向選択を防ぎます。2 つ目のステップは、モデル構造内のレイヤータイプの違いを見落としながら、1 つのグローバルホットカーネルをじっと見つめることを防ぎます。
4.1 Humanize/RLCR: ループへの外部レビューの追加
Humanize は、長期実行タスクにおけるステータス管理とレビューを扱います。高リスクの SGLang パフォーマンスタスクは、通常 1 回の実装パスで完了しません。ベンチマーク、プロファイリング、パッチ適用、元に戻す、方向転換、再検証といった多くのラウンドを経る可能性があります。Humanize はこのプロセスを 2 つのステージに分割します。
- まず gen-plan を実行します。humanize-gen-plan はドラフト要件を構造化された plan.md に変換し、そこにはゴールの説明、受容基準、正負のテスト、パス境界、マイルストーン、実装ノートが含まれます。
- 次に RLCR ループを実行します。humanize-rlcr は plan.md からループを開始します。各ラウンドで Claude Code は .humanize/rlcr/<timestamp>/round-<N>-prompt.md を読み込み、実装し、コミットし、サマリーを記述します。その後 Codex Review がステータスファイル、サマリー、git のクリーンliness、レビュー結果、未解決の質問、最大反復条件、その他のゲートを確認します。「タスク完了」という単なる一文だけではループから脱出することはできません。
このメカニズムは、SGLang SOTA パフォーマンスループの実行とレビューの基盤を提供します。Claude Code はベンチマークを実行し、プロファイルを読み込み、SGLang コードを変更し、再検証を行います。Codex Review は各ラウンド終了時に証拠、ステータス、リスクを確認します。これは PR になる可能性のあるタスクや、サービングの正しさに影響を与えるタスク、あるいは数日間にわたる多段階の実験を必要とするタスクに特に適しています。
実際には、エージェントが直接実装に移行しないよう、コマンド順序は明示的に指定する必要があります。
- artifact_root/draft.md の下にタスクドラフトを作成します。
- humanize-gen-plan を実行して、artifact_root/plan.md を生成します。
- artifact_root/plan.md から humanize-rlcr を起動します。
- すべての意思決定、要約、およびレビュー状態は、ローカルの Humanize ワークスペース内に保持してください。
4.2 SGLang SOTA Performance Loop (Loop Engineering)
単一のスキルで一つのタスクを安定させることは可能です。しかし、十数回の実験を繰り返した結果、新たな問題が浮き彫りになります:どの候補が最良なのか、どの方向性がすでに失敗しているのか、直前の NCU レポートは何を示していたのか、ベンチマークは依然としてベースラインと一致しているのか、そしていつ停止すべきか。この状態情報はチャットコンテキスト内だけに存在させることはできません。
SGLang SOTA Performance Loop は、Humanize/RLCR に基づいて構築された Loop Engineering ワークフローです。ここでいう SOTA とは、固定された実験条件下における最良の再現可能な結果を指します:同じモデル、ハードウェア、GPU 数、精度、ワークロード、SLA(サービスレベルアグリーメント)、フレームワークコミット、およびサービングパラメータです。問われるのは、これらの条件下で SGLang が現在の最良の再現可能な結果に到達できるかどうかです。
図 1: SGLang SOTA Performance Loop。まず固定された公平なベンチマークによって再現可能なベースラインが確立されます。その後のギャップ判断、プロファイリング、パイプライン分析、パッチ適用、再検証は、Humanize/RLCR ループによって駆動されます。
完全な SGLang SOTA Performance Loop には、以下のステージが含まれます:
- ターゲットの境界を定義する。例えば、Qwen/Qwen3-Next-80B-A3B-Instruct-FP8、シングルノード構成で 2x B200 GPU を使用し FP8 量子化、SGLang の TP=2(Tensor Parallelism: テンソル並列)設定とし、同じ 2-GPU バジェット下で要求されたオープンソース推論フレームワークと比較する。
- まず公平な検索を実行する。SGLang にパッチを適用する前に、同じ負荷とリソース予算の下で、SGLang および各要求されたオープンソース推論フレームワークに対して再現可能な最適なコマンドを検索する。
- 差額(ギャップ)を判断する。もし SGLang が既に同等かそれ以上の性能を示す場合は、完了の証拠を記録する。一方、しきい値を超える遅れが継続している場合は、プロファイリングへ進む。
- プロファイルを用いて差額を説明する。安易にコード変更を行う前に、まずカーネルテーブル、パイプラインテーブル、オーバーラップ/融合テーブル、必要に応じて NCU(NVIDIA Compute Profiler)レポートを作成する。
- 証拠によって裏付けられたパスのみをパッチ適用する。具体的には、ハイブリッドアテンション、Mamba/GDN、ラディックスキャッシュ、ターゲット検証、CUDA グラフ、MoE/EP(Mixture of Experts / Expert Parallelism)、量子化カーネル、またはモデルラッパーなどである。
- 同じ負荷で再検証を行う。各ラウンドではベンチマーク結果、プロファイルデータ、精度、失敗した試行、環境情報、およびクリーンアップアクションを記録する。
2x B200 上で Qwen/Qwen3-Next-80B-A3B-Instruct-FP8 のようなターゲットモデルを扱う場合、ループが重要となるのは、ベンチマーク結果、プロファイルトレース、失敗したパッチ、中間結論のすべてが、同じモデル・ハードウェア・ワークロード・フレームワークコミットに紐付いていなければならないからです。もしこの種のタスクを多数の独立したプロンプトに分割すると、どのコマンドがどの結果を生んだのか、あるいは後続のプロファイルがもとのベースラインと依然として整合しているのかを見失う容易さがあります。証拠とレビューを伴うループを用いることで、各ラウンド間で条件を整合させることができます。
4.3 Codex Goal: より低コストなループ実装
上記の SGLang SOTA Performance Loop は、Claude Code がベンチマーク実行・プロファイリング・パッチ適用・再検証を行い、Codex Review が各ラウンド終了時にチェックを行うという 2 つの役割分担構成を採用しています。この構成は本格的な PR(Pull Request)作業には適していますが、各ラウンドで実行モデルとレビューモデルの両方を消費するため、コストと待機時間が増加します。
Codex Goal は別の実装方法を提供します。「公平なベンチマーク → 差の判断 → プロファイリング → パッチ適用 → 再検証 → アーティファクト台帳」という一連の流れを永続的な Goal に記述しておけば、単一の Codex Goal が実行・自己チェック・再検証を一貫して担うことができ、2 つの役割分担による実行/レビュー構成は不要になります。SGLang SOTA Performance Loop の核心的な制約はそのまま維持されます:固定されたワークロード、証拠に基づくパッチ、同一の実験条件下での再検証、そして各ラウンド終了後のアーティファクトマニフェスト更新です。
両アプローチの違いは以下の通りです。
| Dimension | Humanize/RLCR SOTA Loop | Codex Goal |
|---|
ExecutionClaude Code は実装と実験を処理し、Codex Review は各ラウンドを検証します。One Codex Goal は継続的に実行され、自己チェックを行い、再検証を行います。
State location: Plan, プロンプト、サマリー、およびレビュー結果は .humanize/rlcr/... 下に保存されます。現在のゴールスレッドとマニフェスト/証拠は artifact_root 内に配置されます。
Review method: Stop hook、Codex Review、および git/state/schema チェックを行います。ゴールレベルの自己チェック、アーティファクト契約、および人間のスポットチェックを実施します。
Cost: 2 つのモデル役割が参加するため、各ラウンドのコストは高くなります。一方、One Goal は実行とチェックの両方を担うため、コストを削減できます。
Main risk: ループ設定がより複雑になり、各ラウンドの待機時間が長くなる可能性があります。ゴールのドリフトや、明確なハードストップ条件がない場合の早期完了というリスクがあります。
以下は、AI-Infra-Auto-Driven-SKILLS/prompts から引用した、2x B200 モデル最適化プロンプトの例です。
Humanize/RLCR バージョン:
sglang-sota-humanize-loop ワークフローを使用してください。
タスク:
単一ノード上の 2 枚の NVIDIA B200 GPU、FP8 精度、初期 SGLang TP=2 の環境において、Qwen/Qwen3-Next-80B-A3B-Instruct-FP8 の SGLang サービングパフォーマンスを最適化してください。SGLang は、要求されたオープンソース推論フレームワークの同じ 2 GPU バジェット、ワークロード、SLA(Service Level Agreement: サービスレベル契約)、モデル、精度、および環境制約下で達成可能な最良の再現結果に匹敵するか、それを超える必要があります。
必ず JSON 形式で返してください。translation フィールドのみ。他のフィールド (technical_terms 等) は一切追加しないこと — 余計なフィールドを書こうとして本文翻訳がトークン上限で打ち切られる事故を防ぐため:
{"translation": "翻訳全文"}
必要なワークフロー:
- artifact_root の下にドラフトタスクドキュメントを作成する。
- humanize-gen-plan を実行して、ドラフトを構造化された plan.md に変換する。
- Claude Code セッション内でその plan.md から humanize-rlcr を起動する。
- ベンチマーク、プロファイリング、パッチ適用、再検証に関する決定は、すべて同じ Humanize ワークスペース内に保持すること。
証拠と安全性要件:
- パッチ適用前に、SGLang と要求されたオープンソース推論フレームワークセットに対して公平な有界検索を実行する。
- SGLang ベースラインを選択する前に、sgl-project/sglang および BBuf/sglang 内の関連する未解決 PR を確認する。
- SGLang の遅れが 1% を超える場合は、パッチ適用前にプロファイリングを行う。
- ハイブリッドアテンション(hybrid attention)、Mamba/GDN、ラディックスキャッシュ(radix cache)、ターゲット検証(target verify)、CUDA グラフに関する証拠を優先する。
- 各ラウンドについて、ベンチマークコマンド、プロファイル成果物、失敗した試行、クリーンアップの証拠を記録する。
- 証拠によって裏付けられた SGLang のコードパスのみをパッチ適用する。
- PR が必要な場合は、BBuf/sglang に対してのみプッシュまたはオープンし、ベンチマーク結果、GSM8K、および完全な MMLU 精度表を含めること。
artifact_root:
/workspace/sglang-agent-artifacts/b200_qwen3_next_80b_a3b_instruct_fp8_sota_humanize
Codex Goal バージョン:
/goal SGLang の Qwen/Qwen3-Next-80B-A3B-Instruct-FP8 モデルに対するシングルノード(2 枚の NVIDIA B200 GPU を搭載)での推論サービス最適化を、SGLang が同じ 2 GPU バジェット、FP8 精度、ワークロード、SLA(Service Level Agreement: サービスレベルアグリーメント)、モデル、環境制約の下で要求されたオープンソース推論フレームワークから得られる最良の再現可能な結果に匹敵するか、あるいはそれを上回るまで継続すること。現在の Codex のゴールは、このループ内で行われる一連のプロセスである:公平なベンチマーク測定、ギャップ判断、プロファイリング、パイプライン分析、根拠に基づくパッチ適用、再検証、最終報告書作成、および任意の PR(Pull Request)準備。
完了条件として、ベンチマークによる証拠、SGLang が劣っていた場合のプロファイルによる証拠、正解性・精度に関する証拠、最終的なアーティファクトマニフェスト、そして環境安全性制約における回帰(性能低下や不具合の再発)がないことが必要である。
model_id: Qwen/Qwen3-Next-80B-A3B-Instruct-FP8
root_dir: /workspace
target_hardware: シングルノード 2x NVIDIA B200
minimum_gpu_count: 2
precision_quantization: FP8(8 ビット浮動小数点量化)
initial_deployment: SGLang TP=2(Tensor Parallelism: テンソル並列度 2)
artifact_root:
/workspace/sglang-agent-artifacts/b200_qwen3_next_80b_a3b_instruct_fp8_sota_goal
要件:
- 現在の Codex の目標を、唯一の永続的なループとして使用してください。
- パッチ適用前に、同じ 2 GPU バジェット内で SGLang と要求されたオープンソース推論フレームワークについて、公平な有界検索を実行してください。
- SGLang が 1% を超えて遅れている場合は、同じ目標内でプロファイリングを行い、その後、必要に応じて llm-torch-profiler-analysis、llm-pipeline-analysis、ncu-report-skill をパッチ適用前に使用してください。
- ハイブリッドアテンション(hybrid attention)、Mamba/GDN、ラディックスキャッシュ(radix cache)、ターゲット検証(target verify)、CUDA グラフに焦点を当ててください。
- 各ラウンドごとに、アーティファクトマニフェスト、ベンチマーク証拠、プロファイル証拠、失敗した試行、次のステップの決定を更新してください。
- リソースが利用できない場合、証拠が信頼できない場合、予算が尽きた場合、または防御可能な次のパッチが存在しない場合は停止し、ブロック要因を報告してください。
目標バージョンは、同じベンチマーク、プロファイル、精度、アーティファクト要件を維持します。異なる点は、実行とレビューが 1 つの永続的なターゲットに統合されていることです。明確なハードストップ条件により、オーケストレーションを減らしつつ、同じ SGLang の SOTA(State-of-the-Art)パフォーマンスループを実現できます。
5. SGLang システム向けの KDA ベース CUDA カーネル最適化
LLM や拡散モデルレベルの最適化を超えて、カーネル最適化にはより厳しいスケーリング問題が存在します。ハードウェアやワークロードに依存しない単一の最良カーネルは存在しません。同じ演算子でも、H100、H200、B200、B300 といった異なるハードウェア上で異なる実装が好まれることがあります。また、異なるモデルアーキテクチャは異なるテンソル形状やレイアウト制約を露呈し、サービングワークロードではバッチサイズ、シーケンス長、精度フォーマット、ラッパーのオーバーヘッド、同期動作、フォールバックパスが変化します。実際には、探索空間はハードウェア、モデル、ワークロード定義の直積となります。
これは組み合わせ最適化の負担を生み出します。各候補カーネルに対して、開発者は代表的な生産環境の行データを抽出し、同じ ABI を持つハネスを構築し、A/B 測定を実行し、形状バケット全体で正しさを確認し、NCU メトリクスを読み込み、どのバケットが専門化に値するかを判断し、その後実際の SGLang パス内で再検証する必要があります。すべてのハードウェア/モデル/ワークロードの組み合わせを手動で行うのは高価です。これは同時に、人間が不変条件を定義し最終パスを検証する限りにおいて、エージェントが得意とする反復的で証拠に依存したワークフローの典型でもあります。
しかし、エージェントに CUDA を直接書かせることは、容易にベンチマーク報酬ハッキングにつながります。具体的には、ベンチマークを変更したり、軽量なラッパーを使用したり、ベースラインで使用していない高速数学を有効化したり、一つの形状のみを最適化したり、数値的意味論を破ったり、実際の SGLang パスで何の改善も生じない結果をもたらす可能性があります。
KDA-Pilot はカーネル最適化を独立したタスクに分割することで、エージェントが SGLang リポジトリ全体を自由に修正できないようにしています:
- ワークロードは実際の SGLang 拡散モデルから取得されます。まず 20 の拡散モデルを実行し、実際のカーネルメタデータを要約します。
- ベースラインは上位版の SGLang main ブランチからコピーされ、ソースの系譜が記録されます。
- ベースラインと候補は、同じローカル 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 の結果と一致しています。
2026 年 6 月 27 日現在、KDA-Pilot に由来する 3 つの最適化が SGLang の本流(upstream)にマージされました。1 つ目は SGLang PR #27392 で、Qwen-Image-2512 向けの B200 ネイティブ拡散ノルムスケールシフト CUDA ファストパスです。その週の後半にはさらに 2 つがマージされ、SGLang PR #29281 は Cosmos3 VAE の因果的 Conv3D cat/pad コピーパス向け、SGLang PR #29361 は LTX-2.3 のリジューアルゲート更新パス向けです。
本流 PRTarget パスカーネルレベルのエビデンスモデルパスエビデンス
#27392 Qwen-Image ノルムスケールシフトターゲットカーネルグループプロファイラーアトリビューションで 1.279 倍改善B200 1 台で片側あたり 5 回のインターリーブ実行を実施した結果、フルリクエスト速度が 1.125 倍、デノイズウォール時間が 1.130 倍向上
#29281 Cosmos3 因果的 Conv3D cat/padB200 の加重カーネルグループが、追跡された VAE デコード呼び出し全体で 10.621 ms から 5.240 ms(2.03 倍)に改善torch.compile を Cosmos3-Nano T2V で有効化すると、エンドツーエンド時間の中央値が 181.521 ms から 177.687 ms(1.021 倍)に改善
#29361 LTX-2.3 リジューアルゲート更新大規模 B200 の LTX-2.3 ロウが既存の Triton パスに対して 1.108 倍から 1.130 倍に改善し、隣接する拡散ロウでは最大 2.587 倍向上LTX-2.3 HQ T2V ではエンドツーエンド時間が 46644.08 ms から 45198.37 ms(1.032 倍)に改善
重要な教訓は、個々のスタンドアロンカーネルの勝利がそのまま大規模なエンドツーエンドの勝利になるということではありません。重要なのは、同じ KDA-Pilot 証拠パッケージ(固定された生産行、正しさゲート、同一 ABI 比較、プロファイラーによる帰属分析、実モデルチェック)を用いることで、カーネルタスクを孤立したベンチマークから、レビュー可能な SGLang サービングパスへと移行できるということです。
図 2: KDA-Pilot によって最適化された 10 の追跡対象 SGLang 拡散カーネルタスクに対する B200 の証拠。ほとんどの行は KDA-Pilot の壁面幾何平均速度向上比(wall-geomean speedup)を報告しています。壁面時間には、Python ディスパッチ、ラッパーのオーバーヘッド、カーネル起動、および cuda.synchronize() を通じて可視化される同期オーバーヘッドが含まれており、これは純粋なカーネルデバイス時間よりも実際の呼び出しパスに近いものです。
カーネルタスク B200 証拠 メイン最適化方向
qknorm_rope 1.1341x シェアド RoPE staging、Q/K 再利用、大規模行用高速パス
norm_infer 1.3523x Warp-row RMS、タイル化された永続型 RMS、8B/16B ベクトルパス
rotary_embedding 1.4912x 128 ビットベクトル 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_copy1.30xSingle-launch region copy, pitched 16B block gather, strict layout/device rejection
causal_conv3d_cat_pad2.06xFlat chunking, 16B vectorized stores, stride-aware fallback, bitwise-exact gate
residual_gate_add1.11xOne-pass CUDA fusion, pinned-GPU correctness, SGLang PR #29361 B200 Triton-row re-benchmark
このチャートとタスクリストは、実験設定を念頭に置いて読む必要があります。これらは抽出された生産環境の行におけるカーネル・タスクの高速化率を示しており、モデル全体のエンドツーエンドでの性能向上を表すものではありません。それでも有用です。ベースライン、ワークロード、正しさ、プロファイリング、レビューが確立されれば、エージェントは実際のフレームワークカーネルに対してレビュー可能な漸進的な改善を生成できるようになります。
KDA-Pilot 実験から得られた 2 つのルールは維持する価値があります:
- ベンチマーク報酬のハッキングの余地を残さないこと。ベースラインと候補が異なる ABI、異なる高速数学設定、または異なるラッパーパスを使用している場合、結果は信頼できなくなります。もう一つの一般的な問題は、結果を見た後にベンチマークの形状セットを変更することです。例えば、候補の方が遅い形状を削除するなど。そのような結果は使用すべきではありません。
- ルーフラインに近いバケットでは、実行不可またはフォールバックの判断を許容する必要があります。優れたカーネル最適化タスクとは、エージェントがすべての形状で勝利することを強制するものではありませんです。巨大な連続的なバケットや帯域幅制限にすでに近いパスにおいては、より複雑さを追加するよりも、フォールバックを記録する方がよい場合があります。
6. Practice Rules
- エージェントを開始する前にタスクの境界を定義してください。
「SGLang の最適化」は広すぎます。「固定された 1000→1000 および 8000→1000 のワークロード下で、2x B200 上で Qwen/Qwen3-Next-80B-A3B-Instruct-FP8 に対する別のオープンソース推論フレームワークとの性能を一致させること」こそが実行可能な目標です。
- プロファイルを読み込む前にベンチマークを固定してください。
結果が判明した後にワークロードを変更できる場合、エージェントは誤ってより簡単な問題を最適化してしまう可能性があります。SOTA ループと KDA-Pilot の両方で、パッチ適用前に固定されたワークロードを設定しています。
- カーネルの計算特性に応じて NCU(NVIDIA Compute Profiler)の結果を解釈してください。
メモリーバウンド型のカーネルの場合、DRAM/L2 スループット、読み書き効率、およびメモリーパイプの利用率に焦点を当てます。計算バウンド型の GEMM(General Matrix Multiplication: 一般行列乗算)やアテンションカーネルの場合は、Tensor Core の利用率、SM(Streaming Multiprocessor: ストリーミングマルチプロセッサ)の稼働率、対象となるワープ数、および主要なストール原因に焦点を当てます。小規模でレイテンシバウンド型のカーネルの場合、起動回数、カーネルごとの継続時間、同期ポイント、および融合の可能性を確認します。単一のトレーススクリーンショットでは不十分です。次のコード変更は、具体的なメトリクスによって裏付けられるべきです。
- プロファイルを信頼する前に、バックエンドとフォールバックのゲートを確認してください。
LLM の実行が静かにアテンションバックエンドを切り替えたり、CUDA グラフ(CUDA Graph)を無効にしたり、ベンチマークされたパスとは異なるラッパーパスを経由したりした場合、そのトレースはもはや対象となるサービングパスを記述しているものではありません。同様のルールが拡散モデルにも適用されます:ログに diffusers バックエンドへのフォールバックが表示される場合、そのトレースはネイティブ SGLang 拡散の証拠として使用することはできません。これらのハードストップ条件は、スキル(技能)内に実装しておくべきです。
- カーネル最適化では、同じ ABI(アプリケーションバイナリインターフェース)、ラッパー、コンパイルフラグを使用する必要があります。特に、候補が軽微なパスを黙って選択してはならず、--use_fast_math は片側だけで有効にしてはいけません。
- 以前以上にレビューが重要です。エージェントはより多くの PR を作成できますが、同時により説得力のある誤りも生み出します。SGLang のような高性能システムに対するレビューでは、形状、データ型、分散実行、CUDA グラフの動作、フォールバック動作、精度、サービング API、メトリクス、ベンチマーク設定を確認する必要があります。
- エージェント時代における SGLang 開発は、開発者をシステムから排除するものではありません。より現実的な変化とは、開発者体験をワークフローに組み込み、反復的な実行をエージェントに任せ、判断、設計、レビューを人間に残すことです。節約された時間は、より困難なパフォーマンス問題、モデルパス、プロダクションの安定性、あるいはエージェントワークフロー自体の改善に充てることができます。オープンソース推論フレームワークにとって、このようなインフラは持続的な投資価値があります。
7. 謝辞
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. 参考文献
- SGLang GitHub リポジトリ
- SGLang .claude/skills
- SGLang diffusion .claude/skills
- AI-Infra-Auto-Driven-SKILLS
- AI-Infra-Auto-Driven-SKILLS プロンプト
- Kernel Design Agents (KDA)
- KernelWiki スキル
- ncu-report-skill
- KDA-Pilot
- SGLang Diffusion 高度な最適化、LMSYS ブログ
- 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:
QuestionWhat the skill should capture
When to use itTrigger scenarios, supported models, supported hardware, and hard-stop cases
How to startPreflight checks, environment variables, repository state, dependency checks, and model configuration
How to validateBenchmark commands, profile commands, test entry points, and accuracy gates
How to decideOutput tables, failure modes, priorities, risk categories, and fallback conditions
How to deliverArtifact 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.
LayerRepresentative skill / projectProblem it solves
CUDA crashdebug-cuda-crashRecords inputs, exceptions, and dumps around custom op/kernel API boundaries, turning transient crashes into samples that can be analyzed offline
LLM benchmarkllm-serving-auto-benchmarkRuns fair, bounded, resumable serving benchmark search across SGLang and other OpenAI-compatible inference stacks
Capacity planningllm-serving-capacity-plannerParses SGLang and other inference-framework startup logs to explain weight memory, KV cache budget, CUDA graph overhead, request capacity, and OOM pressure
Trace triagellm-torch-profiler-analysisProduces 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 analysisllm-pipeline-analysisSlices torch profiler traces into forward passes, layers, and kernel flows to locate steady-state passes, bottleneck layer types, and Perfetto time ranges
Model compute simulationmodel-compute-simulationBuilds operator-level compute templates for LLMs and estimates tensor shapes, FLOPs, MFU, kernel-to-op mapping, and parallelism what-ifs
Diffusion benchmark/profilesglang-diffusion-benchmark-profileCaptures denoise latency, perf dumps, and torch profiler traces, while first checking that execution is actually using the native SGLang diffusion backend
Add diffusion modelsglang-diffusion-add-modelAdds a new diffusion model from a Diffusers/reference pipeline into the SGLang pipeline/stage/model/config structure
Diffusion performance tuningsglang-diffusion-performanceChooses performance settings such as torch.compile, warmup, SP/CFG parallelism, offload, attention backend, and quantization
Production triagesglang-prod-incident-triageCollects live-server bundles, saves failing requests, replays them, and then routes to focused crash/hang/profile tools
SGLang review / PR historysglang-humanize-review and model-pr-history-knowledgeReviews 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-loopFirst 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.
CaseResultKey point
Router long-context tokenization deduplication, SGLang PR #28744On 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 #22664On 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 msThis 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 #27401For 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 #27488For 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 magnitudesThis 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 #27524Denoising 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 setupThis 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 #27431The 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 GiBThe 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:
DimensionHumanize/RLCR SOTA LoopCodex Goal
ExecutionClaude Code handles implementation and experiments; Codex Review reviews each roundOne Codex Goal continuously executes, self-checks, and revalidates
State locationPlan, prompt, summary, and review results under .humanize/rlcr/...Current Goal thread plus manifest/evidence under artifact_root
Review methodStop hook, Codex Review, and git/state/schema checksGoal-level self-checks, artifact contracts, and human spot checks
CostTwo model roles participate, so each round costs moreOne Goal carries both execution and checks, reducing cost
Main riskMore complex loop setup and longer waits per roundGoal 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 PRTarget pathKernel-level evidenceModel-path evidence
#27392Qwen-Image norm-scale-shiftTarget kernel group improved by 1.279x in profiler attributionOn one B200, five interleaved runs per side showed 1.125x full-request speedup and 1.130x denoise-wall speedup
#29281Cosmos3 causal Conv3D cat/padB200 weighted kernel group improved from 10.621 ms to 5.240 ms, or 2.03x, across traced VAE decode callsWith torch.compile enabled on Cosmos3-Nano T2V, median E2E time improved from 181.521 ms to 177.687 ms, or 1.021x
#29361LTX-2.3 residual-gate updateLarge B200 LTX-2.3 rows improved 1.108x to 1.130x over the existing Triton path, with neighboring diffusion rows up to 2.587xOn 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 taskB200 evidenceMain optimization direction
qknorm_rope1.1341xShared RoPE staging, Q/K reuse, large-row fast path
norm_infer1.3523xWarp-row RMS, tiled persistent RMS, 8B/16B vector path
rotary_embedding1.4912x128-bit vector I/O, cos/sin hoisting, LTX2 block matching
cutedsl_norm_tanh_mul_add1.4953xRow-invariant math hoisting, launch-bounds tuning, exact tanh
cutedsl_norm_scale_shift1.3201xOperand-class dispatch, 16B/32B vectors, two-pass variance
fuse_scale_shift2.7499xrowgrid/flatvec/exact-C paths, cache hints, one-pass reduction
group_norm_silu2.3118xSplit-group stats, channels-last direct path, fallback for giant rows
attention_concat_copy1.30xSingle-launch region copy, pitched 16B block gather, strict layout/device rejection
causal_conv3d_cat_pad2.06xFlat chunking, 16B vectorized stores, stride-aware fallback, bitwise-exact gate
residual_gate_add1.11xOne-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日報で今日の重要ニュースをまとめ読み