Skip to content

[NVIDIA] Support flashinfer Mega Moe - #31470

Merged
Fridge003 merged 75 commits into
sgl-project:mainfrom
wenscarl:mega_moe_flashinfer
Sep 10, 2026
Merged

Fridge003 merged 75 commits into
sgl-project:mainfrom
wenscarl:mega_moe_flashinfer

Conversation

@wenscarl

@wenscarl wenscarl commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Fork from https://github.com/djns99/sglang/tree/djns99/mega_moe_flashinfer
@djns99 is the main author of this PR.

Motivation

Modifications

Accuracy Tests

Speed Tests and Profiling

Checklist

Review and Merge Process

  1. Ping Merge Oncalls to start the process. See the PR Merge Process.
  2. Get approvals from CODEOWNERS and other reviewers.
  3. Trigger CI tests with comments or contact authorized users to do so.
    • Common commands include /tag-and-rerun-ci, /tag-run-ci-label, /rerun-failed-ci
  4. After green CI and required approvals, ask Merge Oncalls or people with Write permission to merge the PR.

MoE backend benchmark: flashinfer_trtllm_routed (baseline) vs flashinfer_megamoe

Benchmark of the DeepSeek-V4-Flash NVFP4 model comparing two MoE backend configurations
on the serving path. flashinfer_trtllm_routed (trtllm routed MoE runner + flashinfer
A2A) is used as the baseline; flashinfer_megamoe is the compared configuration.
All deltas are reported relative to the trtllm_routed baseline.

Environment

  • Model: nvidia/DeepSeek-V4-Flash-NVFP4
  • Parallelism: TP=4, DP=4, DP-attention enabled (attn_dp_size=4, so per-rank decode batch = max_running_requests / 4)
  • 1x node, same hardware for both runs

Server commands

Baseline — flashinfer_trtllm_routed:

python -m sglang.launch_server \
  --trust-remote-code \
  --model-path nvidia/DeepSeek-V4-Flash-NVFP4 \
  --dp-size 4 --tp-size 4 --enable-dp-attention \
  --chunked-prefill-size 4096 \
  --disable-flashinfer-autotune \
  --swa-full-tokens-ratio 0.1 \
  --host 0.0.0.0 --port 30000 \
  --moe-runner-backend flashinfer_trtllm_routed \
  --moe-a2a-backend flashinfer \
  --max-running-requests 1024

Compared — flashinfer_megamoe:

python -m sglang.launch_server \
  --trust-remote-code \
  --model-path nvidia/DeepSeek-V4-Flash-NVFP4 \
  --dp-size 4 --tp-size 4 --enable-dp-attention \
  --chunked-prefill-size 4096 \
  --disable-flashinfer-autotune \
  --swa-full-tokens-ratio 0.1 \
  --host 0.0.0.0 --port 30000 \
  --moe-runner-backend flashinfer_megamoe \
  --moe-a2a-backend flashinfer_megamoe \
  --max-running-requests 1024

Client command

python -m sglang.bench_serving \
  --backend sglang \
  --model nvidia/DeepSeek-V4-Flash-NVFP4 \
  --dataset-name random \
  --random-input-len 8 --random-output-len 1024 --random-range-ratio 1.0 \
  --num-prompts $((5 * C)) \
  --max-concurrency C     # C in {32, 128, 1024}, num-prompts = 5 x C

Results

Output token throughput (tok/s, higher is better)

max_conc trtllm_routed (baseline) megamoe Δ (megamoe vs baseline)
32 876.88 674.21 −23.1%
128 1215.93 1092.54 −10.1%
1024 3223.92 3245.20 +0.7%

Mean TPOT (ms, lower is better)

max_conc trtllm_routed (baseline) megamoe Δ (megamoe vs baseline)
32 34.49 38.77 +12.4%
128 109.93 106.83 −2.8%
1024 422.61 394.92 −6.6%

Full metrics

config max_conc out_tput (tok/s) mean TPOT (ms) median TPOT (ms) p99 TPOT (ms) achieved conc mean TTFT (ms)
trtllm_routed 32 876.88 34.49 33.32 102.42 28.76 421
megamoe 32 674.21 38.77 40.27 78.13 26.53 321
trtllm_routed 128 1215.93 109.93 104.71 395.33 116.12 797
megamoe 128 1092.54 106.83 101.22 345.54 103.68 776
trtllm_routed 1024 3223.92 422.61 343.54 2429.78 994.81 3142
megamoe 1024 3245.20 394.92 322.13 2356.07 951.20 3261

Takeaways

  • Low/mid concurrency (c32, c128): flashinfer_trtllm_routed wins on throughput — +23% at c32 and +11% at c128 output token throughput, with comparable or better median TPOT. It also sustains higher achieved concurrency (28.8/116.1 vs 26.5/103.7), i.e. it drains the request queue faster.
  • High concurrency (c1024): the two are effectively tied on throughput (3224 vs 3245 tok/s, +0.7% for megamoe — within run-to-run noise). At this point both are decode-bound / saturated (achieved conc < target, p99 TPOT ~7x median), so the MoE backend is no longer the bottleneck.
  • TPOT crossover: megamoe has slightly lower mean TPOT at c1024 (−6.6%) but a worse p99 tail at low load (c32: 102 ms vs 78 ms). trtllm_routed gives more consistent per-token latency at low concurrency.
  • Net: flashinfer_trtllm_routed is the better default for latency-sensitive / low-to-mid concurrency serving; at saturation the choice is throughput-neutral.

FlashInfer MegaMOE env knobs

This PR exposes SGLANG_FLASHINFER_MEGAMOE_COMBINE_DTYPE for the FlashInfer NVFP4 MegaMOE path. It selects the cross-rank combine wire format passed to Nvfp4CutedslMegaMoeConfig.combine_dtype.

Supported values:

  • bf16: default, exact combine path.
  • mxfp8: quantized combine traffic with a small accuracy tradeoff.
  • nvfp4: lower combine traffic with a small accuracy tradeoff.

Example:

SGLANG_FLASHINFER_MEGAMOE_COMBINE_DTYPE=nvfp4 \
python -m sglang.launch_server \
  --trust-remote-code \
  --model-path nvidia/DeepSeek-V4-Flash-NVFP4 \
  --dp-size 4 --tp-size 4 --enable-dp-attention \
  --moe-runner-backend flashinfer_megamoe \
  --moe-a2a-backend flashinfer_megamoe

mxfp8 and nvfp4 are incompatible with SGLANG_FLASHINFER_MEGAMOE_IN_KERNEL_FC2_REDUCE=1; server args validation now rejects that combination early.

Note: the flashinfer_megamoe in-kernel FC2-reduce variant (SGLANG_FLASHINFER_MEGAMOE_IN_KERNEL_FC2_REDUCE=1) was excluded from this comparison due to a known issue and is not reflected here.
Update 7/27/2026:

MoE backend comparison — DeepSeek-V4-Flash-NVFP4, TP4/DP4/EP4

Baseline: trtllm. Positive throughput and negative latency are both wins.
Tokens/rank = per-DP-rank prefill chunk (DP attention routes each request wholly to one rank;
--chunked-prefill-size is divided by dp_size internally).

Prefill

2048 tokens/rank (input len 2048, concurrency 128)

Backend Input tput (tok/s) Mean TTFT (ms) Median TTFT (ms) P99 TTFT (ms)
trtllm (baseline) 38,884 3,084 3,233 4,104
deepgemm megamoe 46,117 2,572 2,719 3,372
flashinfer_cutedsl_megamoe_plain 42,324 2,952 3,018 3,849
flashinfer_cutedsl_megamoe_ikr 41,291 3,036 3,122 3,955
flashinfer_cutedsl_megamoe_combine_nvfp4 42,408 2,953 3,044 3,838

Change vs trtllm:

Backend Input tput Mean TTFT Median TTFT P99 TTFT
deepgemm megamoe +18.60% -16.59% -15.88% -17.84%
flashinfer_cutedsl_megamoe_plain +8.85% -4.28% -6.65% -6.21%
flashinfer_cutedsl_megamoe_ikr +6.19% -1.57% -3.43% -3.63%
flashinfer_cutedsl_megamoe_combine_nvfp4 +9.06% -4.23% -5.84% -6.48%

Note: trtllm/deepgemm rows are 640 requests (676,871 input tokens); the flashinfer rows are
1,280 requests (1,327,019 input tokens). Same input len and concurrency, so the rates are
comparable, but the request counts differ.

8192 tokens/rank (input len 8192, 640 requests, 2,665,479 input tokens, concurrency 128)

