#180·Firefly

qlora微调baichuan2-13B-Base时出现损失异常

作者: delian11创建于 2023年11月10日更新于 2024年10月18日

The configuration settings are as follows: { "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 }

When using qlora to train Baichuan2-13B-Base on V100, setting fp16 to True causes the loss to be 0 at the beginning of training. Setting fp16 to False allows normal training to begin, but after more than 1000 steps, the loss suddenly increases and then drops to 0. The same situation occurs when running on A100, with bf16 set to True causing the loss to be 0 at the beginning, and setting it to False allows normal training to begin for more than 1000 steps, after which the loss suddenly increases and then drops to 0. Changing several versions of transformers, peft, and bitsandbytes does not solve the problem.

内容来源: yangjianxin1/Firefly