Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
29758d1
Upgrade the GPU backend target from vLLM `v0.26.0` to `v0.30.0` (#402)
yujuancao07 Sep 28, 2026
259e838
fix(npu): backport CANN 9.1 operator build fix to v0.30.0 (#405)
jiangkuaixue123 Sep 28, 2026
043a039
feat(npu): adapt AFD to vLLM 0.30.0 and Ascend MRV1 (#407)
jiangkuaixue123 Sep 29, 2026
4f74787
refactor(npu): remove AFD W8A8 force-balance patch (#411)
jiangkuaixue123 Sep 29, 2026
651e87a
fix(npu): align ModelRunner V2 with vLLM 0.30 interfaces (#413)
lirx-pd Sep 30, 2026
3352e75
fix(npu): correct routing, workspace lifetime and DP stage coordinati…
jiaran-king Sep 30, 2026
85aaf25
fix(npu): align gate precision and MoE activation, reuse routers per …
lirx-pd Sep 30, 2026
4c98691
feat(gpu): support MRV2 DBO with FULL CUDA Graph (#424)
jiaran-king Oct 8, 2026
4e5905b
Merge vLLM 0.30.0 upgrade into current main
jiaran-king Oct 8, 2026
2a6d8b8
test: align isolated runtime checks with upgrade dependencies
jiaran-king Oct 8, 2026
3ee2e81
fix: resolve upgrade type-check failures without new runtime guards
jiaran-king Oct 8, 2026
1de1a99
docs: align v0.30 integration status and CI metadata
jiaran-king Oct 8, 2026
e63d004
docs: correct the integrated Ascend source pin
jiaran-king Oct 8, 2026
babcbd1
fix(npu): align CAMP counts and release submitted workspaces
jiaran-king Oct 8, 2026
2145e82
fix(npu): synchronize layered W4A8 SwiGLU write-back
jiaran-king Oct 8, 2026
87e53ac
docs: keep NPU acceptance records in PR discussion
jiaran-king Oct 8, 2026
563164a
fix(npu): pad live Legacy DBO CAMP stages at runtime
jiaran-king Oct 8, 2026
df0a57c
Merge latest main and finalize v0.30 integration
jiaran-king Oct 8, 2026
6941faf
fix(npu): align DSV2 shared experts with SP token layout
jiaran-king Oct 9, 2026
c900c87
refactor: separate deferred NPU fixes from v0.30 integration
jiaran-king Oct 9, 2026
1778228
fix(ci): build the v0.30 integration on the matching vLLM image
jiaran-king Oct 9, 2026
3d30d17
fix(ci): allow upstream NCCL dependency override
jiaran-king Oct 9, 2026
04ac606
fix(gpu): order DBO FFN transfers on the communication stream
jiaran-king Oct 9, 2026
a06d850
test(gpu): restore MRV2 chunked-prefill defaults
jiaran-king Oct 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .buildkite/cuda/test-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ steps:
"tests/e2e/models/deepseek_v2_lite/test_deepseek_v2_lite.py::test_deepseek_v2_lite[afd-v2-eager-tp2]"
"tests/e2e/models/deepseek_v2_lite/test_deepseek_v2_lite.py::test_deepseek_v2_lite[afd-v2-graph-dp2]"
"tests/e2e/models/deepseek_v2_lite/test_deepseek_v2_lite.py::test_deepseek_v2_lite[afd-v2-graph-tp2]"
"tests/e2e/models/deepseek_v2_lite/test_deepseek_v2_lite.py::test_deepseek_v2_lite[afd-v2-eager-dbo-dp2]"
"tests/e2e/models/deepseek_v2_lite/test_deepseek_v2_lite.py::test_deepseek_v2_lite[afd-v2-graph-dbo-dp2]"
mirror_hardwares: l4_4
2 changes: 2 additions & 0 deletions .buildkite/cuda/test-ready.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ steps:
"tests/e2e/models/deepseek_v2_lite/test_deepseek_v2_lite.py::test_deepseek_v2_lite[afd-v2-eager-tp2]"
"tests/e2e/models/deepseek_v2_lite/test_deepseek_v2_lite.py::test_deepseek_v2_lite[afd-v2-graph-dp2]"
"tests/e2e/models/deepseek_v2_lite/test_deepseek_v2_lite.py::test_deepseek_v2_lite[afd-v2-graph-tp2]"
"tests/e2e/models/deepseek_v2_lite/test_deepseek_v2_lite.py::test_deepseek_v2_lite[afd-v2-eager-dbo-dp2]"
"tests/e2e/models/deepseek_v2_lite/test_deepseek_v2_lite.py::test_deepseek_v2_lite[afd-v2-graph-dbo-dp2]"
mirror_hardwares: l4_4
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/100-bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ body:
attributes:
value: >
Before submitting, please search existing issues to avoid duplicates.
afd-plugin targets vLLM v0.26.0 unless an issue explicitly says otherwise.
afd-plugin targets vLLM v0.30.0 unless an issue explicitly says otherwise.

- type: markdown
attributes:
Expand Down Expand Up @@ -76,5 +76,5 @@ body:
options:
- label: I searched existing issues for related reports.
required: true
- label: I confirmed whether this reproduces against vLLM v0.26.0 or explained why not.
- label: I confirmed whether this reproduces against vLLM v0.30.0 or explained why not.
required: true
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/200-feature-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ body:
attributes:
value: >
Before submitting, please search existing issues and RFCs. Keep proposals
tied to vLLM v0.26.0 compatibility unless the issue explicitly proposes a
tied to vLLM v0.30.0 compatibility unless the issue explicitly proposes a
version expansion.

- type: textarea
Expand All @@ -31,7 +31,7 @@ body:
id: compatibility
attributes:
label: vLLM compatibility and extension points
description: Explain how this should work without modifying the vLLM v0.26.0 source tree.
description: Explain how this should work without modifying the vLLM v0.30.0 source tree.
placeholder: |
Preferred extension point:
Compat shim needed:
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ or any behavior that intentionally differs from the original AFD commit.

- [ ] Purpose is clear and linked to public context when possible.
- [ ] Scope is bounded.
- [ ] Compatibility with vLLM v0.26.0 is considered.
- [ ] Compatibility with vLLM v0.30.0 is considered.
- [ ] No changes are made to the vLLM source checkout.
- [ ] Plugin-owned classes or explicit dotted class paths are preferred over monkey patches.
- [ ] Any compat shim or monkey patch is isolated, idempotent, version-guarded, documented, and tested.
Expand Down
67 changes: 47 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ tests for GPU and Ascend NPU deployments.
> This project is still experimental and needs more large-scale testing across
> different hardware backends.

The target runtime is **vLLM `v0.26.0`**. The plugin does not modify the vLLM
The target runtime is **vLLM `v0.30.0`** at commit `ced6857a`; the Ascend
integration targets vLLM-Ascend `8d4409d6`. The plugin does not modify the vLLM
source tree. AFD behavior is installed through the `vllm.general_plugins` entry
point, `--additional-config`, automatically selected role workers, plugin-owned
model wrappers, and narrow version-scoped compatibility shims.
Expand All @@ -36,7 +37,8 @@ Core runtime support:
execution for CUDA and Ascend NPU.
- Eager and `FULL_DECODE_ONLY` graph execution, plus backend-specific profiling
support.
- Native DBO with exactly two ubatches on CUDA and the synchronous Ascend path.
- Native DBO with exactly two ubatches on CUDA V1/V2 and the synchronous
Ascend V1 path; Ascend V2 DBO remains unsupported.
- DeepSeek MoE handoff at the remote-experts boundary on CUDA, with the gate
placed on either Attention or FFN.

Expand All @@ -46,7 +48,7 @@ Model support:
| --- | --- | --- | --- |
| DeepSeekV2 / DeepSeekV3 / DeepSeekV3.2 | `DeepseekForCausalLM`, `DeepseekV2ForCausalLM`, `DeepseekV3ForCausalLM`, `DeepseekV32ForCausalLM` | `AFDDeepseekForCausalLM`, `AFDDeepseekV2ForCausalLM`, `AFDDeepseekV3ForCausalLM` | DeepSeekV3.2 uses `AFDDeepseekV3ForCausalLM`. Each AFD role constructs and loads only its role-required model components, while shared embedding, normalization, and output components remain available where required by the model lifecycle. |
| Qwen3 MoE | `Qwen3MoeForCausalLM` | `AFDQwen3MoeForCausalLM` | CUDA with `compute_gate_on_attention=false`. |
| Qwen3.5 / Qwen3.6 MoE | `Qwen3_5MoeForConditionalGeneration` | `AFDQwen3_5MoeForConditionalGeneration` | Qwen3.5/Qwen3.6 adapter family. Repository CUDA E2E evidence currently covers text-only Qwen3.6-35B-A3B with `--language-model-only`, synchronous `P2pNcclAFDConnector`, native DP4/TP1/EP4 baseline, and AFD 2A1F eager/graph/graph+DBO. |
| Qwen3.5 / Qwen3.6 MoE | `Qwen3_5MoeForConditionalGeneration` | `AFDQwen3_5MoeForConditionalGeneration` | CUDA text-only Qwen3.6-35B-A3B with `--language-model-only`, native DP4/TP1/EP4, and synchronous AFD 2A1F eager/graph. DBO remains excluded by a known FFN CUDA fault; see the [E2E limits](docs/design/module/e2e_testing.md). |

Connector support:

Expand All @@ -55,17 +57,32 @@ See the [recipe index](recipe/README.md) for deployment and benchmark examples.
| Connector | Platform | Recommend Stage | Sync or Async | Graph Support | Notes |
| --- | --- | --- | --- | --- | --- |
| `P2pNcclAFDConnector` | CUDA | Decode | Sync | `FULL_DECODE_ONLY` CUDA graph | FFN ranks are ordered before Attention ranks. `num_attention_ranks` must be greater than or equal to `num_ffn_ranks`; the Attention ranks are spread over the FFN ranks in blocks that differ in size by at most one. See the [DeepSeek V2 Lite recipe](recipe/gpu/P2pNcclAFDConnector/deepseek_v2_lite/README.md). |
| `CAMP2pAFDConnector` | Ascend NPU | Decode | Sync | `FULL_DECODE_ONLY` ACL graph | Uses HCCL/CAMP2P custom ops. Ascend ops build by default on NPU platforms. See the [synchronous DeepSeek V3.2 recipe](recipe/npu/CAMP2pAFDConnector/deepseek_v3_2/README.md). |
| `CAMAsyncAFDConnector` | Ascend NPU | Prefill / decode | Async | Not supported | Experimental v0.26 DP+TP/SP path with AFD-managed two-stage MoE ubatching; native DBO and PCP are unsupported. Post-fix DeepSeek-V3.2 DP2TP8+EP16 token split reached `0.9522` strict match on the complete GSM8K evaluation. The [legacy PCP8 recipe](recipe/npu/CAMAsyncAFDConnector/deepseek_v3_2/README.md) requires `release/v0.19.1rc1`. |
| `CAMP2pAFDConnector` | Ascend NPU | Decode | Sync | V1 `FULL_DECODE_ONLY`; V2 also `FULL` | Uses HCCL/CAMP2P custom ops. Ascend ops build by default on NPU platforms. See the [synchronous DeepSeek V3.2 recipe](recipe/npu/CAMP2pAFDConnector/deepseek_v3_2/README.md). |
| `CAMAsyncAFDConnector` | Ascend NPU | Prefill / decode | Async | Not supported | Experimental DP+TP/SP path with AFD-managed two-stage MoE ubatching; native DBO and PCP are unsupported. V2-Lite and DSV4 Flash W4A8 have [representative v0.30 validation](https://github.com/vllm-project/afd-plugin/pull/425#issuecomment-6063910923). The [legacy PCP8 recipe](recipe/npu/CAMAsyncAFDConnector/deepseek_v3_2/README.md) requires `release/v0.19.1rc1`. |

Connector implementations are grouped by backend package:
`afd_plugin.connectors.gpu` for GPU-only connectors,
`afd_plugin.connectors.npu` for NPU-only connectors.

Known gaps:

- vLLM versions other than `0.26.0` are not claimed as supported.
- vLLM/vLLM-Ascend model runner v2 is not supported.
- The GPU target is exactly vLLM `0.30.0`; other vLLM versions are not
claimed as supported on GPU.
- NPU hardware evidence covers representative DeepSeek-V2-Lite and DSV4
Flash W4A8 deployments; see the [runtime matrix](docs/design/module/execution_platforms.md#tested-runtime-matrix).
Other models and topologies remain unverified. Historical v0.26 results retain
their recorded vLLM-Ascend `80d8c194f` environment.
- NPU MRV2 many-to-one padding and DSV2 Async SP with TP-sharded shared
experts have known correctness defects deferred to separate fixes; see the
[runtime matrix](docs/design/module/execution_platforms.md#tested-runtime-matrix).
- Synchronous DSV4 E2E profiles are smoke cases; A5 concurrent answers remain
incorrect. See the [profile limits](tests/e2e/README.md#dsv4-flash-sync-camp2p-concurrent-requests-local-4-or-16-npus).
- GPU ModelRunnerV2 supports synchronous `P2pNcclAFDConnector` with
`compute_gate_on_attention=false`, including two-microbatch DBO and
`FULL_DECODE_ONLY`. H20 validation covers DeepSeek-V2-Lite, 2A2F DP2/TP1;
see the [MRV2 DBO scenarios](tests/e2e/README.md#gpu-mrv2-dbo-development-comparison).
Representative 300-question comparisons do not establish numerical
equivalence; see the [runtime matrix](docs/design/module/execution_platforms.md#tested-runtime-matrix). NPU MRV2 DBO is unsupported.
- GPU and NPU E2E tests are opt-in and require real hardware plus model weights.
- GPU CUDA graph support is limited to `FULL_DECODE_ONLY`.
- Native DBO is limited to exactly two ubatches and is not supported by
Expand All @@ -79,7 +96,7 @@ Known gaps:
multi-node execution are unsupported; quantization is unverified; no
performance claim is made.
- PCP-based NPU model-runner-v1 deployments from v0.19.1rc1 are not supported
on v0.26.
on v0.30.

## Install

Expand All @@ -103,28 +120,35 @@ command:
uv sync --group dev --extra vllm
```

The optional extra pins `vllm==0.26.0`.
The optional extra pins `vllm==0.30.0`.

### Ascend NPU installation

AFD's Ascend path is validated on openEuler 22.03 (aarch64) with
Ascend 910C / Atlas A3. Install a compatible driver and firmware, and confirm
the devices with `npu-smi info`. Use this source baseline:
The Ascend target uses the source pair below. Representative v0.30 validation
uses Ascend 910C / Atlas A3; see the [recorded environment and results](https://github.com/vllm-project/afd-plugin/pull/425#issuecomment-6063910923).
Install a compatible driver and firmware, and confirm the devices with
`npu-smi info`.

| Component | Version |
| --- | --- |
| Python | `3.10` or `3.11` |
| vLLM | `0.26.0` |
| vLLM-Ascend | commit [`80d8c194f`](https://github.com/vllm-project/vllm-ascend/commit/80d8c194f7584b17fe08065ea99a130916f6b0e7) |
| vLLM | `0.30.0`, commit `ced6857afa0ea7b2e3f0846a62e1394e90f15607` |
| vLLM-Ascend | commit [`8d4409d6`](https://github.com/vllm-project/vllm-ascend/commit/8d4409d6256d8a6729140ddcc0d1889e3f96cdd6) |
| CANN / torch / torch-npu | Use the mutually compatible versions required by that vLLM-Ascend source snapshot. |

> Hardware evidence is scoped to the recorded models, configurations, and
> sample counts; it does not cover every NPU deployment or guarantee clean
> device shutdown.

#### Environment

The v0.26 integration was refreshed against vLLM-Ascend commit `80d8c194f`;
the repository does not currently claim a released v0.26 container tag. Use the
[installation guide at that source snapshot](https://github.com/vllm-project/vllm-ascend/blob/80d8c194f7584b17fe08065ea99a130916f6b0e7/docs/source/installation.md)
The Ascend environment targets vLLM-Ascend commit `8d4409d6` and vLLM
`0.30.0`. The recorded A3 environment uses CANN 9.1.0, torch 2.10.0+cpu,
and torch-npu 2.10.0.post4. The repository does not claim a released container
tag for either target. Use the
[installation guide at that source snapshot](https://github.com/vllm-project/vllm-ascend/blob/8d4409d6256d8a6729140ddcc0d1889e3f96cdd6/docs/source/getting_started/installation.md)
to prepare a matching A3/openEuler environment, then install AFD from the
repository root. Do not reuse the former v0.19.1rc1 image as a v0.26 runtime.
repository root. Do not reuse the former v0.19.1rc1 image as a v0.30 runtime.

#### Install AFD

Expand Down Expand Up @@ -177,8 +201,11 @@ or standard Ascend NPU platform. Explicit AFD worker paths remain accepted for
compatibility with existing commands, but are not required or stable launch
interfaces.

GPU model runner v2 is not supported. Select model runner v1 before starting
either GPU role:
The examples below use model runner v1. For GPU MRV2, set
`VLLM_USE_V2_MODEL_RUNNER=1` on both roles and use the
[dedicated E2E scenarios](tests/e2e/README.md#gpu-mrv2-dbo-development-comparison).
MRV2 DBO requires two microbatches and Attention DP > 1.
For the MRV1 examples below, select:

```bash
export VLLM_USE_V2_MODEL_RUNNER=0
Expand Down
13 changes: 11 additions & 2 deletions afd_plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,17 @@ def register_afd() -> None:
exc_info=True,
)

# NPU compatibility patches are applied during AFD config construction and
# worker startup, after vLLM-Ascend completes its platform initialization.
# EngineCore constructs Ascend schedulers before handshake revalidation or
# AFD worker startup. Install the namespace factory at plugin registration
# so direct scheduler calls and already imported aliases accept AFD settings.
from vllm.platforms import current_platform

if current_platform.device_type == "npu":
from afd_plugin.compat.patches.npu.ascend_config import (
apply_afd_ascend_config_patch,
)

apply_afd_ascend_config_patch()

from vllm.model_executor.models import ModelRegistry

Expand Down
2 changes: 2 additions & 0 deletions afd_plugin/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
TARGET_VLLM_VERSION,
assert_vllm_version_supported,
get_installed_vllm_version,
is_target_vllm_compatible,
is_vllm_version_supported,
)

__all__ = [
"TARGET_VLLM_VERSION",
"assert_vllm_version_supported",
"get_installed_vllm_version",
"is_target_vllm_compatible",
"is_vllm_version_supported",
]
2 changes: 2 additions & 0 deletions afd_plugin/compat/npu/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
)
from afd_plugin.compat.npu.runtime import (
apply_afd_ascend_config_patch_if_needed,
apply_afd_ascend_engine_core_config_patch_if_needed,
apply_afd_ascend_patches_if_needed,
apply_afd_async_dp_engine_patch_if_needed,
ascend_forward_context,
Expand All @@ -30,6 +31,7 @@

__all__ = [
"apply_afd_ascend_config_patch_if_needed",
"apply_afd_ascend_engine_core_config_patch_if_needed",
"apply_afd_ascend_patches_if_needed",
"apply_afd_async_dp_engine_patch_if_needed",
"ascend_forward_context",
Expand Down
25 changes: 25 additions & 0 deletions afd_plugin/compat/npu/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,14 @@
def apply_afd_ascend_config_patch_if_needed() -> None:
"""Apply patches required while vLLM builds an AFD NPU config."""

from afd_plugin.compat.patches.npu.ascend_config import (
apply_afd_ascend_config_patch,
)
from afd_plugin.compat.patches.npu.ascend_platform import (
apply_afd_ascend_dbo_config_patch,
)

apply_afd_ascend_config_patch()
if not apply_afd_ascend_dbo_config_patch():
raise RuntimeError(
"AFD NPU DBO config patch requires vLLM-Ascend NPUPlatform",
Expand Down Expand Up @@ -59,6 +63,26 @@ def apply_afd_async_dp_engine_patch_if_needed(vllm_config: VllmConfig) -> bool:
return True


def apply_afd_ascend_engine_core_config_patch_if_needed(
vllm_config: VllmConfig,
) -> bool:
"""Prepare AFD sync Attention and FFN DP children for Ascend config."""
afd_config = parse_optional_afd_config(vllm_config, validate=False)
if afd_config is None or (
afd_config.role == "attention" and is_afd_async_dp(vllm_config)
):
return False

from vllm.v1.engine.core import EngineCoreProc

from afd_plugin.compat.patches.npu.ascend_config import (
run_afd_ascend_engine_core,
)

EngineCoreProc.run_engine_core = staticmethod(run_afd_ascend_engine_core)
return True


def apply_afd_ascend_patches_if_needed() -> None:
"""Apply plugin-owned runtime patches after Ascend initialization."""

Expand All @@ -80,6 +104,7 @@ def apply_afd_ascend_patches_if_needed() -> None:

__all__ = [
"apply_afd_async_dp_engine_patch_if_needed",
"apply_afd_ascend_engine_core_config_patch_if_needed",
"apply_afd_ascend_config_patch_if_needed",
"apply_afd_ascend_patches_if_needed",
"ascend_forward_context",
Expand Down
55 changes: 40 additions & 15 deletions afd_plugin/compat/npu/runtime_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
from vllm.config import VllmConfig

FLASHINFER_ALL2ALLV_BACKEND = "flashinfer_all2allv"
DEEPSEEK_V2_MODEL_TYPES = frozenset(
("deepseek", "deepseek_v2", "deepseek_v3", "deepseek_v32", "glm_moe_dsa")
)


def npu_afd_num_ubatches(vllm_config: VllmConfig) -> int:
Expand All @@ -19,27 +22,49 @@ def npu_afd_num_ubatches(vllm_config: VllmConfig) -> int:
return 1


def npu_model_uses_sequence_parallel_moe(vllm_config: VllmConfig) -> bool:
"""Match the DSV2 decoder's effective SP setting under pipeline parallelism."""
parallel_config = vllm_config.parallel_config
model_type = vllm_config.model_config.hf_text_config.model_type
return parallel_config.use_sequence_parallel_moe and (
model_type not in DEEPSEEK_V2_MODEL_TYPES
or parallel_config.pipeline_parallel_size == 1
)


def npu_model_uses_sharded_pp_tensors(vllm_config: VllmConfig) -> bool:
"""Return the model's PP wire layout independently of its internal SP.

Target DSV4 gathers the complete sequence before each PP boundary. Target
DSV2 disables MoE SP when PP is enabled; its PP tensors are global too.
"""
return (
npu_model_uses_sequence_parallel_moe(vllm_config)
and vllm_config.model_config.hf_text_config.model_type != "deepseek_v4"
)


def fix_all2all_backend_for_afd(vllm_config: VllmConfig) -> None:
"""Apply vLLM-Ascend's default-worker all2all fix to AFD workers.

vLLM-Ascend normally rewrites ``all2all_backend`` to
``"flashinfer_all2allv"`` when sequence parallelism is disabled, but that
compatibility rewrite is gated on the default ``worker_cls == "auto"``.
Automatic AFD worker selection preserves that upstream rewrite. Legacy
commands that explicitly select an AFD worker miss it and can keep the
default ``"allgather_reducescatter"`` backend.

Leaving that backend in place can make the Ascend MoE path think sequence
parallel MoE is enabled and split tokens through ``sequence_parallel_chunk``,
which is not the layout AFD's NPU connector path sends. Mirror the upstream
rewrite here before AFD creates the NPU model runner.
"""Keep configured model SP while preserving the non-SP worker fallback.

Target Ascend derives SP from ParallelConfig.use_sequence_parallel_moe.
AscendConfig first applies the effective FlashComm config switch to the
backend. Preserve that result, including for explicit AFD worker classes.
Rewriting its all2all backend disables model-owned token sharding even
when EP/DP/TP requested it. Non-SP workers keep the legacy backend fix.
"""
parallel_config = vllm_config.parallel_config
if (
not vllm_config.compilation_config.pass_config.enable_sp
not parallel_config.use_sequence_parallel_moe
and not vllm_config.compilation_config.pass_config.enable_sp
and parallel_config.all2all_backend != FLASHINFER_ALL2ALLV_BACKEND
):
parallel_config.all2all_backend = FLASHINFER_ALL2ALLV_BACKEND


__all__ = ["fix_all2all_backend_for_afd", "npu_afd_num_ubatches"]
__all__ = [
"fix_all2all_backend_for_afd",
"npu_afd_num_ubatches",
"npu_model_uses_sequence_parallel_moe",
"npu_model_uses_sharded_pp_tensors",
]
Loading
Loading