modelscope / modelscope/ms-swift

Best-Practice of Qwen3.5 GRPO training by Megatron-Swift

Open
#8,289 19 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Checklist / 检查清单
  • I have searched existing issues, and this is a new question or discussion topic. / 我已经搜索过现有的 issues,确认这是一个新的问题与讨论。
Question Description / 问题描述

MS-Swift v4.0.1版本中,Qwen3.5-9B采用ms-swift训练GRPO速度很慢,参考 https://github.com/modelscope/ms-swift/issues/8241#issuecomment-4028489645 后安装了 flash-linear-attentioncausal-conv1d ,但是仍然很慢。

有以下几个问题请教:

  1. 下面的参数中是否需要调整?
  2. 是否需要采用Megatron-Swift?
  3. 能否提供Megatron-Swift微调Qwen3.5的完整实践,类似于 https://swift.readthedocs.io/zh-cn/latest/BestPractices/Qwen3_5-Best-Practice.html ,这里面只有ms-swift部分。
  4. 采用ms-swift做sft训练时速度并不慢,为什么做grpo时速度会很慢?
# CUDA_VISIBLE_DEVICES=0,1 \
# swift rollout \
#     --model output/qwen3d5-sft/checkpoint-1077/ \
#     --vllm_tensor_parallel_size  2 \
#     --port 9000

NPROC_PER_NODE=6 \
CUDA_VISIBLE_DEVICES=2,3,4,5,6,7 \
swift rlhf \
    --rlhf_type grpo \
    --tuner_type full \
    --model output/qwen3d5-sft/checkpoint-1077/ \
    --dataset 'my_dataset_grpo_train.json' \
    --val_dataset 'my_dataset_grpo_val.json' \
    --external_plugins rewards_plugin.py \
    --reward_funcs format accuracy \
    --reward_weights 0.8 0.2 \
    --max_pixels 1605632 \
    --beta 0.001 \
    --epsilon 0.2 \
    --epsilon_high 0.28 \
    --loss_type grpo \
    --use_vllm true \
    --vllm_mode server \
    --vllm_server_host 127.0.0.1 \
    --vllm_server_port 9000 \
    --freeze_aligner false \
    --freeze_vit false \
    --add_non_thinking_prefix true \
    --torch_dtype bfloat16 \
    --load_from_cache_file true \
    --max_length 8096 \
    --max_completion_length 4096 \
    --overlong_filter false \
    --num_train_epochs 5 \
    --per_device_train_batch_size 4 \
    --per_device_eval_batch_size 4 \
    --learning_rate 1e-6 \
    --gradient_accumulation_steps 8 \
    --save_strategy 'steps' \
    --eval_strategy 'steps' \
    --eval_steps 5 \
    --save_steps 5 \
    --save_total_limit 3 \
    --logging_steps 1 \
    --output_dir output/qwen3d5-grpo \
    --warmup_ratio 0.01 \
    --dataloader_num_workers 4 \
    --num_generations 8 \
    --temperature 1.0 \
    --deepspeed zero3 \
    --log_completions true \
    --num_iterations 1 \
    --async_generate false \
    --attn_impl flash_attn

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 linked Qwen3.5 best-practice page and issue 8241's comment, then review the shown swift rollout and swift rlhf commands and their Megatron-Swift question. Done means documenting a complete Qwen3.5 GRPO workflow and addressing the parameter, speed, and ms-swift versus Megatron-Swift questions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation, machine-learning
Issue type
Documentation
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.