Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moe finetune error #17

Closed
AdonLee072348 opened this issue Feb 3, 2024 · 12 comments
Closed

Moe finetune error #17

AdonLee072348 opened this issue Feb 3, 2024 · 12 comments

Comments

@AdonLee072348
Copy link

The following error occurred while running the script finetune_moe.sh:
The model has moe layers, but None of the param groups are marked as MoE. Create a param group with 'moe' key set to True before creating optimizer.
error

@LinB203
Copy link
Member

LinB203 commented Feb 3, 2024

Could you post your command & transformers version & deepspeed version & torch version. Thanks

@AdonLee072348
Copy link
Author

AdonLee072348 commented Feb 3, 2024

Thanks for your reply. The script is MoE-LLaVA/scripts/v1_5/qwen/finetune_moe.sh

torch version: 2.0.1+cu117
deepspeed version: 0.13.1
transformers version: 4.33.0

command:
moe_mode="sparse"
num_experts=4
top_k_experts=2
use_residual=False
router_aux_loss_coef=0.01
JSON_FOLDER="./MoE-LLaVA/train_json"
IMAGE_FOLDER="./MoE-LLaVA/"
HF_DATASETS_OFFLINE=1 TRANSFORMERS_OFFLINE=1 deepspeed moellava/train/train_mem.py
--moe_enable True --num_experts ${num_experts} --top_k_experts ${top_k_experts}
--moe_mode ${moe_mode} --use_residual ${use_residual} --router_aux_loss_coef ${router_aux_loss_coef}
--train_modules fc1 fc2 wg
--deepspeed ./scripts/zero2.json
--model_name_or_path ./checkpoints/llava-moe-qwen-1.8b-pretrain-finetune
--version qwen
--data_path ${JSON_FOLDER}/llava_image_tune_.json ${JSON_FOLDER}/nlp_tune.json
--image_folder ${IMAGE_FOLDER}
--image_tower ./pretrain_weight/clip-vit-large-patch14-336
--image_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-moe-qwen-1.8b-pretrain-finetune-moe
--num_train_epochs 1
--per_device_train_batch_size 8
--per_device_eval_batch_size 4
--gradient_accumulation_steps 2
--evaluation_strategy "no"
--save_strategy "steps"
--save_steps 24000
--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 2048
--gradient_checkpointing True
--dataloader_num_workers 4
--lazy_preprocess True
--report_to tensorboard
--cache_dir "./cache_dir"

@whalefa1I
Copy link

Could you post your command & transformers version & deepspeed version & torch version. Thanks

pip list|grep -E "torch|transformers|accelerate|deepspeed"
accelerate                    0.23.0
deepspeed                     0.9.5+cf42c28        
open-clip-torch               2.20.0
pytorch-lightning             1.7.7
pytorch-metric-learning       2.3.0
pytorch-wavelets              1.3.0
pytorch-wpe                   0.0.1
pytorch3d                     0.7.4
rotary-embedding-torch        0.3.0
taming-transformers-rom1504   0.0.6
torch                         2.0.1+cu118
torch-complex                 0.4.3
torch-scatter                 2.1.1
torchaudio                    2.0.2+cu118
torchmetrics                  0.11.4
torchsummary                  1.5.1
torchvision                   0.15.2+cu118
transformers                  4.34.1
transformers-stream-generator 0.0.4

command

HF_DATASETS_OFFLINE=1 TRANSFORMERS_OFFLINE=1 deepspeed moellava/train/train_mem.py     --moe_enable True --num_experts 4 --top_k_experts 2     --moe_mode sparse --use_residual False --router_aux_loss_coef 0.01     --train_modules fc1 fc2 wg     --deepspeed ./scripts/zero2.json     --model_name_or_path ./checkpoints/llavaqwen-1.8b-finetune     --version qwen     --data_path ./IMAGE_FOLDER/train_json/llava_image_tune_.json ./IMAGE_FOLDER/train_json/nlp_tune.json     --image_folder ./IMAGE_FOLDER     --image_tower ./cache/clip-vit-large-patch14-336     --image_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/llavaqwen-1.8b-finetune-moe     --num_train_epochs 1     --per_device_train_batch_size 8     --per_device_eval_batch_size 4     --gradient_accumulation_steps 2     --evaluation_strategy "no"     --save_strategy "steps"     --save_steps 24000     --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 2048     --gradient_checkpointing True     --dataloader_num_workers 4     --lazy_preprocess True     --report_to tensorboard --cache_dir "./cache_dir"

@LinB203
Copy link
Member

LinB203 commented Feb 3, 2024

Have you try it on transformers==4.36.2 & deepspeed==0.9.5? We will check MoE-Qwen latter. And could you guys try Phi or StableLM?

@AdonLee072348
Copy link
Author

Have you try it on transformers==4.36.2 & deepspeed==0.9.5? We will check MoE-Qwen latter. And could you guys try Phi or StableLM?

