Skip to content

[Spec] Enable FlashInfer autotune for spec draft - #29595

Merged
Fridge003 merged 13 commits into
mainfrom
mmangkad/flashinfer-spec-autotune
Jul 1, 2026
Merged

Fridge003 merged 13 commits into
mainfrom
mmangkad/flashinfer-spec-autotune

Conversation

@mmangkad

@mmangkad mmangkad commented Jun 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Enable FlashInfer autotuning for speculative decoding draft graph paths

Validation

Checked on GB300 with auto picking flashinfer_trtllm for both target and draft MoE runner backends:

sglang serve \
  --model-path nvidia/GLM-5.2-NVFP4 \
  --tensor-parallel-size 4 \
  --speculative-algorithm EAGLE \
  --speculative-num-steps 5 \
  --speculative-eagle-topk 1 \
  --speculative-num-draft-tokens 6

In this setup, the target model was already autotuned before this change:

Target:

[2026-06-29 01:38:08 TP3] Running FlashInfer autotune with cache: /root/.cache/sglang/flashinfer/autotune/0.6.12/sm103/15fc7a2edb371f48/rank_tp3_pp0_dp0.json
[2026-06-29 01:38:08 TP0] Running FlashInfer autotune with cache: /root/.cache/sglang/flashinfer/autotune/0.6.12/sm103/15fc7a2edb371f48/rank_tp0_pp0_dp0.json
[2026-06-29 01:38:08 TP1] Running FlashInfer autotune with cache: /root/.cache/sglang/flashinfer/autotune/0.6.12/sm103/15fc7a2edb371f48/rank_tp1_pp0_dp0.json
[2026-06-29 01:38:08 TP2] Running FlashInfer autotune with cache: /root/.cache/sglang/flashinfer/autotune/0.6.12/sm103/15fc7a2edb371f48/rank_tp2_pp0_dp0.json
[AutoTuner]: Tuning flashinfer::trtllm_fp4_block_scale_moe: 100%|███████████████████████████████████████████████████████████████████| 10/10 [01:29<00:00,  8.92s/profile]
[AutoTuner]: Tuning flashinfer::trtllm_fp4_block_scale_moe: 100%|███████████████████████████████████████████████████████████████████| 10/10 [01:29<00:00,  8.97s/profile]
[AutoTuner]: Tuning flashinfer::trtllm_fp4_block_scale_moe: 100%|███████████████████████████████████████████████████████████████████| 10/10 [01:29<00:00,  8.99s/profile]
[AutoTuner]: Tuning flashinfer::trtllm_fp4_block_scale_moe: 100%|███████████████████████████████████████████████████████████████████| 10/10 [01:30<00:00,  9.03s/profile]

With this change, the same run also autotunes both speculative draft phases:

Draft decode:

[2026-06-29 01:45:38 TP2] Running FlashInfer autotune with cache: /root/.cache/sglang/flashinfer/autotune/0.6.12/sm103/15fc7a2edb371f48/rank_tp2_pp0_dp0.json
[2026-06-29 01:45:38 TP0] Running FlashInfer autotune with cache: /root/.cache/sglang/flashinfer/autotune/0.6.12/sm103/15fc7a2edb371f48/rank_tp0_pp0_dp0.json
[2026-06-29 01:45:38 TP1] Running FlashInfer autotune with cache: /root/.cache/sglang/flashinfer/autotune/0.6.12/sm103/15fc7a2edb371f48/rank_tp1_pp0_dp0.json
[2026-06-29 01:45:38 TP3] Running FlashInfer autotune with cache: /root/.cache/sglang/flashinfer/autotune/0.6.12/sm103/15fc7a2edb371f48/rank_tp3_pp0_dp0.json
[AutoTuner]: Tuning flashinfer::trtllm_bf16_moe: 100%|████████████████████████████████████████████████████████████████████████████████| 7/7 [00:46<00:00,  6.62s/profile]
[AutoTuner]: Tuning flashinfer::trtllm_bf16_moe: 100%|████████████████████████████████████████████████████████████████████████████████| 7/7 [00:46<00:00,  6.64s/profile]
[AutoTuner]: Tuning flashinfer::trtllm_bf16_moe: 100%|████████████████████████████████████████████████████████████████████████████████| 7/7 [00:46<00:00,  6.71s/profile]
[AutoTuner]: Tuning flashinfer::trtllm_bf16_moe: 100%|████████████████████████████████████████████████████████████████████████████████| 7/7 [00:46<00:00,  6.71s/profile]

Draft extend:

[2026-06-29 01:46:29 TP1] Running FlashInfer autotune with cache: /root/.cache/sglang/flashinfer/autotune/0.6.12/sm103/15fc7a2edb371f48/rank_tp1_pp0_dp0.json
[2026-06-29 01:46:29 TP3] Running FlashInfer autotune with cache: /root/.cache/sglang/flashinfer/autotune/0.6.12/sm103/15fc7a2edb371f48/rank_tp3_pp0_dp0.json
[2026-06-29 01:46:29 TP2] Running FlashInfer autotune with cache: /root/.cache/sglang/flashinfer/autotune/0.6.12/sm103/15fc7a2edb371f48/rank_tp2_pp0_dp0.json
[2026-06-29 01:46:29 TP0] Running FlashInfer autotune with cache: /root/.cache/sglang/flashinfer/autotune/0.6.12/sm103/15fc7a2edb371f48/rank_tp0_pp0_dp0.json
[AutoTuner]: Tuning flashinfer::trtllm_bf16_moe: 100%|██████████████████████████████████████████████████████████████████████████████| 10/10 [00:28<00:00,  9.39s/profile]
[AutoTuner]: Tuning flashinfer::trtllm_bf16_moe: 100%|██████████████████████████████████████████████████████████████████████████████| 10/10 [00:28<00:00,  9.39s/profile]
[AutoTuner]: Tuning flashinfer::trtllm_bf16_moe: 100%|██████████████████████████████████████████████████████████████████████████████| 10/10 [00:28<00:00,  9.55s/profile]
[AutoTuner]: Tuning flashinfer::trtllm_bf16_moe: 100%|██████████████████████████████████████████████████████████████████████████████| 10/10 [00:28<00:00,  9.55s/profile]

Speed Test

python -m sglang.benchmark.serving \
  --backend sglang \
  --host 127.0.0.1 --port 30000 \
  --model nvidia/GLM-5.2-NVFP4 \
  --dataset-name random \
  --random-input-len 8192 --random-output-len 1024 \
  --num-prompts 8 --max-concurrency 1 \
  --warmup-requests 64 --flush-cache \
  --random-range-ratio 1.0
Interactivity: 465.1 -> 485.4 tok/s (+4.4%)

CI States

Latest PR Test (Base): ✅ Run #28506915247
Latest PR Test (Extra): ❌ Run #28506914972

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@mmangkad mmangkad added the run-ci CI: run the baseline test suite on this PR label Jun 29, 2026
@JustinTong0323

Copy link
Copy Markdown
Collaborator

/tag-and-rerun-ci

@mmangkad
mmangkad requested a review from kpham-sgl July 1, 2026 03:19

@kpham-sgl kpham-sgl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved but please remove some AI gens comment

@Fridge003
Fridge003 merged commit 8f0d320 into main Jul 1, 2026
128 of 141 checks passed
@Fridge003
Fridge003 deleted the mmangkad/flashinfer-spec-autotune branch July 1, 2026 20:36
vstone-w pushed a commit to ClownBin/sglang that referenced this pull request Jul 2, 2026
Chronostasys pushed a commit to MindLab-Research/sglang that referenced this pull request Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-ci CI: run the baseline test suite on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants