verl icon indicating copy to clipboard operation
verl copied to clipboard

Llava_onevision model support FSDP issues

Open gpt-dance opened this issue 1 year ago • 4 comments

Summary

I’m integrating the LlavaOneVision model into the VERL training framework. When configuring FSDP, I encountered two different critical issues depending on the FSDP wrapping strategy.

1️⃣ Behavior When Using transformer_layer_cls_to_wrap: ["Qwen2DecoderLayer"] When I set: transformer_layer_cls_to_wrap: ["Qwen2DecoderLayer"](It's correct Decoder Layer in my model) the training process starts, but GPU-Util and GPU memory utilization both spike to 100% and remain stuck, effectively hanging the process without progressing. 2️⃣ Behavior When Using Large min_num_params (e.g., 100M) When I increase the min_num_params: 100000000 RuntimeError: setStorage: sizes [896, 152000], strides [1, 896], storage offset 0, and itemsize 4 requiring a storage size of 544768000 are out of bounds for storage of size 0 Root Cause (suspected) •The lm_head is also wrapped and sharded by FSDP. 3️⃣ Expected Behavior FSDP should only wrap Transformer layers (e.g., Qwen2DecoderLayer) and leave lm_head / embedding layers unsharded. Training should proceed without hanging or sharding the output head.

😭😭😭 Could you please clarify: • The recommended FSDP configuration for LlavaOneVision under VERL? • How to prevent the lm_head (and possibly other non-transformer modules) from being automatically sharded?

gpt-dance avatar Oct 26 '25 13:10 gpt-dance

6️⃣ The model structure 
FullyShardedDataParallel(
  (_fsdp_wrapped_module): LlavaOnevisionForConditionalGeneration(
    (model): LlavaOnevisionModel(
      (vision_tower): SiglipVisionModel(
        (vision_model): SiglipVisionTransformer(
          (embeddings): SiglipVisionEmbeddings(
            (patch_embedding): Conv2d(3, 1152, kernel_size=(14, 14), stride=(14, 14), padding=valid)
            (position_embedding): Embedding(729, 1152)
          )
          (encoder): FullyShardedDataParallel(
            (_fsdp_wrapped_module): SiglipEncoder(
              (layers): ModuleList(
                (0-25): 26 x SiglipEncoderLayer(
                  (layer_norm1): LayerNorm((1152,), eps=1e-06, elementwise_affine=True)
                  (self_attn): SiglipAttention(
                    (k_proj): Linear(in_features=1152, out_features=1152, bias=True)
                    (v_proj): Linear(in_features=1152, out_features=1152, bias=True)
                    (q_proj): Linear(in_features=1152, out_features=1152, bias=True)
                    (out_proj): Linear(in_features=1152, out_features=1152, bias=True)
                  )
                  (layer_norm2): LayerNorm((1152,), eps=1e-06, elementwise_affine=True)
                  (mlp): SiglipMLP(
                    (activation_fn): PytorchGELUTanh()
                    (fc1): Linear(in_features=1152, out_features=4304, bias=True)
                    (fc2): Linear(in_features=4304, out_features=1152, bias=True)
                  )
                )
              )
            )
          )
          (post_layernorm): LayerNorm((1152,), eps=1e-06, elementwise_affine=True)
        )
      )
      (multi_modal_projector): LlavaOnevisionMultiModalProjector(
        (linear_1): Linear(in_features=1152, out_features=896, bias=True)
        (act): GELUActivation()
        (linear_2): Linear(in_features=896, out_features=896, bias=True)
      )
      (language_model): FullyShardedDataParallel(
        (_fsdp_wrapped_module): Qwen2Model(
          (embed_tokens): FullyShardedDataParallel(
            (_fsdp_wrapped_module): Embedding(152000, 896)
          )
          (layers): ModuleList(
            (0-23): 24 x Qwen2DecoderLayer(
              (self_attn): Qwen2Attention(
                (q_proj): Linear(in_features=896, out_features=896, bias=True)
                (k_proj): Linear(in_features=896, out_features=128, bias=True)
                (v_proj): Linear(in_features=896, out_features=128, bias=True)
                (o_proj): Linear(in_features=896, out_features=896, bias=False)
              )
              (mlp): Qwen2MLP(
                (gate_proj): Linear(in_features=896, out_features=4864, bias=False)
                (up_proj): Linear(in_features=896, out_features=4864, bias=False)
                (down_proj): Linear(in_features=4864, out_features=896, bias=False)
                (act_fn): SiLU()
              )
              (input_layernorm): Qwen2RMSNorm((896,), eps=1e-06)
              (post_attention_layernorm): Qwen2RMSNorm((896,), eps=1e-06)
            )
          )
          (norm): Qwen2RMSNorm((896,), eps=1e-06)
          (rotary_emb): Qwen2RotaryEmbedding()
        )
      )
    )
    (lm_head): FullyShardedDataParallel(
      (_fsdp_wrapped_module): Linear(in_features=896, out_features=152000, bias=False)
    )
  )
)

gpt-dance avatar Oct 26 '25 14:10 gpt-dance

5️⃣ Full Training Command
python3 -m verl.trainer.main_ppo \
    **actor_rollout_ref.model.use_remove_padding=False \
    actor_rollout_ref.model.use_fused_kernels=True \**
    algorithm.adv_estimator=grpo \
    data.train_files=/mnt/largeml-data-gui-agent/geometry3k/train.parquet \
    data.val_files=/mnt/largeml-data-gui-agent/geometry3k/test.parquet \
    data.train_batch_size=512 \
    data.max_prompt_length=10000 \
    data.max_response_length=2048 \
    data.truncation='error' \
    data.image_key=images \
    **actor_rollout_ref.model.path=llava-onevision-qwen2-0.5b-ov-hf \**
    actor_rollout_ref.actor.optim.lr=1e-6 \
    actor_rollout_ref.actor.ppo_mini_batch_size=128 \
    actor_rollout_ref.actor.ppo_micro_batch_size_per_gpu=10 \
    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=True \
    actor_rollout_ref.actor.fsdp_config.optimizer_offload=True \
    actor_rollout_ref.rollout.log_prob_micro_batch_size_per_gpu=20 \
    actor_rollout_ref.rollout.tensor_model_parallel_size=2 \
    actor_rollout_ref.rollout.name=$ENGINE \
    +actor_rollout_ref.rollout.engine_kwargs.vllm.disable_mm_preprocessor_cache=True \
    actor_rollout_ref.rollout.gpu_memory_utilization=0.6 \
    actor_rollout_ref.rollout.enable_chunked_prefill=False \
    actor_rollout_ref.rollout.enforce_eager=False \
    actor_rollout_ref.rollout.free_cache_engine=True \
    actor_rollout_ref.rollout.n=5 \
    actor_rollout_ref.ref.log_prob_micro_batch_size_per_gpu=20 \
    actor_rollout_ref.ref.fsdp_config.param_offload=True \
    algorithm.use_kl_in_reward=False \
    trainer.critic_warmup=0 \
    trainer.logger='["console","mlflow"]' \
    trainer.project_name='verl_grpo_example_geo3k' \
    trainer.experiment_name='qwen2_5_vl_7b_function_rm' \
    trainer.n_gpus_per_node=8 \
    trainer.nnodes=1 \
    trainer.save_freq=20 \
    trainer.test_freq=5 \
    trainer.val_before_train=False \
    trainer.total_epochs=15 $@

gpt-dance avatar Oct 26 '25 14:10 gpt-dance

求助求助,顶顶顶 如何支持 llava_one_vision 在 verl 中用 fsdp 训练碰到问题

gpt-dance avatar Oct 28 '25 08:10 gpt-dance

定时 issue 清理检查结果:本 issue 最近一次非当前运行账号(Kirrito-k423)的公开回复或公开引用是 2025-10-28T08:24:57Z,类型为 comment,账号为 gpt-dance,证据链接:https://github.com/verl-project/verl/issues/3912#issuecomment-3455146138。本轮同时检查了 issue comments(数量 3)和 timeline(事件数量 3;来源:https://github.com/verl-project/verl/issues/3912#issuecomment-timeline)。截至 2026-07-22,该最近非本人公开互动已经超过 6 个月。

因此按定时清理标准关闭。若作者或社区成员仍能提供新的复现、证据或需求背景,欢迎继续评论请求重开,或创建新的 issue 并链接到这里。

Scheduled issue cleanup check: the latest public reply or public reference not made by the current automation account (Kirrito-k423) was at 2025-10-28T08:24:57Z (kind: comment, actor: gpt-dance; evidence: https://github.com/verl-project/verl/issues/3912#issuecomment-3455146138). This run checked issue comments (3) and timeline events (3; source: https://github.com/verl-project/verl/issues/3912#issuecomment-timeline). As of 2026-07-22, that latest non-self public interaction is older than 6 months.

Therefore, this is being closed under the scheduled cleanup policy. If the author or community can provide a fresh reproduction, evidence, or requirement context, please comment to request reopening or open a new issue linking back here.

This response was generated by a scheduled Codex GPT5.5 issue processing task.

Kirrito-k423 avatar Jul 22 '26 01:07 Kirrito-k423