this error still occurred on transformers==4.36.2 & deepspeed==0.9.5

@LinB203
Copy link
Member

LinB203 commented Feb 3, 2024

Have you try it on transformers==4.36.2 & deepspeed==0.9.5? We will check MoE-Qwen latter. And could you guys try Phi or StableLM?

this error still occurred on transformers==4.36.2 & deepspeed==0.9.5

Copy that. I will check it as soon as possible.

@LinB203
Copy link
Member

LinB203 commented Feb 3, 2024

Hi, everyone. Sorry for that, we updated the new runing command to fix it. Checking out here

@whalefa1I
Copy link

Hi, everyone. Sorry for that, we updated the new runing command to fix it. Checking out here

Works for me, thx~!

@LinB203
Copy link
Member

LinB203 commented Feb 3, 2024

For training stage 3, we print the loss for each step to observe the router banlanced loss. If someone do not like it, just comment out this line.

@hxhcreate
Copy link

Hi, everyone. Sorry for that, we updated the new runing command to fix it. Checking out here

I still have the following error

AssertionError: The model has moe layers, but None of the param groups are marked as MoE. Create a param group with 'moe' key set to True before creating optimizer

here is my command

torchrun $DISTRIBUTED_ARGS moellava/train/train_mem.py \
    --moe_enable True --num_experts ${num_experts} --top_k_experts ${top_k_experts} --capacity_factor 1.5 \
    --moe_mode ${moe_mode} --use_residual ${use_residual} --router_aux_loss_coef ${router_aux_loss_coef} \
    --train_modules mlp.w1 mlp.w2 mlp.c_proj wg \
    --deepspeed ./scripts/zero2.json \
    --model_name_or_path ./checkpoints/llavaqwen1.5-1.8b-finetune \
    --version qwen \
    --data_path ${JSON_FOLDER}/llava_image_tune_.json ${JSON_FOLDER}/nlp_tune.json \
    --image_folder ${IMAGE_FOLDER} \
    --image_tower openai/clip-vit-large-patch14-336 \
    --image_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/llavaqwen-1.8b-finetune-moe \
    --num_train_epochs 1 \
    --per_device_train_batch_size 8 \
    --per_device_eval_batch_size 4 \
    --gradient_accumulation_steps 2 \
    --evaluation_strategy "no" \
    --save_strategy "steps" \
    --save_steps 24000 \
    --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 2048 \
    --gradient_checkpointing True \
    --dataloader_num_workers 4 \
    --lazy_preprocess True \
    --report_to tensorboard \
    --cache_dir "./cache_dir"

here is my package version

accelerate                0.21.0
deepspeed                 0.9.5
torch                     2.0.1
torchvision               0.15.2
transformers              4.37.0

@PangziZhang523
Copy link

I still have the following error !!!!!

AssertionError: The model has moe layers, but None of the param groups are marked as MoE. Create a param group with 'moe' key set to True before creating optimizer

here is my package version:
accelerate 0.21.0
deepspeed 0.9.5
torch 2.0.1
torchvision 0.15.2
transformers 4.37.0

@Wuyingwen
Copy link

Hi, everyone. Sorry for that, we updated the new runing command to fix it. Checking out here

I still have the following error

AssertionError: The model has moe layers, but None of the param groups are marked as MoE. Create a param group with 'moe' key set to True before creating optimizer

here is my command

torchrun $DISTRIBUTED_ARGS moellava/train/train_mem.py \
    --moe_enable True --num_experts ${num_experts} --top_k_experts ${top_k_experts} --capacity_factor 1.5 \
    --moe_mode ${moe_mode} --use_residual ${use_residual} --router_aux_loss_coef ${router_aux_loss_coef} \
    --train_modules mlp.w1 mlp.w2 mlp.c_proj wg \
    --deepspeed ./scripts/zero2.json \
    --model_name_or_path ./checkpoints/llavaqwen1.5-1.8b-finetune \
    --version qwen \
    --data_path ${JSON_FOLDER}/llava_image_tune_.json ${JSON_FOLDER}/nlp_tune.json \
    --image_folder ${IMAGE_FOLDER} \
    --image_tower openai/clip-vit-large-patch14-336 \
    --image_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/llavaqwen-1.8b-finetune-moe \
    --num_train_epochs 1 \
    --per_device_train_batch_size 8 \
    --per_device_eval_batch_size 4 \
    --gradient_accumulation_steps 2 \
    --evaluation_strategy "no" \
    --save_strategy "steps" \
    --save_steps 24000 \
    --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 2048 \
    --gradient_checkpointing True \
    --dataloader_num_workers 4 \
    --lazy_preprocess True \
    --report_to tensorboard \
    --cache_dir "./cache_dir"

here is my package version

accelerate                0.21.0
deepspeed                 0.9.5
torch                     2.0.1
torchvision               0.15.2
transformers              4.37.0

hi, I have the same environment setting as you. And meet the same problem when training a moe version of llama_llava. Have you solve the problem now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants