Skip to content

[WIP][NPU]Add DSV4 NPU ubatch async connector - #264

Open
bjf-frz wants to merge 15 commits into
vllm-project:v0.26.0_camasync_dsv4from
bjf-frz:v0.26.0_camasync_dsv4
Open

[WIP][NPU]Add DSV4 NPU ubatch async connector#264
bjf-frz wants to merge 15 commits into
vllm-project:v0.26.0_camasync_dsv4from
bjf-frz:v0.26.0_camasync_dsv4

Conversation

@bjf-frz

@bjf-frz bjf-frz commented Aug 24, 2026

Copy link
Copy Markdown

PLEASE FILL IN THE PR DESCRIPTION AND MAKE SURE THE CHECKLIST ITEMS HAVE BEEN CONSIDERED.

Purpose

Issue

  • Related issue(s): #
  • Closing keyword, only if fully resolved: Closes #

Scope

  • In scope:
  • Out of scope:

Implementation Notes

Test Plan

Test Result

Docs Impact

  • Files updated:
  • If none, reason:

Essential PR Checklist
  • Purpose is clear and linked to public context when possible.
  • Scope is bounded.
  • Compatibility with vLLM v0.26.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.
  • Imports remain CPU-safe; CUDA-heavy work is delayed or GPU-gated.
  • Validation evidence is included, including skipped GPU tests when applicable.
  • Documentation impact is stated.

@jiangkuaixue123 jiangkuaixue123 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.

Please address the inline comments.

Comment thread afd_plugin/__init__.py
_logger = logging.getLogger(__name__)
_registered = False


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.

Why do we need this process-wide multiprocessing override here? It does not appear necessary for the AFD plugin itself, and mutating Python's global multiprocessing context (including the private _concrete_contexts registry) is quite intrusive. Please remove this unless there is a concrete AFD-specific requirement and reproducer that cannot be addressed in the affected NPU runtime path.

# fail_if_unsupported_npu_afd_features; the AFD async MoE ubatching
# path drives stage counts through connector_extra_config
# (async_moe_num_ubatches), which is validated there as well.
if self.vllm_config.parallel_config.use_ubatching:

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.

This check does not look correct. Rejecting use_ubatching in the wrapper disables native ubatching for ordinary decode as well, rather than only restricting the CAM async path. Please remove this change so normal decode ubatching can still be enabled.

from vllm.platforms import current_platform

if current_platform.device_type == "npu":
from afd_plugin.model_executor.models.deepseek_v4_npu import (

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 we place the GPU and NPU implementations under dedicated gpu/ and npu/ directories, respectively, and keep the two backend implementations isolated? Please avoid sharing/reusing backend-specific DeepSeek-V4 code across GPU and NPU.

@@ -0,0 +1,164 @@
# SPDX-License-Identifier: Apache-2.0

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.

I do not understand why this KV-cache patch is necessary. What concrete upstream issue does it address, and why must it be patched in AFD rather than fixed in vLLM-Ascend? Please provide a minimal reproducer and explain the necessity of this patch; otherwise, please remove it.

@@ -0,0 +1,119 @@
# SPDX-License-Identifier: Apache-2.0

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.

I do not understand why this ModelSlim patch is necessary. What exact incompatibility requires AFD to override the upstream prefix mapping, and why cannot it be handled in vLLM-Ascend? Please provide a concrete reproducer and justify the patch; otherwise, please remove it.

@jiangkuaixue123

Copy link
Copy Markdown
Collaborator

Please fix conflict.

@bjf-frz
bjf-frz force-pushed the v0.26.0_camasync_dsv4 branch from 2cc1aa8 to 053b808 Compare August 24, 2026 09:11
@ShwStone

Copy link
Copy Markdown
Contributor

It seems that there are a lot of documents and operation manuals in the repository about specific test environments. Please make sure that the documents you submit are general guidance and avoid submitting irrelevant documents and startup scripts.

# Keep EngineCore's synthetic KV-cache profile local so that workspace
# is not mistaken for reclaimable KV capacity. The first real request
# performs the normal CAM dispatch/receive sequence below.
if forward_context.in_profile_run:

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.

Could you explain why the startup profile must skip CAM dispatch/combine here?

PR #248 intentionally removed an equivalent guard to fix #247. Matched profile traffic ensures that every Attention DP rank enters the CAM operators before live serving; skipping it appears to defer lazy CAM/HCCL initialization to the first real request, potentially reintroducing the DP>1 first-request deadlock.

Has the CAM 209 initialization contract changed? If so, how does this PR initialize all Attention ranks before serving, and has the DP2 single-cold-request scenario from #247 been validated?

This also appears to conflict with the existing test_async_cam_profile_forward_runs_matched_connector_io regression test added by #248.

@ShwStone

Copy link
Copy Markdown
Contributor

Could you clarify the motivation for replacing the previous global-DP topology with multiple independent DP1 Attention services?

The previous setup already supported a cross-node DP3TP8 + EP8 topology (for example, local DP2 on one node and DP1 on another), while vLLM handled request routing across the Attention DP replicas automatically. With this change, request routing must be moved to an external load balancer, and the FFN side additionally needs multiple CAM/HCCL communicators plus a TCPStore scheduler.

What concrete limitation or failure in the previous global CAM world requires this higher-complexity design? Is this mandated by a DSV4/CAM 209 contract, or does the old topology exhibit a reproducible correctness or performance issue under concurrent DP traffic?

It would also be helpful to explain why the existing cross-node DP mechanism cannot satisfy the intended deployment and what benefit justifies giving up vLLM built-in DP routing.

Signed-off-by: bjf-frz <frz123db@gmail.com>
Signed-off-by: bjf-frz <frz123db@gmail.com>
Signed-off-by: bjf-frz <frz123db@gmail.com>
Signed-off-by: bjf-frz <frz123db@gmail.com>
@bjf-frz
bjf-frz force-pushed the v0.26.0_camasync_dsv4 branch from eaada78 to ca2eacb Compare August 25, 2026 07:06
@bjf-frz
bjf-frz changed the base branch from main to v0.26.0_camasync_dsv4 August 25, 2026 07:12
Comment thread .buildkite/cuda/test-merge.yml Outdated
depends_on: upload-merge-pipeline
steps:
- label: "E2E · DeepSeekV2-Lite"
- label: "E2E · DeepSeekV2-Lite · Legacy"

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.

This file change is not needed.

Comment thread .buildkite/cuda/test-ready.yml Outdated
depends_on: upload-ready-pipeline
steps:
- label: "E2E · DeepSeekV2-Lite"
- label: "E2E · DeepSeekV2-Lite · Legacy"

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.

This file change is not needed.

Signed-off-by: bjf-frz <frz123db@gmail.com>
Signed-off-by: bjf-frz <frz123db@gmail.com>
Signed-off-by: bjf-frz <frz123db@gmail.com>
@bjf-frz
bjf-frz force-pushed the v0.26.0_camasync_dsv4 branch from ca2eacb to ea44030 Compare August 25, 2026 07:22
):
# Install DSV4's Ascend KV grouping compatibility before an EngineCore can
# ask vLLM to construct its cache configuration.
from afd_plugin.compat.patches.npu.deepseek_v4_kv_cache import (

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.

Remove these two patches if there is no need.

llama_4_scaling,
)

# CAM allocates persistent operator workspace on its first dispatch.

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.

Please remove this.

Signed-off-by: bjf-frz <frz123db@gmail.com>
# small dummy batch with an FFN receive-capacity buffer and leave the
# external communicator in a broken state. Keep the profile local;
# live forwards below retain the real remote-FFN exchange.
if bool(getattr(forward_context, "in_profile_run", False)):

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.

There is no need. Please remove.

# dispatch-recv for all following MoE layers can reuse CAM's
# bounded buffers while the prior combine is still in flight.
# The target baseline is deliberately serialized per layer;
# async MoE ubatching will introduce explicit stage credits.

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.

Need remove.

@bjf-frz
bjf-frz force-pushed the v0.26.0_camasync_dsv4 branch from d7d3b20 to ff23e6d Compare August 27, 2026 08:04
if not self.connector.is_initialized:
self.connector.init_afd_connector()

def _is_dsv4_model(self) -> bool:

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.

这个函数多余

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.

3 participants