Repository navigation
[Refactor] moe: simplify FlashInfer MegaMoE autotune handoff - #45905
Merged
Fridge003 merged 4 commits intoNov 13, 2026
Merged
Conversation
Contributor
Author
|
cc @akaashrp |
4 of 5 tasks
2 of 5 tasks
ziang-and
force-pushed
the
refactor/megamoe-autotune-knobs
branch
from
November 12, 2026 00:20
e15e06c to
4a92b10
Compare
zianglih
marked this pull request as ready for review
November 12, 2026 00:23
zianglih
requested review from
BBuf,
Edwardf0t1,
Fridge003,
HaiShaw,
Ying1123,
ch-wan,
ispobock and
merrymercy
as code owners
November 12, 2026 00:23
ziang-and
force-pushed
the
refactor/megamoe-autotune-knobs
branch
from
November 12, 2026 03:53
4a92b10 to
5aa43cd
Compare
Contributor
Author
|
/tag-and-rerun-ci |
Fridge003
approved these changes
Nov 13, 2026
Contributor
Author
|
/rerun-failed-ci |
This was referenced Nov 14, 2026
4 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
@HumansAnd
Simplify MegaMoE startup autotuning by handing selected knobs directly from the temporary tuning layer to fixed workspaces through FlashInfer's public APIs. This removes native-cache JSON file transport and process-wide
FLASHINFER_MOE_EP_KNOB_CACHEmutation.Follows the suggestion in #43789.
Dependency satisfied: SGLang #49771 is merged and upstream now pins FlashInfer 0.7.4, which supplies both public APIs (FlashInfer #6415, #6416). This PR is rebased on that merge; dependency pins and Dockerfiles are provided by upstream.
Modifications
get_tuned_knobs()before destroying it, then callmega.create_workspace(capacity, knobs=knobs)and warm the fixed workspace before capture. Temporary layers are destroyed on warmup/getter failures.sglang_flashinfer_megamoe_knobsfor direct knob dictionaries; old native-file envelope records are ignored and retuned once. Remove the process-global winner cache so a later context honors a cleared/replaced cache while existing workspace handles keep their fixed knobs.Accuracy Tests
5aa43cd4c66c7906fbb1eb975f9efa32710478a3, rebased onto upstream maina081aaa257fddb22d8b9fcc506fe84d80c86b7fa(the merged FlashInfer 0.7.4 bump).git diff --checkpassed. GPU validation and performance were not rerun for this rebase; recorded results below retain their tested source hashes.4a92b10daecf6538b8129760fe913756b39458ee, rebased on upstream mainfc6d3b6f91bb3aecc03aff8183c212d0ef8888a1. Only the adapter and its existing unit suite change; no new test cases were added during the refresh.lmsysorg/sglang:nightly-dev-cu13-20261111-314bce7c, AMD64 digestsha256:a524b68e5657707ee4f6adb93c6ae3fd6d62a5a5a2ec6d2ddd3acf2d46ec1ebb.PYTHONPATH.flashinfer-python/flashinfer-cubin0.7.4, matching0.7.4+cu130JIT shim and all six required providers. All nine wheels passed published SHA-256 checks and were installed with--no-deps; no other image package changed. All required Python dependencies were already satisfied. Version checks stayed enabled; no FlashInfer source overlay was used.TestMegaMoEAutotuneStartupalso passed: 1 test + 5 subtests, covering the current runner/context bridge and profile-limit resolution.[1,2,8], and rank-local token-count vectors[0,1,1,2],[0,1,2,7]and[8,8,8,8]. Cold runs tune once per capacity across both layers; separate processes then load persisted direct knobs with zero AUTO calls.git diff --checkpassed.All cases require bit-exact agreement with an independently constructed fixed-default MegaMoE control, finite outputs, rank-consistent records, shared workspace identity, and pool references 2 → 1 → 0. Graph replay observes in-place FC1 alpha changes for NVFP4 and prepared FC1 weight-scale changes for MXFP8. Borrowed output views are cloned for comparisons. NVFP4 configures the new optional decode capacity to 2 and verifies startup tuning supersedes it without allocating that untuned workspace; the existing unit suite covers its untuned selection path.
Native AUTO is confined to temporary pre-capture layers; later forwards and graph replay do not tune. FlashInfer's collective-AUTO startup advisory is expected and retained in the raw logs. Harness SHA-256:
975a78c68fca5e4c5aa2d760d1769142233ccc979279caab5fdedf24b474bfbd.Boundary: synthetic adapter/native validation at hidden/intermediate 256, 8 experts, top-k 4, SiLU, EP4, with supplied synchronized DP counts. Full scheduler synchronization, full-model serving/accuracy, other activations and throughput were not tested.
Reproduce inside the image above
The installer verifies exact wheel URLs/SHA-256 values in
wheel-lock.jsonbefore its--no-depsinstall. The runner verifies source/harness hashes, runs the two registered test commands and the sixtorchrun --nproc-per-node=4cases, and records per-case exit codes and source proofs.It sets
CUDA_VISIBLE_DEVICES=0,1,2,3,NVSHMEM_REMOTE_TRANSPORT=none,NVSHMEM_IB_ENABLE_IBGDA=0,NVSHMEM_DISABLE_LOCAL_ONLY_PROXY=1,OMP_NUM_THREADS=1,MAX_JOBS=8, and task-local SGLang/FlashInfer/CuTe/Torch-extension caches. The harness setsFLASHINFER_MOE_EP_KNOB_CACHE=0,SGLANG_FLASHINFER_MEGAMOE_IN_KERNEL_FC2_REDUCE=0,SGLANG_FLASHINFER_MEGAMOE_COMBINE_DTYPE=bf16, maximum capacity 4 and optional decode capacity 2; it enablesSGLANG_FLASHINFER_CUTEDSL_NVFP4_W4A16only for W4A16.FLASHINFER_DISABLE_VERSION_CHECKis unset and asserted disabled.Complete registered-test output
Adapter suite:
Existing startup bridge:
Complete native result records: every case and rank, all exit codes 0
w4a16-silu-reuse0w4a16-silu-reuse1w4a4-silu-reuse0w4a4-silu-reuse1mxfp8-silu-reuse0mxfp8-silu-reuse1Immutable evidence: verified summary, release environment, full native logs, runner, harness, release API audit, surrounding-code audit, wheel lock, source postflight, package postflight.
Speed Tests and Profiling
No serving-speed or memory-reduction claim. This cleanup changes startup handoff and cache ownership; capacity selection and steady-state workspace dispatch are preserved. Performance benchmarking is outside this PR.
Checklist
CI States
Latest PR Test (Base): ✅ Run #43379262011
Latest PR Test (Extra): ❌ Run #43379261697
Latest PR Test (AMD ROCm 10): ❌ Run #43379261755
Tip
Base CI only covers the core cases, and its workload may not exercise your change. Use
/rerun-testto run the tests your change touches, or copy this prompt for an agent: