#180·Firefly

qlora微调baichuan2-13B-Base出现loss异常

Author: delian11Created Nov 10, 2023Updated Oct 18, 2024

版本: Python 3.8 torch==2.0.1 transformers==4.30.2 peft==0.4.0 bitsandbytes==0.39.0

config设置: { "output_dir": "mypath/trans-baichuan2-13b", "model_name_or_path": "/mypath/Baichuan2-13B-Base", "train_file": "mypath/firefly-translation.jsonl", "num_train_epochs": 1, "per_device_train_batch_size": 4, "gradient_accumulation_steps": 2, "learning_rate": 1e-4, "max_seq_length": 1024, "logging_steps": 10, "save_steps": 500, "save_total_limit": 1, "lr_scheduler_type": "constant_with_warmup", "warmup_steps": 1000, "lora_rank": 64, "lora_alpha": 16, "lora_dropout": 0.05, "gradient_checkpointing": true, "disable_tqdm": false, "optim": "paged_adamw_32bit", "seed": 42, "fp16": false, "bf16": true, "report_to": "tensorboard", "dataloader_num_workers": 5, "save_strategy": "steps", "weight_decay": 0, "max_grad_norm": 0.3, "remove_unused_columns": false }

使用qlora训练Baichuan2-13B-Base的时候,在V100上面设置fp16为True会出现一开始训练loss就为0的情况,设置fp16为False开始可以正常训练,但是1000多个step之后loss突增,然后降为0。换成在A100上跑也是类似情况,bf16为true就一开始loss就为0,为false就正常训练1000多个step,然后loss突增再降为0。更换了好几种transformers、peft和bitsandbytes版本也不能解决问题