ms-swift icon indicating copy to clipboard operation
ms-swift copied to clipboard

"Address already in use" during multi-turn GRPO training on v4.0+

Open liudl85 opened this issue 8 months ago • 6 comments

Checklist / 检查清单

  • [x] I have searched existing issues, and this is a new bug report. / 我已经搜索过现有的 issues,确认这是一个新的 bug report。

Bug Description / Bug 描述

Im conducting multi-turn GRPO training with a distributed setup: one machine (8 GPUs) is used for rollout, and another machine is used for GRPO execution.

Referring to previous issues, regardless of how --vllm_server_group_port is provided, the process consistently fails at init_communicator with the error "Address already in use".

Has anyone encountered similar issues?

The exact same code runs successfully on version v3.12.5 (training qwen3), but switching to v4.0 or above (including the main branch) (training qwen3.5) results in errors.

update: single node works. multi-node fails every time.

How to Reproduce / 如何复现

ms-swift v4.0 and above official docker with image modelscope-registry.cn-hangzhou.cr.aliyuncs.com/modelscope-repo/modelscope:ubuntu22.04-cuda12.8.1-py311-torch2.10.0-vllm0.17.1-modelscope1.34.0-swift4.0.2

Additional Information / 补充信息

No response

liudl85 avatar Mar 21 '26 18:03 liudl85

cc @Jintao-Huang

liudl85 avatar Mar 23 '26 02:03 liudl85

Please clean up residual processes, attempt to reproduce the issue, and provide a minimal reproducible script along with the error stack trace.

hjh0119 avatar Mar 23 '26 02:03 hjh0119

@hjh0119 It's quite easy to reproduce

follow your demo on server_multi_node.sh

rollout:

CUDA_VISIBLE_DEVICES=0,1,2,3 \
NPROC_PER_NODE=4 swift rollout \
    --model Qwen/Qwen3.5-27B \
    --vllm_tensor_parallel_size 2 \
    --vllm_data_parallel_size 2 \
    --max_turns 10 \
    --vllm_use_async_engine True \
    --port 8000

grpo: don't forget --vllm_server_host

export MASTER_PORT=29500

NNODES=1 \
SWIFT_PATCH_CONV3D=1 \
CUDA_VISIBLE_DEVICES=0,1,2,3 \
NPROC_PER_NODE=4 \
swift rlhf \
    --rlhf_type grpo \
    --model Qwen/Qwen3.5-27B \
    --reward_funcs accuracy \
    --use_vllm true \
    --vllm_mode server \
    --dataset AI-MO/NuminaMath-TIR#1000 \
    --load_from_cache_file true \
    --max_completion_length 2048 \
    --per_device_train_batch_size 1 \
    --gradient_accumulation_steps 1 \
    --learning_rate 1e-6 \
    --save_total_limit 2 \
    --logging_steps 1 \
    --warmup_ratio 0.05 \
    --dataloader_num_workers 4 \
    --dataset_num_proc 4 \
    --num_generations 4 \
    --deepspeed zero3 \
    --log_completions true \
    --vllm_mode server \
    --vllm_server_host your_own \
    --vllm_server_port 8000 \
    --loss_scale last_round \
    --eval_strategy no \
    --importance_sampling_level sequence \

stack trace from rollout script:

[ERROR:swift] Method execution failed: collective_rpc
Traceback (most recent call last):
  File "/mnt/XXX/qwen35/ms-swift/swift/pipelines/infer/rollout.py", line 358, in async_llm_worker
    result = await method(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/vllm/v1/engine/async_llm.py", line 947, in collective_rpc
    return await self.engine_core.collective_rpc_async(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/vllm/v1/engine/core_client.py", line 1143, in collective_rpc_async
    return await self.call_utility_async(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/vllm/v1/engine/core_client.py", line 1390, in call_utility_async
    await asyncio.gather(
  File "/usr/local/lib/python3.11/site-packages/vllm/v1/engine/core_client.py", line 1064, in _call_utility_async
    return await future
           ^^^^^^^^^^^^
Exception: Call to collective_rpc method failed: Worker failed with error '[Errno 98] Address already in use', please check the stack trace above for the root cause

liudl85 avatar Mar 23 '26 03:03 liudl85

@hjh0119 any updates?

liudl85 avatar Mar 25 '26 03:03 liudl85

follow your demo on server_multi_node.sh

First: When using swift rollout, we do not specify NPROC_PER_NODE

Second: https://github.com/vllm-project/vllm/pull/30739 removed data parallelism (DP) for dense models

hjh0119 avatar Mar 25 '26 05:03 hjh0119

you saved my day! but that "Address already in use" is pretty confusing. you might want to update the docs or add some info in the comments.

liudl85 avatar Mar 25 '26 11:03 liudl85