FlagEmbedding icon indicating copy to clipboard operation
FlagEmbedding copied to clipboard

使用deepspeed训练后保存模型出现size mismatch

Open SingL3 opened this issue 1 year ago • 2 comments

我的训练启动命令:

  torchrun --nnodes $NNODES --nproc_per_node $NPROC_PER_NODE \
      --node_rank $RANK --master_addr $MASTER_ADDR --master_port $MASTER_PORT \
      -m FlagEmbedding.baai_general_embedding.finetune.run \
      --output_dir path/to/output \
      --model_name_or_path bge-large-zh-v1.5 \
      --train_data path/to/data.jsonl \
      --learning_rate $LEARNINGRATE \
      --fp16 \
      --num_train_epochs $EPOCHS \
      --gradient_accumulation_steps 12 \
      --per_device_train_batch_size $BATCHSIZE \
      --dataloader_drop_last True \
      --max_example_num_per_dataset 10000000000 \
      --normlized True \
      --temperature 0.02 \
      --query_max_len 64 \
      --passage_max_len 512 \
      --train_group_size 2 \
      --negatives_cross_device \
      --logging_steps 10 \
      --save_strategy epoch \
      --save_total_limit 3 \
      --gradient_checkpointing \
      --save_safetensors false \
      --deepspeed examples/finetune/ds_config_zero3.json \
      --query_instruction_for_retrieval "为这个句子生成表示以用于检索相关文章:"

保存后模型文件只有:

config.json  model.safetensors  special_tokens_map.json  tokenizer_config.json  training_args.bin  vocab.txt

不使用deepspeed的模型保存为:

1_Pooling    config.json                        model.safetensors  README.md                  special_tokens_map.json  tokenizer.json     vocab.txt
2_Normalize  config_sentence_transformers.json  modules.json       sentence_bert_config.json  tokenizer_config.json    training_args.bin

若读取deepspeed的模型,会报错:

Traceback (most recent call last):
  File "/mnt/home/xxx/bge/FlagEmbedding/C_MTEB/eval_C-MTEB.py", line 36, in <module>
    model = FlagDRESModel(model_name_or_path=args.model_name_or_path,
  File "/mnt/home/xxx/bge/FlagEmbedding/C_MTEB/flag_dres_model.py", line 20, in __init__
    self.model = AutoModel.from_pretrained(model_name_or_path)
  File "/mnt/data/conda/envs/bge/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py", line 563, in from_pretrained
    return model_class.from_pretrained(
  File "/mnt/data/conda/envs/bge/lib/python3.10/site-packages/transformers/modeling_utils.py", line 3754, in from_pretrained
    ) = cls._load_pretrained_model(
  File "/mnt/data/conda/envs/bge/lib/python3.10/site-packages/transformers/modeling_utils.py", line 4265, in _load_pretrained_model
    raise RuntimeError(f"Error(s) in loading state_dict for {model.__class__.__name__}:\n\t{error_msg}")
RuntimeError: Error(s) in loading state_dict for BertModel:
        size mismatch for embeddings.word_embeddings.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([21128, 1024]).
        size mismatch for embeddings.position_embeddings.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([512, 1024]).
        size mismatch for encoder.layer.0.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.0.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.0.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.0.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.0.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.0.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.1.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.1.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.1.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.1.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.1.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.1.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.2.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.2.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.2.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.2.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.2.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.2.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.3.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.3.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.3.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.3.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.3.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.3.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.4.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.4.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.4.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.4.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.4.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.4.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.5.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.5.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.5.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.5.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.5.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.5.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.6.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.6.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.6.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.6.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.6.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.6.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.7.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.7.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.7.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.7.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.7.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.7.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.8.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.8.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.8.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.8.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.8.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.8.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.9.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.9.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.9.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.9.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.9.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.9.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.10.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.10.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.10.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.10.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.10.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.10.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.11.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.11.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.11.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.11.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.11.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.11.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.12.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.12.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.12.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.12.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.12.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.12.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.13.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.13.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.13.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.13.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.13.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.13.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.14.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.14.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.14.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.14.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.14.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.14.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.15.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.15.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.15.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.15.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.15.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.15.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.16.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.16.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.16.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.16.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.16.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.16.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.17.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.17.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.17.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.17.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.17.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.17.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.18.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.18.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.18.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.18.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.18.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.18.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.19.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.19.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.19.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.19.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.19.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.19.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.20.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.20.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.20.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.20.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.20.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.20.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.21.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.21.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.21.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.21.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.21.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.21.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.22.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.22.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.22.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.22.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.22.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.22.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for encoder.layer.23.attention.self.query.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.23.attention.self.key.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.23.attention.self.value.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.23.attention.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        size mismatch for encoder.layer.23.intermediate.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([4096, 1024]).
        size mismatch for encoder.layer.23.output.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 4096]).
        size mismatch for pooler.dense.weight: copying a param with shape torch.Size([0]) from checkpoint, the shape in current model is torch.Size([1024, 1024]).
        You may consider adding `ignore_mismatched_sizes=True` in the model `from_pretrained` method.

我的deepspeed config:

{
    "bf16": {
      "enabled": "auto"
    },
    "fp16": {
        "enabled": "auto",
        "loss_scale": 0,
        "loss_scale_window": 1000,
        "initial_scale_power": 12,
        "hysteresis": 2,
        "min_loss_scale": 1
    },
    "optimizer": {
      "type": "AdamW",
      "params": {
        "lr": "auto",
        "betas": "auto",
        "eps": "auto",
        "weight_decay": "auto"
      }
    },
    "scheduler": {
      "type": "WarmupDecayLR",
      "params": {
        "total_num_steps": "auto",
        "warmup_min_lr": "auto",
        "warmup_max_lr": "auto",
        "warmup_num_steps": "auto"
      }
    },
    "zero_optimization": {
      "stage": 3,
      "offload_optimizer": {
        "device": "none",
        "pin_memory": true
      },
      "offload_param": {
          "device": "none",
          "pin_memory": true
      },
      "overlap_comm": true,
      "contiguous_gradients": true,
      "sub_group_size": 1e9,
      "reduce_bucket_size": "auto",
      "stage3_prefetch_bucket_size": "auto",
      "stage3_param_persistence_threshold": "auto",
      "stage3_max_live_parameters": 1e9,
      "stage3_max_reuse_distance": 1e9,
      "stage3_gather_16bit_weights_on_model_save": false
    },
    "gradient_accumulation_steps": "auto",
    "gradient_clipping": "auto",
    "steps_per_print": 100,
    "train_batch_size": "auto",
    "train_micro_batch_size_per_gpu": "auto",
    "wall_clock_breakdown": false
  }

SingL3 avatar Jun 11 '24 08:06 SingL3

可以试试stage 0或者1,large级别的模型不需要开stage3。

staoxiao avatar Jun 11 '24 16:06 staoxiao

你好,请问你后来解决了吗?

meiru-cam avatar May 05 '25 22:05 meiru-cam