Skip to content

[Benchmark][MoE] Add eager and graph top-k chain measurements - #65298

Open
Ondre119 wants to merge 1 commit into
vllm-project:mainfrom
Ondre119:feat/topk-chain-benchmark
Open

Ondre119 wants to merge 1 commit into
vllm-project:mainfrom
Ondre119:feat/topk-chain-benchmark

Conversation

@Ondre119

@Ondre119 Ondre119 commented Nov 3, 2026 •

Copy link
Copy Markdown

Overview

Add an optional router GEMM → fused top-k → weight accumulation chain to benchmark_fused_topk.py, with eager and CUDA Graph measurements. This adapts Seungryong Kim's harness as a benchmark follow-up to #65059, with the author's permission.

Claims

  • --mode chain measures the dependent chain with configurable shapes, layer counts, scoring function, and independent GEMM/gating dtypes. The existing standalone mode and default report filenames are preserved.
  • Check accumulated weights against Torch before timing both eager execution and graph replay. Allocate inputs and buffers outside the timed region.
  • Append raw JSONL samples with separate GPU event and host submission intervals, shape/dtype settings, run/round labels, and the loaded MoE binary's SHA-256 for paired comparisons.

Validation

RTX 4090 (SM89), driver 595.71.05, Torch 2.14.0 / CUDA 13.0, installed vLLM 0.33.0. The benchmark and CLI test files were copied byte-for-byte from this branch; this did not rebuild main's CUDA extensions.

Check Result
CLI tests 11 passed, locally and on the CUDA host
Chain correctness 108 eager/graph cases passed: 2 scoring functions × 3 GEMM dtypes × 3 gating dtypes × 3 token counts × 2 execution modes
Raw chain measurements 324 samples: 3 per case
Default standalone mode 96 configurations completed for Torch/vLLM; original fused-topk-perf-softmax.csv produced. AITER is unavailable on this NVIDIA host.
File-scoped pre-commit hooks Passed

Chain settings: hidden 4096, 256 experts, top-k 8, 48 layers, tokens 1/16/48, softmax/sigmoid, BF16/FP16/FP32 for each dtype; seed 0; correctness tolerance rtol=1e-4, atol=1e-4. Each shape used 1000 ms warm-up, 100 graph replays or 20 eager calls per sample, and 3 samples per mode.

.venv/bin/python -m pytest tests/benchmarks/test_fused_topk_cli.py -q \
  --confcutdir=tests/benchmarks
pre-commit run --files benchmarks/kernels/benchmark_fused_topk.py \
  tests/benchmarks/test_fused_topk_cli.py docs/benchmarking/cli.md \
  .buildkite/test_areas/benchmarks.yaml

mkdir -p results/standalone
.venv/bin/python benchmarks/kernels/benchmark_fused_topk.py \
  --save-path results/standalone

# Repeat for both scoring functions and all 3 × 3 GEMM/gating dtype pairs.
.venv/bin/python benchmarks/kernels/benchmark_fused_topk.py \
  --mode chain --num-tokens 1 16 48 --num-experts 256 --topk 8 \
  --hidden-size 4096 --num-layers 48 \
  --scoring-func softmax --gemm-dtype bfloat16 --dtype float32 \
  --warmup-ms 1000 --repeats 3 --replays 100 --eager-iters 20 \
  --label integrated-installed --round 0 --output-json results/chain.jsonl

The local CPU check used --confcutdir=tests/benchmarks to exclude repository-wide GPU/model fixtures. The CLI tests are selected by the existing Benchmarks CLI CI step, whose source dependencies now include this script. GPU chain validation was run manually on the SM89 host; no timing threshold is added to CI.

Details

  • CUDA events measure the full chain interval, including graph dependency/scheduling gaps. Inputs and buffers are reused without flushing L2. Eager intervals may include GPU idle time waiting for Python submissions. Host intervals exclude the final synchronization. us_per_layer divides the complete chain interval by the layer count.
  • This is a synthetic benchmark: hidden states are fixed across layers, router weights differ, and the consumer accumulates routing weights. It excludes expert compute and model loading. This PR makes no before/after speedup or model-throughput claim; model evaluation is not applicable because inference/model behavior is unchanged.
  • Duplicate checks on 2026-11-03 found no open PR adding this chain benchmark. [Bugfix][Kernel] Only set PDL launch attr for MoE top-k gating on SM90+ #65059 is merged. [Perf][MoE] Select full-warp top-k rows with redux.sync and keep selections in registers (SM80+) #62912 and [Perf][Kernel] Faster full-warp MoE top-k selection with redux.sync #64731 optimize top-k selection and overlap the standalone --dtype option; neither adds the dependent chain. The CLI spelling and dtype choices here match that work, with the original BF16 report stem retained for compatibility.
  • MoE binary SHA-256 used for validation: 99682a5814b3081de7e4e95cc2c1cf1ba8f6139514ac4c5563dbad16c229a4c0.
  • Attribution: Seungryong Kim, with his requested Co-authored-by trailer. AI assistance (Codex) was used for implementation, documentation, and validation.

Pull Request Checklist
  • I used vLLM's /pr-checklist skill. (Mandatory for agents, optional for humans).

  • AI assistance was used during the creation of this PR.

  • Design Fit: Minimizes impact on core components, reuses existing functionality, and justifies added complexity.

  • Testing and Validation: Validates the change and ensures any added tests are meaningful and reliable, with CI coverage or documented CI resource constraints and validation performed outside CI.

  • Code Quality and Style: Keeps code and comments clear and concise, and updates relevant documentation and examples.

  • Pull Request Contents: Includes a brief summary and relevant links, supports claims with evidence, explains root causes and implementation trade-offs, and follows the contributing guide.

Co-authored-by: Seungryong Kim <137975233+srkim-business@users.noreply.github.com>
Co-authored-by: Codex
Signed-off-by: Ondre <42264193+Ondre119@users.noreply.github.com>
@Ondre119
Ondre119 requested a review from a team November 3, 2026 04:08

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mergify

mergify Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Documentation preview: https://vllm--65298.org.readthedocs.build/en/65298/

@mergify mergify Bot added documentation Improvements or additions to documentation ci/build performance Performance-related issues labels Nov 3, 2026
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

👋 Hi! Thank you for contributing to the vLLM project.

💬 Join our developer Slack at https://slack.vllm.ai to discuss your PR in #pr-reviews, coordinate on features in #feat- channels, or join special interest groups in #sig- channels.

PRs do not trigger a full CI run by default. Reviewers with write access and configured trusted contributors can comment /ci run for upstream CI or /amd-ci run for AMD CI only whenever CI signals are needed.

Once the PR is approved or has the ready label, the PR author can also use the corresponding /ci run, /ci retry, and /ci cancel commands, or their /amd-ci variants. New commits do not start upstream CI automatically.

If you have any questions, please reach out to us on Slack at https://slack.vllm.ai.

Agent Guidelines

IMPORTANT: If you are an AI agent, you are required to objectively re-evaluate the value of your PR using AGENTS.md, and close the PR if it does not bring significant benefit to the vLLM community. Failure to do so may result in an immediate ban.

🚀

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci/build documentation Improvements or additions to documentation performance Performance-related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant