modelscope / modelscope/ms-swift

swift 3.10.1 colocate 模式 grpo 训练出现乱码

Open
#6,736 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

npu
Dominant language
Python
Stars
15.7k
Forks
1.7k
Avg merge
1d 16h
Merged PRs (30d)
136

Description

在使用自己数据启动grpo训练过程中,发现模型采样的回答全部都是乱码。

尝试将rl数据变成一些简单问题,此时采样的回答正常。如下assistant部分所示:

NFO 11-24 20:41:24 [worker_v1.py:127] Sleep mode freed 11.70 GiB memory, 3.70 GiB memory is still in use.
INFO 11-24 20:41:24 [executor_base.py:188] It took 0.671789 seconds to fall asleep.
INFO 11-24 20:41:24 [worker_v1.py:127] Sleep mode freed 11.70 GiB memory, 3.32 GiB memory is still in use.
INFO 11-24 20:41:24 [executor_base.py:188] It took 0.682231 seconds to fall asleep.
msg=[{'role': 'system', 'content': 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.'}, {'role': 'user', 'content': '32乘以64等于多少?', 'loss': None}, {'role': 'assistant', 'content': '32乘以64等于2048。'}]error_reason='Missing target tools: card.getAlarms'reward=0
msg=[{'role': 'system', 'content': 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.'}, {'role': 'user', 'content': '32乘以64等于多少?', 'loss': None}, {'role': 'assistant', 'content': '32乘以64等于2048。'}]error_reason='Missing target tools: card.getAlarms'reward=0
msg=[{'role': 'system', 'content': 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.'}, {'role': 'user', 'content': '32乘以64等于多少?', 'loss': None}, {'role': 'assistant', 'content': '32乘以64等于2048。'}]error_reason='Missing target tools: card.getAlarms'reward=0
msg=[{'role': 'system', 'content': 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.'}, {'role': 'user', 'content': '32乘以64等于多少?', 'loss': None}, {'role': 'assistant', 'content': '32乘以64等于2048。'}]error_reason='Missing target tools: card.getAlarms'reward=0
[INFO:swift] Memory cleanup attempt 1: Freed 0.08 GB reserved, 0.00 GB allocated
msg=[{'role': 'system', 'content': 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.'}, {'role': 'user', 'content': '32乘以64等于多少?', 'loss': None}, {'role': 'assistant', 'content': '32乘以64等于2048。'}]error_reason='Missing target tools: card.getAlarms'reward=0
msg=[{'role': 'system', 'content': 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.'}, {'role': 'user', 'content': '32乘以64等于多少?', 'loss': None}, {'role': 'assistant', 'content': '32乘以64等于2048。'}]error_reason='Missing target tools: card.getAlarms'reward=0
msg=[{'role': 'system', 'content': 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.'}, {'role': 'user', 'content': '32乘以64等于多少?', 'loss': None}, {'role': 'assistant', 'content': '32乘以64等于2048。'}]error_reason='Missing target tools: card.getAlarms'reward=0
msg=[{'role': 'system', 'content': 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.'}, {'role': 'user', 'content': '32乘以64等于多少?', 'loss': None}, {'role': 'assistant', 'content': '32乘以64等于2048。'}]error_reason='Missing target tools: card.getAlarms'reward=0
{'loss': 0.0, 'grad_norm': 0.0, 'learning_rate': 0.0002, 'completions/mean_length': 13.0, 'completions/min_length': 13.0, 'completions/max_length': 13.0, 'completions/clipped_ratio': 0.0, 'reward': 0.0, 'reward_std': 0.0, 'frac_reward_zero_std': 1.0, 'rewards/SPNMultiTurnToolUseReward/mean': 0.0, 'rewards/SPNMultiTurnToolUseReward/std': 0.0, 'entropy/mean': 0.03173828, 'entropy/max': 0.03173828, 'entropy/min': 0.03173828, 'clip_ratio/low_mean': 0.0, 'clip_ratio/low_min': 0.0, 'clip_ratio/high_mean': 0.0, 'clip_ratio/high_max': 0.0, 'clip_ratio/region_mean': 0.0, 'epoch': 2.0, 'global_step/max_steps': '2/50', 'percentage': '4.00%', 'elapsed_time': '1m 45s', 'remaining_time': '42m 16s', 'train_speed(iter/s)': 0.01892}
Train:   4%|███████▊                                                                                                                                                                                           | 2/50 [01:45<37:55, 47.41s/it][INFO:swift] Saving model checkpoint to /data/lab/results/Agent/rl/test/v4-20251124-203722/checkpoint-2

但是换成更难的问题,就不太对劲了

msg=[{'role': 'system', 'content': 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.'}, {'role': 'user', 'content': '【故障现象】  \n09:15:22起东莞莞城汇聚节点(NE-001203)至东莞万江接入节点(NE-001204)间出现多条MPLS-TP隧道(TUN-Lib-Main/TUN-Gov-Main)异常倒换,同时东莞图书馆视频监控业务(Lib-Video-SVC)出现持续300ms以上单向时延突增(≥120ms),政务中心办公VPN(Gov-Office-VPN)在09:18:45检测到AC侧PW-Lib-001承载通道的CV帧丢失告警,伴随NE-001203北向端口(1/0/1)的OSPF邻居状态异常抖动(Up→Down→Up切换3次)。  \n\n【网络拓扑】  \n涉及网元:NE-001203(`ce56023d-fdc2-11ec-854b-286ed4bd1256`)及其主控板`e1f2g3h4-fdc6-11ec-9b9c-286ed4bd1356`  \n关联链路:  \n- LNK-001202-203(`f23a425c-fdc4-11ec-9f2b-286ed4bd1255`):连接NE-001202[1/0/3](`b4f8c4d4-fdc3-11ec-8ea1-286ed4bd1257`)与NE-001203[1/0/1](`c5f8d5e5-fdc3-11ec-8ea1-286ed4bd1258`)  \n- LNK-001203-204(`f34a536d-fdc4-11ec-9f2b-286ed4bd1256`):连接NE-001203[1/0/2](`c6f8e6f6-fdc3-11ec-8ea1-286ed4bd1259`)与NE-001204[1/0/1](`d7f8f707-fdc3-11ec-8ea1-286ed4bd1260`)  \n承载业务:  \n- Lib-Video-SVC(`2cdeed06-fdc5-11ec-ad8c-286ed4bd1260`)经TUN-Lib-Main(`067b86a0-fdc5-11ec-ad8c-286ed4bd1254`)路径NE-001201→NE-001202→NE-001203  \n- Gov-Office-VPN(`2deffe17-fdc5-11ec-ad8c-286ed4bd1261`)经TUN-Gov-Protect(`09abb9d3-fdc5-11ec-ad8c-286ed4bd1257`)路径NE-001201→NE-001202→NE-001203→NE-001204', 'loss': None}, {'role': 'assistant', 'content': '褶1000123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123'}]
msg=[{'role': 'system', 'content': 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.'}, {'role': 'user', 'content': '【故障现象】  \n09:15:22起东莞莞城汇聚节点(NE-001203)至东莞万江接入节点(NE-001204)间出现多条MPLS-TP隧道(TUN-Lib-Main/TUN-Gov-Main)异常倒换,同时东莞图书馆视频监控业务(Lib-Video-SVC)出现持续300ms以上单向时延突增(≥120ms),政务中心办公VPN(Gov-Office-VPN)在09:18:45检测到AC侧PW-Lib-001承载通道的CV帧丢失告警,伴随NE-001203北向端口(1/0/1)的OSPF邻居状态异常抖动(Up→Down→Up切换3次)。  \n\n【网络拓扑】  \n涉及网元:NE-001203(`ce56023d-fdc2-11ec-854b-286ed4bd1256`)及其主控板`e1f2g3h4-fdc6-11ec-9b9c-286ed4bd1356`  \n关联链路:  \n- LNK-001202-203(`f23a425c-fdc4-11ec-9f2b-286ed4bd1255`):连接NE-001202[1/0/3](`b4f8c4d4-fdc3-11ec-8ea1-286ed4bd1257`)与NE-001203[1/0/1](`c5f8d5e5-fdc3-11ec-8ea1-286ed4bd1258`)  \n- LNK-001203-204(`f34a536d-fdc4-11ec-9f2b-286ed4bd1256`):连接NE-001203[1/0/2](`c6f8e6f6-fdc3-11ec-8ea1-286ed4bd1259`)与NE-001204[1/0/1](`d7f8f707-fdc3-11ec-8ea1-286ed4bd1260`)  \n承载业务:  \n- Lib-Video-SVC(`2cdeed06-fdc5-11ec-ad8c-286ed4bd1260`)经TUN-Lib-Main(`067b86a0-fdc5-11ec-ad8c-286ed4bd1254`)路径NE-001201→NE-001202→NE-001203  \n- Gov-Office-VPN(`2deffe17-fdc5-11ec-ad8c-286ed4bd1261`)经TUN-Gov-Protect(`09abb9d3-fdc5-11ec-ad8c-286ed4bd1257`)路径NE-001201→NE-001202→NE-001203→NE-001204', 'loss': None}, {'role': 'assistant', 'content': '褶32013年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,2022年10月1日,'}]

同样的问题和模型,在非训练环境使用vllm推理,回答是正常的,如下:

'根据您提供的故障现象描述,我们可以对东莞莞城汇聚节点和东莞万江接入节点之间的MPLS-TP隧道进行分析。以下是可能的原因及建议:\n\n### 案件一:多条MPLS-TP隧道异常倒换\n\n**原因分析:...

系统:4.19.90-vhulk2211.3.0.h1543.eulerosv2r10.aarch64
NPU:910B4 32GB
CANN:CANN-8.3.RC1.alpha001
gcc:10.3.1
conda
python: 3.10
trl: 0.19.0
transformers:4.56.2
torch/torch_npu: 2.8.0/2.8.0rc1
vllm/vllm_ascend: 0.10.2+empty / 0.10.2rc1
peft:0.14.0
deepspeed:0.16.9

启动代码如下:

#!/bin/bash

swift rlhf \
    --dataset /data/lab/datasets/Agent/rl/test.json \
    --external_plugins /data/lab/work_dir/ms-swift-3.10.1/examples/train/grpo/plugin/spn_agent.py \
    --reward_funcs external_spn_multi_turn_tool_use_reward \
    --beta 0 \
    --dataloader_num_workers 4 \
    --dataset_shuffle True \
    --epsilon_high 0.28 \
    --generation_batch_size 8 \
    --num_generations 8 \
    --gradient_accumulation_steps 16 \
    --importance_sampling_level token \
    --learning_rate 3e-4 \
    --log_completions true \
    --log_entropy true \
    --logging_steps 1 \
    --loss_type bnpo \
    --lr_scheduler_type cosine \
    --num_train_epochs 50 \
    --max_completion_length 2048 \
    --max_resample_times 1 \
    --model /data/lab/models/Qwen2_5-0_5B-Instruct/ \
    --model_type qwen2_5 \
    --move_model_batches 32 \
    --num_iterations 1 \
    --output_dir "$SAVE_URL" \
    --per_device_eval_batch_size 1 \
    --per_device_train_batch_size 1 \
    --repetition_penalty 1 \
    --reward_weights 1 \
    --rlhf_type grpo \
    --save_steps 1 \
    --save_total_limit 100 \
    --sequence_parallel_size 1 \
    --soft_cache_length 512 \
    --temperature 0.6 \
    --torch_dtype bfloat16 \
    --train_type lora \
    --warmup_ratio 0.05 \
    --use_vllm true \
    --vllm_mode colocate \
    --sleep_level 1 \
    --offload_optimizer false \
    --offload_model false \
    --vllm_tensor_parallel_size 2 \
    --vllm_gpu_memory_utilization 0.5 \
    --vllm_max_model_len 32768 \
    --vllm_enable_prefix_caching True \
    --deepspeed zero3

请问这是精度问题吗?还是昇腾vllm的适配问题?或是我的启动命令配置不对?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the shown swift rlhf launch script and the external plugin at /data/lab/work_dir/ms-swift-3.10.1/examples/train/grpo/plugin/spn_agent.py; compare this training path with the reported normal vLLM inference environment. Reproduce using both the simple and long network-fault prompts, and consider the issue resolved when long-prompt GRPO sampling no longer produces乱码.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, python
Domain
ai, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.