Backend Input tput (tok/s) Mean TTFT (ms) Median TTFT (ms) P99 TTFT (ms)
trtllm (baseline) 151,213 3,137 3,339 4,361
deepgemm megamoe 154,359 3,047 3,286 4,163
flashinfer_cutedsl_megamoe_plain 162,342 2,945 3,159 4,146
flashinfer_cutedsl_megamoe_ikr 165,658 2,831 3,018 3,835
flashinfer_cutedsl_megamoe_combine_nvfp4 169,175 2,745 2,905 3,753

Change vs trtllm:

Backend Input tput Mean TTFT Median TTFT P99 TTFT
deepgemm megamoe +2.08% -2.84% -1.58% -4.52%
flashinfer_cutedsl_megamoe_plain +7.36% -6.10% -5.39% -4.93%
flashinfer_cutedsl_megamoe_ikr +9.55% -9.73% -9.60% -12.06%
flashinfer_cutedsl_megamoe_combine_nvfp4 +11.88% -12.50% -13.00% -13.93%

Decode

Input len 32, output len 1024, 10,240 requests, concurrency 8192, 5,256,337 generated tokens.

Backend Output tput (tok/s) Mean TPOT (ms) Median TPOT (ms) P99 TPOT (ms)
trtllm (baseline) 8,783 795.2 727.4 2,244.7
deepgemm megamoe 8,620 762.8 721.3 1,944.3
flashinfer_cutedsl_megamoe_plain 8,832 783.1 722.0 2,167.6
flashinfer_cutedsl_megamoe_ikr 8,849 780.0 717.7 2,182.1
flashinfer_cutedsl_megamoe_combine_nvfp4 8,886 776.6 715.8 2,151.7

Change vs trtllm:

Backend Output tput Mean TPOT Median TPOT P99 TPOT
deepgemm megamoe -1.86% -4.08% -0.84% -13.38%
flashinfer_cutedsl_megamoe_plain +0.55% -1.53% -0.75% -3.44%
flashinfer_cutedsl_megamoe_ikr +0.75% -1.91% -1.33% -2.79%
flashinfer_cutedsl_megamoe_combine_nvfp4 +1.17% -2.34% -1.60% -4.14%

Takeaways

  • Prefill: the best backend depends on tokens/rank. deepgemm wins at 2048 tok/rank
    (+18.6% throughput, -16.6% mean TTFT) but only edges trtllm at 8192 tok/rank (+2.1%).
    flashinfer_cutedsl_megamoe is the reverse: +9% at 2048, +11.9% at 8192.
  • Prefill: the flashinfer variant ranking does not hold across sizes. At 8192 tok/rank it is
    plain < ikr < combine_nvfp4. At 2048 tok/rank, plain and combine_nvfp4 are tied
    (+8.85% vs +9.06%, mean TTFT within 2 ms) and ikr is weakest (+6.19%).
  • Decode is nearly a wash on throughput. All backends land within ±2% of trtllm
    (8,620-8,886 tok/s), far tighter than the prefill spread. At concurrency 8192 this workload is
    memory-bound, so the MoE kernel is not the bottleneck.
  • Decode tail latency is where backends separate. deepgemm cuts P99 TPOT by 13.4% and mean TPOT
    by 4.1%, at the cost of 1.9% throughput — the only backend that trades throughput for tail
    latency. flashinfer improves both modestly.
  • combine_nvfp4 is the best flashinfer variant in decode, leading on every metric
    (+1.17% throughput, -2.34% mean TPOT), reproducing the 8192 tok/rank prefill ordering.
  • Overall recommendation: flashinfer_cutedsl_megamoe_combine_nvfp4 for large-prefill and
    decode-heavy serving; deepgemm megamoe if small-prefill throughput or decode P99 dominates.

Reproduce

<VARIANT-SELECTOR> below is whatever selects plain / ikr / combine_nvfp4 — it is not a
server arg (all three record moe_runner_backend=flashinfer_megamoe).

Decode — flashinfer_cutedsl_megamoe

# server
python -m sglang.launch_server \
  --trust-remote-code \
  --model-path nvidia/DeepSeek-V4-Flash-NVFP4 \
  --dp-size 4 --tp-size 4 --enable-dp-attention \
  --chunked-prefill-size 8192 --max-prefill-tokens 8192 \
  --disable-flashinfer-autotune --swa-full-tokens-ratio 0.1 \
  --moe-runner-backend flashinfer_megamoe --moe-a2a-backend flashinfer_megamoe \
  --max-running-requests 8192 \
  --host 0.0.0.0 --port 30000   # <VARIANT-SELECTOR>

