Repository navigation
[Performance][MoE] Produce cumulative boundaries for A2 INT8 routing - #23258
Thymos2027 wants to merge 4 commits into
Conversation
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>
|
👋 Hi! Thank you for contributing to the vLLM Ascend project. The following points will speed up your PR merge:
If CI fails, you can run linting and testing checks locally according Contributing and Testing. 🤖 How to trigger CI
Note Until the CI gate has run on a commit, the required |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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).
| 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 |
| 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() | ||
| ), |
There was a problem hiding this comment.
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.
| 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() | |
| ), |
|
Last updated: 2026-11-26 08:14 UTC+8 for commit ci-gate failed. Reason:
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>
|
/run |
Coverage
More info see: Summary |
zhenwenqi2024
left a comment
There was a problem hiding this comment.
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>
|
/run [Bot]: run command accepted. E2E has been queued on the latest commit |
|
@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 |
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_typeto 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 on8679c7665fe150f7b191bdc1179e3ed53ee774f2. 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
c410543d9ffff03f5f6c4a8c0ae1d3ad082c4a15. Targets:test_cumulative_int8_routing.py,test_hardware_profile.py, andtest_fused_moe.py.bash format.sh cipassed 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.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.
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
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.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
f35fc80a797414987ca567eae03db80d15dddfe1addresses 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-defssettings 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
Before merge: CODEOWNERS approval and a maintainer's
ready-preciselabel 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.