haotian-liu/LLaVA

[Question] Model parameters during finetuning (prints me only mm_projector parameters)

daulettoibazar opened this issue · 1 comments

Question

Hi @haotian-liu, I am trying to pretrain and finetune llava model on my custom dataset. But during the fine-tuning, when I load projector.bin, LLava model and Image encoder, when i run train.py with following changes, it only prints the weights of projector (no model weight, no image encoder weights):

    total_params = sum(param.numel() for param in model.parameters())
    
    # Total number of trainable parameters
    trainable_params = sum(param.numel() for param in model.parameters() if param.requires_grad)
    
    print(f"Total Parameters: {total_params}")
    print(f"Trainable Parameters: {trainable_params}")
    data_module = make_supervised_data_module(tokenizer=tokenizer,
                                              data_args=data_args)
    trainer = LLaVATrainer(model=model,
                    tokenizer=tokenizer,
                    args=training_args,
                    **data_module)

The output is

Total Parameters: 32000000
Trainable Parameters:32000000

Below is my fine tuning script:

deepspeed LLaVA/llava/train/train_mem.py \
    --deepspeed "LLaVA/scripts/zero3.json" \
    --model_name_or_path "./tmp/model/v1.5_model" \
    --version v1 \
    --freeze_backbone True \
    --data_path "./tmp/data/fv4.json" \
    --image_folder ./tmp/data/images \
    --vision_tower openai/clip-vit-large-patch14-336 \
    --pretrain_mm_mlp_adapter ./tmp/models/v1.5_model/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 ./llava-v1.5-13b_fv4 \
    --num_train_epochs 1 \
    --per_device_train_batch_size 8 \
    --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-5 \
    --weight_decay 0. \
    --warmup_ratio 0.03 \
    --lr_scheduler_type "cosine" \
    --logging_steps 1 \
    --tf32 True \
    --model_max_length 4096 \
    --gradient_checkpointing True \
    --dataloader_num_workers 4 \
    --lazy_preprocess True \
    --report_to wandb

Why other weights are not visible here?