# client
python -m sglang.bench_serving \
  --backend sglang --model nvidia/DeepSeek-V4-Flash-NVFP4 \
  --dataset-name random \
  --random-input-len 32 --random-output-len 1024 \
  --num-prompts 10240 --request-rate inf --max-concurrency 8192

The trtllm baseline is the same command with
--moe-runner-backend flashinfer_trtllm_routed --moe-a2a-backend flashinfer.

Backend Input tput Mean TTFT Median TTFT P99 TTFT
deepgemm megamoe +2.08% -2.84% -1.58% -4.52%
flashinfer_cutedsl_megamoe_plain +7.36% -6.10% -5.39% -4.93%
flashinfer_cutedsl_megamoe_ikr +9.55% -9.73% -9.60% -12.06%
flashinfer_cutedsl_megamoe_combine_nvfp4 +11.88% -12.50% -13.00% -13.93%

Decode

Input len 32, output len 1024, 10,240 requests, concurrency 8192, 5,256,337 generated tokens.

Backend Output tput (tok/s) Mean TPOT (ms) Median TPOT (ms) P99 TPOT (ms)
trtllm (baseline) 8,783 795.2 727.4 2,244.7
deepgemm megamoe 8,620 762.8 721.3 1,944.3
flashinfer_cutedsl_megamoe_plain 8,832 783.1 722.0 2,167.6
flashinfer_cutedsl_megamoe_ikr 8,849 780.0 717.7 2,182.1
flashinfer_cutedsl_megamoe_combine_nvfp4 8,886 776.6 715.8 2,151.7

Change vs trtllm:

Backend Output tput Mean TPOT Median TPOT P99 TPOT
deepgemm megamoe -1.86% -4.08% -0.84% -13.38%
flashinfer_cutedsl_megamoe_plain +0.55% -1.53% -0.75% -3.44%
flashinfer_cutedsl_megamoe_ikr +0.75% -1.91% -1.33% -2.79%
flashinfer_cutedsl_megamoe_combine_nvfp4 +1.17% -2.34% -1.60% -4.14%

Takeaways

  • Prefill: the best backend depends on tokens/rank. deepgemm wins at 2048 tok/rank
    (+18.6% throughput, -16.6% mean TTFT) but only edges trtllm at 8192 tok/rank (+2.1%).
    flashinfer_cutedsl_megamoe is the reverse: +9% at 2048, +11.9% at 8192.
  • Prefill: the flashinfer variant ranking does not hold across sizes. At 8192 tok/rank it is
    plain < ikr < combine_nvfp4. At 2048 tok/rank, plain and combine_nvfp4 are tied
    (+8.85% vs +9.06%, mean TTFT within 2 ms) and ikr is weakest (+6.19%).
  • Decode is nearly a wash on throughput. All backends land within ±2% of trtllm
    (8,620-8,886 tok/s), far tighter than the prefill spread. At concurrency 8192 this workload is
    memory-bound, so the MoE kernel is not the bottleneck.
  • Decode tail latency is where backends separate. deepgemm cuts P99 TPOT by 13.4% and mean TPOT
    by 4.1%, at the cost of 1.9% throughput — the only backend that trades throughput for tail
    latency. flashinfer improves both modestly.
  • combine_nvfp4 is the best flashinfer variant in decode, leading on every metric
    (+1.17% throughput, -2.34% mean TPOT), reproducing the 8192 tok/rank prefill ordering.
  • Overall recommendation: flashinfer_cutedsl_megamoe_combine_nvfp4 for large-prefill and
    decode-heavy serving; deepgemm megamoe if small-prefill throughput or decode P99 dominates.

Reproduce

<VARIANT-SELECTOR> below is whatever selects plain / ikr / combine_nvfp4 — it is not a
server arg (all three record moe_runner_backend=flashinfer_megamoe).

Decode — flashinfer_cutedsl_megamoe

# server
python -m sglang.launch_server \
  --trust-remote-code \
  --model-path nvidia/DeepSeek-V4-Flash-NVFP4 \
  --dp-size 4 --tp-size 4 --enable-dp-attention \
  --chunked-prefill-size 8192 --max-prefill-tokens 8192 \
  --disable-flashinfer-autotune --swa-full-tokens-ratio 0.1 \
  --moe-runner-backend flashinfer_megamoe --moe-a2a-backend flashinfer_megamoe \
  --max-running-requests 8192 \
  --host 0.0.0.0 --port 30000   # <VARIANT-SELECTOR>

