Skip to content

[NPU] support multi-agent rollout pipeline#298

Open
Windfeng8 wants to merge 2 commits into
vllm-project:ascendfrom
Windfeng8:fix/multi-agent
Open

[NPU] support multi-agent rollout pipeline#298
Windfeng8 wants to merge 2 commits into
vllm-project:ascendfrom
Windfeng8:fix/multi-agent

Conversation

@Windfeng8

@Windfeng8 Windfeng8 commented Jun 30, 2026

Copy link
Copy Markdown

Added local token/logprob parsing for compatibility with the latest VIME.Assigned the same to sibling agent samples.

Signed-off-by: Windfeng8 <523758380@qq.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +22 to +25
new_response_log_probs = [
float(item.get("logprob", 0.0)) if isinstance(item, dict) else 0.0
for item in content_items
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Suggested change
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
]

Comment thread scripts/run-qwen3-4B-multi-agent-npu.sh Outdated
Comment on lines +5 to +20
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}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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.

Suggested change
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}"

Comment on lines +43 to 46
for sibling in samples:
sibling.rollout_id = compact_rollout_id

random.shuffle(samples)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Suggested change
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 = []

@Windfeng8 Windfeng8 changed the title support multi-agent rollout pipeline [NPU] support multi-agent rollout pipeline Jun 30, 2026
Comment thread scripts/run-qwen3-4B-multi-agent-npu.sh Outdated

source "${SCRIPT_DIR}/models/qwen3-4B.sh"

python "${VIME_ROOT}/train.py" \

@floatlibai floatlibai Jun 30, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use ray to submit task instead of using python directly, just ref the gpu script.

@Windfeng8 Windfeng8 Jul 1, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified

Comment thread scripts/run-qwen3-4B-multi-agent-npu.sh Outdated

@floatlibai floatlibai Jun 30, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should put this script under examples/multi_agent folder

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Modified

Signed-off-by: Windfeng8 <523758380@qq.com>
--balance-data
)

EVAL_ARGS=(

@floatlibai floatlibai Jul 1, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EVAL_ARGS and WANDB_ARGS can be removed since they are not used.

@floatlibai

Copy link
Copy Markdown

Could you add a short PR description covering what changes were made to the multi-agent example and why?

@Windfeng8

Copy link
Copy Markdown
Author

Could you add a short PR description covering what changes were made to the multi-agent example and why?

done

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.

2 participants