OptimalScale / LMFlow

An Extensible Toolkit for Finetuning and Inference of Large Foundation Models. Large Models for All.
https://optimalscale.github.io/LMFlow/
Apache License 2.0
8.11k stars 819 forks source link

[Model Support] Qwen2 update #849

Closed wheresmyhair closed 3 weeks ago

wheresmyhair commented 3 weeks ago

Description

Support Qwen2 models. Only docs are updated, since the pipeline requirements are the same as Qwen1.5.

Pipeline Tests

  1. Full-Finetune full

2 LoRA lora

Known Issue

Note: This isn't a bug in LMFlow, but we will add a logger notification ASAP to notify users when they might trigger this bug.

When do lora (or other peft tuning that uses peft library) first and saved model at a dir, say, A, and then do another finetuning work that also specifies the same output_dir A, pipeline will fail to update the model card, since Qwen2ForCausalLM doesn't have attribute .create_or_update_model_card(). But this will not affect the model saving.

Bug logi:

  1. Finetune with PeftTrainer and save leads to a modelcard with library_name = 'peft'.
  2. When do anyother finetune with same output_dir, since https://github.com/huggingface/transformers/blob/bdf36dcd48106a4a0278ed7f3cc26cd65ab7b066/src/transformers/trainer.py#L4114, os.path.exists(model_card_filepath) is True, and then is_peft_library is True.
  3. At https://github.com/huggingface/transformers/blob/bdf36dcd48106a4a0278ed7f3cc26cd65ab7b066/src/transformers/trainer.py#L4143, transformers will do .create_or_update_model_card(), which Qwen2ForCausalLM doesn't have.

qwenbug

We strongly recommend to use different output_dir for every finetuning work to avoid unexpected issues like the one above.