Skip to content

[Refactor] moe: simplify FlashInfer MegaMoE autotune handoff - #45905

Merged
Fridge003 merged 4 commits into
sgl-project:mainfrom
zianglih:refactor/megamoe-autotune-knobs
Nov 13, 2026
Merged

Fridge003 merged 4 commits into
sgl-project:mainfrom
zianglih:refactor/megamoe-autotune-knobs

Conversation

@zianglih

@zianglih zianglih commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

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_CACHE mutation.

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

  • Direct handoff: warm a temporary AUTO layer, read get_tuned_knobs() before destroying it, then call mega.create_workspace(capacity, knobs=knobs) and warm the fixed workspace before capture. Temporary layers are destroyed on warmup/getter failures.
  • Cache ownership: startup-context records deduplicate layers and use FlashInfer's existing namespaced persistence. Use the unversioned namespace sglang_flashinfer_megamoe_knobs for 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.
  • JSON boundary: restore top-level tuple-valued knobs after JSON loading immediately before workspace creation, matching FlashInfer's decoder. Record comparison/publication precedes that conversion so a persisted cache hit stays clean.
  • Collective ordering: rank zero broadcasts the reuse/tuning decision and selected knobs. Remove temporary directories, native file/envelope parsing, environment mutation, and the collective that checked staging writes. Native AUTO may still persist its own results when configured to do so.
  • Upstream behavior preserved: retain enum-valued geometry-key serialization from [Fix] megamoe: Accept FlashInfer 0.7.3 knob cache and enum config fields in startup autotune #49096 and optional decode workspaces, output-view forwarding and skip logging from [Perf] flashinfer-megamoe: Add an optional decode workspace #46213. Nine surrounding functions, including profile sizing, workspace dispatch and capture safeguards, are AST-identical to the rebased upstream base.
  • Runtime scope: preserve decode/prefill capacities, synchronized DP profile selection, transformed-weight sharing and workspace/graph lifetimes. Fixed knobs participate in FlashInfer's workspace-pool identity. This refactor does not reduce retained workspace counts or sizes.

