Skip to content

[Feat] runtime: Include FlashInfer’s default tactic in startup tuning. - #43927

Merged
nvpohanh merged 5 commits into
sgl-project:mainfrom
leejnau:include-flashinfer-default-tactic
Oct 15, 2026
Merged

nvpohanh merged 5 commits into
sgl-project:mainfrom
leejnau:include-flashinfer-default-tactic

Conversation

@leejnau

@leejnau leejnau commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Motivation

Startup tuning can omit FlashInfer's default tactic (-1) and select an explicit tactic even when the default is faster for the profiling inputs. This adopts v2 candidate selection with existing v1 persistence.

Modifications

  • Import autotune_v2 from FlashInfer and enter autotune_v2(mode="tune", persistent_cache=False) immediately after the existing autotune(...) context. Measurement policy remains unspecified.
  • Retain existing v1 JSON load/save persistence, cache-disabled behavior, skip controls, streams, and distributed synchronization. Managed-store migration is excluded; upstream's existing MegaMoE integration is retained without changes.
  • Add one autotune_v2 stub to the existing upstream startup-test fixture, which already mocks the v1 tuner. No new test is added.

Accuracy Tests

Current commit: e4be6ffca60afd66198b53981f275b543f5ec624, merging upstream 27b68303d043ddbddf9861c55c26bc8617ea7c35. Relative to that upstream commit, the PR adds three production lines and one existing-fixture line. FlashInfer remains pinned to 0.7.1.

The current merged commit has passed the local suite and repository checks below; new-head GitHub CI is pending. The following H100 results ran on the prior head 0ad44b07144da52c6af842c44b961b373afb20b0, before merging main:

The RTX 5090 validation below ran on a9c46a964dfb87ad218d2460198848d8580bfd14 before the test-only removal and upstream merge. The historical 12-test CUDA run and pre-fix control include the subsequently removed regression.

  • Historical CUDA registered suite: 12 passed, zero skips/failures/errors, 212.267 seconds. All 11 existing tests plus the subsequently removed regression passed, including all three real two-rank Gloo cache tests.

  • Historical pre-fix control reproduced the regression: replacing only the v2 context with nullcontext() produced two expected subtest assertion failures, zero errors, in 0.439 seconds. The default-winner case selected 0 instead of -1; the explicit-winner control showed -1 missing from profiling.

  • Numerical smoke through the SGLang wrapper: all six phases passed. Real FlashInfer bmm_fp8, backend cublas, FP8 E4M3 inputs, BF16 output, [B,M,N,K]=[1,128,64,256], compared with FP32 torch.bmm of the quantized inputs at rtol=0.02, atol=0.25.

    Phase Maximum absolute error
    Cold startup eager 0.1241455078125
    Bare eager after context exit 0.1241455078125
    Bare CUDA Graph replay, changed inputs 0.0625
    Warm startup through v1 load 0.0625
    Warm bare eager 0.0625
    Warm CUDA Graph replay, changed inputs 0.0311737060546875

    Cold tuning made 72 profiling calls, including 8 for -1, and saved 8 v1 winner entries. Warm reuse made 0 additional profiling calls, including bare eager execution and graph replay.

CUDA environment: native x86_64, RTX 5090 (SM120), driver 615.36, Python 3.12.3, PyTorch 2.13.0+cu130, CUDA 13.0, exact FlashInfer 0.7.1. SGLang Python sources were overlaid from the validated commit. The throwaway container used FlashInfer source JIT after removing its older optional 0.6.18 binary providers. Image: lmsysorg/sglang@sha256:2dbe4c7f53230b09aaa8fa41891c13c51d9d2e253f486a70822aaf08783fff75 (amd64). The validation allocation completed with exit 0 and released its GPU.

Executed commands with PYTHONPATH=/tmp/sglang-default-tactic-2485957-0/fi:/run/source/python:

python3 /run/source/test/registered/unit/model_executor/runner/test_flashinfer_autotune_sync.py -v
python3 /run/source/numerical_smoke.py
  • Current macOS arm64 registered suite: 11 passed, 1 CUDA-only skipped, 18.861 seconds, on Python 3.12.12, PyTorch 2.14.1, FlashInfer 0.7.1, including all real two-rank Gloo tests. Command: PYTHONPATH=python /private/tmp/sglang-default-tactic-venv/bin/python test/registered/unit/model_executor/runner/test_flashinfer_autotune_sync.py -v with task-local cache directories.
  • Repository checks passed: pre-commit run --files python/sglang/srt/model_executor/runner/flashinfer_autotune.py test/registered/unit/model_executor/runner/test_flashinfer_autotune_sync.py (all applicable hooks, including formatting and registry checks), plus git diff --check.
  • GitHub lint passed on the prior head 0ad44b0714. The current merged head's lint check is pending.

Pending: GitHub CI on the current merged commit, including CUDA validation. The PR is ready for review and has the run-ci label. H100 unit and model-accuracy runs used the repository's PyTorch 2.14.1 pin on the prior head; the separate six-phase numerical smoke used 2.13.0. Repeating that numerical smoke with 2.14.1 remains pending.

Speed Tests and Profiling

Serving performance remains unmeasured. Historical controlled timings and numerical-smoke profiling-call counts establish selection and cache behavior; no serving-performance improvement is claimed.


CI States

Latest PR Test (Base): 🚫 Run #38552427356
Latest PR Test (Extra): ❌ Run #38552427316
Latest PR Test (AMD ROCm 10): ❌ Run #38552427203

@leejnau

leejnau commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/unit/model_executor/runner/test_flashinfer_autotune_sync.py

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

🚀 1-gpu-h100 (1 test): ✅ View workflow run

cd test/ && python3 registered/unit/model_executor/runner/test_flashinfer_autotune_sync.py

@leejnau

leejnau commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-test test/registered/e2e/quantization/test_modelopt_fp8.py::TestModeloptFP8.test_gsm8k

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

🚀 1-gpu-h100 (1 test): ✅ View workflow run

cd test/ && python3 registered/e2e/quantization/test_modelopt_fp8.py TestModeloptFP8.test_gsm8k

@leejnau
leejnau marked this pull request as ready for review October 13, 2026 14:26
@leejnau

leejnau commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator Author

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Oct 13, 2026
@leejnau

leejnau commented Oct 13, 2026

Copy link
Copy Markdown
Collaborator Author

/rerun-failed-ci

@nvpohanh

Copy link
Copy Markdown
Collaborator

[by Claude Code] I've started babysitting the NVIDIA CI of this PR. I'll check it every 30 minutes until all NV pipelines pass. If a relevant job fails, I may rerun it, merge the latest main into this branch, push a small test-only fix, or post a note here.

Anyone can stop me at any time: just post a comment asking me to stop (for example, stop babysitting). I'll stop at my next check, within 30 minutes, and take no further action on this PR.

@leejnau leejnau changed the title Include FlashInfer’s default tactic in startup tuning. [Feat] runtime: Include FlashInfer’s default tactic in startup tuning. Oct 14, 2026
@nvpohanh

Copy link
Copy Markdown
Collaborator

[by Claude Code] PR Test Base on 559b1cd93b: all stage A, B, and C test jobs passed. The run shows as cancelled only because the stage B wait job hit GitHub's 6-hour job limit.

Run: https://github.com/sgl-project/sglang/actions/runs/38552427356 (head 559b1cd93bd8948ce622b48bf749045c18892b42, attempt 1)

Lint passed: https://github.com/sgl-project/sglang/actions/runs/38552427218

Gates (passed)

Stage A: 15/15 passed

Stage B: 19/19 passed

Stage C: 14/14 passed

Why the run is not green

Earlier failure on this PR is resolved

@nvpohanh

Copy link
Copy Markdown
Collaborator

merging since all stages a/b/c have passed.

@nvpohanh
nvpohanh merged commit 33618d4 into sgl-project:main Oct 15, 2026
179 of 194 checks passed
@leejnau
leejnau deleted the include-flashinfer-default-tactic branch October 15, 2026 14:53
detain pushed a commit to detain/sglang that referenced this pull request Oct 29, 2026
sgl-project#43927)

Co-authored-by: Po-Han Huang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 33618d4)
(cherry picked from commit 5bd91df552edb52bdd7c2dfabf35bd21a3cf8744)
detain added a commit to detain/sglang that referenced this pull request Oct 29, 2026
sgl-project#44514 from port-autotune (entries 257-260)

Batch 2 of the 2026-10-28 second wave. Four picks landed CLEAN in strict
order onto the comm docs tip -- code tip 2705ebb:
f46e547 sgl-project#40420 (open port, EP autotune-cache digest: per-rank caches
no longer dropped every startup; worker RED-proof 2F->2P), 894d4a7
sgl-project#45543 (open port, seeded distinct dummy token ids for the decode MoE
autotune; base_runner union preserves the entry-176 EXTEND call site;
upstream-only TestModelPrefillAutotune NOT carried in --
autotune_prefill_kernels absent, grep-verified), 6c866f3 sgl-project#43927
(merged pick 33618d4, default tactic joins tuning -- PARTIALLY
SATISFIES the C0a sweep-gap record; entry-243/246 'no tactic=-1'
PASS-needles STALE, CAVEATS bullet added), 2705ebb sgl-project#44514 (merged
pick 1897575, cache-key bump -> exactly ONE cold autotune boot,
entry-228 boot-cost practice).

Header bookkeeping for BOTH batches: STACK bumped to
qwennext-stack-260-2026-10-28 with the comm + autotune wave lines,
entries 1-260, tip 2705ebb, updated: 2026-10-28 (entries 255-260)
block. FAM-A1 LANDED + NEW TODO S-EXT1 (stack-owned: EXTEND autotune
still tunes on zero-filled dummies -- the bug sgl-project#45543 fixed for decode).

Verified at landed tips (prod venv, CVD=9), all EXACT vs predictions:
sync+gate 22P/1S/5sub, runner dir 89P/1S/47sub, MoE set 139P/22S/141sub,
qwen4_exp_ple_staging 37P; comm named set 114P/1S/30sub, dir
120P/1S/35sub 0F, new comm files collect 18. In-flight workers NOT
landed -- no drift attributable. NOTHING PUSHED.
detain added a commit to detain/sglang that referenced this pull request Oct 29, 2026
…k-274, wanted_stack LANDED marks, CAVEATS docs-only ledger items

(A) Header: STACK line 260->274; three wave lines (+spec-mamba-2026-10-28
(pr45491+pr45435+pr45472+pr45670), +admission-2026-10-28(pr46272*+
pr43484*+pr46496*+pr46643*+pr45607*+pr45789*), +parsers-2026-10-28
(pr44124+pr45631+pr45855+pr46167)); tip line -> 2714457; updated
261-274 headline block (entry-119 SUPERSEDED by upstream sgl-project#45435/sgl-project#45472;
classic-pool mamba admission gate w/ upstream ImportError CAUGHT;
UNCONDITIONAL latch reset = TTFT watch; coder-parser union; logits
trilogy as CONTRACT UNIT; 14 picks, 0 integrator conflicts).

(B) wanted_stack.txt: FAM-A5 + FAM-B234 blocks deleted -> LANDED records
(chain shas, interlock audit, supersession + behavior-change pointers
into entries 261-270); SECTION-B sgl-project#44124/trilogy blocks -> LANDED;
sgl-project#37958/sgl-project#45559 block -> DONE (verdict now in CAVEATS).

(C) DOCS-ONLY LEDGER ITEMS: CAVEATS gains the sgl-project#37958/sgl-project#45559 VERIFIED-
INERT bullet (two independent hard gates, coarse-barrier fallback,
do-not-re-litigate-at-merge-sgl-project#5 line, revisit condition = dropping NEXTN
or HiCache) and the dated C0b/C0c corrections (sgl-project#44030 obsolete rationale,
sgl-project#44858 REVERSED by sgl-project#45289 [ported-pending wt-moe], sgl-project#44115 permanent N/A,
10-28 open-status re-verification list, no-pin-moves note: 0.7.2/0.4.9
floor unchanged) with the C0a tick (sgl-project#37625/sgl-project#37941/sgl-project#39727 still
outstanding; only sgl-project#43927/sgl-project#44849 partially satisfied). C0b/C0c/C8 marked
DONE in wanted_stack; C0a stays open.
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.

3 participants