haotian-liu / LLaVA

[NeurIPS'23 Oral] Visual Instruction Tuning (LLaVA) built towards GPT-4V level capabilities and beyond.
https://llava.hliu.cc
Apache License 2.0
19.29k stars 2.12k forks source link

No "mm_projector_lr" when fine-tuning llava-1.5-7b #757

Closed guxm2021 closed 10 months ago

guxm2021 commented 10 months ago

Describe the issue

When I fine-tune the llava-1.5-7b using scripts/v1_5/finetune_lora.sh with minimal changes, here is my command

Command:

deepspeed llava/train/train_mem.py \
    --lora_enable True --lora_r 128 --lora_alpha 256 --mm_projector_lr 2e-5 \
    --deepspeed ./scripts/zero3.json \
    --model_name_or_path lmsys/vicuna-7b-v1.5 \
    --version v1 \
    --data_path ../LLaVA/playground/data/llava_v1_5_mix665k.json \
    --image_folder ../LLaVA/playground/data \
    --vision_tower openai/clip-vit-large-patch14-336 \
    --pretrain_mm_mlp_adapter ../LLaVA/checkpoints/llava-v1.5-mlp2x-336px-pretrain-vicuna-7b-v1.5/mm_projector.bin \
    --mm_projector_type mlp2x_gelu \
    --mm_vision_select_layer -2 \
    --mm_use_im_start_end False \
    --mm_use_im_patch_token False \
    --image_aspect_ratio pad \
    --group_by_modality_length True \
    --bf16 True \
    --output_dir ./checkpoints/llava-v1.5-7b-lora \
    --num_train_epochs 1 \
    --per_device_train_batch_size 16 \
    --per_device_eval_batch_size 4 \
    --gradient_accumulation_steps 1 \
    --evaluation_strategy "no" \
    --save_strategy "steps" \
    --save_steps 50000 \
    --save_total_limit 1 \
    --learning_rate 2e-4 \
    --weight_decay 0. \
    --warmup_ratio 0.03 \
    --lr_scheduler_type "cosine" \
    --logging_steps 1 \
    --tf32 True \
    --model_max_length 2048 \
    --gradient_checkpointing True \
    --dataloader_num_workers 4 \
    --lazy_preprocess True \
    --report_to wandb

I encountered the value error: Log:

ValueError: Some specified arguments are not used by the HfArgumentParser: ['--mm_projector_lr', '2e-5']

When I remove the argument --mm_projector_lr 2e-5 in the command, the command can work. But I don't know whether I could get the correct model.

Cooperx521 commented 6 months ago

Hello, I have met the similar problem, do you know whether --mm_projector_lr works when setting --learning_rate? I'm confused about the priority of --mm_projector_lr and --learning_rate 2e-4 @guxm2021

            optimizer_cls, optimizer_kwargs = Trainer.get_optimizer_cls_and_kwargs(self.args)

            self.optimizer = optimizer_cls(optimizer_grouped_parameters, **optimizer_kwargs)

@haotian-liu I just can not figure out whether optimizer_grouped_parameters func in llava_trainer.py works when --learning_rate is set