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

Qwen3.5 4.0.2 docker 镜像训练如果有视频数据训练中断(packing)

Open yszhli opened this issue 8 months ago • 5 comments

Checklist / 检查清单

  • [x] I have searched existing issues, and this is a new bug report. / 我已经搜索过现有的 issues,确认这是一个新的 bug report。

Bug Description / Bug 描述

here seems not to be a single sample in your epoch_iterator, stopping training at step 0! This is expected if you're using an IterableDataset and set num_steps (5674) higher than the number of available samples.

Train: 0%| | 0/5674 [00:00<?, ?it/s]There seems not to be a single sample in your epoch_iterator, stopping training at step 0! This is expected if you're using an IterableDataset and set num_steps (5674) higher than the number of available samples. [INFO:swift] use_logits_to_keep: False [WARNING:swift] The cross_entropy loss function defined in Liger Kernel will not take effect, potentially leading to increased GPU memory consumption. [rank5]: Traceback (most recent call last): [rank5]: File "/usr/local/lib/python3.11/site-packages/swift/cli/sft.py", line 20, in [rank5]: sft_main() [rank5]: File "/usr/local/lib/python3.11/site-packages/swift/pipelines/train/sft.py", line 354, in sft_main [rank5]: return SwiftSft(args).main() [rank5]: ^^^^^^^^^^^^^^^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/swift/pipelines/base.py", line 52, in main [rank5]: result = self.run() [rank5]: ^^^^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/swift/ray/base.py", line 168, in wrapper [rank5]: return func(self, *args, **kwargs) [rank5]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/swift/pipelines/train/sft.py", line 197, in run [rank5]: return self.train(trainer) [rank5]: ^^^^^^^^^^^^^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/swift/pipelines/train/sft.py", line 270, in train [rank5]: trainer.train(resume_checkpoint) [rank5]: File "/usr/local/lib/python3.11/site-packages/swift/trainers/mixin.py", line 895, in train [rank5]: res = super().train(*args, **kwargs) [rank5]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/transformers/trainer.py", line 1424, in train [rank5]: return inner_training_loop( [rank5]: ^^^^^^^^^^^^^^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/transformers/trainer.py", line 1506, in _inner_training_loop [rank5]: self._run_epoch( [rank5]: File "/usr/local/lib/python3.11/site-packages/transformers/trainer.py", line 1734, in _run_epoch [rank5]: tr_loss_step = self.training_step(model, inputs, num_items_in_batch) [rank5]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/swift/trainers/seq2seq_trainer.py", line 227, in training_step [rank5]: return super().training_step(model, inputs, *args, **kwargs) [rank5]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/transformers/trainer.py", line 1906, in training_step [rank5]: loss = self.compute_loss(model, inputs, num_items_in_batch=num_items_in_batch) [rank5]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/swift/trainers/seq2seq_trainer.py", line 137, in compute_loss [rank5]: outputs = model(**inputs) [rank5]: ^^^^^^^^^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1776, in _wrapped_call_impl [rank5]: return self._call_impl(*args, **kwargs) [rank5]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1787, in _call_impl [rank5]: return forward_call(*args, **kwargs) [rank5]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/deepspeed/utils/nvtx.py", line 20, in wrapped_fn [rank5]: ret_val = func(*args, **kwargs) [rank5]: ^^^^^^^^^^^^^^^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/deepspeed/runtime/engine.py", line 2316, in forward [rank5]: loss = self.module(*inputs, **kwargs) [rank5]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1776, in _wrapped_call_impl [rank5]: return self._call_impl(*args, **kwargs) [rank5]: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1882, in _call_impl [rank5]: return inner() [rank5]: ^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1819, in inner [rank5]: args_result = hook(self, args) [rank5]: ^^^^^^^^^^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/deepspeed/utils/nvtx.py", line 20, in wrapped_fn [rank5]: ret_val = func(*args, **kwargs) [rank5]: ^^^^^^^^^^^^^^^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/deepspeed/runtime/zero/parameter_offload.py", line 253, in _start_of_forward_hook [rank5]: self.get_param_coordinator().reset_step() [rank5]: File "/usr/local/lib/python3.11/site-packages/torch/_dynamo/eval_frame.py", line 1181, in _fn [rank5]: return fn(*args, **kwargs) [rank5]: ^^^^^^^^^^^^^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/deepspeed/runtime/zero/partitioned_param_coordinator.py", line 245, in reset_step [rank5]: assert_ints_same_as_other_ranks([m.ds_id for m in self.__submodule_order]) [rank5]: File "/usr/local/lib/python3.11/site-packages/deepspeed/utils/nvtx.py", line 20, in wrapped_fn [rank5]: ret_val = func(*args, **kwargs) [rank5]: ^^^^^^^^^^^^^^^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/deepspeed/runtime/zero/utils.py", line 112, in assert_ints_same_as_other_ranks [rank5]: assert_lst_len_same_as_other_ranks(ints) [rank5]: File "/usr/local/lib/python3.11/site-packages/deepspeed/utils/nvtx.py", line 20, in wrapped_fn [rank5]: ret_val = func(*args, **kwargs) [rank5]: ^^^^^^^^^^^^^^^^^^^^^ [rank5]: File "/usr/local/lib/python3.11/site-packages/deepspeed/runtime/zero/utils.py", line 82, in assert_lst_len_same_as_other_ranks [rank5]: raise RuntimeError(f"Detected a disagreement on list length between rank0 and rank{dist.get_rank()}: " [rank5]: RuntimeError: Detected a disagreement on list length between rank0 and rank5:

