Repository navigation
[WS1][CUDA][Qwen3-Next] Comparison benchmarks and plots for the Qwen3-Next stack: MoE, attention, logprob, EP (RFC #428 stack 11/11) - #551
Conversation
Rank r owns experts [128r, 128r+128) at full intermediate width; attention, GDN, embedding, LM head and the shared expert stay TP4. The MoE input is replicated, so dispatch is local: every rank computes the same routes, evaluates its own routes with the fixed-config grouped GEMM (through vLLM's expert_map), and the ranks exchange those rows with the deterministic collective's all-gather; every rank then applies the ordered FP32 combine. Backward keeps expert weight gradients on their owner and sums each token's route contributions in ascending expert order, as the EP1 path does. Add the EP4 real-weight gate and CPU placement tests. Signed-off-by: Wenbo Ji <[email protected]>
…E recompute
The launcher takes --ep {1,4}; the run's topology and provider config record
it, so every stage, certificate and identity comparison binds to it, and the
layers stage runs the EP4 MoE gate instead of the TP4 one at EP4.
vLLM: expert parallelism must match the identity, with linear placement; the
bound model checks 128 full-width local experts and that vLLM's expert map is
[128r, 128r+128) on rank r, and SharedVLLMMoE evaluates them with
shared_moe_ep. VIME: EP4 x ETP1 is accepted next to EP1 x ETP4; SharedVIMEEPMoE
requires Megatron's EP rank to equal the TP rank and loads only this rank's
experts. Training and EP4 weight export stay EP1-only and fail closed.
Signed-off-by: Wenbo Ji <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
67a4516 to
48516ee
Compare
Signed-off-by: Wenbo Ji <[email protected]>
Signed-off-by: Wenbo Ji <[email protected]>
48516ee to
3bc3f7e
Compare
Signed-off-by: Wenbo Ji <[email protected]>
1026162 to
8f675f3
Compare
…xt gate scripts The scripts moved from ci/ to ci/scripts/ with the repository refactor but still resolved the root one directory up, so the preflight operator gates looked for ci/tools/validation/models/qwen3_next_operator_gates.py. Signed-off-by: Wenbo Ji <[email protected]>
Signed-off-by: Wenbo Ji <[email protected]>
Signed-off-by: Wenbo Ji <[email protected]>
Signed-off-by: Wenbo Ji <[email protected]>
The EP4 MoE gate moves to tools/validation/models/qwen3_next/ with the other Qwen3-Next gates, following the maintainer's layout review on the TP PR. Signed-off-by: Wenbo Ji <[email protected]>
Signed-off-by: Wenbo Ji <[email protected]>
The scheduler and L2 matrix validators still required topology ep=1, so the EP4 layers stage failed after all of its gates had passed. Both now use supported_topology (TP4/PP1/CP1 with EP 1 or 4), and the chain report's config fingerprint records the measured expert parallelism. Training stays EP1-only. Signed-off-by: Wenbo Ji <[email protected]>
The disclaimer said TP4 x EP1 and the backend profile was the EP1 one for every chain. Both now follow the topology recorded in the L2 matrix; EP1 reports are unchanged. Signed-off-by: Wenbo Ji <[email protected]>
Adds the expert-parallel section to the distributed logprob contract (placement, local dispatch, byte-only route exchange, combine and gradient order, fail-closed topologies) and a short summary of the TP4 x EP4 preflight, layers and L2 run measured at 1c4ae26. The raw JSON is a ZIP release attachment; the summary records its SHA-256 and the commands that reproduce it. Signed-off-by: Wenbo Ji <[email protected]>
Runs RL-Kernel's EP4 routed MoE, vLLM's expert-parallel fused_experts (default and VLLM_BATCH_INVARIANT=1) and Megatron-core's MoELayer with the alltoall and allgather dispatchers on the same replicated input at EP4 and EP1. Each launch records the output digest, repeatability, batch invariance, the error against an FP64 evaluation and latency; the merge step compares EP4 with EP1 and EP4 launches under different NCCL settings. Signed-off-by: Wenbo Ji <[email protected]>
…anges Clearing it around every call made each timed default-mode call look up the tile config file again, which inflated vLLM's default latency. Signed-off-by: Wenbo Ji <[email protected]>
With torch.use_deterministic_algorithms(True) Megatron's token unpermute uses index_add_ instead of scatter_add_, so its deterministic mode is a separate candidate. The runner sets CUBLAS_WORKSPACE_CONFIG for every candidate. Adds the figure renderer for the merged report. Signed-off-by: Wenbo Ji <[email protected]>
Seven candidates on real layer-0 weights at EP4 under 13 NCCL settings and at EP1, measured at 225c5a4; raw JSON and the figure are a ZIP release attachment. Signed-off-by: Wenbo Ji <[email protected]>
…ce, backward Adds FlashInfer's cutlass_fused_moe (CUTLASS grouped GEMM) with ep_size/ep_rank, and runs vLLM's expert kernel with vLLM's own all-reduce dispatch as deployed (the NCCL-only combine stays as a separate candidate). Batch invariance is now a grid of batch sizes 8-1024 with the probe rows first, middle and last; the candidates that train (RL-Kernel, Megatron) also report input and owned-expert weight gradient digests, repeatability, the same grid on the input gradient and backward latency; forward latency covers 64-4096 tokens. Signed-off-by: Wenbo Ji <[email protected]>
Signed-off-by: Wenbo Ji <[email protected]>
Signed-off-by: Wenbo Ji <[email protected]>
… the benchmark branch Signed-off-by: Wenbo Ji <[email protected]>
Signed-off-by: Wenbo Ji <[email protected]>
… moves here Per the layout review on RL-Align#549, the remaining comparison benchmarks and plots of the Qwen3-Next stack join this PR under benchmarks/models/qwen3_next/: the routed-MoE and full-attention prior-art candidates and runners, their plots, and the chain and batch-invariance plots. Code is unchanged apart from imports and paths; the validation PRs keep only checks and CI tests. Signed-off-by: Wenbo Ji <[email protected]>
…arty, logprob and EP plots Signed-off-by: Wenbo Ji <[email protected]>
Signed-off-by: Wenbo Ji <[email protected]>
Signed-off-by: Wenbo Ji <[email protected]>
|
Replies to the six OpenCodeReview summary items. The plot fixes are compiled but I have not re-rendered the figures from the evidence.
|
Signed-off-by: Wenbo Ji <[email protected]>
Signed-off-by: Wenbo Ji <[email protected]>
|
One OpenCodeReview summary item:
|
…) into RL-Align#557 Signed-off-by: Wenbo Ji <[email protected]>
…ine_routes The EP4 MoE gate compared only the routed experts on fixed routes. Each token count now also runs the whole routed block end to end (shared_moe_ep: shared_router, stable_top10_routes, the experts and combine_routes) against shared_moe (EP1) on the same weights, bitwise: the output, route indices and weights, the input gradient, the router weight gradient and the owned experts' weight gradients. The router weight gradient must be non-zero and identical on every rank. The four new case ids are mandatory in the layer contract. Signed-off-by: Wenbo Ji <[email protected]>
…, EP4 router/combine gate) into RL-Align#551 Signed-off-by: Wenbo Ji <[email protected]>
| lq = [s[0].shape[0] for s in seqs] | ||
| lk = [s[1].shape[0] for s in seqs] | ||
| blocks = [(n + block - 1) // block for n in lk] | ||
| k_cache = torch.zeros(sum(blocks), block, HKV, D, device="cuda", dtype=torch.bfloat16) |
There was a problem hiding this comment.
_vllm_triton.run allocates and fills the paged K/V caches (and builds the block table) on every call, and _latency times the whole run via _sample_us. For decode (lq=1, kv=8192) the actual unified_attention kernel is a few microseconds while zeroing/copying ~8 MB of cache dominates, so this candidate's decode_us_kv8192 is far larger than varlen candidates that do no such setup. The reported decode/prefill latencies are therefore non-equivalent and would support a wrong conclusion about the kernel. Build the cache once outside the timed closure (per fixed shape) and time only the kernel launch.
| dw13 = torch.stack([e.linear_fc1.weight.grad for e in experts]) | ||
| dw2 = torch.stack([e.linear_fc2.weight.grad for e in experts]) | ||
| return x.grad, dw13, dw2 |
There was a problem hiding this comment.
_megatron.backward reads .grad after layer.zero_grad(set_to_none=True) and torch.stacks them. Experts that received no routed tokens are not part of the autograd graph, so their .weight.grad stays None, and torch.stack raises TypeError. candidate_report invokes cand.backward(probe, dprobe) with only PROBE=8 rows (80 top-10 slots spread over 128/512 experts), so most experts are unselected and this path will almost certainly crash the whole measurement (the backward section is one of the few spots not wrapped in try/except). Materialize missing grads as zeros before stacking.
Suggestion:
| dw13 = torch.stack([e.linear_fc1.weight.grad for e in experts]) | |
| dw2 = torch.stack([e.linear_fc2.weight.grad for e in experts]) | |
| return x.grad, dw13, dw2 | |
| dw13 = torch.stack([ | |
| e.linear_fc1.weight.grad | |
| if e.linear_fc1.weight.grad is not None | |
| else torch.zeros_like(e.linear_fc1.weight) | |
| for e in experts | |
| ]) | |
| dw2 = torch.stack([ | |
| e.linear_fc2.weight.grad | |
| if e.linear_fc2.weight.grad is not None | |
| else torch.zeros_like(e.linear_fc2.weight) | |
| for e in experts | |
| ]) | |
| return x.grad, dw13, dw2 |
…in the provider job, RL-Align#503 bias grad gate) into RL-Align#557 check_qwen3_next_vllm_model_contract.py stays only in this PR's four-GPU step, which already runs it. Signed-off-by: Wenbo Ji <[email protected]>
…in the provider job, RL-Align#503 bias grad gate) into RL-Align#551 Signed-off-by: Wenbo Ji <[email protected]>
Candidates with per-batch setup now expose prepare(seqs) -> launch: packing and cu_seqlens for the varlen engines, the paged KV cache and block table for vLLM Triton, FlashInfer's plan, and the bottom-right masks for SDPA and Megatron run once per shape, as an engine does once per step for all layers. Latency times launch() only; run(seqs) is prepare(seqs)() so the batch-invariance checks still cover the setup. Before, the Triton candidate zeroed and copied the whole KV cache and FlashInfer planned (with a device-to-host copy) inside every timed sample. The backward timing now probes each candidate once and leaves out one that raises, as the forward already did, and --only builds only the selected candidates. Signed-off-by: Wenbo Ji <[email protected]>
The attention merge stops when both reports measured the same candidate, and replaces a candidate the base recorded as unavailable with the extra report's entry, so a candidate's verdicts and latency come from one process. The MoE EP and logprob runners give a usage error for --merge without --out, or a measurement without --checkpoint and --output. Signed-off-by: Wenbo Ji <[email protected]>
…t rerun Step 5: the RL-Align#507 attention prior art on H100 with RL-Align#551's timing fix (per-batch setup out of the timed region), plus a bundle of the local OCR fixes (fix/551-flink-r1 at 2c0cd1e, prerequisites ea999fd and 6248771). Signed-off-by: Wenbo Ji <[email protected]>
Fixed on #543 in |
Fixed in |
Fixed in |
Fixed in |
Fixed in |
… rerun Rerun of the RL-Align#507 attention prior art on B200 with the RL-Align#551 runner at 2c0cd1e (per-batch setup outside the timed region). Batch-invariance verdicts and accuracy are unchanged; latencies, the archive link and its SHA-256 are updated, and the summary records the Transformer Engine 2.20.2 and Megatron-core 0.20.0 versions of this run. Signed-off-by: Wenbo Ji <[email protected]>
What
Per the layout review on #549, every comparison benchmark and plot of the Qwen3-Next stack lives here, under
benchmarks/models/qwen3_next/; the validation PRs keep only checks and CI tests. Code is moved from the validation PRs with imports and paths adjusted, except the new EP benchmark.moe_route_candidates.pyqwen3_next_moe_prior_art.pyplot_qwen3_next_moe_prior_art.pyattention_candidates.pyqwen3_next_attention_prior_art.pyplot_qwen3_next_attention_prior_art.pyplot_qwen3_next_chain.pyplot_qwen3_next_batch_invariance.pylogprob_candidates.pyqwen3_next_logprob_prior_art.pyplot_qwen3_next_distributed_logprob.pymoe_ep_candidates.pyqwen3_next_moe_ep_prior_art.pyplot_qwen3_next_moe_ep.pyMiles and verl are measured, not read:
thirdparty_sources.pyimports their own kernels unmodified from checkouts of pinned commits (radixark/miles@23d3d38,volcengine/verl@e5a627c) and records the SHA-256 of every file used. New here:qwen3_next_miles_moe_backward.py(Miles' routed-MoE backward, 20 identical launches on the real layer-0 weights, RL-Kernel as the control),qwen3_next_logprob_backward.py(verl, Miles and RL-Kernel logprob backward),miles_fusedandverl_fusedin the logprob candidates, andplot_qwen3_next_thirdparty.py.Results summaries (download link, SHA-256, tested commit, commands) are in
reports/experiments/qwen3_next/:qwen3-next-logprob-comparison-b200.md,qwen3-next-moe-ep-comparison-b200.mdandqwen3-next-thirdparty-comparison-b200.mdhere; the MoE-route, attention, chain and BI summaries in their validation PRs.Prior art & reuse decision
N/A: benchmarks only. The reuse decisions are in each validation PR; this PR provides the code that measures them.
Results
Expert-parallel MoE (new, for the EP PR), layer 0 real weights, EP4 under 13 NCCL settings and EP1, 4 × B200, measured at
7db4a14b(summary, raw results ZIP, SHA-2562375ec36…97c6cf):VLLM_BATCH_INVARIANT=1all_reducecutlass_fused_moe(CUTLASS)Miles and verl (for #503, #549, EP PR), measured at
6ad63611(MoE backward, logprob forward) and03a5898e(logprob backward, TP1 and TP4) (summary, raw results ZIP, SHA-256d0eaa326…f2ff):dx/dWgate/up /dWdown equal the firsttl.atomic_add)dxof probe rows alone == in batch (10 cells)Miles' MoE backward is not reproducible; both libraries' logprob forward depends on the NCCL algorithm like Megatron's and VIME's. Their logprob backward also depends on the NCCL algorithm at TP4 (it consumes the all-reduced forward statistics) and differs from TP1, while RL-Kernel's does not. Not what the source suggested: verl's backward
tl.atomic_adddid not change the bits between launches, and its forwardatomic_addonly runs forreductionsum/mean.TP logprob (#549): measured in #549 (summary and ZIP there): TP4 median latency 2.55 ms (RL-Kernel), 1.51 ms (vLLM), 0.57 ms (Megatron), 0.56 ms (VIME); invariance as in #549.
The routed-MoE, attention, chain and BI figures are rendered by the moved plot scripts from the ZIPs attached to their PRs (checked: each renders from the downloaded evidence layout).
Figures of the validation PRs, rendered by the plot scripts in this PR from the evidence ZIPs of those PRs:
Status
ea999fd4, on top of [WS1][CUDA][Qwen3-Next] EP4 distributed logprob parity: expert-parallel MoE, full-model L2 bitwise on TP4 x EP4 (RFC #428 stack 10/11) #557 (62487710). CI is green on this head: lint, unit-tests, docs and DCO pass;providerandws1-gtestskip because no self-hosted runner is attached. Since @Flink-ddd's LGTM at2c699e3fthe only change is the merge of [WS1][CUDA][Qwen3-Next] EP4 distributed logprob parity: expert-parallel MoE, full-model L2 bitwise on TP4 x EP4 (RFC #428 stack 10/11) #557; no file of this PR's own diff changed.3a5263d2); Megatron was first measured only without deterministic algorithms (added in6e316f4b); v2 adds FlashInfer, vLLM's own all-reduce dispatch, a two-dimensional batch grid and the backward. The first v2 launch crashed in vLLM's parallel-state setup because the job'sTMPDIRpath exceeded the IPC socket path limit; the published run uses a short node-localTMPDIR(recorded in the summary).History
ea999fd4): the Hopper allowance, [WS1][CUDA][Qwen3-Next] MoE route/combine contract with a batch-invariant grouped expert GEMM (RFC #428 stack 5/11) #503'scombine_routesbackward fix and the extended EP4 gate. No benchmark file changed.pull_requestpaths were missing Qwen3-Next modules that its checks import; merged the additions of [WS1][CUDA][Qwen3-Next] Full-model chain: vLLM rollout vs VIME recompute, raw-bit through two updates and a reload (RFC #428 stack 7/11) #543 and [WS1][CUDA][Qwen3-Next] Batch-invariance matrix for the full model, 97/97 cells bitwise (RFC #428 stack 8/11) #544 (015bec4a). Workflow-only change; shared infrastructure such asrl_engine/opsandrl_engine/platformsstays out of the filter.cc7dc4bc. Kernel arithmetic is unchanged, so the measured results stand.test-qwennextafter [WS1][CUDA][Qwen3-Next] C1: zero-centred RMSNorm references and CUDA kernel (RFC #428 stack 2/4) #467 landed (c382dd4b), through [WS1][CUDA][Qwen3-Next] EP4 distributed logprob parity: expert-parallel MoE, full-model L2 bitwise on TP4 x EP4 (RFC #428 stack 10/11) #557's new head85297004, in5364c406. No conflicts.Tests
--helpand every plot rendered from its published evidenceScope
CUDA, B200. Benchmarks and plots only.