Skip to content

perf(cuda): re-measure the fused-MoE Dff bound on GB10 with a null arm - #2962

Merged
inureyes merged 3 commits into
lablup:mainfrom
Jaeyeong-CHOI:perf/2540-fused-moe-dff-remeasure
Nov 15, 2026
Merged

inureyes merged 3 commits into
lablup:mainfrom
Jaeyeong-CHOI:perf/2540-fused-moe-dff-remeasure

Conversation

@Jaeyeong-CHOI

Copy link
Copy Markdown
Contributor

Summary

Re-measures the CUDA fused decode-MoE bound (FUSED_MOE_MAX_DFF_CUDA = 8192) on a DGX Spark GB10 at 28d884a5 (MLX pin 9f806b36) with interleaved fused / gather / null arms, as #2540 asks. The bound stays at 8192; the constant and its unit tests are unchanged. The record also corrects what the earlier sweeps rested on.

Related issues

Closes #2540

Type of change

  • feat — new user-visible feature
  • fix — bug fix
  • perf — performance improvement (include before/after numbers in the PR body)
  • refactor — internal restructuring without behavior change
  • chore — build, CI, dependencies, release infrastructure
  • docs — documentation only
  • test — tests only

No runtime behavior changes: this is a measurement, its record, and the comments and docs that cite it.

Findings

Full record: docs/benchmark_results/fused-moe-dff-crossover-gb10-2026-11-11.md. 384 measured runs, one process each, no discarded or failed run.

Dff model fused over gather, as specified (n = 5) full 100-token window (n = 7) pinned to fast cores (n = 7) verdict
768 qwen3-30b-a3b +28.4% +34.7% +31.4% win
1792 lfm2-8b-a1b +2.6% -0.9% -2.4% tie
6400 phi-3.5-moe +0.2% +1.3% +2.4% tie
8192 llama-4-scout-17b -0.2% -0.1% not run not a fused-path point
14336 mixtral-8x7b -2.0% -2.3% -1.8% loss
  1. 8192 is kept. With the issue's primary harness the ratio crosses 1.0 at an interpolated Dff of 7318 (7148 without llama-4-scout), on the same side of 8192 as perf(cuda/moe): backend-specific default for the fused decode-MoE Dff threshold #626 (about 8000) and perf(moe): re-validate the CUDA fused-MoE Dff cap sweep on MLX 0.32.1 (GB10) #712 (about 7672). The decision rule says keep.
  2. The 8192 row never measured the fused kernel. Llama 4 has its own SwitchGLU in src/models/llama4.rs that calls gather_qmm and does not read MLXCEL_FUSED_MOE or MLXCEL_FUSED_MOE_MAX_DFF. On an empty kernel cache both llama-4-scout arms compiled the same seven modules and no moe_gateup_kernel / moe_down_kernel; the lfm2 control compiled six such files in the fused arm and none in the gather arm. llama4.rs is byte-identical at the commits of the perf(cuda/moe): backend-specific default for the fused decode-MoE Dff threshold #626 sweep and the perf(moe): re-validate the CUDA fused-MoE Dff cap sweep on MLX 0.32.1 (GB10) #712 re-validation, so "break-even at 8192" there compared a path with itself. The issue adds llama-4-scout to get a point at 8192; that point cannot come from this checkpoint.
  3. The crossover is only bracketed. The fused-path models give a tie at 6400 and a clear loss at 14336 (null floor 0.2% to 0.3%). The three passes interpolate to 7148, 9239 and 10668, because the 6400 median moves inside its own null floor.
  4. The earlier lfm2 advantage does not reproduce (+12% in perf(cuda/moe): backend-specific default for the fused decode-MoE Dff threshold #626, +14.2% in perf(moe): re-validate the CUDA fused-MoE Dff cap sweep on MLX 0.32.1 (GB10) #712, +6.6% on 2026-10-22): a tie in all three bench-decode passes and all four generate cells. In the generate cell that matches the 2026-10-22 record, three of four arms reproduce within 2% and the lfm2 gather_qmm arm moved from 102.25 to 109.02 tok/s.
  5. The qwen3-30b size discrepancy is not prompt length or decode length. generate gives +23.5% to +29.9% across a 439-word / short prompt by 256 / 100 token grid, and bench-decode gives +28% to +35%. The outlier is the perf(cuda/moe): backend-specific default for the fused decode-MoE Dff threshold #626 figure (+0.4% on MLX pin e9463bb).

What changed

  • New record docs/benchmark_results/fused-moe-dff-crossover-gb10-2026-11-11.md and its rows under docs/benchmark_results/data/fused-moe-dff-crossover-gb10-2026-11-11/runs.csv (450 rows, warm-ups included and flagged).
  • scripts/bench_fused_moe_dff.py (driver: rotating arms, quiet-host wait, JIT-notice discard) and scripts/bench_fused_moe_dff_report.py (the record's tables), plus the fixed 439-word prompt under tests/fixtures/bench/.
  • src/models/switch_layers.rs: the provenance comment on FUSED_MOE_MAX_DFF_CUDA no longer says a re-validation is pending and states what 8192 does and does not rest on.
  • docs/environment-variables.md: the MLXCEL_FUSED_MOE_MAX_DFF row cites the new record.
  • docs/benchmark_results/README.md, versions/v0.3.0.md, versions/v0.8.0.md: index entry and "Related evidence / subsequent correction" lines.

Scope note: #2540 lists an addendum to fused-moe-decode-kernel-design.md and a corrected bullet in fused-moe-jit-cache-gb10-2026-10-22.md. Both files were consolidated into the release archives by #2949, and the last committed version of the 2026-10-22 record already carries the corrected wording, so this PR links the new record from the two archived sections instead.

Test plan

Run on a DGX Spark GB10 (sm_121, driver 580.178.04, CUDA 13.0), release profile.

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --features metal,accelerate -- -D warnings (not run; Linux host, and the only Rust change is a doc comment)
  • cargo test --workspace --profile test-fast --features metal,accelerate --no-fail-fast -- --test-threads=1 (not run; see the issue's command below)
  • cargo deny check (not run; no dependency change)
  • Validated with real checkpoints: mlx-community/Qwen3-30B-A3B-4bit, LFM2-8B-A1B-4bit, Phi-3.5-MoE-instruct-4bit, Llama-4-Scout-17B-16E-Instruct-4bit, Mixtral-8x7B-Instruct-v0.1-4bit, at the revisions listed in the record.
  • If the change moves the numbers: not applicable, no dispatch or kernel change.

The issue's verification commands:

cargo build --release --features cuda --bin mlxcel-bench-decode --bin mlxcel
cargo test --release --features cuda --lib switch_layers -- --test-threads=1
cargo fmt --all -- --check

All three pass on the GB10 host. switch_layers: 58 passed, 0 failed, 1 ignored, including fused_moe_max_dff_default_is_backend_aware_and_env_overrides and fused_moe_dff_above_cap_declines_and_at_cap_dispatches.

Repository gates run locally: env-var docs, benchmark raw logs, benchmark CSV schema, binary assets, cross-repo refs, license headers.

The branch was rebased onto 6289fbe6 before opening. The three commits since 28d884a5 touch only XLA code and another row of the env-var table, and the MLX pin is unchanged. The measurement, cargo fmt and the unit tests above ran on the tree at 28d884a5; the repository gates were re-run after the rebase.

Notes for reviewers

  • Host and checkpoints differ from the earlier records. This is spark-d9e2, not spark-101, and the checkpoints were downloaded from the public mlx-community repositories because /home/inureyes/models is not available to me. Only ratios are compared with earlier records, never absolute tok/s.
  • gpu-lock. This host has no upstream gpu-lock; a user-local flock(1) shim with the same CLI shape serialized every run. It is not a CI runner and nothing else used the GPU; the driver's quiet-host wait never triggered.
  • The 439-word prompt is not the original. The 2026-10-22 record never committed its prompt text, so the secondary harness uses its own fixed 439-word prompt, committed as a fixture. Three of the four comparable cells still reproduce that record within 2%.
  • Unexplained spread. The null floor is 2.8% to 19% on the three fast models and 0.2% to 0.4% on the two slow ones. Pinning to the ten faster cores did not reduce it. The cause was not found, and it is why 1792 and 6400 are ties rather than small wins or losses.
  • Not measured. A fused-path model at Dff 8192; which change sped up the lfm2 gather_qmm arm since 2026-10-22; Metal, ROCm, gemma4, qwen3_next and batched decode.
  • A possible follow-up, not in this PR. If a real point between 6400 and 14336 matters, it needs a fused-path checkpoint of that width or a synthetic expert; and Llama 4 could be moved onto the shared SwitchGLU, which would make its 8192 row meaningful.
  • Measured and written with AI assistance (Claude) driving the GB10 host. Every number comes from the committed runs.csv.

Checklist

  • PR title uses a Conventional Commits prefix (feat:, fix:, etc.)
  • One logical change per PR (split unrelated changes)
  • Updated docs/ if user-facing behavior or supported models changed
  • Updated // Used by: ... comments on any shared function I modified (see docs/code-guidelines.md) (no function modified)
  • No secrets, credentials, or .env files committed

Re-measure FUSED_MOE_MAX_DFF_CUDA on a DGX Spark GB10 at 28d884a (MLX pin
9f806b36) with interleaved fused / gather / null arms, one process per run:
384 measured runs over five checkpoints, the lablup#712 bench-decode command, two
full-window passes and a generate prompt-length by decode-length grid.

The bound stays at 8192 under the issue's decision rule. The record also
shows that the llama-4-scout row earlier sweeps read as break-even at 8192
never ran the fused kernel (Llama 4 has its own gather_qmm SwitchGLU), that
the fused path wins at Dff 768, ties at 1792 and 6400 and loses about 2% at
14336, and that the earlier lfm2 advantage does not reproduce.

Adds the record, its rows, the driver and report scripts and the prompt
fixture; replaces the stale pending-re-validation provenance comment and the
environment-variable row; links the record from the two archived sections it
corrects. The constant and its unit tests are unchanged.

Closes lablup#2540
Both carry a shebang, and tests/test_script_executable_modes.py requires an
executable Git mode for a Python entry point.
@inureyes inureyes added arch:moe Sparse mixture-of-experts decoder area:benchmark Benchmark harness and performance measurement (bench_*.sh, /update-benchmarks) platform:linux Linux (CUDA / packaging) specific priority:low Low priority status:review Under review type:performance Performance improvements labels Nov 15, 2026
The Dff benchmark recorded failed measurements but returned success after the measured loop, allowing automation to accept an incomplete sweep. Preserve every attempt and finish the remaining arms, then return a failure status if any measured arm exhausted retries.

Validated normal runs, process failures and repeated JIT-discarded runs with a focused unittest; regenerated the committed CSV summary successfully.

Refs lablup#2962, lablup#2540
@inureyes

Copy link
Copy Markdown
Member

Implementation hardening for PR #2962. Reviewed #2540 and the committed 450-row measurement record. Regenerated its tables from runs.csv; the runtime bound remains 8192 and the Llama 4 non-fused control is explicitly identified. Found and fixed a reliability gap: exhausted measured-run retries previously returned success. Commit 3521e75 preserves every attempt and returns failure after any exhausted arm. The regression test covers successful, failed and repeated-JIT measurements. New GPU throughput measurements were not performed.

Security review found no new credential, injection or untrusted execution path. Performance review found no hot-path behavior change. Hosted checks must pass on the updated head before merge.

@inureyes
inureyes merged commit e8abc02 into lablup:main Nov 15, 2026
31 checks passed
@inureyes inureyes added status:done Completed and removed status:review Under review labels Nov 15, 2026
@inureyes inureyes added this to the 0.9 milestone Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch:moe Sparse mixture-of-experts decoder area:benchmark Benchmark harness and performance measurement (bench_*.sh, /update-benchmarks) platform:linux Linux (CUDA / packaging) specific priority:low Low priority status:done Completed type:performance Performance improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(cuda): re-measure the fused-MoE Dff bound and GB10 fused-MoE defaults without the JIT compile in the window

2 participants