Accuracy Tests

  • Current source: 5aa43cd4c66c7906fbb1eb975f9efa32710478a3, rebased onto upstream main a081aaa257fddb22d8b9fcc506fe84d80c86b7fa (the merged FlashInfer 0.7.4 bump).
  • Rebase verification: All three feature commits and the complete two-file feature diff are unchanged. Runtime adapter/autotune code, the startup bridge and relevant callers are byte-identical to the just-tested head. Changed-file pre-commit and git diff --check passed. GPU validation and performance were not rerun for this rebase; recorded results below retain their tested source hashes.
  • GPU-tested source: SGLang 4a92b10daecf6538b8129760fe913756b39458ee, rebased on upstream main fc6d3b6f91bb3aecc03aff8183c212d0ef8888a1. Only the adapter and its existing unit suite change; no new test cases were added during the refresh.
  • Hardware/image: C3 node with 8×NVIDIA B300 SXM6 AC (SM103, 275040 MiB/GPU); native runs use GPUs 0–3 for EP4. Driver 595.91.07; image lmsysorg/sglang:nightly-dev-cu13-20261111-314bce7c, AMD64 digest sha256:a524b68e5657707ee4f6adb93c6ae3fd6d62a5a5a2ec6d2ddd3acf2d46ec1ebb.
  • Runtime: Python 3.12.16, PyTorch 2.14.1+cu130, CUDA/NVCC 13.0/13.0.88, Triton 3.8.0, CUTLASS DSL 4.8.0, NVSHMEM 3.4.5, nvshmem4py 0.4.1, TVM FFI 0.1.11. SGLang imports from the tested source through PYTHONPATH.
  • Release installation: exact released flashinfer-python/flashinfer-cubin 0.7.4, matching 0.7.4+cu130 JIT 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.
  • Registered tests: 31 adapter tests passed, covering persistence/tuple restoration, cross-layer reuse, cache removal with live handles, legacy-cache isolation and temporary-layer cleanup. The existing TestMegaMoEAutotuneStartup also passed: 1 test + 5 subtests, covering the current runner/context bridge and profile-limit resolution.
  • Native matrix: 6 cases / 24 passing rank records / 216 CUDA-graph replays. Each case uses two layers, unrestricted native AUTO, capacities [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.
  • Postflight: all 12,428 source-file hashes and all 373 package versions were unchanged after testing. Changed-file pre-commit and git diff --check passed.
Precision Cold tuning Fresh-process cache hit AUTO calls/rank (cold / hit) Graph replays/rank/case
NVFP4 W4A16 Pass Pass 3 / 0 9
NVFP4 W4A4 Pass Pass 3 / 0 9
MXFP8 Pass Pass 3 / 0 9

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
git clone https://github.com/zianglih/sglang.git
git -C sglang fetch origin 4a92b10daecf6538b8129760fe913756b39458ee
git -C sglang checkout 4a92b10daecf6538b8129760fe913756b39458ee
git -C sglang fetch origin fc4ae808c2a324bfca18d7665d8852d32930e6c1
git -C sglang archive FETCH_HEAD | tar -x
export TASK_ROOT="$PWD"
python install-flashinfer.py
bash run_validation.sh "$TASK_ROOT"
python summarize_validation.py

The installer verifies exact wheel URLs/SHA-256 values in wheel-lock.json before its --no-deps install. The runner verifies source/harness hashes, runs the two registered test commands and the six torchrun --nproc-per-node=4 cases, 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 sets FLASHINFER_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 enables SGLANG_FLASHINFER_CUTEDSL_NVFP4_W4A16 only for W4A16. FLASHINFER_DISABLE_VERSION_CHECK is unset and asserted disabled.

Complete registered-test output

Adapter suite:

...............................                                          [100%]
31 passed in 6.61s

Existing startup bridge:

.                                                                   [100%]
1 passed, 5 subtests passed in 32.20s
Complete native result records: every case and rank, all exit codes 0

w4a16-silu-reuse0

MEGAMOE_AUTOTUNE_SMOKE={"rank": 2, "passed": true, "activation": "silu", "precision": "w4a16", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 2, "decode_workspace_created": false, "auto_calls": 3, "reuse_cache": false, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}
MEGAMOE_AUTOTUNE_SMOKE={"rank": 1, "passed": true, "activation": "silu", "precision": "w4a16", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 2, "decode_workspace_created": false, "auto_calls": 3, "reuse_cache": false, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}
MEGAMOE_AUTOTUNE_SMOKE={"rank": 3, "passed": true, "activation": "silu", "precision": "w4a16", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 2, "decode_workspace_created": false, "auto_calls": 3, "reuse_cache": false, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}
MEGAMOE_AUTOTUNE_SMOKE={"rank": 0, "passed": true, "activation": "silu", "precision": "w4a16", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 2, "decode_workspace_created": false, "auto_calls": 3, "reuse_cache": false, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}

w4a16-silu-reuse1

MEGAMOE_AUTOTUNE_SMOKE={"rank": 1, "passed": true, "activation": "silu", "precision": "w4a16", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 2, "decode_workspace_created": false, "auto_calls": 0, "reuse_cache": true, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}
MEGAMOE_AUTOTUNE_SMOKE={"rank": 3, "passed": true, "activation": "silu", "precision": "w4a16", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 2, "decode_workspace_created": false, "auto_calls": 0, "reuse_cache": true, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}
MEGAMOE_AUTOTUNE_SMOKE={"rank": 2, "passed": true, "activation": "silu", "precision": "w4a16", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 2, "decode_workspace_created": false, "auto_calls": 0, "reuse_cache": true, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}
MEGAMOE_AUTOTUNE_SMOKE={"rank": 0, "passed": true, "activation": "silu", "precision": "w4a16", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 2, "decode_workspace_created": false, "auto_calls": 0, "reuse_cache": true, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}

w4a4-silu-reuse0

MEGAMOE_AUTOTUNE_SMOKE={"rank": 2, "passed": true, "activation": "silu", "precision": "w4a4", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 2, "decode_workspace_created": false, "auto_calls": 3, "reuse_cache": false, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}
MEGAMOE_AUTOTUNE_SMOKE={"rank": 0, "passed": true, "activation": "silu", "precision": "w4a4", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 2, "decode_workspace_created": false, "auto_calls": 3, "reuse_cache": false, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}
MEGAMOE_AUTOTUNE_SMOKE={"rank": 3, "passed": true, "activation": "silu", "precision": "w4a4", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 2, "decode_workspace_created": false, "auto_calls": 3, "reuse_cache": false, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}
MEGAMOE_AUTOTUNE_SMOKE={"rank": 1, "passed": true, "activation": "silu", "precision": "w4a4", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 2, "decode_workspace_created": false, "auto_calls": 3, "reuse_cache": false, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}

w4a4-silu-reuse1

MEGAMOE_AUTOTUNE_SMOKE={"rank": 0, "passed": true, "activation": "silu", "precision": "w4a4", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 2, "decode_workspace_created": false, "auto_calls": 0, "reuse_cache": true, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}
MEGAMOE_AUTOTUNE_SMOKE={"rank": 2, "passed": true, "activation": "silu", "precision": "w4a4", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 2, "decode_workspace_created": false, "auto_calls": 0, "reuse_cache": true, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}
MEGAMOE_AUTOTUNE_SMOKE={"rank": 3, "passed": true, "activation": "silu", "precision": "w4a4", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 2, "decode_workspace_created": false, "auto_calls": 0, "reuse_cache": true, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}
MEGAMOE_AUTOTUNE_SMOKE={"rank": 1, "passed": true, "activation": "silu", "precision": "w4a4", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 2, "decode_workspace_created": false, "auto_calls": 0, "reuse_cache": true, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}

mxfp8-silu-reuse0

MEGAMOE_AUTOTUNE_SMOKE={"rank": 1, "passed": true, "activation": "silu", "precision": "mxfp8", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 0, "decode_workspace_created": false, "auto_calls": 3, "reuse_cache": false, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}
MEGAMOE_AUTOTUNE_SMOKE={"rank": 3, "passed": true, "activation": "silu", "precision": "mxfp8", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 0, "decode_workspace_created": false, "auto_calls": 3, "reuse_cache": false, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}
MEGAMOE_AUTOTUNE_SMOKE={"rank": 2, "passed": true, "activation": "silu", "precision": "mxfp8", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 0, "decode_workspace_created": false, "auto_calls": 3, "reuse_cache": false, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}
MEGAMOE_AUTOTUNE_SMOKE={"rank": 0, "passed": true, "activation": "silu", "precision": "mxfp8", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 0, "decode_workspace_created": false, "auto_calls": 3, "reuse_cache": false, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}

mxfp8-silu-reuse1

MEGAMOE_AUTOTUNE_SMOKE={"rank": 1, "passed": true, "activation": "silu", "precision": "mxfp8", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 0, "decode_workspace_created": false, "auto_calls": 0, "reuse_cache": true, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}
MEGAMOE_AUTOTUNE_SMOKE={"rank": 2, "passed": true, "activation": "silu", "precision": "mxfp8", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 0, "decode_workspace_created": false, "auto_calls": 0, "reuse_cache": true, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}
MEGAMOE_AUTOTUNE_SMOKE={"rank": 3, "passed": true, "activation": "silu", "precision": "mxfp8", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 0, "decode_workspace_created": false, "auto_calls": 0, "reuse_cache": true, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}
MEGAMOE_AUTOTUNE_SMOKE={"rank": 0, "passed": true, "activation": "silu", "precision": "mxfp8", "flashinfer_version": "0.7.4", "source_commit": "4a92b10daecf6538b8129760fe913756b39458ee", "module_sources": {"adapter": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe.py", "sha256": "3c001933cb79b6099cab990cb9916b5084de2b6c1ad6c7bcc466dfa4f49fde59"}, "autotune": {"path": "/scratch/ziangli/sglang-megamoe-autotune-api-cleanup/ready-20261111/sglang/python/sglang/srt/layers/moe/flashinfer_megamoe_autotune.py", "sha256": "d0aec43ea4af3137a2eeb9bed0d1afc3e0504f9eba825b50fe65353b2947bed9"}}, "cache_namespace": "sglang_flashinfer_megamoe_knobs", "configured_decode_workspace_capacity": 0, "decode_workspace_created": false, "auto_calls": 0, "reuse_cache": true, "capacities": [1, 2, 8], "bootstrap_capacity": 4, "decode_num_tokens": 2, "prefill_num_tokens": 8, "startup_contexts": 1, "layers_per_context": 2, "checked_counts": [[0, 1, 1, 2], [0, 1, 2, 7], [8, 8, 8, 8]], "graph_replays": 9, "bit_exact": true, "borrowed_outputs_cloned": true, "fc1_scale_mutation_observed": true, "pool_refcounts": [2, 1, 0]}

Immutable 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

  • Format your code according to the contribution guide.
  • Add unit tests according to the contribution guide.
  • Documentation: no user-facing configuration changes.
  • Provide GPU validation results.
  • Follow the SGLang code style guidance.

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-test to run the tests your change touches, or copy this prompt for an agent:

Find the registered tests this PR affects and run them with /rerun-test, following https://github.com/sgl-project/sglang/blob/main/.agents/skills/rerun-test/SKILL.md

@zianglih

Copy link
Copy Markdown
Contributor Author

cc @akaashrp

@akaashrp akaashrp left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks, LGTM

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@ziang-and
ziang-and force-pushed the refactor/megamoe-autotune-knobs branch from 4a92b10 to 5aa43cd Compare November 12, 2026 03:53
@zianglih

Copy link
Copy Markdown
Contributor Author

/tag-and-rerun-ci

@github-actions github-actions Bot added the run-ci CI: run the baseline test suite on this PR label Nov 12, 2026
@zianglih

Copy link
Copy Markdown
Contributor Author

/rerun-failed-ci

@Fridge003
Fridge003 merged commit 69635d1 into sgl-project:main Nov 13, 2026
225 of 243 checks passed
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