DeepSpeedExamples icon indicating copy to clipboard operation
DeepSpeedExamples copied to clipboard

Load model error in step3

Open YingtongBu2 opened this issue 3 years ago • 8 comments

When setting zero_stage=3, load my own ckpt in .pt format:

model_config = AutoConfig.from_pretrained(model_name_or_path) model = AutoModel.from_config(model_config)

the shape of param in model is all torch.Size([0]), because the error message is: size mismatch for model.decoder.layers.1.self_attn.k_proj.weight: copying a param with shape torch.Size([5120, 5120]) from checkpoint, the shape in current model is torch.Size([0]). The ckpt I load is with correct shape of params, but the model build from config seems wrong. With other zero_stages, the error will not occur.

I run the script line by line, the error does not occur either. Anyone come across this problem?

YingtongBu2 avatar May 31 '23 09:05 YingtongBu2

Same error. The code of deepspeed chat in step3 , critic and reward model are all load with zero_stage=0 ,So i can't find example that how to load model from checkpoint with zero_stage=3.

EthenZhang avatar Jun 01 '23 08:06 EthenZhang

mark

gongyaguang-tal avatar Jun 05 '23 02:06 gongyaguang-tal

solved, have to load from pytorch_model.bin of pretrained huggingface model when using zero3, otherwise after setting HfDeepSpeedConfig (a must for zero3), model = model_class.from_config(model_config) will make all parameters of model zero tensors.

YingtongBu2 avatar Jun 08 '23 12:06 YingtongBu2

@YingtongBu2 Can you tell me in detail how you solved this bug? Also can you share this code?

iamsile avatar Jun 13 '23 15:06 iamsile

@iamsile

Actually we don't need to modify any codes in model_utils.py, which is used to load model. The best solution is to convert model format to .bin for all steps

YingtongBu2 avatar Jun 16 '23 02:06 YingtongBu2

@YingtongBu2 I used model.bin file in every step, but it doesn't work. I don't know where is wrong

iamsile avatar Jun 16 '23 09:06 iamsile

@YingtongBu2 I used model.bin file in every step, but it doesn't work. I don't know where is wrong

do you solve the problem now?

JumpingRain avatar Jul 17 '23 06:07 JumpingRain

Have you solved the problem?

BaenRH avatar Aug 16 '23 02:08 BaenRH