How to Reproduce / 如何复现

PYTORCH_ALLOC_CONF='expandable_segments:True'
QWENVL_BBOX_FORMAT='new'
SWANLAB_API_KEY=QDnbD22xn3vlEZrEuBGXY
IMAGE_MAX_TOKEN_NUM=1600 NPROC_PER_NODE=8 CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 swift sft
--model /opt/wfs2_5t/models/hub/Qwen3.5-4B
--load_from_cache_file True
--dataset test.jsonl
--per_device_train_batch_size 1
--per_device_eval_batch_size 1 --deepspeed zero3
--save_total_limit 2 --save_steps 2500 --eval_steps 2500
--output_dir output_model --train_type full
--torch_dtype bfloat16 --learning_rate 1e-5 --num_train_epochs 1
--attn_impl flash_attn --warmup_ratio 0.1 --save_only_model True
--use_liger_kernel true
--gradient_accumulation_steps 2 --dataloader_num_workers 4
--enable_channel_loss True
--padding_free True
--max_length 30000
--packing True
--add_non_thinking_prefix true
--loss_scale ignore_empty_think
--dataset_num_proc 100
视频数据格式如下: {'messages': [{'role': 'user', 'content': "These are frames of a video.\nMeasuring from the closest point of each object, which of these objects (door, towel, plant, chair) is the closest to the refrigerator?\nIf there are multiple instances of an object category, measure to the closest.\nOptions:\nA. door\nB. towel\nC. plant\nD. chair\nAnswer with the option's letter from the given choices directly."}, {'role': 'assistant', 'content': 'D'}], 'videos': [['frame1.jpg','xxx']]}

Additional Information / 补充信息

No response

yszhli avatar Mar 17 '26 11:03 yszhli

https://github.com/huggingface/transformers/pull/44474

Jintao-Huang avatar Mar 18 '26 02:03 Jintao-Huang

遇到同样问题

KYRIE-LI11 avatar Mar 18 '26 19:03 KYRIE-LI11

同样遇到加载不到视频数据,不过没后面的那些报错: [INFO:swift] Successfully registered post_encode hook: ['PeftModelForCausalLM']. The tokenizer has new PAD/BOS/EOS tokens that differ from the model config and generation config. The model config and generation config were aligned accordingly, being updated with the tokenizer's values. Updated tokens: {'eos_token_id': 248046, 'pad_token_id': 248044}. Train: 0%| | 0/189 [00:00<?, ?it/s]There seems not to be a single sample in your epoch_iterator, stopping training at step 0! This is expected if you're using an IterableDataset and set num_steps (189) higher than the number of available samples. {'train_runtime': '0.2679', 'train_samples_per_second': '5598', 'train_steps_per_second': '705.4', 'train_loss': '0', 'epoch': 0, 'global_step/max_steps': '0/189', 'elapsed_time': '0s', 'remaining_time': '0s', 'memory(GiB)': '1.62', 'train_speed(s/it)': '0'} Train: 0%| | 0/189 [00:00<?, ?it/s]

coderworld avatar Mar 19 '26 02:03 coderworld

use transformers 5.2.0

Jintao-Huang avatar Mar 19 '26 03:03 Jintao-Huang

use transformers 5.2.0

实测已解决,谢谢!

KYRIE-LI11 avatar Mar 19 '26 06:03 KYRIE-LI11