Skip to content

[Performance][MoE] Produce cumulative boundaries for A2 INT8 routing - #23258

Open
Thymos2027 wants to merge 4 commits into
vllm-project:mainfrom
Thymos2027:perf/int8-cumulative-routing-pr
Open

Thymos2027 wants to merge 4 commits into
vllm-project:mainfrom
Thymos2027:perf/int8-cumulative-routing-pr

Conversation

@Thymos2027

@Thymos2027 Thymos2027 commented Nov 25, 2026 •

Copy link
Copy Markdown

What this PR does / why we need it?

Local AllGather routing produces per-expert counts, while fused dynamic INT8 SwiGLU GMM1 needs cumulative boundaries. For eligible A2 W8A8/SILU fused consumers, request cumulative output directly from routing and propagate the matching group_list_type to the MLP. This removes a redundant count-to-prefix conversion without changing expert assignments or introducing a new kernel.

The optimization requires an A2 hardware capability, an EP process-group size of one, no expert map or redundant experts, no dynamic EPLB, and no active LoRA. Other contracts retain counts; the new internal preference defaults to false. In the tested stack, TP2 creates an EP process group of size two even with expert sharding disabled, so this PR intentionally retains its original path.

Related work: #21465 applies the same representation idea to A5 MXFP8; this PR covers the A2 dynamic INT8 consumer contract. #19762 targets an independently retained count-to-prefix conversion. No general mechanism novelty is claimed.

Does this PR introduce any user-facing change?

Eligible local A2 INT8 MoE inference has lower routing/decode overhead without a configuration change. The measured benefit below is for TP1. There is no claimed TP2 speedup. Includes release_notes/fragments/23258.yaml; no new public option, environment variable, checkpoint format, or MC2/All2All change.

How was this patch tested?

Implementation: a780f835507bc5a86d70e75195c22d3a935b5e29, based on 8679c7665fe150f7b191bdc1179e3ed53ee774f2. Current PR head: f35fc80a797414987ca567eae03db80d15dddfe1; follow-up commits add the release note, correct nightly-test typing, and reuse test weights via a shape-scoped fixture. Production implementation is unchanged.

Source checks and CPU CI

  • Affected standard UTs: 226 passed, zero skipped, using the repository conftest and pinned vLLM c410543d9ffff03f5f6c4a8c0ae1d3ad082c4a15. Targets: test_cumulative_int8_routing.py, test_hardware_profile.py, and test_fused_moe.py.
  • Existing dispatcher/MLP regressions: 64 passed, 11 existing skips from their register-kernels/CANN skip marker.
  • bash format.sh ci passed for the original candidate. The current head's full upstream pre-commit job, including mypy for Python 3.10/3.11/3.12, passed. Upstream CPU UTs passed with 23039 passed/131 skipped on the pinned vLLM commit and 23034 passed/136 skipped on v0.34.0. CI run 45608951261.
  • Tests cover enum/string SILU consumers, disabled fusion, other activations/quantization, dynamic EPLB, expert mapping, EP size, redundancy, LoRA, and A3/A5/310P capability fallbacks. A negative control using the original dispatcher fails the eligible-format assertion. A prefix-identity test rejects an unnecessary cumsum.

Hardware measurements — frozen stack

Qwen3.6-35B-A3B W8A8, Ascend 910B4-1, one card for TP1 and two cards for TP2, colocated prefill/decode, concurrency 1, actual input 134 tokens, fixed output 512 tokens, greedy generation with EOS ignored for timing. Each TP ran baseline-a → candidate-a → candidate-b → baseline-b, with three warmups and ten measured requests per deployment; 80 measured and 24 warmup requests total. The timing deployments had no profiler or contract observer and used the same workload and thermal gates.

TP / pair Baseline request TPOT p50 (ms) PR request TPOT p50 (ms) Reduction
TP1 / a 14.10245 13.17176 6.60%
TP1 / b 14.52581 13.15684 9.42%
TP2 / a 16.60325 16.42070 1.10%
TP2 / b 16.30884 16.42147 -0.69%

TP1 improved in both paired comparisons. TP2 did not meet the original 2% performance threshold; its negative result is retained. Its optimization branch was excluded by the EP-size guard, so these TP2 ratios are not evidence of a speedup. All measured/warmup responses matched in full within each TP configuration. Two short paired windows do not establish long-term or broad-workload performance.

