Qwen3-VL SFT n_try_fetch error
Checklist / 检查清单
- [x] I have searched existing issues, and this is a new question or discussion topic. / 我已经搜索过现有的 issues,确认这是一个新的问题与讨论。
Question Description / 问题描述
boot cmd: when FPS_MAX_FRAMES = 16 is ok, but FPS_MAX_FRAMES=360 or larger has error.
PYTORCH_CUDA_ALLOC_CONF='expandable_segments:True' \
IMAGE_MAX_TOKEN_NUM=1024 \
VIDEO_MAX_TOKEN_NUM=256 \
FPS_MAX_FRAMES=360 \
NPROC_PER_NODE=2 \
CUDA_VISIBLE_DEVICES=0,1 \
swift sft \
--model local_path/Qwen3-VL-8B-Instruct \
--dataset 'dataset/data_train.jsonl' \
--val_dataset 'dataset/data_val.jsonl' \
--load_from_cache_file true \
--split_dataset_ratio 0.01 \
--train_type lora \
--torch_dtype bfloat16 \
--num_train_epochs 1 \
--per_device_train_batch_size 1 \
--per_device_eval_batch_size 1 \
--attn_impl flash_attn \
--padding_free true \
--learning_rate 1e-4 \
--lora_rank 8 \
--lora_alpha 32 \
--target_modules all-linear \
--freeze_vit true \
--freeze_aligner true \
--packing true \
--gradient_checkpointing true \
--vit_gradient_checkpointing false \
--gradient_accumulation_steps 2 \
--eval_steps 100 \
--save_steps 100 \
--save_total_limit 2 \
--logging_steps 5 \
--max_length 4096 \
--output_dir output \
--warmup_ratio 0.05 \
--deepspeed zero2 \
--dataset_num_proc 4 \
--dataloader_num_workers 4
Error log:
[rank0]: Traceback (most recent call last):
[rank0]: File "/usr/local/miniconda3/lib/python3.10/site-packages/swift/cli/sft.py", line 20, in <module>
[rank0]: sft_main()
[rank0]: File "/usr/local/miniconda3/lib/python3.10/site-packages/swift/llm/train/sft.py", line 365, in sft_main
[rank0]: return SwiftSft(args).main()
[rank0]: File "/usr/local/miniconda3/lib/python3.10/site-packages/swift/llm/base.py", line 49, in main
[rank0]: result = self.run()
[rank0]: File "/usr/local/miniconda3/lib/python3.10/site-packages/swift/ray/base.py", line 170, in wrapper
[rank0]: return func(self, *args, **kwargs)
[rank0]: File "/usr/local/miniconda3/lib/python3.10/site-packages/swift/llm/train/sft.py", line 184, in run
[rank0]: train_dataset, val_dataset = self._prepare_dataset()
[rank0]: File "/usr/local/miniconda3/lib/python3.10/site-packages/swift/ray/base.py", line 170, in wrapper
[rank0]: return func(self, *args, **kwargs)
[rank0]: File "/usr/local/miniconda3/lib/python3.10/site-packages/swift/llm/train/sft.py", line 144, in _prepare_dataset
[rank0]: datasets = self._post_process_datasets(datasets)
[rank0]: File "/usr/local/miniconda3/lib/python3.10/site-packages/swift/llm/train/sft.py", line 160, in _post_process_datasets
[rank0]: dataset = LazyLLMDataset(dataset, template.encode, strict=args.strict, random_state=args.data_seed)
[rank0]: File "/usr/local/miniconda3/lib/python3.10/site-packages/swift/llm/dataset/utils.py", line 77, in __init__
[rank0]: assert n_try_fetch >= 1
[rank0]: AssertionError
try --max_length 8192
try --max_length 8192 @Jintao-Huang Thanks
-
What are the differences between FPS and FPS_MAX_FRAMES, and will there be conflicts when setting them simultaneously?
-
The timestamp result is a bit strange when performing temporal video grounding task. What Settings should be taken to avoid it when training and inference? The input is a video file.
For the FPS follow-up: FPS controls the requested sampling rate, while FPS_MAX_FRAMES caps the resulting number of sampled frames. They can be used together; for a long video the cap means the effective sampling rate may be lower than the requested FPS.
For temporal grounding, compare the actual selected frame indices/timestamps between training and inference. Don't reconstruct timestamps as frame_index / requested_FPS after a frame cap or resampling has changed the selection. Keep the processor/video backend versions and sampling settings aligned too.
The original 360-frame example also has a 4096-token limit. Check the final encoded length before training: hundreds of frames plus text can exceed it even if the video itself decodes successfully. The n_try_fetch assertion alone doesn't identify the first encoding error; inspecting one sample with strict error reporting should expose it.