Repository navigation
[WS1][CUDA][Qwen3-Next] TP distributed logprob parity: fixed reduction order, selected-token logprob exact across NCCL settings (RFC #428 stack 9/11) - #549
Conversation
…s NCCL settings qwen3_next_logprob_parity.py records, on real weights, SHA-256 digests at the vocabulary-parallel embedding, the row-parallel outputs and input gradients of GDN layer 0, full-attention layer 3 and the layer-0 MoE block, the TP4 selected-token logprob/LSE/entropy and its logits gradient, the gathered sampling logits and the TP1 logprob over the same logits; plus a negative control reducing real o_proj partials with NCCL all_reduce. qwen3_next_logprob_parity_compare.py checks one digest per rank across NCCL algorithm, protocol and channel settings, and TP4 == TP1. Signed-off-by: Wenbo Ji <[email protected]>
The WS2 provider merges per-tile logprob statistics in global tile order, so selected logprob and LSE do not depend on the TP degree; entropy is summed per shard in rank order and is outside the selected-logprob contract. The run records whether entropy matches TP1 instead of failing on it. Signed-off-by: Wenbo Ji <[email protected]>
…n logprob Runs RL-Kernel's WS2 provider, vLLM's gather + log_softmax sampler path, Megatron-core vocab_parallel_cross_entropy and VIME's default logprob on the same official-LM-head logits at TP4 and TP1, and records TP-degree and NCCL setting invariance, batch invariance, error against FP64, pairwise differences and latency. Signed-off-by: Wenbo Ji <[email protected]>
…rward paths NCCL changes its summation order with the algorithm, protocol and channel count. Scan the Qwen3-Next model, engine and VIME modules for raw reductions; all_gather (data movement) and an integer MAX of flags are allowed, and the TP reduction must go through RL-Kernel's fixed-order collective. Signed-off-by: Wenbo Ji <[email protected]>
Document every TP4 cross-rank point of Qwen3-Next (embedding, row-parallel projections, MoE combine, column-parallel input gradients, the vocabulary- parallel selected logprob/LSE/entropy and the sampling logits): which ones move bytes with NCCL all-gather and which ones sum with RL-Kernel's fixed-order collective, with orders and dtypes, the reuse decision against vLLM, Megatron and VIME, and the known entropy TP-degree dependence. Add the figure script. Signed-off-by: Wenbo Ji <[email protected]>
Copies the per-setting rank reports, the comparison report and the prior-art reports into the repository with the chain publisher's redaction rules, refuses anything a forbidden pattern still matches, and writes redaction.json and SHA256SUMS. Signed-off-by: Wenbo Ji <[email protected]>
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
|
Flink-ddd
left a comment
There was a problem hiding this comment.
Please trim this PR down or split it into two: one for the TP logprob checks and CI tests, and another for the comparison benchmarks and plotting code. Upload the raw JSON results as an attachment and follow the repository layout guide for file placement.
| ``qwen3_next_bi_manifest.json``. | ||
| """ | ||
|
|
||
| from __future__ import annotations |
There was a problem hiding this comment.
Please group the Qwen3-Next validation code and JSON resources under rl_engine/validation/models/qwen3_next/, and the validation scripts under tools/validation/models/qwen3_next/. Follow the repository layout guide and update imports, resource paths and CI commands together.
There was a problem hiding this comment.
Addressed in b10b661. Qwen3-Next validation modules and JSON resources now live under rl_engine/validation/models/qwen3_next/, and the validation scripts under tools/validation/models/qwen3_next/. Imports, repository-root/resource lookups, CI launch commands, affected tests, and reproduction commands were updated together.
The relocated code has now been rerun on four B200 GPUs from clean commit b10b6616, with vLLM 0.30.0, torch 2.13.0+cu130, Triton 3.7.1 and NCCL 2.29.7:
- Full operator-case collection passed; all 233 mandatory operator cases and all four norm forward/gradient gates passed without skips. The TP reduction guard also passed.
- Vocabulary-parallel logprob tests: 31 passed, with four ROCm-only cases skipped.
- Across all 13 NCCL settings, all 17 deterministic points had one digest per rank. TP4 selected-token logprob and LSE matched TP1 bitwise; the raw-NCCL negative control produced five distinct digests per rank.
In the pinned vLLM/Megatron environment, all 423 related CPU tests also passed without skips. The Python 3.10 artifact-hashing fix in 3927fad7 adds four passing regression tests; remote unit tests, lint, docs and DCO passed for that fix. GPU results are explicitly pinned to b10b6616; full-model L2 and the 97-cell batch-invariance sweep were not repeated.
New raw GPU reports, logs and provenance (ZIP) · Result summary and reproduction commands. All 153 internal checksums and the public ZIP download hash were verified.
| # Copyright (c) 2026 RL-Kernel Contributors | ||
|
|
||
| """Prior art for the Qwen3-Next vocabulary-parallel selected-token logprob. | ||
|
|
There was a problem hiding this comment.
Please move the comparison benchmarks and plotting code to a separate PR under benchmarks/models/qwen3_next/, keeping this PR focused on the TP logprob checks and CI tests.
There was a problem hiding this comment.
Split into #551. The comparison candidates, measurement/merge runner, and plotting script now live under benchmarks/models/qwen3_next/ in that separate draft PR. They have been removed from #549, along with the comparison-specific discussion, leaving this PR's TP work focused on parity checks, the reduction contract, and CI guards.
#551 is stacked on this PR and remains draft until this lands; its own change is five files: benchmark-only diff. The relocated merge runner reproduces the archived comparison report exactly, and the plotting CLI renders successfully.
| ```bash | ||
| python tools/validation/models/qwen3_next_run.py --stage all --until l2 \ | ||
| --runs-root <runs> --checkpoint <checkpoint> --cuda-home <cuda-13.0> --python <venv>/bin/python | ||
| python tools/validation/models/qwen3_next_run.py --stage bi --bi-suite full --previous <runs>/<...-l2-...> \ |
There was a problem hiding this comment.
Please upload the raw JSON results as a ZIP attachment. Keep a brief summary under reports/experiments/qwen3_next/, with the download link, tested commit and commands to reproduce the results.
There was a problem hiding this comment.
Uploaded both raw-result ZIPs as release attachments and removed the corresponding committed evidence directories. Brief summaries now live under reports/experiments/qwen3_next/:
- Batch invariance: measured at
759755e. - TP logprob parity: measured at
04db726.
Each summary includes the download link, ZIP SHA-256, tested commit, and reproduction commands. The archives preserve the original published evidence bytes and SHA256SUMS; every checksum was verified, and the public downloads match the local ZIP hashes. The relocated parity comparator also reproduces the archived report exactly.
…vidence Signed-off-by: Wenbo Ji <[email protected]>
4da4647 to
b10b661
Compare
Signed-off-by: Wenbo Ji <[email protected]>
Signed-off-by: Wenbo Ji <[email protected]>
…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 the runner under ci/. Signed-off-by: Wenbo Ji <[email protected]>
Brings in the stdlib-only artifact hashing of the evidence runtime: the launcher imports it as a script, where rl_engine (and torch) are not on the path, so the TP PR's launcher could not start. The digest test now loads the runtime from its tools/validation/models/qwen3_next/ location. Signed-off-by: Wenbo Ji <[email protected]>
…erge Signed-off-by: Wenbo Ji <[email protected]>
The earlier PRs now carry the reviewed layout themselves, so the inherited prior-art runners and plots leave this branch too (they move to the Qwen3-Next benchmark PR), as do the inherited committed evidence directories; their summaries live in reports/experiments/qwen3_next/. Signed-off-by: Wenbo Ji <[email protected]>
Not changed. The plain and gated bindings ship in the same |
Same point as 503-S7, 549-S2, 557-I4383087967; not changed. |
Same point as 469-S4, 507-S1, 544-S4; not changed. Both hooks return per-row contributions on purpose: the C4 harness keys them per logical token, checks the row count and folds them itself in fixed fp32 order. It always passes 2-D |
Same point as 507-S3, 507-S2; not changed. The hook and the backward share |
Same point as 549-S3, 543-S3; not changed. pip merges the base and extra specifiers, so |
Same point as 543-S4; not changed. |
Signed-off-by: Wenbo Ji <[email protected]>
Signed-off-by: Wenbo Ji <[email protected]>
|
One OpenCodeReview summary item:
|
Provider job, chain preflight (failed at rollout-smoke), logprob prior art over 13 NCCL settings, EP matrix at 2c699e3, RL-Align#557 gates at f935bf3, RL-Align#549 parity at 30c0e5a, RL-Align#543/RL-Align#544 preflight at their own heads. Redacted. Signed-off-by: Wenbo Ji <[email protected]>
| tests/models/qwen3_next/test_qwen3_next_failure.py \ | ||
| tests/models/qwen3_next/test_qwen3_next_imported_binary.py \ | ||
| tests/models/qwen3_next/test_qwen3_next_installed_provider_identity.py \ | ||
| tests/models/qwen3_next/test_qwen3_next_l2.py \ |
There was a problem hiding this comment.
This 28-module qwen3_next block was appended to the "Run Mocked Hardware Discovery Tests" step, which does not build the rl_engine._C extension and is CPU-only. Several of the newly listed modules (e.g. test_qwen3_next_imported_binary.py, test_qwen3_next_installed_provider_identity.py, test_qwen3_next_storage.py, test_qwen3_next_training_checkpoint.py, test_qwen3_next_l2.py) exercise compiled-extension, vLLM-import or on-disk binary/provider evidence paths. Any module that imports those at module scope without pytest.importorskip/skip markers will fail collection here, turning the required CI job red instead of skipping. Please confirm each newly added module is import-safe on a runner without the extension/vLLM (or split these into their own step with the appropriate skip guard).
Flink-ddd
left a comment
There was a problem hiding this comment.
LGTM, Thank for you push it. also cc @inaniloquentee
…) into RL-Align#549 Signed-off-by: Wenbo Ji <[email protected]>
| passed = ( | ||
| first is None | ||
| and all(matrix["status"] == "passed" for matrix in matrices.values()) | ||
| and all(item.passed for item in invariance) | ||
| and (bi_matrix is None or bi_matrix["status"] == "passed") | ||
| ) |
There was a problem hiding this comment.
passed omits the train_infer and per-cell decode_prefill verdicts that are computed above. The shared reference gate (rl_engine/validation/models/chain_gate.py:674-690) folds both train_infer.passed and all(verdict.passed for _case_id, verdict in decode_prefill) into the top-level passed. Here, a chunked-prefill vs full-prefill divergence beyond the contract tolerance (which is not covered by the bitwise invariance check, since those cells are different computations) still yields passed=True. The CLI then exits 0 and run_qwen3_next_chain_gate.sh reports success for a real numerical failure.
Suggestion:
| passed = ( | |
| first is None | |
| and all(matrix["status"] == "passed" for matrix in matrices.values()) | |
| and all(item.passed for item in invariance) | |
| and (bi_matrix is None or bi_matrix["status"] == "passed") | |
| ) | |
| passed = ( | |
| first is None | |
| and all(matrix["status"] == "passed" for matrix in matrices.values()) | |
| and all(item.passed for item in invariance) | |
| and (bi_matrix is None or bi_matrix["status"] == "passed") | |
| and train_infer.passed | |
| and all(verdict.passed for _case_id, verdict in decode_prefill) | |
| ) |
…in the provider job, RL-Align#503 bias grad gate) into RL-Align#549 Signed-off-by: Wenbo Ji <[email protected]>
Fixed in
|
Fixed in |
Signed-off-by: Wenbo Ji <[email protected]>
…rovider job, #503 bias grad gate) into #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]>
Provider job, chain preflight (failed at rollout-smoke), logprob prior art over 13 NCCL settings, EP matrix at 2c699e3, RL-Align#557 gates at f935bf3, RL-Align#549 parity at 30c0e5a, RL-Align#543/RL-Align#544 preflight at their own heads. Redacted. Signed-off-by: Wenbo Ji <[email protected]>
What
docs/operators/qwen3-next-distributed-logprob.md): every TP4 point where ranks combine values -- embedding, row-parallel GDN/attention/MoE outputs, column-parallel input gradients, the vocabulary-parallel selected logprob / LSE / entropy, sampling logits -- with its operation, order, dtype and transport (NCCL all-gather for bytes only; RL-Kernel's fixed-order collectivecuda_ipc_fixed_treefor sums).tools/validation/models/qwen3_next/qwen3_next_logprob_parity.py, 4 GPUs, real weights): SHA-256 of every point's output and gradient per rank, a TP1 reference, and a raw-NCCL negative control;qwen3_next_logprob_parity_compare.pychecks one digest per rank across NCCL settings.tests/models/qwen3_next/test_qwen3_next_tp_reductions.py): no rawtorch.distributedreduction in Qwen3-Next model, engine or VIME modules; the TP reduction must use the fixed-order collective.rl_engine/validation/models/qwen3_next/, scripts undertools/validation/models/qwen3_next/, comparison benchmarks and plots in the benchmark PR ([WS1][CUDA][Qwen3-Next] Comparison benchmarks and plots for the Qwen3-Next stack: MoE, attention, logprob, EP (RFC #428 stack 11/11) #551), raw JSON as release ZIPs with summaries inreports/experiments/qwen3_next/. The earlier PRs of the stack now follow the same layout themselves.Prior art & reuse decision
Same official-LM-head logits for every measured candidate (TP4 shards are slices of one full-vocabulary product), 1024 tokens:
shared_logprob(both engines here)log_softmaxlog_softmax(srt/layers/logits_processor.py)vocab_parallel_cross_entropycalculate_log_probs_and_entropyradixark/miles@23d3d38)fused_log_probs_and_entropy, imported unmodifiedvolcengine/verl@e5a627c)linear_cross_entropy, imported unmodified (fuses the LM-head GEMM; own logits, FP64 reference of its own product)atomic_addruns only forreductionsum/mean); backwardd_hidden/d_weightusetl.atomic_addbut are repeat-stable (20/20), not batch invariant (probe rows 1/10 cells)The measured implementations differ from each other by up to 9.5e-7 (Megatron and VIME agree with each other). vLLM's path is exact for rollout, but the training side has no counterpart that reproduces it; Megatron/VIME, Miles and verl (all measured) reduce max and sum-exp with NCCL all-reduce, so they move with NCCL settings. Decision: both engines keep RL-Kernel's WS2 provider -- the only measured way to equal bits on both sides. Its cost is latency (4.5× Megatron at this shape); a faster tile-stats kernel can keep the same merge order and is follow-up work.
Results (4 × B200, official checkpoint)
Top: digest of every TP4 point under each NCCL setting vs NCCL defaults; the last row is the raw-NCCL negative control. Bottom: prior-art invariance, largest pairwise difference, latency.
o_projpartials, NCCLall_reduceNCCL 2.29 has no Tree all-gather, so the Tree settings restrict all-reduce only (
NCCL_ALGO=allreduce:tree). Summary, tested commits and commands:reports/experiments/qwen3_next/qwen3-next-distributed-logprob-b200.md; raw reports ZIP (SHA-256a48bf29d…2cd9), parity measured at04db726, prior art at33495ad. Post-review GPU rerun atb10b6616(ZIP): all 233 mandatory operator cases and four norm gates passed; all 17 points invariant across the 13 settings; selected logprob / LSE equal TP1; the negative control again gave five digests per rank.Status
e8195782, on top of [WS1][CUDA][Qwen3-Next] Batch-invariance matrix for the full model, 97/97 cells bitwise (RFC #428 stack 8/11) #544 (c49419ae). CI is green on this head: lint, unit-tests, docs, DCO and the bot review pass;providerandws1-gtestskip because no self-hosted runner is attached. Since the approval atb15de6e7the only change is that merge of [WS1][CUDA][Qwen3-Next] Batch-invariance matrix for the full model, 97/97 cells bitwise (RFC #428 stack 8/11) #544: the Hopper allowance of the four-GPU guards (it touches this PR'sqwen3_next_preflight.pyandqwen3_next_l2.py, where the guard is called) and [WS1][CUDA][Qwen3-Next] MoE route/combine contract with a batch-invariant grouped expert GEMM (RFC #428 stack 5/11) #503's fixed-ordercombine_routesbackward. The logprob code and CI guard of this PR are unchanged.3927fad7); stdlib-only launcher runtime.90c09164): the EP1 chain passed throughl2,train1,train2andtrain(L2 artifacts bitwise identical to thec67ec14run) and the full BI suite passed 97 / 97 cells (see [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).History
e8195782), which brings [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's Hopper allowance and [WS1][CUDA][Qwen3-Next] MoE route/combine contract with a batch-invariant grouped expert GEMM (RFC #428 stack 5/11) #503'scombine_routesbackward fix.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 (3f7cf6ec). Workflow-only change; shared infrastructure such asrl_engine/opsandrl_engine/platformsstays out of the filter.5ffd4c31runstest_file_digest.pyonce in the CPU job. The fixes of the PRs below it are merged in; new head5ffd4c31. 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] Batch-invariance matrix for the full model, 97/97 cells bitwise (RFC #428 stack 8/11) #544's new headeb04b15f, infe6ed386. This PR moves the norm workload, manifest and evidence scripts underqwen3_next/, so [WS1][CUDA][Qwen3-Next] Gated RMSNorm CUDA kernel for the GDN block (RFC #428 stack 3/4) #468's later changes to them were taken at those paths, and [WS1][CUDA][Qwen3-Next] Gated RMSNorm CUDA kernel for the GDN block (RFC #428 stack 3/4) #468's reuse check (new here) reads the moved manifest.Tests
ci.yml+ digest testsall_reduce/reduce_scatter_tensoris reported0b88a839)Scope
CUDA, TP4 × EP1 × CP1, one node of four B200. Expert parallelism is #557; ROCm is a separate claim.
Results (H100 / Hopper, 4 GPUs, official checkpoint)
Run at this PR's head
8e88cd82. 4 × NVIDIA H100 80GB, torch 2.13.0+cu130, vLLM 0.30.0, NCCL 2.29.7, checkpoint revision9c7f2fbe. Raw data:hopper-qwen3-next/pr549.tests/models/qwen3_next/test_*.py+check_*.py(4 GPUs)deterministic_points_invariant: true).tp4_equals_tp1: true); entropy differs between TP4 and TP1 as documented (entropy_tp4_equals_tp1: false).all_reduceof theo_projpartials gives 8 distinct results over the 13 settings, the fixed-order collective gives 1.Logprob prior-art on H100 (1024 tokens, TP4 vs TP1, 10 repeats; runner at
77d59a59):rl_kernel_ws2vllm_gathermegatron_cevime_defaultmiles_fused,verl_fusedReport:
pr549_logprob/report.json(alsoparity/report.jsonfor the gate parity).