[NPU] support multi-agent rollout pipeline#298
Conversation
Signed-off-by: Windfeng8 <523758380@qq.com>
Documentation build overview
41 files changed ·
|
There was a problem hiding this comment.
Code Review
This pull request introduces a compatibility helper for extracting token IDs and log probabilities from vLLM rollout responses, updates multi-agent rollouts to share a single rollout_id among sibling samples to prevent over-counting during loss reduction, and adds a training script for Qwen3-4B on NPU. The review feedback highlights several critical improvements: adding defensive checks to prevent TypeError when converting potentially None log probabilities, handling cases where the multi-agent function returns None or empty samples, and replacing hardcoded absolute paths in the shell script with dynamic path resolution to ensure portability.
| new_response_log_probs = [ | ||
| float(item.get("logprob", 0.0)) if isinstance(item, dict) else 0.0 | ||
| for item in content_items | ||
| ] |
There was a problem hiding this comment.
If item.get("logprob") is explicitly None or missing, calling float(None) will raise a TypeError and crash the rollout pipeline. We should defensively check if the logprob value is not None before converting it to a float.
| new_response_log_probs = [ | |
| float(item.get("logprob", 0.0)) if isinstance(item, dict) else 0.0 | |
| for item in content_items | |
| ] | |
| new_response_log_probs = [ | |
| float(item.get("logprob")) if isinstance(item, dict) and item.get("logprob") is not None else 0.0 | |
| for item in content_items | |
| ] |
| export PYTHONPATH="/workspace/issue205/Megatron-Bridge/src:/workspace/issue205/Megatron-Bridge:/workspace/issue205/Megatron-LM:/workspace/issue205/vime-ascend:${PYTHONPATH}" | ||
| export ASCEND_RT_VISIBLE_DEVICES="${ASCEND_RT_VISIBLE_DEVICES:-0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}" | ||
| export CUDA_DEVICE_MAX_CONNECTIONS=1 | ||
| export RAY_EXPERIMENTAL_NOSET_ASCEND_RT_VISIBLE_DEVICES=1 | ||
| export HCCL_HOST_SOCKET_PORT_RANGE=60000-60050 | ||
| export HCCL_NPU_SOCKET_PORT_RANGE=61000-61050 | ||
| export HYDRA_FULL_ERROR=1 | ||
| export MASTER_PORT="${MASTER_PORT:-$(shuf -i 20000-65000 -n 1)}" | ||
| export DISABLE_L2_CACHE=1 | ||
| export VLLM_ASCEND_ENABLE_NZ=0 | ||
|
|
||
| VIME_ROOT="${VIME_ROOT:-/workspace/issue205/vime-ascend}" | ||
| SCRIPT_DIR="${VIME_ROOT}/scripts" | ||
| WEIGHT_DIR="${WEIGHT_DIR:-/home/data/weights/Qwen3-4B}" | ||
| DATA_FILE="${DATA_FILE:-/home/w00893744/dataset/dapo-math-17k.jsonl}" | ||
| LOG_FILE="${LOG_FILE:-/home/w00893744/train_qwen3_4b_multi_agent_vllm.log}" |
There was a problem hiding this comment.
The script contains hardcoded absolute paths specific to a single user's environment (e.g., /workspace/issue205/... and /home/w00893744/...). This makes the script non-portable and prone to immediate failure on other machines or for other users.
We should dynamically resolve the project root (VIME_ROOT) and workspace directory relative to the script's location, and avoid hardcoding user-specific home directories for DATA_FILE and LOG_FILE.
| export PYTHONPATH="/workspace/issue205/Megatron-Bridge/src:/workspace/issue205/Megatron-Bridge:/workspace/issue205/Megatron-LM:/workspace/issue205/vime-ascend:${PYTHONPATH}" | |
| export ASCEND_RT_VISIBLE_DEVICES="${ASCEND_RT_VISIBLE_DEVICES:-0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}" | |
| export CUDA_DEVICE_MAX_CONNECTIONS=1 | |
| export RAY_EXPERIMENTAL_NOSET_ASCEND_RT_VISIBLE_DEVICES=1 | |
| export HCCL_HOST_SOCKET_PORT_RANGE=60000-60050 | |
| export HCCL_NPU_SOCKET_PORT_RANGE=61000-61050 | |
| export HYDRA_FULL_ERROR=1 | |
| export MASTER_PORT="${MASTER_PORT:-$(shuf -i 20000-65000 -n 1)}" | |
| export DISABLE_L2_CACHE=1 | |
| export VLLM_ASCEND_ENABLE_NZ=0 | |
| VIME_ROOT="${VIME_ROOT:-/workspace/issue205/vime-ascend}" | |
| SCRIPT_DIR="${VIME_ROOT}/scripts" | |
| WEIGHT_DIR="${WEIGHT_DIR:-/home/data/weights/Qwen3-4B}" | |
| DATA_FILE="${DATA_FILE:-/home/w00893744/dataset/dapo-math-17k.jsonl}" | |
| LOG_FILE="${LOG_FILE:-/home/w00893744/train_qwen3_4b_multi_agent_vllm.log}" | |
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
| VIME_ROOT="${VIME_ROOT:-$(cd "${SCRIPT_DIR}/.." && pwd)}" | |
| WORKSPACE_DIR="$(cd "${VIME_ROOT}/.." && pwd)" | |
| export PYTHONPATH="${WORKSPACE_DIR}/Megatron-Bridge/src:${WORKSPACE_DIR}/Megatron-Bridge:${WORKSPACE_DIR}/Megatron-LM:${VIME_ROOT}:${PYTHONPATH}" | |
| export ASCEND_RT_VISIBLE_DEVICES="${ASCEND_RT_VISIBLE_DEVICES:-0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}" | |
| export CUDA_DEVICE_MAX_CONNECTIONS=1 | |
| export RAY_EXPERIMENTAL_NOSET_ASCEND_RT_VISIBLE_DEVICES=1 | |
| export HCCL_HOST_SOCKET_PORT_RANGE=60000-60050 | |
| export HCCL_NPU_SOCKET_PORT_RANGE=61000-61050 | |
| export HYDRA_FULL_ERROR=1 | |
| export MASTER_PORT="${MASTER_PORT:-$(shuf -i 20000-65000 -n 1)}" | |
| export DISABLE_L2_CACHE=1 | |
| export VLLM_ASCEND_ENABLE_NZ=0 | |
| WEIGHT_DIR="${WEIGHT_DIR:-/home/data/weights/Qwen3-4B}" | |
| if [ -z "${DATA_FILE}" ]; then | |
| echo "Error: DATA_FILE environment variable is not set." >&2 | |
| exit 1 | |
| fi | |
| LOG_FILE="${LOG_FILE:-/tmp/train_qwen3_4b_multi_agent_vllm.log}" |
| for sibling in samples: | ||
| sibling.rollout_id = compact_rollout_id | ||
|
|
||
| random.shuffle(samples) |
There was a problem hiding this comment.
If the custom multi-agent function custom_multi_agent_func returns None or an empty list, iterating over samples or calling random.shuffle(samples) will raise a TypeError. We should add a defensive check to ensure samples is not None or empty before processing.
| for sibling in samples: | |
| sibling.rollout_id = compact_rollout_id | |
| random.shuffle(samples) | |
| if samples: | |
| for sibling in samples: | |
| if sibling is not None: | |
| sibling.rollout_id = compact_rollout_id | |
| random.shuffle(samples) | |
| else: | |
| samples = [] |
|
|
||
| source "${SCRIPT_DIR}/models/qwen3-4B.sh" | ||
|
|
||
| python "${VIME_ROOT}/train.py" \ |
There was a problem hiding this comment.
Please use ray to submit task instead of using python directly, just ref the gpu script.
There was a problem hiding this comment.
You should put this script under examples/multi_agent folder
Signed-off-by: Windfeng8 <523758380@qq.com>
| --balance-data | ||
| ) | ||
|
|
||
| EVAL_ARGS=( |
There was a problem hiding this comment.
EVAL_ARGS and WANDB_ARGS can be removed since they are not used.
|
Could you add a short PR description covering what changes were made to the multi-agent example and why? |
done |
Added local token/logprob parsing for compatibility with the latest VIME.Assigned the same to sibling agent samples.