# client
python -m sglang.bench_serving \
  --backend sglang --model nvidia/DeepSeek-V4-Flash-NVFP4 \
  --dataset-name random \
  --random-input-len 32 --random-output-len 1024 \
  --num-prompts 10240 --request-rate inf --max-concurrency 8192

The trtllm baseline is the same command with
--moe-runner-backend flashinfer_trtllm_routed --moe-a2a-backend flashinfer.

Prefill 8192 tokens/rank — flashinfer_cutedsl_megamoe

# server
python -m sglang.launch_server \
  --trust-remote-code \
  --model-path nvidia/DeepSeek-V4-Flash-NVFP4 \
  --dp-size 4 --tp-size 4 --enable-dp-attention \
  --chunked-prefill-size 32768 --max-prefill-tokens 32768 \
  --disable-flashinfer-autotune --swa-full-tokens-ratio 0.1 \
  --moe-runner-backend flashinfer_megamoe --moe-a2a-backend flashinfer_megamoe \
  --max-running-requests 1024 \
  --host 0.0.0.0 --port 30000   # <VARIANT-SELECTOR>

# client
python -m sglang.bench_serving \
  --backend sglang --model nvidia/DeepSeek-V4-Flash-NVFP4 \
  --dataset-name random \
  --random-input-len 8192 --random-output-len 1 \
  --num-prompts 640 --request-rate inf --max-concurrency 128

For the 2048 tokens/rank point, use --chunked-prefill-size 8192 --max-prefill-tokens 8192 on the
server and --random-input-len 2048 --num-prompts 1280 on the client.

Setup & caveats
  • kv_cache_dtype=fp8_e4m3, page_size=256, EP4, dp-attention enabled

  • Best run per metric across repeats (max throughput, min latency)

  • Repeat counts vary: prefill flashinfer variants 2-6 runs each, trtllm/deepgemm 1-2 runs;
    decode is a single run per backend

  • Prefill 2048 tok/rank: the plain/combine_nvfp4 throughput gap (~200 tok/s) is inside the
    run-to-run spread (~1,100 tok/s), so treat those two as tied rather than ranked

  • Decode: single run per backend. The flashinfer variants span only 0.6% in throughput and 0.8%
    in mean TPOT, so their relative ordering is suggestive, not established. The deepgemm P99 TPOT
    win (-13.4%) is large enough to be credible from one run.

  • Server commands above are reconstructed from the recorded server_args; mem_fraction_static
    was auto-derived (0.8 decode, 0.681 / 0.876 prefill) and is not passed explicitly

  • FLASHINFER_MOE_EP_KNOB_CACHE point to the autotuned configs.

Remaining soft spot: every decode number is a single run, and the three FlashInfer variants differ by well under 1% in throughput. If you want the decode ranking to
hold up in review, 2–3 repeats per variant would settle it; the deepgemm P99 result is the only decode finding that stands on its own.

Accuracy — GSM8K (8-shot, 1316 questions)

python3 benchmark/gsm8k/bench_sglang.py --num-shots 8 --num-questions 1316 --parallel 1316
Backend Accuracy vs baseline Invalid Latency (s) Output tput (tok/s)
trtllm (baseline) 0.948 - 0.000 18.155 6,912
flashinfer_cutedsl_megamoe_plain 0.956 +0.8 pt 0.000 17.773 7,041
flashinfer_cutedsl_megamoe_ikr 0.951 +0.3 pt 0.000 18.563 6,805
flashinfer_cutedsl_megamoe_combine_nvfp4 0.956 +0.8 pt 0.000 18.482 6,749

No accuracy regression. All three flashinfer_cutedsl_megamoe variants match or slightly exceed
the trtllm baseline, with zero invalid outputs. At n=1316 the binomial standard error is ~0.6 pt,
so the +0.3 to +0.8 pt differences are within noise — the variants should be read as accuracy-
equivalent to the baseline, not better than it.

The latency/throughput columns here are not a perf signal: an ~18 s run at --parallel 1316 is
dominated by warm-up and scheduling, and the ordering contradicts the 10-minute decode benchmark
above. Use the decode section for throughput and TPOT.

Update 7/29/2026 — latest 2048 tokens/rank prefill rerun

Workload: DeepSeek-V4-Flash-NVFP4, 2048 tokens/rank prefill, output len 1,
640 requests, max concurrency 128.

Backend / config Input tput (tok/s) Mean TTFT (ms) Median TTFT (ms) P95 TTFT (ms) P99 TTFT (ms)
flashinfer_cutedsl_megamoe_combine_nvfp4, without autotune 46,686.44 10,017.09 10,971.72 13,067.52 13,739.66
deepgemm megamoe 51,865.66 8,959.21 9,848.21 11,661.31 12,296.46
flashinfer_cutedsl_megamoe_combine_nvfp4, with autotuned config 53,150.67 8,592.50 9,150.89 12,980.44 13,935.91

Takeaway: in this latest setup, the autotuned combine_nvfp4 config improves throughput and average
TTFT over the non-autotuned combine_nvfp4 path (+13.8% input throughput, -14.2% mean TTFT).
Against deepgemm megamoe, autotuned combine_nvfp4 has slightly higher input throughput (+2.5%)
and lower mean TTFT (-4.1%), while deepgemm megamoe has better tail latency (-10.2% P95 TTFT,
-11.8% P99 TTFT).

CI States


CI States

Latest PR Test (Base): ✅ Run #34431504439
Latest PR Test (Extra): ❌ Run #34431504350
Latest PR Test (AMD ROCm 10): ❌ Run #34431504462

@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!

@github-actions github-actions Bot added documentation Improvements or additions to documentation quant LLM Quantization deepseek labels Jul 16, 2026
@wenscarl
wenscarl marked this pull request as ready for review July 23, 2026 21:33
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@wenscarl

wenscarl commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator Author

cc. @ch-wan @Fridge003 @nvpohanh

@Fridge003 Fridge003 self-assigned this Jul 28, 2026
@nvpohanh

Copy link
Copy Markdown
Collaborator

This depends on FlashInfer PR that is not merged yet. Should we mark this as Draft for now?

@wenscarl
wenscarl marked this pull request as draft July 30, 2026 15:57
@github-actions github-actions Bot added the dependencies Pull requests that update a dependency file label Sep 1, 2026
@YAMY1234

YAMY1234 commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

/rerun-failed-ci bypass-fastfail 30a27fa


The first mega layer's first forward creates it (collective; safe because
warmup runs the same layer on all ranks in lockstep); later layers reuse it.
"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we have any suggestions on what a fixed flashinfer API would look like?

Comment thread python/sglang/srt/layers/moe/token_dispatcher/flashinfer.py
Comment thread python/sglang/srt/model_executor/model_runner.py
)


def _ensure_shared_workspace(mega: Any) -> None:

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.

[suggestion] _ensure_shared_workspace and warmup_all_flashinfer_megamoe_layers carry multi-paragraph history (a prior commit hash, why FlashInfer's pool missed, the capture repro narrative). That belongs in the PR body; the line only needs the live constraint (share by geometry because per-layer alpha tensors are identity-keyed; build every MegaMOE layer before capture).

Suggestion: Collapse each to one or two sentences stating the cross-module constraint, and drop the changelog/repro story.

The first mega layer's first forward creates it (collective; safe because
warmup runs the same layer on all ranks in lockstep); later layers reuse it.
"""
if getattr(mega, "_workspace", None) is not None:

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.

please do not use getattr/hasattr

Comment thread python/sglang/srt/layers/moe/flashinfer_megamoe.py
@wenscarl
wenscarl requested review from ch-wan and nvpohanh September 8, 2026 21:02
@nvpohanh

nvpohanh commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

All NV pipelines passed.

# Conflicts:
#	python/sglang/srt/runtime_context.py
@Fridge003
Fridge003 merged commit 1b77f49 into sgl-project:main Sep 10, 2026
262 of 291 checks passed
mqhc2020 pushed a commit to mqhc2020/sglang that referenced this pull request Sep 15, 2026
Co-authored-by: djns99 <40156487+djns99@users.noreply.github.com>
Co-authored-by: 云挚 <ningyunxiao.nyx@antgroup.com>
Co-authored-by: Yangmin Li <yangminl@nvidia.com>
Co-authored-by: Po-Han Huang (NVIDIA) <53919306+nvpohanh@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bypass-fastfail deepseek dependencies Pull requests that update a dependency file documentation Improvements or additions to documentation high priority quant LLM Quantization release-highlight Candidate PR for release note highlight run-ci

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants