From e07acaba6e878076fa8a05c2f159f6695126516d Mon Sep 17 00:00:00 2001 From: kaiyuan Date: Thu, 2 Jul 2026 09:29:08 +0800 Subject: [PATCH 1/2] fix(npu): trim vllm-ascend colocate patch and pin native IPC engine Drop the redundant npu_ipc_engine.py hunk now that vLLM Ascend 5ca762a provides the NPU IPC init fix upstream. Pin VLLM_ASCEND_COMMIT in Dockerfile.npu and document colocate validation notes. Signed-off-by: kaiyuan --- docker/Dockerfile.npu | 9 ++++--- docker/npu_patch/README.md | 23 ++++++++++++++---- docker/npu_patch/vllm-ascend.patch | 15 ------------ docs/en/get_started/NPU.md | 39 +++++++++++++++++++++++++++--- 4 files changed, 59 insertions(+), 27 deletions(-) diff --git a/docker/Dockerfile.npu b/docker/Dockerfile.npu index 2338d809..e205070b 100644 --- a/docker/Dockerfile.npu +++ b/docker/Dockerfile.npu @@ -7,6 +7,7 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"] WORKDIR /root ARG MEGATRON_COMMIT=3714d81d418c9f1bca4594fc35f9e8289f652862 +ARG VLLM_ASCEND_COMMIT=5ca762a704f2a7acbd1bd839c3f3b421e5c0dcaf ARG MEGATRON_BRIDGE_COMMIT=3fd3768045422d0aa5c97e90a4e6c659aea9acb9 ARG MINDSPEED_COMMIT=fc63de5c48426dd019c3b3f39e65f5bdf56e4086 ARG MBRIDGE_COMMIT=89eb10887887bc74853f89a4de258c0702932a1c @@ -44,12 +45,12 @@ RUN sed -i '/ports\.ubuntu\.com/ {h;s|ports\.ubuntu\.com|mirrors.tuna.tsinghua.e "https://download.pytorch.org/whl/cpu/ https://mirrors.huaweicloud.com/ascend/repos/pypi" && \ git config --global http.version HTTP/1.1 -# Clone vllm and vllm-ascend sources. +# Clone vllm and vllm-ascend sources (pin ascend for native NPU IPC engine). RUN pip uninstall -y \ vllm vllm-ascend megatron-bridge megatron-core mindspeed mbridge vime || true && \ git clone https://github.com/vllm-project/vllm.git /root/vllm && \ - git clone --depth 1 --branch main \ - https://github.com/vllm-project/vllm-ascend.git /root/vllm-ascend + git clone https://github.com/vllm-project/vllm-ascend.git /root/vllm-ascend && \ + git -C /root/vllm-ascend checkout "${VLLM_ASCEND_COMMIT}" # Switch vllm to the vllm-ascend verified commit, apply the NPU patch, install. RUN VLLM_COMMIT=$(cat /root/vllm-ascend/.github/vllm-main-verified.commit) && \ @@ -58,7 +59,7 @@ RUN VLLM_COMMIT=$(cat /root/vllm-ascend/.github/vllm-main-verified.commit) && \ VLLM_TARGET_DEVICE=empty pip install -v -e /root/vllm --trusted-host download.pytorch.org \ --trusted-host download-r2.pytorch.org -# vLLM Ascend: apply colocate patch before install. +# vLLM Ascend: apply colocate worker patch only (IPC engine fix is upstream). RUN source /usr/local/Ascend/ascend-toolkit/set_env.sh && \ source /usr/local/Ascend/nnal/atb/set_env.sh && \ git -C /root/vllm-ascend submodule update --init --recursive && \ diff --git a/docker/npu_patch/README.md b/docker/npu_patch/README.md index 8f376aec..f6677c34 100644 --- a/docker/npu_patch/README.md +++ b/docker/npu_patch/README.md @@ -6,7 +6,9 @@ This guide provides instructions for installing Vime with NPU support, including | Component | Version/Commit | Source | | --------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | -| vime | main | [GitHub](https://github.com/vllm-project/vime/tree/main) | +| vime | ascend | [GitHub](https://github.com/vllm-project/vime/tree/ascend) | +| vLLM | see `.github/vllm-main-verified.commit` at pinned vLLM Ascend | [GitHub](https://github.com/vllm-project/vllm) | +| vLLM Ascend | 5ca762a704f2a7acbd1bd839c3f3b421e5c0dcaf | [GitHub](https://github.com/vllm-project/vllm-ascend) | | Megatron-Bridge | 3fd3768045422d0aa5c97e90a4e6c659aea9acb9 | [GitHub](https://github.com/radixark/Megatron-Bridge) | | Megatron-LM | 3714d81d418c9f1bca4594fc35f9e8289f652862 | [GitHub](https://github.com/NVIDIA/Megatron-LM) | | MindSpeed | fc63de5c48426dd019c3b3f39e65f5bdf56e4086 | [GitCode](https://gitcode.com/Ascend/MindSpeed) | @@ -100,23 +102,34 @@ pip install --no-deps output/torch_memory_saver-0.0.8-cp312-cp312-linux_aarch64. ```bash -export VLLM_COMMIT=9090368b650896bf5fc990c921df7eb4c20355a5 +export VLLM_ASCEND_COMMIT=5ca762a704f2a7acbd1bd839c3f3b421e5c0dcaf + +git clone https://github.com/vllm-project/vllm-ascend.git "${WORKSPACE}/vllm-ascend" +git -C "${WORKSPACE}/vllm-ascend" checkout "${VLLM_ASCEND_COMMIT}" +git -C "${WORKSPACE}/vllm-ascend" submodule update --init --recursive +export VLLM_COMMIT="$(cat "${WORKSPACE}/vllm-ascend/.github/vllm-main-verified.commit")" git clone https://github.com/vllm-project/vllm.git "${WORKSPACE}/vllm" git -C "${WORKSPACE}/vllm" checkout "${VLLM_COMMIT}" +git -C "${WORKSPACE}/vllm" apply --whitespace=nowarn "${PATCH_DIR}/vllm.patch" VLLM_TARGET_DEVICE=empty pip install -v -e "${WORKSPACE}/vllm" -git clone https://github.com/vllm-project/vllm-ascend.git "${WORKSPACE}/vllm-ascend" -git -C "${WORKSPACE}/vllm-ascend" submodule update --init --recursive +git -C "${WORKSPACE}/vllm-ascend" apply --whitespace=nowarn "${PATCH_DIR}/vllm-ascend.patch" pip install -v -e "${WORKSPACE}/vllm-ascend" ``` > [!NOTE] > vLLM Ascend has not yet cut a release tag against vLLM 0.22.0. As a temporary -> measure we pin vLLM to the commit below and build vLLM Ascend from source. +> measure we pin vLLM and vLLM Ascend to the commits above and build from source. > Once vLLM Ascend officially supports 0.22.0, this whole step can be omitted and > the released packages used instead. +> [!NOTE] +> `vllm-ascend.patch` only patches `worker.py` for colocate (skip free-memory +> checks when training and inference share NPUs). The `NPUIPCWeightTransferEngine` +> init fix is upstream since vLLM Ascend `5ca762a` (#10996); do not re-patch +> `npu_ipc_engine.py`. + ## Additional Dependencies Ensure the following packages are pinned to these matching versions: diff --git a/docker/npu_patch/vllm-ascend.patch b/docker/npu_patch/vllm-ascend.patch index 42a6c280..52748d89 100644 --- a/docker/npu_patch/vllm-ascend.patch +++ b/docker/npu_patch/vllm-ascend.patch @@ -37,18 +37,3 @@ index 63ee94c..4e81943 100644 self.available_kv_cache_memory_bytes = ( self.requested_memory - profile_result.non_kv_cache_memory - npugraph_memory_estimate_applied ) -diff --git a/vllm_ascend/distributed/weight_transfer/npu_ipc_engine.py b/vllm_ascend/distributed/weight_transfer/npu_ipc_engine.py -index 0000000..0000000 100644 ---- a/vllm_ascend/distributed/weight_transfer/npu_ipc_engine.py -+++ b/vllm_ascend/distributed/weight_transfer/npu_ipc_engine.py -@@ -116,8 +116,8 @@ class NPUIPCWeightTransferEngine(WeightTransferEngine[NPUIPCWeightTransferInitIn - init_info_cls = NPUIPCWeightTransferInitInfo - update_info_cls = NPUIPCWeightTransferUpdateInfo - -- def __init__(self, config: WeightTransferConfig, parallel_config: ParallelConfig) -> None: -- super().__init__(config, parallel_config) -+ def __init__(self, config: WeightTransferConfig, parallel_config: ParallelConfig, model: torch.nn.Module = None) -> None: -+ super().__init__(config, parallel_config, model) - - def parse_update_info(self, update_dict: dict[str, Any]) -> NPUIPCWeightTransferUpdateInfo: - """Parse update dict, deserializing pickled IPC handles if present. diff --git a/docs/en/get_started/NPU.md b/docs/en/get_started/NPU.md index 6a12457f..46293a9c 100644 --- a/docs/en/get_started/NPU.md +++ b/docs/en/get_started/NPU.md @@ -8,8 +8,8 @@ issue on [vllm-project/vime](https://github.com/vllm-project/vime/issues). If you are running vime on Ascend NPU, please refer to the following materials. This tutorial explains how to set up the runtime environment and provides an end-to-end example for running GRPO training. It uses the **Megatron** training -backend together with the **vLLM Ascend** rollout backend, synchronizing actor -weights to vLLM through the native HCCL weight-sync path. +backend together with the **vLLM Ascend** rollout backend. In decoupled mode, +weights sync over HCCL; in colocate mode (`--colocate`), weights sync over NPU IPC. The current NPU support targets Ascend **Atlas A2 / A3** (aarch64) hosts with the Ascend driver and **CANN 9.0.0** (Toolkit, Kernels, and NNAL/ATB) installed. @@ -27,7 +27,7 @@ docker pull "${IMAGE}" ``` For source builds and dependency debugging, the patch list and pinned commits are -documented in [`docker/npu_patch/README.md`](https://github.com/vllm-project/vime/blob/npu/docker/npu_patch/README.md). +documented in [`docker/npu_patch/README.md`](https://github.com/vllm-project/vime/blob/ascend/docker/npu_patch/README.md). ## Quick Start @@ -202,3 +202,36 @@ python /root/vime/train.py \ --train-memory-margin-bytes 2147483648 \ 2>&1 | tee -a "$LOG_FILE" ``` + +### Example: Qwen3-4B Colocate + +Colocate runs training and rollout on the same NPUs (8×910B validated). Add +`--colocate` and set `--tensor-model-parallel-size` to match the NPU count. +Use `--megatron-to-hf-mode bridge` for weight export. + +```bash +python /root/vime/train.py \ + --train-backend megatron \ + --actor-num-nodes 1 \ + --actor-num-gpus-per-node 8 \ + --rollout-num-gpus 8 \ + --rollout-num-gpus-per-engine 8 \ + --colocate \ + --train-memory-margin-bytes 2147483648 \ + --megatron-to-hf-mode bridge \ + --tensor-model-parallel-size 8 \ + ... # same GRPO / optimizer flags as the decoupled example +``` + +Colocate notes (validated on 8× Ascend910B1, Qwen3-4B TP=8): + +- Do **not** pass `--vllm-enforce-eager`; it raises `train_rollout_logprob_abs_diff` + to ~0.2 (normal colocate diff is ~0.012). +- Kill leftover `VLLMWorker` / `train.py` processes and release HBM before each + run (`npu-smi info` should show ~3 GB per card idle). +- vLLM Ascend must be at least `5ca762a` (#10996) for the native NPU IPC weight + transfer engine; only the colocate `worker.py` patch in `vllm-ascend.patch` + is still required from Vime. + +Validated results: smoke (4 rollouts) diff ~0.012; 100-step long run diff +0.00785–0.01257 with stable convergence. From eefd80ccc14d2daaad4b7846f3b857dc5e7cf271 Mon Sep 17 00:00:00 2001 From: kaiyuan Date: Thu, 2 Jul 2026 09:32:28 +0800 Subject: [PATCH 2/2] docs(npu): add pip version labels alongside vllm-ascend commit pin Document dev snapshot version strings next to commit hashes in the component table for easier cross-reference with validation reports. Signed-off-by: kaiyuan --- docker/npu_patch/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docker/npu_patch/README.md b/docker/npu_patch/README.md index f6677c34..cab6efea 100644 --- a/docker/npu_patch/README.md +++ b/docker/npu_patch/README.md @@ -7,8 +7,8 @@ This guide provides instructions for installing Vime with NPU support, including | Component | Version/Commit | Source | | --------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | | vime | ascend | [GitHub](https://github.com/vllm-project/vime/tree/ascend) | -| vLLM | see `.github/vllm-main-verified.commit` at pinned vLLM Ascend | [GitHub](https://github.com/vllm-project/vllm) | -| vLLM Ascend | 5ca762a704f2a7acbd1bd839c3f3b421e5c0dcaf | [GitHub](https://github.com/vllm-project/vllm-ascend) | +| vLLM | `0.22.1rc1` (see `.github/vllm-main-verified.commit` at pinned vLLM Ascend) | [GitHub](https://github.com/vllm-project/vllm) — e.g. `967c5c3bc38891f4465d3f4e99917ed837bb3833` at pin above | +| vLLM Ascend | `0.1.dev1+g5ca762a704f2` (dev snapshot; pin commit below) | [GitHub](https://github.com/vllm-project/vllm-ascend) — commit `5ca762a704f2a7acbd1bd839c3f3b421e5c0dcaf` (#10996) | | Megatron-Bridge | 3fd3768045422d0aa5c97e90a4e6c659aea9acb9 | [GitHub](https://github.com/radixark/Megatron-Bridge) | | Megatron-LM | 3714d81d418c9f1bca4594fc35f9e8289f652862 | [GitHub](https://github.com/NVIDIA/Megatron-LM) | | MindSpeed | fc63de5c48426dd019c3b3f39e65f5bdf56e4086 | [GitCode](https://gitcode.com/Ascend/MindSpeed) |