The NPU environment is an existing ARM64 vLLM/vLLM Ascend v0.30.0, CANN 9.2.1, torch 2.10.0+cpu / torch_npu 2.10.0.post7 image, HDK 26.2.rc1. The dispatcher/consumer patch applies unchanged; the hardware capability registration is ported to the older registry layout. This is separate from current-main full-stack NPU CI.

Numerical, integration and branch coverage

  • 93 real NPU local-chain cases passed, zero skipped: 90 numerical cases plus three graph input-update cases, checking eight intermediate/final stages with rtol=atol=0. Includes single-row, uneven row counts, empty-expert/skewed routing, and fused/prequantized inputs. The frozen-stack runner isolates the incompatible global conftest; this is not a run of the full standard nightly suite. The PR adds the nightly numerical regression test.
  • Nine local-chain shapes, seven alternating rounds and 64 warmed graph replays per NPU Event sample: 63/63 timing pairs improved; E256/H2048 complete-chain reductions were 4.58%–22.38%. Isolated M1 GMM2 timings regressed 5.89%/8.05%; these component regressions remain in the analysis. Component medians are not an additive explanation of model latency.
  • Earlier baseline/candidate functional serving checks passed three graph gates per deployment and twelve normal-EOS prompts with matching same-TP responses. This limited prompt set is not a broad accuracy evaluation.
  • Four separate diagnostic deployments passed 12 graph gates, 84 warmup and 84 measured gate requests, plus four fixed-length diagnostic requests with matching same-TP responses. Six rank logs contain 240 real layer records: every rank covers all 40 routed layers, sharing one dispatcher. TP1 candidate uses cumulative format 0 with EP size 1; both TP2 candidate ranks retain count format 1 with EP size 2 and consumer preference true.
  • Branch observations describe non-compiling model warmup/capture forwards, not Python callbacks during graph replay or a new device-kernel trace. The original diagnostic run failed due to counting shared dispatcher identities as layers; its failed outcome remains unchanged. Only the corrected four diagnostic deployments were rerun, reusing the completed performance evidence.
  • Current artifacts, frozen sources and downloaded files passed 348/84/238 SHA checks; 572 predecessor entries passed before/after and 9066 older entries passed afterward. All six recovery containers exited normally with no OOM/new EDAC counts, and the original service state was preserved.

Current-main full-stack NPU CI, broader model quality, and untested hardware/topologies remain pending or outside the measured scope. Original GMM timing attribution is not fully resolved. No distributed correctness claim is derived from the synthetic single-rank local-chain tests.

Maintainer review follow-up — shape-scoped test weights

Commit f35fc80a797414987ca567eae03db80d15dddfe1 addresses the shape-scoped weight-fixture request. A module-scoped fixture parametrized by the three shapes generates, uploads and NZ-casts the seeded read-only weights once per shape. The same 90 eager cases and three separate graph-input-update regressions remain; inputs, mutable buffers, local contexts and graph objects are still created inside each test. Only this nightly test file changed.

Validation: all applicable pre-commit hooks passed for the changed file; mypy passed with the repository's --follow-imports skip --check-untyped-defs settings for Python 3.10/3.11/3.12. An isolated pytest lifecycle audit (allocation spies, not NPU kernels) confirmed all 93 cases and exactly three weight factories; AST comparisons confirmed unchanged numerical helpers, input generation, graph capture/update and assertions. The previous hardware numerical/model measurements remain separate evidence; this fixture-only follow-up has not rerun real NPU execution. A fresh CI run is being requested for the new head; the green CI results above refer to the preceding head.

Checklist

  • Boundary/edge coverage: single-row and uneven sizes, empty-expert routing, and eligibility boundaries.
  • Regression coverage: original-dispatcher negative control, producer/consumer format agreement, and real NPU chain numerical tests.
  • Fallback coverage: unsupported consumers/hardware, EP groups, expert maps, redundancy, dynamic EPLB and LoRA.
  • Meaningful tests: assertions exercise production behavior; CPU mocks and real NPU execution are reported separately.
  • Performance evidence: paired model benchmarks and representation invariants; no portable CI timing threshold is claimed.

Before merge: CODEOWNERS approval and a maintainer's ready-precise label to run the required NPU tests. The existing final CI gate is red for these missing requirements; pre-commit and both CPU-UT variants passed.

Avoid a separate count-to-prefix conversion before fused INT8 SwiGLU GMM1.

- Opt eligible W8A8/SILU consumers into the A2 cumulative routing contract.
- Preserve counts for other quantization, mapping, EPLB, EP and LoRA paths.
- Cover producer-consumer fallbacks and exact local MoE chains in tests.

Signed-off-by: Thymos2027 <187644295+Thymos2027@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:‌‌

  • A PR should do only one thing, smaller PRs enable faster reviews.
  • Every PR should include unit tests and end-to-end tests ‌to ensure it works and is not broken by other future PRs.
  • Write the commit message by fulfilling the PR description to help reviewer and future developers understand.

If CI fails, you can run linting and testing checks locally according Contributing and Testing.

🤖 How to trigger CI

CI runs automatically when the PR is opened or reopened. Pushing a new commit no longer re-runs the E2E CI (to save NPU runner resources), so use the comment commands below when needed. They are available to the PR author and users with triage permission or above:

  • /run — run the full PR CI gate on the latest commit.
  • /rerun — re-run the failed CI jobs (e.g. after a flaky failure).
  • /e2e — run selected E2E tests instead of the full gate.
  • /nightly / /presmoke / /weekly — run the corresponding large-scale tests (triage permission or above; blocked during the nightly maintenance window).
  • /cancel — cancel a running CI on this PR.

Note

Until the CI gate has run on a commit, the required ci-gate check stays pending and the PR cannot merge — remember to comment /run after pushing.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for cumulative INT8 routing on compatible Ascend hardware by adding the MOE_INT8_CUMULATIVE_GROUP_LIST capability. It updates the token dispatch input to determine consumer preference for cumulative group lists and adjusts the token dispatcher to utilize cumulative boundaries when appropriate. Unit tests have also been added to verify this behavior. The review feedback suggests avoiding direct dependencies on vLLM internals by refactoring the activation type checks to use getattr instead of importing MoEActivation directly.

Comment on lines +25 to +30
from vllm.model_executor.layers.fused_moe.activation import MoEActivation

from vllm_ascend.ops.fused_moe.dataclass.moe_quant import MoEQuantParams
from vllm_ascend.ops.fused_moe.dataclass.router_input import MoeRouterInput
from vllm_ascend.ops.fused_moe.moe_utils import enable_fusion_gmmswigluquant
from vllm_ascend.quantization.quant_type import QuantType

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

To reduce direct dependencies on vllm internals and improve maintainability, we can avoid importing MoEActivation by using getattr(..., "value", ...) to extract the activation string name. This aligns with the pattern used elsewhere in the codebase (e.g., in moe_utils.py).

Suggested change
from vllm.model_executor.layers.fused_moe.activation import MoEActivation
from vllm_ascend.ops.fused_moe.dataclass.moe_quant import MoEQuantParams
from vllm_ascend.ops.fused_moe.dataclass.router_input import MoeRouterInput
from vllm_ascend.ops.fused_moe.moe_utils import enable_fusion_gmmswigluquant
from vllm_ascend.quantization.quant_type import QuantType
from vllm_ascend.ops.fused_moe.dataclass.moe_quant import MoEQuantParams
from vllm_ascend.ops.fused_moe.dataclass.router_input import MoeRouterInput
from vllm_ascend.ops.fused_moe.moe_utils import enable_fusion_gmmswigluquant
from vllm_ascend.quantization.quant_type import QuantType

Comment on lines +102 to +107
prefer_cumulative_group_list=(
fused_experts_input.quant.quant_type == QuantType.W8A8
and fused_experts_input.activation in (MoEActivation.SILU, "silu")
and not fused_experts_input.dynamic_eplb
and enable_fusion_gmmswigluquant()
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

Using getattr(..., "value", ...) is more robust and consistent with how activation names are extracted and checked in other parts of the codebase (e.g., in moe_utils.py). This also allows us to remove the dependency on MoEActivation from vllm.

Suggested change
prefer_cumulative_group_list=(
fused_experts_input.quant.quant_type == QuantType.W8A8
and fused_experts_input.activation in (MoEActivation.SILU, "silu")
and not fused_experts_input.dynamic_eplb
and enable_fusion_gmmswigluquant()
),
prefer_cumulative_group_list=(
fused_experts_input.quant.quant_type == QuantType.W8A8
and getattr(fused_experts_input.activation, "value", fused_experts_input.activation) == "silu"
and not fused_experts_input.dynamic_eplb
and enable_fusion_gmmswigluquant()
),

@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Last updated: 2026-11-26 08:14 UTC+8 for commit f35fc80.

ci-gate failed. Reason:

CODEOWNERS approval gate failed: at least one changed file has no approval from its owner(s). Open the 'CODEOWNERS' steps above to see which files are missing approvals and who can approve.
This PR touches source code (src=true, ci_pipeline=false), so precision/full tests are required before merge. Fix: a maintainer adds the 'ready-precise' label; the workflow reruns automatically once the label is added.

See the workflow run for full logs. This comment is updated in place on each new failure and marked as passed once the gate passes (it is kept for history, not deleted).

Missing owner approvals. Every changed file needs one approval from its CODEOWNERS owner(s):

Signed-off-by: Thymos2027 <187644295+Thymos2027@users.noreply.github.com>
Annotate tensor snapshots and bind routing inputs explicitly so all supported mypy Python targets accept the numerical test. Preserve the chain operations, routing matrix and assertions.

Signed-off-by: Thymos2027 <187644295+Thymos2027@users.noreply.github.com>

Thymos2027 commented Nov 25, 2026 •

Copy link
Copy Markdown
Author

/run
[Bot]: run command accepted. E2E has been queued on the latest commit 6256b66b27a6b53a0f01b578d4f9ccc0e2f5e111 of this PR, with whatever test-scope labels the PR currently carries. Track progress in PR checks.

@vllm-ascend-ci vllm-ascend-ci added the ci-run E2E requested manually on the latest commit label Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Coverage

Total Coverage Diff Coverage
Total 158754 lines 19 lines
Missing 45209 lines 0 lines
Coverage 72% 100%

More info see: Summary

@zhenwenqi2024 zhenwenqi2024 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could test_exact_complete_int8_chain reuse a shape-scoped weight fixture? make_layer() builds the same seeded weights for all 30 (rows, pattern, prequantized) cases per shape. The largest shape generates and uploads 768 MiB of raw INT8 weights, then casts both tensors to NZ, on every case. The GMM calls only read those weights. A module-scoped fixture parametrized by shape would keep the same eager matrix and separate graph-replay regression, while generating and casting the weights once per shape. Keep the inputs and graph state per test.

Build seeded NZ-format weights once per module-scoped shape fixture.
Reuse them across the 90 eager cases and three graph regressions while
keeping input tensors and graph state local to each test.

Signed-off-by: Thymos2027 <187644295+Thymos2027@users.noreply.github.com>
@Thymos2027

Thymos2027 commented Nov 26, 2026 •

Copy link
Copy Markdown
Author

/run

[Bot]: run command accepted. E2E has been queued on the latest commit f35fc80a797414987ca567eae03db80d15dddfe1 of this PR, with whatever test-scope labels the PR currently carries. Track progress in PR checks.

@vllm-ascend-ci vllm-ascend-ci added ci-run E2E requested manually on the latest commit and removed ci-run E2E requested manually on the latest commit labels Nov 26, 2026
@Thymos2027

Copy link
Copy Markdown
Author

@zhenwenqi2024 Addressed in f35fc80.

Added a module-scoped fixture parametrized by shape, so seeded weight generation, upload and NZ conversion run once per shape. The 90 eager cases and three separate graph-replay regressions remain; inputs, mutable buffers and graph state stay local to each test.

Validation: changed-file pre-commit and mypy for Python 3.10/3.11/3.12 passed. An isolated pytest lifecycle audit confirmed three weight-factory calls across all 93 cases; numerical and graph code is unchanged. This follow-up did not rerun real NPU execution locally.

The latest CI run passed pre-commit and both CPU-UT variants. The final gate still needs CODEOWNERS approval and the ready-precise label to run NPU tests. Could you please take another look and enable the NPU checks when appropriate?

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-run E2E requested manually on the latest commit module:ops module:tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants