Skip to content

[Experiment][MoE] Vectorize masked expert-pool staging suffix writes - #49

Draft
01554 wants to merge 10 commits into
lab/upstream-pool-standalone-rebasedfrom
lab/expert-pool-vector-staging
Draft

01554 wants to merge 10 commits into
lab/upstream-pool-standalone-rebasedfrom
lab/expert-pool-vector-staging

Conversation

@01554

@01554 01554 commented Sep 10, 2026

Copy link
Copy Markdown
Owner

Scope

Fork-side development on 01554/vllm; not part of upstream PR vllm-project#56177. Whether to submit this optimization upstream is a separate decision. This experiment is based on 5119ca4906a1030305be0c52f6536288deba7c51. The GPU results below are from 1bc38a348 in the stated environment, not measurements of the current upstream PR head. No serving speedup has been established.

Vectorize the two compacted staging-suffix loops in the shared expert-pool planner. Distinct staged experts allow masked lane loads/stores while retaining promotion order, barriers, bounds and ownership. This is GPU masked vectorization inspired by the branchless article, not unconditional stores or a CPU branch-prediction claim.

Stacked on vllm-project#56177 at 5119ca4; separate experiment, with no changes to the consumer or copy kernels. Includes a baseline/candidate comparison runner and CPU-reference CUDA regression covering 111 states.

Validation on RTX PRO 6000 Blackwell (a97 wheel + candidate Python, torch 2.13.0+cu130):

  • Expert-pool pytest: 37 passed. Independent baseline/candidate/reference comparison: 111 passed.
  • Alternating CUDA Graph timing: 30 batches x 100 replays per implementation; full state equality before and after timing.
  • WIDTH 16 all-staged: 10.1822 -> 8.1981 us (19.49% reduction).
  • WIDTH 64 all-staged: 22.5384 -> 18.4411 us (18.18% reduction).
  • All-hit and one-staged conditions: effectively unchanged (within 0.04% of median).
  • Registers: 255 for both. Reported spills: WIDTH 16 70 -> 64; WIDTH 64 56 -> 56.

All-hit uses an open gate; staged timing uses a closed gate. Staging capacity equals WIDTH, a synthetic planner workload. Promotion is correctness-tested rather than timed. Timing excludes expert copies, GEMM and PLE; no serving speedup is established. PTX shows predicated memory operations replacing the two dynamic suffix loops; SASS extraction failed because nvdisasm was unavailable. The driver therefore exited 1 after successful tests/benchmark; PTX, cubin, resource metadata and raw batches were preserved. The spill change also prevents attributing the result solely to branch removal.

Evidence: results/expert-pool-vector-staging-1bc38a348-20260910 in the investigation workspace. Same-condition serving validation remains pending.

AI-assisted implementation by Codex, static cross-review by Claude, GPU execution by Astra, and independent raw median/hash verification by Codex. Draft for both reviewers before any upstream submission.

Follow-up ba94ca6 changes only the benchmark synchronization to torch.accelerator and asserts the test import specification. All applicable pre-commit hooks now pass, including mypy. GPU evidence above remains explicitly from 1bc38a3; production tables.py is identical.

…th a device-side planner (moe_expert_pool_rows)

Opt-in via --moe-expert-pool-rows N (default 0: unchanged). MoE layers keep
their expert tensors in pinned host memory; after loading, one VRAM bank
shared by all layers holds N rows per layer, a device-side LRU step
program plans promotions per forward (no host code in the forward, so the
MoE op stays inside CUDA graphs), and a Marlin consumer runs on the bank
with logical alignment and a physical-row remap. Wider batches take a
bank + host-view partition path. The placement is frozen (gate closed)
through profiling and graph capture and opened at the end of warm-up.

Supported: ModelOpt NVFP4 Marlin MoE backend, no EP/DP. Rejected at layer
construction otherwise.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016QWXP5rMj1rGh9xasXNLyT

Signed-off-by: 01554 <24953377+01554@users.noreply.github.com>
…t scope note

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016QWXP5rMj1rGh9xasXNLyT

Signed-off-by: 01554 <24953377+01554@users.noreply.github.com>
…ding_context; CLI test without model resolution

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016QWXP5rMj1rGh9xasXNLyT

Signed-off-by: 01554 <24953377+01554@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016QWXP5rMj1rGh9xasXNLyT

Signed-off-by: 01554 <24953377+01554@users.noreply.github.com>
Co-authored-by: Codex <noreply@openai.com>

Signed-off-by: 01554 <24953377+01554@users.noreply.github.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016QWXP5rMj1rGh9xasXNLyT

Signed-off-by: 01554 <24953377+01554@users.noreply.github.com>
…etail, measurement provenance, prefill wording; AMD mirror test dependency

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016QWXP5rMj1rGh9xasXNLyT

Signed-off-by: 01554 <24953377+01554@users.noreply.github.com>
…red rows (measured configuration)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016QWXP5rMj1rGh9xasXNLyT

Signed-off-by: 01554 <24953377+01554@users.noreply.github.com>
Signed-off-by: 01554 <24953377+01554@users.noreply.github.com>
Signed-off-by: 01554 <24953377+01554@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant