[BugFix] Add async communication check for capturing mode (#8149)

### What this PR does / why we need it?
Introduce a check to not using asynchronous communication under
`enable_dsa_cp_with_layer_shard` branch on capturing mode. This change
prevents potential stream and event issues when operating in
graph/capturing mode, ensuring safer communication practices.

### Does this PR introduce _any_ user-facing change?
No.

### How was this patch tested?
E2E test with dsv32 + FC1 + FULL_DECODE_ONLY +
kv_transfer_config(kv_both)

---------

Signed-off-by: chenchuw886 <chenchuw@huawei.com>
Co-authored-by: chenchuw886 <chenchuw@huawei.com>
This commit is contained in:
Frank Chen
2026-04-12 21:52:54 +08:00
committed by GitHub
parent c1f323ee46
commit 31186a3a9d
8 changed files with 85 additions and 3 deletions

View File

@@ -233,6 +233,20 @@ class NPUPlatform(Platform):
def set_device(cls, device: torch.device):
torch.npu.set_device(device)
@classmethod
def _validate_layer_sharding_config(cls, vllm_config: VllmConfig) -> None:
additional_config = vllm_config.additional_config or {}
layer_sharding = additional_config.get("layer_sharding") or []
if not layer_sharding:
return
kv_transfer_config = vllm_config.kv_transfer_config
if kv_transfer_config is not None and kv_transfer_config.kv_role != "kv_producer":
raise ValueError(
"additional_config.layer_sharding is only supported on P nodes "
"(kv_role='kv_producer') when KV transfer is enabled."
)
@classmethod
def check_and_update_config(cls, vllm_config: VllmConfig) -> None:
from vllm_ascend.quantization.utils import maybe_auto_detect_quantization
@@ -240,6 +254,8 @@ class NPUPlatform(Platform):
if vllm_config.model_config is not None:
maybe_auto_detect_quantization(vllm_config)
cls._validate_layer_sharding_config(vllm_config)
# initialize ascend config from vllm additional_config
cls._fix_incompatible_config(vllm_config)

View File

@@ -1238,7 +1238,9 @@ def enable_dsa_cp_with_layer_shard() -> bool:
vllm_config = get_current_vllm_config()
# because the broadcast in layer sharding needs to be overlapped with a heavy compute stream to be
# effectively hidden, it is enabled only during the prefill stage.
is_prefill_instance = vllm_config.kv_transfer_config is not None and vllm_config.kv_transfer_config.is_kv_producer
is_prefill_instance = (
vllm_config.kv_transfer_config is not None and vllm_config.kv_transfer_config.kv_role == "kv_producer"
)
return is_prefill_instance