在微调时llm_reranker.finetune_for_layerwise
在微调时llm_reranker.finetune_for_layerwise
CUDA_VISIBLE_DEVICES=4,5,6,7 torchrun --nproc_per_node=4
-m FlagEmbedding.llm_reranker.finetune_for_layerwise.run
--output_dir ./model_ha
--model_name_or_path ./bge-reranker-v2-minicpm-layerwise
--train_data ./data/train_0425.jsonl
--learning_rate 2e-4
--num_train_epochs 50
--per_device_train_batch_size 2
--gradient_accumulation_steps 16
--dataloader_drop_last False
--query_max_len 1024
--passage_max_len 512
--train_group_size 4
--logging_steps 100
--save_steps 3000
--save_total_limit 50
--ddp_find_unused_parameters False
--gradient_checkpointing
--warmup_ratio 0.1
--fp16
--use_lora True
--lora_rank 32
--lora_alpha 64
--use_flash_attn False
--target_modules q_proj k_proj v_proj o_proj
--start_layer 8
--head_multi True
--head_type simple
--lora_extra_parameters linear_head
RuntimeError: Expected to have finished reduction in the prior iteration before starting a new one. This error indicates that your module has parameters that were not used in producing loss. You can enable unused parameter detection by passing the keyword argument find_unused_parameters=True to torch.nn.parallel.DistributedDataParallel, and by
making sure all forward function outputs participate in calculating loss.
If you already have done the above, then the distributed data parallel module wasn't able to locate the output tensors in the return value of your module's forward function. Please include the loss function and the structure of the return value of forward of your module when reporting this issue (e.g. list, dict, iterable).
Parameter indices which did not receive grad for rank 1: 320 322 324 326 328 330 332 334 336 338 340 342 344 346 348 350 352 354 356 358 360 362 364 366 368 370 372 374 376 378 380 382 384
In addition, you can set the environment variable TORCH_DISTRIBUTED_DEBUG to either INFO or DETAIL to print out information about which particular parameters did not receive gradient on this rank as part of this error
但是并没有发现分布式的写法在代码中torch.nn.parallel.DistributedDataParallel
torchrun --nproc_per_node=4就会启动DDP
微调的时候需要加上--finetune_type from_finetuned_model以及将linear_head放到target_modules中
上述报错是计算损失函数时,有些模型参数没有被使用引起的,可以设置--ddp_find_unused_parameters True来启用未使用参数检测。这样,PyTorch 会检查哪些参数在计算损失时没有被使用,从而帮助找出问题所在
感谢感谢 已经解决了
torchrun --nproc_per_node=4就会启动DDP 微调的时候需要加上
--finetune_type from_finetuned_model以及将linear_head放到target_modules中 上述报错是计算损失函数时,有些模型参数没有被使用引起的,可以设置--ddp_find_unused_parameters True来启用未使用参数检测。这样,PyTorch 会检查哪些参数在计算损失时没有被使用,从而帮助找出问题所在