baichuan-inc / Baichuan2

A series of large language models developed by Baichuan Intelligent Technology
https://huggingface.co/baichuan-inc
Apache License 2.0
4.08k stars 293 forks source link

如何进行全参数训练呢? #202

Open FanWan opened 12 months ago

FanWan commented 12 months ago

使用代码库:https://github.com/hiyouga/LLaMA-Efficient-Tuning

deepspeed --include localhost:4,5,6,7 --master_port $MASTER_PORT src/train_bash.py \ --stage sft \ --model_name_or_path /home/work/record/llm_models/Baichuan2-13B-Chat \ --do_train \ --cutoff_len 1536 \ --max_length 320 \ --overwrite_output_dir \ --dataset train_intent_args_all \ --template baichuan2 \ --finetuning_type full \ --output_dir output/$SAVE_MODEL_PATH \ --overwrite_cache \ --per_device_train_batch_size 1 \ --gradient_accumulation_steps 1 \ --lr_scheduler_type cosine \ --logging_steps 100 \ --save_steps 400 \ --learning_rate 5e-5 \ --num_train_epochs 5.0 \ --plot_loss \ --deepspeed dsconfig.json \ --bf16 > log/train${SAVE_MODEL_PATH}.log 2>&1 &

报out of memory

torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 12.94 GiB (GPU 1; 79.35 GiB total capacity; 77.65 GiB already allocated; 316.12 MiB free; 77.66 GiB reserved in total by PyTorch) If reserv ed memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF

friendshipity commented 12 months ago

4*A100 80G stage 3 勉强可以跑通

yangluojun commented 11 months ago

4*A100 80G stage 3 勉强可以跑通

请问一下全量参数微调后的模型 推理有 遇到输出都为空的情况吗?

FanWan commented 11 months ago

4*A100 80G stage 3 勉强可以跑通

请问一下全量参数微调后的模型 推理有 遇到输出都为空的情况吗?

并没有。但是,我用8卡全参数训练了下,效果居然没有4卡Lora微调效果好,奇怪。

littletomatodonkey commented 11 months ago

4*A100 80G stage 3 勉强可以跑通

请问一下全量参数微调后的模型 推理有 遇到输出都为空的情况吗?

并没有。但是,我用8卡全参数训练了下,效果居然没有4卡Lora微调效果好,奇怪。

我也遇到了类似的问题,可能是因为lora并不会大幅改变原始模型的权重,所以泛化能力可以得到保证,全参数微调容易过拟合

ReverseSystem001 commented 11 months ago

4*A100 80G stage 3 勉强可以跑通

请问一下全量参数微调后的模型 推理有 遇到输出都为空的情况吗?

并没有。但是,我用8卡全参数训练了下,效果居然没有4卡Lora微调效果好,奇怪。

我也遇到了类似的问题,可能是因为lora并不会大幅改变原始模型的权重,所以泛化能力可以得到保证,全参数微调容易过拟合 --use_lora True 这个参数打开只训练lora参数吗?