Grpo + Lora training in qwen3-vl-8b too slow.
System Info
使用grpo+lora 训练qwen3-vl-8b 训练速度很慢,我的环境如下: torch 2.9 transforms 4.57.1 vllm 0.15.1
训练一个steps 大概了花了2个多小时,日志如下: [36m(TaskRunner pid=7951)[0m step:1 - global_seqlen/min:222592 - global_seqlen/max:232040 - global_seqlen/minmax_diff:9448 - g lobal_seqlen/balanced_min:228026 - global_seqlen/balanced_max:228029 - global_seqlen/mean:228028.25 - actor/entropy:0.12098485976457596 - perf/mfu/actor_infer:0 - actor/pg_loss:-0.0005714366852771491 - actor/kl_loss:0.0 - actor/pg_clipfrac:0.0 - actor/ppo_kl:0.0 - actor/pg_clipfrac_lower:0.0 - actor/kl_coef:0.01 - actor/grad_norm:0.014865432865917683 - perf/mfu/actor:0.01620713721018676 - perf/max_memory_allocated_gb:24.94600486755371 - perf/max_memory_reserved_gb:25.0234375 - perf/cpu_memory_used_gb:145.13869953155518 - perf/gpu_memory_utilization_allocated:0.31431848754470126 - perf/gpu_memory_utilization_reserved:0.31485078295009533 - actor/lr:1e-06 - training/global_step:1 - training/epoch:0 - critic/score/mean:0.00390625 - critic/score/max:1.0 - critic/score/min:0.0 - critic/rewards/mean:0.00390625 - critic/rewards/max:1.0 - critic/rewards/min:0.0 - critic/advantages/mean:-0.00011180120054632425 - critic/advantages/max:1.4999970197677612 - critic/advantages/min:-0.4999989867210388 - critic/returns/mean:-0.00011180120054632425 - critic/returns/max:1.4999970197677612 - critic/returns/min:-0.4999989867210388 - response_length/mean:43.673828125 - response_length/max:310.0 - response_length/min:19.0 - response_length/clip_ratio:0.0 - response_length_non_aborted/mean:43.673828125 - response_length_non_aborted/max:310.0 - response_length_non_aborted/min:19.0 - response_length_non_aborted/clip_ratio:0.0 - response/aborted_ratio:0.0 - prompt_length/mean:1737.796875 - prompt_length/max:1945.0 - prompt_length/min:1295.0 - prompt_length/clip_ratio:0.0 - num_turns/min:2 - num_turns/max:2 - num_turns/mean:2.0 - timing_s/start_profile:0.00028222426772117615 - timing_s/agent_loop/num_preempted/min:-1 - timing_s/agent_loop/num_preempted/max:-1 - timing_s/agent_loop/num_preempted/mean:-1.0 - timing_s/agent_loop/generate_sequences/min:5.930335588753223 - timing_s/agent_loop/generate_sequences/max:12.631410740315914 - timing_s/agent_loop/generate_sequences/mean:8.504107826687687 - timing_s/agent_loop/tool_calls/min:0.0 - timing_s/agent_loop/tool_calls/max:0.0 - timing_s/agent_loop/tool_calls/mean:0.0 - timing_s/agent_loop/slowest/generate_sequences:12.631410740315914 - timing_s/agent_loop/slowest/tool_calls:0.0 - timing_s/agent_loop/slowest/prompt_length:1843 - timing_s/agent_loop/slowest/response_length:310 - timing_s/agent_loop/slowest/num_preempted:-1 - timing_s/gen:21.33842097967863 - timing_s/reward:3.471598029136658e-05 - timing_s/old_log_prob:2534.4657267387956 - timing_s/ref:2538.725990263745 - timing_s/adv:0.022052621468901634 - timing_s/update_actor:2597.0202489718795 - timing_s/update_weights:11.08579715155065 - timing_s/dump_rollout_generations:0.47738963551819324 - timing_s/step:7703.950629860163 - timing_s/stop_profile:5.0107017159461975e-05 - timing_per_token_ms/adv:2.417751031824087e-05 - timing_per_token_ms/gen:0.9542695308652847 - timing_per_token_ms/update_actor:2.8472571369686426 - timing_per_token_ms/ref:2.7833459124732847 - perf/total_num_tokens:912113 - perf/time_per_step:7703.950629860163 - perf/throughput:29.598872183340955
请帮忙分析下原因以及给出解决方案吗?
Information
- [ ] The official example scripts
- [x] My own modified scripts
Tasks
- [ ] An officially supported task in the
examplesfolder (such as GLUE/SQuAD, ...) - [x] My own task or dataset (give details below)
Reproduction
训练配置如下:
algorithm.adv_estimator=grpo
data.train_files=${DATA_RES}/train.parquet
data.val_files=${DATA_RES}/test.parquet
data.train_batch_size=128
data.max_prompt_length=4096
data.max_response_length=1024
data.dataloader_num_workers=4
data.filter_overlong_prompts=True
data.truncation='error'
data.image_key=images
data.prompt_key=prompts
actor_rollout_ref.model.path=${MODEL_RES_0}
actor_rollout_ref.model.trust_remote_code=False
actor_rollout_ref.actor.optim.lr=1e-6
actor_rollout_ref.actor.freeze_vision_tower=True
actor_rollout_ref.model.lora_rank=64
actor_rollout_ref.model.lora_alpha=128
actor_rollout_ref.model.target_modules='[q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj]'
actor_rollout_ref.model.exclude_modules='.visual.'
actor_rollout_ref.rollout.load_format=safetensors
actor_rollout_ref.model.use_remove_padding=False
actor_rollout_ref.actor.ppo_mini_batch_size=128
actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=8
actor_rollout_ref.actor.use_kl_loss=True
actor_rollout_ref.actor.kl_loss_coef=0.01
actor_rollout_ref.actor.kl_loss_type=low_var_kl
actor_rollout_ref.actor.entropy_coeff=0
actor_rollout_ref.model.enable_gradient_checkpointing=True
actor_rollout_ref.actor.fsdp_config.param_offload=False
actor_rollout_ref.actor.fsdp_config.model_dtype=bf16
actor_rollout_ref.actor.fsdp_config.optimizer_offload=False
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=8
actor_rollout_ref.rollout.tensor_model_parallel_size=2
actor_rollout_ref.rollout.name=vllm
+actor_rollout_ref.rollout.engine_kwargs.vllm.limit_mm_per_prompt.images=1
actor_rollout_ref.rollout.max_model_len=6144
actor_rollout_ref.ref.log_prob_use_dynamic_bsz=True
actor_rollout_ref.ref.log_prob_max_token_len_per_gpu=6144
actor_rollout_ref.rollout.log_prob_use_dynamic_bsz=True
actor_rollout_ref.rollout.log_prob_max_token_len_per_gpu=6144
actor_rollout_ref.rollout.gpu_memory_utilization=0.5
actor_rollout_ref.rollout.enable_chunked_prefill=True
actor_rollout_ref.rollout.enforce_eager=False
actor_rollout_ref.rollout.free_cache_engine=False
actor_rollout_ref.rollout.n=4
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=8
actor_rollout_ref.ref.fsdp_config.param_offload=False
algorithm.use_kl_in_reward=False
trainer.critic_warmup=0
trainer.logger='["console","wandb"]'
trainer.project_name='verl_grpo_merchant_profiling'
trainer.experiment_name='qwen_vl_merchant_profiling_lora'
trainer.n_gpus_per_node=4
trainer.nnodes=1
trainer.save_freq=20
trainer.test_freq=5 \
Expected behavior
理论上训练一个step需要的时候应该是几分钟。
一样的错误,qwen2.5vl就是正常的
Looking at your timing breakdown, the bottleneck is clear:
timing_s/old_log_prob: 2534s(32% of step time)timing_s/ref: 2538s(32% of step time)timing_s/update_actor: 2597s(33% of step time)
This is abnormally slow for a single step. The issue is likely:
-
Qwen3-VL architecture changes: Qwen3-VL has different attention patterns compared to Qwen2.5-VL. The DeepStack architecture may not be optimized in vLLM 0.15.1 yet.
-
micro_batch_size too small:
ppo_micro_batch_size_per_gpu=8is reasonable, butlog_prob_micro_batch_size_per_gpu=8with Qwen3-VL's large sequence lengths may be too conservative. -
use_remove_padding=False: This is significant. With
use_remove_padding=False, you're not benefiting from the thd format optimization that handles variable-length sequences efficiently.
Solutions:
- Enable remove_padding:
actor_rollout_ref.model.use_remove_padding=True
- Increase log_prob batch size:
actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=16
actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=16
-
Check vLLM version: vLLM 0.15.1 may have issues with Qwen3-VL. Try downgrading to 0.14.x or check for Qwen3-VL specific optimizations.
-
Reduce sequence length temporarily:
max_model_len=6144with images is memory-intensive. Try 4096 to isolate the issue.
@AllenRay Did you solve the problem?
@Kirrito-k423 Is the version of vLLM related with old_log_prob amd update_actor process??
- transformers: 4.57.3
- torch: 2.9.0+cu129
- flash-attn: 2.8.1
I experienced the same bottleneck while training Qwen3-VL-8B with SAPO + LoRA (rollout.n=8, 8 GPUs).
Vision encoder was taking ~10s per image, making compute_log_prob take hours.
Root cause is still unknown, but the slowdown appears to be in the HF transformers vision encoder path (not vLLM).
I bypassed the issue with two approaches:
-
Dedup vision inputs across rollout.n: With rollout.n=8, the same image is processed 8 times. By passing only unique images to the vision encoder and expanding the outputs, we reduced vision encoder calls 8x. (660 images/GPU → 82, elapsed 6420s → 154s)
-
Cache vision embeddings between compute_log_prob and update_policy: Since the vision encoder is frozen (LoRA only trains the LLM), we cache the image embeddings from
compute_log_proband reuse them inupdate_policy, skipping the vision encoder entirely on the second pass.
Also tried excluding Qwen3VLVisionBlock from FSDP2 individual wrapping
(32 VisionBlocks → each doing all-gather/reshard), but saw no improvement.
System Info
使用grpo+lora 训练qwen3-vl-8b 训练速度很慢,我的环境如下: torch 2.9 transforms 4.57.1 vllm 0.15.1
训练一个steps 大概了花了2个多小时,日志如下: [36m(TaskRunner pid=7951)[0m step:1 - global_seqlen/min:222592 - global_seqlen/max:232040 - global_seqlen/minmax_diff:9448 - g lobal_seqlen/balanced_min:228026 - global_seqlen/balanced_max:228029 - global_seqlen/mean:228028.25 - actor/entropy:0.12098485976457596 - perf/mfu/actor_infer:0 - actor/pg_loss:-0.0005714366852771491 - actor/kl_loss:0.0 - actor/pg_clipfrac:0.0 - actor/ppo_kl:0.0 - actor/pg_clipfrac_lower:0.0 - actor/kl_coef:0.01 - actor/grad_norm:0.014865432865917683 - perf/mfu/actor:0.01620713721018676 - perf/max_memory_allocated_gb:24.94600486755371 - perf/max_memory_reserved_gb:25.0234375 - perf/cpu_memory_used_gb:145.13869953155518 - perf/gpu_memory_utilization_allocated:0.31431848754470126 - perf/gpu_memory_utilization_reserved:0.31485078295009533 - actor/lr:1e-06 - training/global_step:1 - training/epoch:0 - critic/score/mean:0.00390625 - critic/score/max:1.0 - critic/score/min:0.0 - critic/rewards/mean:0.00390625 - critic/rewards/max:1.0 - critic/rewards/min:0.0 - critic/advantages/mean:-0.00011180120054632425 - critic/advantages/max:1.4999970197677612 - critic/advantages/min:-0.4999989867210388 - critic/returns/mean:-0.00011180120054632425 - critic/returns/max:1.4999970197677612 - critic/returns/min:-0.4999989867210388 - response_length/mean:43.673828125 - response_length/max:310.0 - response_length/min:19.0 - response_length/clip_ratio:0.0 - response_length_non_aborted/mean:43.673828125 - response_length_non_aborted/max:310.0 - response_length_non_aborted/min:19.0 - response_length_non_aborted/clip_ratio:0.0 - response/aborted_ratio:0.0 - prompt_length/mean:1737.796875 - prompt_length/max:1945.0 - prompt_length/min:1295.0 - prompt_length/clip_ratio:0.0 - num_turns/min:2 - num_turns/max:2 - num_turns/mean:2.0 - timing_s/start_profile:0.00028222426772117615 - timing_s/agent_loop/num_preempted/min:-1 - timing_s/agent_loop/num_preempted/max:-1 - timing_s/agent_loop/num_preempted/mean:-1.0 - timing_s/agent_loop/generate_sequences/min:5.930335588753223 - timing_s/agent_loop/generate_sequences/max:12.631410740315914 - timing_s/agent_loop/generate_sequences/mean:8.504107826687687 - timing_s/agent_loop/tool_calls/min:0.0 - timing_s/agent_loop/tool_calls/max:0.0 - timing_s/agent_loop/tool_calls/mean:0.0 - timing_s/agent_loop/slowest/generate_sequences:12.631410740315914 - timing_s/agent_loop/slowest/tool_calls:0.0 - timing_s/agent_loop/slowest/prompt_length:1843 - timing_s/agent_loop/slowest/response_length:310 - timing_s/agent_loop/slowest/num_preempted:-1 - timing_s/gen:21.33842097967863 - timing_s/reward:3.471598029136658e-05 - timing_s/old_log_prob:2534.4657267387956 - timing_s/ref:2538.725990263745 - timing_s/adv:0.022052621468901634 - timing_s/update_actor:2597.0202489718795 - timing_s/update_weights:11.08579715155065 - timing_s/dump_rollout_generations:0.47738963551819324 - timing_s/step:7703.950629860163 - timing_s/stop_profile:5.0107017159461975e-05 - timing_per_token_ms/adv:2.417751031824087e-05 - timing_per_token_ms/gen:0.9542695308652847 - timing_per_token_ms/update_actor:2.8472571369686426 - timing_per_token_ms/ref:2.7833459124732847 - perf/total_num_tokens:912113 - perf/time_per_step:7703.950629860163 - perf/throughput:29.598872183340955
请帮忙分析下原因以及给出解决方案吗?
Information
* [ ] The official example scripts[x] My own modified scriptsTasks
* [ ] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)[x] My own task or dataset (give details below)Reproduction
训练配置如下: algorithm.adv_estimator=grpo data.train_files=${DATA_RES}/train.parquet data.val_files=${DATA_RES}/test.parquet data.train_batch_size=128 data.max_prompt_length=4096 data.max_response_length=1024 data.dataloader_num_workers=4 data.filter_overlong_prompts=True data.truncation='error' data.image_key=images data.prompt_key=prompts actor_rollout_ref.model.path=${MODEL_RES_0} actor_rollout_ref.model.trust_remote_code=False actor_rollout_ref.actor.optim.lr=1e-6 actor_rollout_ref.actor.freeze_vision_tower=True actor_rollout_ref.model.lora_rank=64 actor_rollout_ref.model.lora_alpha=128 actor_rollout_ref.model.target_modules='[q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj]' actor_rollout_ref.model.exclude_modules='.visual.' actor_rollout_ref.rollout.load_format=safetensors actor_rollout_ref.model.use_remove_padding=False actor_rollout_ref.actor.ppo_mini_batch_size=128 actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=8 actor_rollout_ref.actor.use_kl_loss=True actor_rollout_ref.actor.kl_loss_coef=0.01 actor_rollout_ref.actor.kl_loss_type=low_var_kl actor_rollout_ref.actor.entropy_coeff=0 actor_rollout_ref.model.enable_gradient_checkpointing=True actor_rollout_ref.actor.fsdp_config.param_offload=False actor_rollout_ref.actor.fsdp_config.model_dtype=bf16 actor_rollout_ref.actor.fsdp_config.optimizer_offload=False actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=8 actor_rollout_ref.rollout.tensor_model_parallel_size=2 actor_rollout_ref.rollout.name=vllm +actor_rollout_ref.rollout.engine_kwargs.vllm.limit_mm_per_prompt.images=1 actor_rollout_ref.rollout.max_model_len=6144 actor_rollout_ref.ref.log_prob_use_dynamic_bsz=True actor_rollout_ref.ref.log_prob_max_token_len_per_gpu=6144 actor_rollout_ref.rollout.log_prob_use_dynamic_bsz=True actor_rollout_ref.rollout.log_prob_max_token_len_per_gpu=6144 actor_rollout_ref.rollout.gpu_memory_utilization=0.5 actor_rollout_ref.rollout.enable_chunked_prefill=True actor_rollout_ref.rollout.enforce_eager=False actor_rollout_ref.rollout.free_cache_engine=False actor_rollout_ref.rollout.n=4 actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=8 actor_rollout_ref.ref.fsdp_config.param_offload=False algorithm.use_kl_in_reward=False trainer.critic_warmup=0 trainer.logger='["console","wandb"]' trainer.project_name='verl_grpo_merchant_profiling' trainer.experiment_name='qwen_vl_merchant_profiling_lora' trainer.n_gpus_per_node=4 trainer.nnodes=1 trainer.save_freq=20 trainer.test_freq=5 \
Expected behavior
理论上训练一个step需要的时候应该是几分钟。
请问 你的cuda版本是多少? @AllenRay
Have the same issue. My experience is on Qwen3-VL-4B.
- Code and image built both on 5/15 commit 5b8986b, i.e., env packages exactly from Dockerfile.stable.vllm of that commit, i.e., transfomers 5.3.0, vllm 0.18.0
On geo3k, clearly slower than full training. See below for the plot: yellow is full training, red is LoRA (256). I tried small LoRA like 16/32, the same.
Have the same issue. My experience is on Qwen3-VL-4B.
* Code and image built both on [5/15 commit 5b8986b](https://github.com/verl-project/verl/commit/5b8986bb94237163c603ed9be08d2f73c3e5d0ba), i.e., env packages exactly from [Dockerfile.stable.vllm of that commit](https://github.com/verl-project/verl/blob/5b8986bb94237163c603ed9be08d2f73c3e5d0ba/docker/Dockerfile.stable.vllm), i.e., transfomers 5.3.0, vllm 0.18.0On geo3k, clearly slower than full training. See below for the plot: yellow is full training, red is LoRA (256). I tried small LoRA like 16/32, the same.
![]()
请问你cuda版本是多少?
Have the same issue. My experience is on Qwen3-VL-4B.
* Code and image built both on [5/15 commit 5b8986b](https://github.com/verl-project/verl/commit/5b8986bb94237163c603ed9be08d2f73c3e5d0ba), i.e., env packages exactly from [Dockerfile.stable.vllm of that commit](https://github.com/verl-project/verl/blob/5b8986bb94237163c603ed9be08d2f73c3e5d0ba/docker/Dockerfile.stable.vllm), i.e., transfomers 5.3.0, vllm 0.18.0On geo3k, clearly slower than full training. See below for the plot: yellow is full training, red is LoRA (256). I tried small LoRA like 16/32, the same.
![]()
请问你cuda版本是多少?
@cqray1990 : cu129 (using the exact original dockerfile making the image, FROM nvidia/cuda:12.9.1-devel-ubuntu24.04)
Have the same issue. My experience is on Qwen3-VL-4B.
* Code and image built both on [5/15 commit 5b8986b](https://github.com/verl-project/verl/commit/5b8986bb94237163c603ed9be08d2f73c3e5d0ba), i.e., env packages exactly from [Dockerfile.stable.vllm of that commit](https://github.com/verl-project/verl/blob/5b8986bb94237163c603ed9be08d2f73c3e5d0ba/docker/Dockerfile.stable.vllm), i.e., transfomers 5.3.0, vllm 0.18.0On geo3k, clearly slower than full training. See below for the plot: yellow is full training, red is LoRA (256). I tried small LoRA like 16/32, the same.
![]()
请问你cuda版本是多少?
@cqray1990 : cu129 (using the exact original dockerfile making the image,
FROM nvidia/cuda:12.9.1-devel-ubuntu24.04)
also it's very slow
补充分析:从日志看,主要瓶颈不是 rollout 生成,timing_s/gen 只有约 21s;慢在 old_log_prob、ref、update_actor 三个 HF/FSDP forward 相关阶段,每个约 2500s。
结合后续复现,较可能的原因是 Qwen3-VL 的 vision encoder 在 GRPO/SAPO + LoRA 多阶段里被重复执行。即使设置了 actor_rollout_ref.actor.freeze_vision_tower=True 和 LoRA 只训练 LLM,当前 forward 路径仍会用 pixel_values 调 model.visual(...) 生成视觉 embedding;rollout.n=4/8 时同一张图还会随多条 response 重复进入 log_prob/ref/update 阶段。
可尝试的规避/优化:
- 先 profile
model.visual(...)或 HF vision encoder,确认 compute_log_prob/update_actor 中每张图的耗时。 - 对同一 prompt/image 在
rollout.n维度做去重,只编码唯一图片,再把视觉 embedding expand 回各条 response。 - 因为 vision tower 已冻结,缓存 compute_log_prob 阶段的 image/deepstack embeddings,并在 update_policy 阶段复用,避免第二次 vision encoder forward。
- 配置侧仍建议打开
actor_rollout_ref.model.use_remove_padding=True,并按显存增大ref/rollout.log_prob_micro_batch_size_per_gpu;这能减少 padding/小 batch 开销,但可能不是根因。 - 为缩小问题,临时降低
rollout.n、max_model_len或图片分辨率,观察耗时是否近似线性下降。
This looks less like a timeout-only issue and more like repeated Qwen3-VL vision-encoder work during log_prob/ref/update_actor. vLLM version may affect rollout generation, but later reports with newer vLLM/CUDA still reproduce the LoRA slowdown, so the more actionable direction is deduplicating/caching frozen vision embeddings and profiling the HF vision path. This response was generated by a scheduled Codex GPT5.5 issue processing task.
