ms-swift icon indicating copy to clipboard operation
ms-swift copied to clipboard

KTO训练,evaluation阶段报错

Open Yiwei98 opened this issue 1 year ago • 10 comments

环境: swift: 3.0.0.dev0 deepspeed: 0.14.5 zero3 accelerate: 1.2.1 transformers: 4.47.1 CUDA: 12.2

自构建数据集 训练可以正常进行,evaluation阶段报错: raise RuntimeError(f"still have inflight params "
hook_result = hook(self, args, result) File "/usr/local/lib/python3.10/dist-packages/deepspeed/utils/nvtx.py", line 18, in wrapped_fn RuntimeError: still have inflight params [{'id': 964, 'status': 'AVAILABLE', 'numel': 65536, 'ds_numel': 65536, 'shape': (8192, 8), 'ds_shape': (8192, 8), 'requires_grad': False, 'grad_shape': None, 'persist': True, 'active_sub_modules': set(), 'ds_tensor.shape': torch.Size([16384])}, {'id': 966, 'status': 'AVAILABLE', 'numel': 8192, 'ds_numel': 8192, 'shape': (1024, 8), 'ds_shape': (1024, 8), 'requires_grad': False, 'grad_shape': None, 'persist': True, 'active_sub_modules': set(), 'ds_tensor.shape': torch.Size([2048])}, {'id': 968, 'status': 'AVAILABLE', 'numel': 8192, 'ds_numel': 8192, 'shape': (1024, 8), 'ds_shape': (1024, 8), 'requires_grad': False, 'grad_shape': None, 'persist': True, 'active_sub_modules': set(), 'ds_tensor.shape': torch.Size([2048])}, {'id': 970, 'status': 'AVAILABLE', 'numel': 65536, 'ds_numel': 65536, 'shape': (8192, 8), 'ds_shape': (8192, 8), 'requires_grad': False, 'grad_shape': None, 'persist': True, 'active_sub_modules': set(), 'ds_tensor.shape': torch.Size([16384])}, {'id': 972, 'status': 'AVAILABLE', 'numel': 236544, 'ds_numel': 236544, 'shape': (29568, 8), 'ds_shape': (29568, 8), 'requires_grad': False, 'grad_shape': None, 'persist': False, 'active_sub_modules': set(), 'ds_tensor.shape': torch.Size([59136])}, {'id': 974, 'status': 'AVAILABLE', 'numel': 236544, 'ds_numel': 236544, 'shape': (29568, 8), 'ds_shape': (29568, 8), 'requires_grad': False, 'grad_shape': None, 'persist': False, 'active_sub_modules': set(), 'ds_tensor.shape': torch.Size([59136])}, {'id': 976, 'status': 'AVAILABLE', 'numel': 65536, 'ds_numel': 65536, 'shape': (8192, 8), 'ds_shape': (8192, 8), 'requires_grad': False, 'grad_shape': None, 'persist': True, 'active_sub_modules': set(), 'ds_tensor.shape': torch.Size([16384])}]

Yiwei98 avatar Dec 22 '24 14:12 Yiwei98

shell发一下

Jintao-Huang avatar Dec 22 '24 15:12 Jintao-Huang

shell发一下

default_values=( [BATCH_SIZE]=1 [LR]=1e-5 [EPOCHS]=2 [SAVE_STPES]=500 [OUTPUT_DIR]='output' [LAZY_TOKENIZE]=True [MAX_LEN]=8196 [TEST_RATIO]=0.05 [DEEPSPEED]='zero3' [LORA_RANK]=8 [LORA_ALPHA]=32 [LORA_DROPOUT_P]=0.05 [LORA_TARGET_MODULES]='all-linear' [GAS]=4 )

NNODES=$WORLD_SIZE
NODE_RANK=$RANK
swift rlhf
--rlhf_type kto
--model_type qwen2_5
--model $MODEL_DIR
--dataset $DATASET
--num_train_epochs $EPOCHS
--train_type lora
--tuner_backend peft
--output_dir $OUTPUT_DIR
--split_dataset_ratio $TEST_RATIO
--lora_rank $LORA_RANK
--lora_alpha $LORA_ALPHA
--lora_dropout $LORA_DROPOUT_P
--target_modules $LORA_TARGET_MODULES
--gradient_checkpointing true
--max_length $MAX_LEN
--lazy_tokenize $LAZY_TOKENIZE
--save_steps $SAVE_STPES
--per_device_train_batch_size $BATCH_SIZE
--torch_dtype bfloat16
--num_train_epochs $EPOCHS
--learning_rate $LR
--attn_impl flash_attn
--add_version false
--gradient_accumulation_steps $GAS
--warmup_ratio 0.01
--save_on_each_node false
--deepspeed $DEEPSPEED \

Yiwei98 avatar Dec 23 '24 03:12 Yiwei98

https://github.com/modelscope/ms-swift/issues/3237

Jintao-Huang avatar Mar 15 '25 03:03 Jintao-Huang

看看这个方法能否解决

Jintao-Huang avatar Mar 15 '25 03:03 Jintao-Huang

我也遇到了这个问题,请问解决了吗

TousenKaname avatar Mar 17 '25 02:03 TousenKaname

我也遇到了这个问题,请问解决了吗

我最后好像就是只训练不eval了。。。

Yiwei98 avatar Mar 17 '25 11:03 Yiwei98

我也遇到了这个问题,请问解决了吗

我最后好像就是只训练不eval了。。。

感谢回答!请问只训练不eval是有一个命令来直接配置吗,还是需要修改源码呢?最后infer的时候推理是没问题的吗,只是eval有问题

TousenKaname avatar Mar 17 '25 12:03 TousenKaname

我也遇到了这个问题,请问解决了吗

我最后好像就是只训练不eval了。。。

感谢回答!请问只训练不eval是有一个命令来直接配置吗,还是需要修改源码呢?最后infer的时候推理是没问题的吗,只是eval有问题

--split_dataset_ratio 我把这个设置成0了,infer没问题的

Yiwei98 avatar Mar 18 '25 03:03 Yiwei98

我也遇到了这个问题,请问解决了吗

我最后好像就是只训练不eval了。。。

感谢回答!请问只训练不eval是有一个命令来直接配置吗,还是需要修改源码呢?最后infer的时候推理是没问题的吗,只是eval有问题

--split_dataset_ratio 我把这个设置成0了,infer没问题的

感谢!🙏

TousenKaname avatar Mar 18 '25 03:03 TousenKaname

please retry with latest swift and vllm, feel free to create a new issue if it the problem persists.

z0o0ey avatar Jul 06 '26 02:07 z0o0ey