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

LLaVA-OneVision-1.5-8B-Instruct sft阶段的训练问题

Open houleisai opened this issue 11 months ago • 7 comments

Describe the bug What the bug is, and how to reproduce, better with screenshots(描述bug以及复现过程,最好有截图)

你好,我遇到以下问题 在使用Qwen2.5_vl_7B_Instruct 以及 Qwen3_vl_8B_Instruct 两个基模能够正常完成sft阶段的全参训练,但是在使用LLaVA-OneVision-1.5-8B-Instruct进行全参训练的过程中却遇到以下问题。 报错信息如下: [rank0]: Traceback (most recent call last): [rank0]: File "/usr/local/lib/python3.10/dist-packages/swift/cli/sft.py", line 20, in [rank0]: sft_main() [rank0]: File "/usr/local/lib/python3.10/dist-packages/swift/llm/train/sft.py", line 364, in sft_main [rank0]: return SwiftSft(args).main() [rank0]: File "/usr/local/lib/python3.10/dist-packages/swift/llm/base.py", line 49, in main [rank0]: result = self.run() [rank0]: File "/usr/local/lib/python3.10/dist-packages/swift/ray/base.py", line 170, in wrapper [rank0]: return func(self, *args, **kwargs) [rank0]: File "/usr/local/lib/python3.10/dist-packages/swift/llm/train/sft.py", line 209, in run [rank0]: return self.train(trainer) [rank0]: File "/usr/local/lib/python3.10/dist-packages/swift/llm/train/sft.py", line 257, in train [rank0]: trainer.train(trainer.args.resume_from_checkpoint) [rank0]: File "/usr/local/lib/python3.10/dist-packages/swift/trainers/mixin.py", line 821, in train [rank0]: res = super().train(*args, **kwargs) [rank0]: File "/usr/local/lib/python3.10/dist-packages/transformers/trainer.py", line 2206, in train [rank0]: return inner_training_loop( [rank0]: File "/usr/local/lib/python3.10/dist-packages/transformers/trainer.py", line 2548, in _inner_training_loop [rank0]: tr_loss_step = self.training_step(model, inputs, num_items_in_batch) [rank0]: File "/usr/local/lib/python3.10/dist-packages/swift/trainers/trainers.py", line 415, in training_step [rank0]: return super().training_step(model, inputs, *args, **kwargs) [rank0]: File "/usr/local/lib/python3.10/dist-packages/transformers/trainer.py", line 3797, in training_step [rank0]: self.accelerator.backward(loss, **kwargs) [rank0]: File "/usr/local/lib/python3.10/dist-packages/accelerate/accelerator.py", line 2844, in backward [rank0]: self.deepspeed_engine_wrapped.backward(loss, sync_gradients=self.sync_gradients, **kwargs) [rank0]: File "/usr/local/lib/python3.10/dist-packages/accelerate/utils/deepspeed.py", line 270, in backward [rank0]: self.engine.backward(loss, **kwargs) [rank0]: File "/usr/local/lib/python3.10/dist-packages/deepspeed/utils/nvtx.py", line 20, in wrapped_fn [rank0]: ret_val = func(*args, **kwargs) [rank0]: File "/usr/local/lib/python3.10/dist-packages/deepspeed/runtime/engine.py", line 2323, in backward [rank0]: self._do_optimizer_backward(loss, retain_graph) [rank0]: File "/usr/local/lib/python3.10/dist-packages/deepspeed/runtime/engine.py", line 2269, in _do_optimizer_backward [rank0]: self.optimizer.backward(loss, retain_graph=retain_graph) [rank0]: File "/usr/local/lib/python3.10/dist-packages/deepspeed/utils/nvtx.py", line 20, in wrapped_fn [rank0]: ret_val = func(*args, **kwargs) [rank0]: File "/usr/local/lib/python3.10/dist-packages/deepspeed/runtime/zero/stage3.py", line 2318, in backward [rank0]: self.loss_scaler.backward(loss.float(), retain_graph=retain_graph) [rank0]: File "/usr/local/lib/python3.10/dist-packages/deepspeed/runtime/fp16/loss_scaler.py", line 65, in backward [rank0]: scaled_loss.backward(retain_graph=retain_graph) [rank0]: File "/usr/local/lib/python3.10/dist-packages/torch/_tensor.py", line 648, in backward [rank0]: torch.autograd.backward( [rank0]: File "/usr/local/lib/python3.10/dist-packages/torch/autograd/init.py", line 353, in backward [rank0]: _engine_run_backward( [rank0]: File "/usr/local/lib/python3.10/dist-packages/torch/autograd/graph.py", line 824, in _engine_run_backward [rank0]: return Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass [rank0]: File "/usr/local/lib/python3.10/dist-packages/torch/autograd/function.py", line 307, in apply [rank0]: return user_fn(self, *args) [rank0]: File "/usr/local/lib/python3.10/dist-packages/torch/utils/checkpoint.py", line 320, in backward [rank0]: torch.autograd.backward(outputs_with_grad, args_with_grad) [rank0]: File "/usr/local/lib/python3.10/dist-packages/torch/autograd/init.py", line 353, in backward [rank0]: _engine_run_backward( [rank0]: File "/usr/local/lib/python3.10/dist-packages/torch/autograd/graph.py", line 824, in _engine_run_backward [rank0]: return Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass [rank0]: RuntimeError: Trying to backward through the graph a second time (or directly access saved tensors after they have already been freed). Saved intermediate values of the graph are freed when you call .backward() or autograd.grad(). Specify retain_graph=True if you need to backward through the graph a second time or if you need to access saved tensors after calling backward. Train: 0%| | 0/40000 [00:02<?, ?it/s] E1217 14:36:29.827000 6531 torch/distributed/elastic/multiprocessing/api.py:874] failed (exitcode: 1) local_rank: 0 (pid: 6553) of binary: /usr/bin/python3 Traceback (most recent call last): File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/usr/local/lib/python3.10/dist-packages/torch/distributed/run.py", line 896, in main() File "/usr/local/lib/python3.10/dist-packages/torch/distributed/elastic/multiprocessing/errors/init.py", line 355, in wrapper return f(*args, **kwargs) File "/usr/local/lib/python3.10/dist-packages/torch/distributed/run.py", line 892, in main run(args) File "/usr/local/lib/python3.10/dist-packages/torch/distributed/run.py", line 883, in run elastic_launch( File "/usr/local/lib/python3.10/dist-packages/torch/distributed/launcher/api.py", line 139, in call return launch_agent(self._config, self._entrypoint, list(args)) File "/usr/local/lib/python3.10/dist-packages/torch/distributed/launcher/api.py", line 270, in launch_agent raise ChildFailedError( torch.distributed.elastic.multiprocessing.errors.ChildFailedError:

/usr/local/lib/python3.10/dist-packages/swift/cli/sft.py FAILED

Failures: <NO_OTHER_FAILURES>

Root Cause (first observed failure): [0]: time : 2025-12-17_14:36:29 host : rank : 0 (local_rank: 0) exitcode : 1 (pid: 6553) error_file: <N/A> traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html

sft阶段的训练代码如下:

MAX_PIXELS=1003520
NPROC_PER_NODE=8
CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7
swift sft
--model /mnt/foundational_model/LLaVA-OneVision-1.5-8B-Instruct
--train_type full
--model_type llava_onevision1_5
--dataset /mnt/datasets/rl_1_image/train_label_updated.jsonl
--torch_dtype bfloat16
--freeze_llm false
--freeze_vit false
--freeze_aligner false
--max_steps 40000
--per_device_train_batch_size 1
--learning_rate 1e-5
--vit_lr 5e-6
--aligner_lr 5e-6
--gradient_accumulation_steps 2
--gradient_checkpointing true
--vit_gradient_checkpointing true
--save_steps 10000
--logging_steps 5
--max_length 10000
--warmup_ratio 0.05
--dataloader_num_workers 8
--dataset_num_proc 8
--save_total_limit 20
--save_only_model true
--deepspeed zero3
--output_dir /mnt/LLaVA_first_label
--loss_scale all
--attn_impl flash_attn

报错信息显示以下三个能够降低显存的参数存在冲突,另外以上报错信息在全参训练的时候出现,在lora训练的时候未出现 --gradient_checkpointing true
--vit_gradient_checkpointing true
--deepspeed zero3 \

我尝试了以下方式1和方式2,能够进行训练,但一段时间后就都会出现oom爆显存的问题 方式1: --gradient_checkpointing false
--vit_gradient_checkpointing false
--deepspeed zero3(zero2、zero1) \

方式2: --gradient_checkpointing ture
--vit_gradient_checkpointing ture \

Your hardware and system info Write your system info like CUDA version/system/GPU/torch version here(在这里给出硬件信息和系统信息,如CUDA版本,系统,GPU型号和torch版本等)

CUDA版本12.4 GPU型号A800 torch版本2.7.1 另外LLaVA-OneVision-1.5-8B-Instruct 对transformers 版本有特定的需求,4.53.1 和4.53.2我试过是可以的,但是最新的transformers版本应该是不适配 具体版本信息如下:

Package Version


absl-py 2.3.1 accelerate 1.12.0 addict 2.4.0 aiofiles 24.1.0 aiohappyeyeballs 2.6.1 aiohttp 3.13.2 aiosignal 1.4.0 aliyun-python-sdk-core 2.16.0 aliyun-python-sdk-kms 2.16.5 annotated-doc 0.0.4 annotated-types 0.7.0 antlr4-python3-runtime 4.9.3 anyio 4.12.0 astor 0.8.1 async-timeout 5.0.1 attrdict 2.0.1 attrs 25.4.0 av 16.0.1 binpacking 1.5.2 blake3 1.0.8 blinker 1.4 brotli 1.2.0 cachetools 6.2.2 cbor2 5.7.1 certifi 2025.11.12 cffi 2.0.0 charset-normalizer 3.4.4 click 8.2.1 cloudpickle 3.1.2 compressed-tensors 0.10.2 contourpy 1.3.2 cpm-kernels 1.0.11 crcmod 1.7 cryptography 3.4.8 cupy-cuda12x 13.6.0 cycler 0.12.1 dacite 1.9.2 datasets 3.3.2 dbus-python 1.2.18 deepspeed 0.17.6 depyf 0.19.0 dill 0.3.8 diskcache 5.6.3 distro 1.7.0 distro-info 1.1+ubuntu0.2 dnspython 2.8.0 einops 0.8.1 email-validator 2.3.0 exceptiongroup 1.3.1 fastapi 0.124.0 fastapi-cli 0.0.16 fastapi-cloud-cli 0.6.0 fastar 0.8.0 fastrlock 0.8.3 ffmpy 1.0.0 filelock 3.20.0 flash_attn 2.7.4.post1 fonttools 4.61.0 frozenlist 1.8.0 fsspec 2024.12.0 future 1.0.0 gguf 0.17.1 gradio 5.50.0 gradio_client 1.14.0 groovy 0.1.2 grpcio 1.76.0 h11 0.16.0 hf-xet 1.2.0 hjson 3.1.0 httpcore 1.0.9 httplib2 0.20.2 httptools 0.7.1 httpx 0.28.1 huggingface-hub 0.36.0 idna 3.11 importlib-metadata 4.6.4 interegular 0.3.3 jeepney 0.7.1 jieba 0.42.1 Jinja2 3.1.6 jiter 0.12.0 jmespath 0.10.0 joblib 1.5.2 json_repair 0.54.2 jsonschema 4.25.1 jsonschema-specifications 2025.9.1 keyring 23.5.0 kiwisolver 1.4.9 lark 1.2.2 latex2sympy2_extended 1.0.6 launchpadlib 1.10.16 lazr.restfulclient 0.14.4 lazr.uri 1.0.6 llguidance 0.7.30 llvmlite 0.44.0 lm-format-enforcer 0.10.12 Markdown 3.10 markdown-it-py 4.0.0 MarkupSafe 3.0.3 math-verify 0.5.2 matplotlib 3.10.7 mdurl 0.1.2 mistral_common 1.8.6 modelscope 1.32.0 more-itertools 8.10.0 mpmath 1.3.0 ms_swift 3.11.0 msgpack 1.1.2 msgspec 0.20.0 multidict 6.7.0 multiprocess 0.70.16 networkx 3.4.2 ninja 1.13.0 nltk 3.9.2 numba 0.61.2 numpy 2.2.6 nvidia-cublas-cu12 12.6.4.1 nvidia-cuda-cupti-cu12 12.6.80 nvidia-cuda-nvrtc-cu12 12.6.77 nvidia-cuda-runtime-cu12 12.6.77 nvidia-cudnn-cu12 9.5.1.17 nvidia-cufft-cu12 11.3.0.4 nvidia-cufile-cu12 1.11.1.6 nvidia-curand-cu12 10.3.7.77 nvidia-cusolver-cu12 11.7.1.2 nvidia-cusparse-cu12 12.5.4.2 nvidia-cusparselt-cu12 0.6.3 nvidia-ml-py 13.590.44 nvidia-nccl-cu12 2.26.2 nvidia-nvjitlink-cu12 12.6.85 nvidia-nvtx-cu12 12.6.77 oauthlib 3.2.0 omegaconf 2.3.0 openai 1.90.0 opencv-python-headless 4.12.0.88 orjson 3.11.5 oss2 2.19.1 outlines_core 0.2.10 packaging 25.0 pandas 2.3.3 partial-json-parser 0.2.1.1.post7 peft 0.16.0 pillow 11.3.0 pip 22.0.2 prometheus_client 0.23.1 prometheus-fastapi-instrumentator 7.1.0 propcache 0.4.1 protobuf 6.33.2 psutil 7.1.3 py-cpuinfo 9.0.0 pyarrow 22.0.0 pybase64 1.4.3 pycountry 24.6.1 pycparser 2.23 pycryptodome 3.23.0 pydantic 2.12.3 pydantic_core 2.41.4 pydantic-extra-types 2.10.6 pydub 0.25.1 Pygments 2.19.2 PyGObject 3.42.1 PyJWT 2.3.0 pyparsing 3.2.5 python-apt 2.4.0+ubuntu4 python-dateutil 2.9.0.post0 python-dotenv 1.2.1 python-json-logger 4.0.0 python-multipart 0.0.20 pytz 2025.2 PyYAML 5.4.1 pyzmq 27.1.0 qwen-vl-utils 0.0.14 ray 2.52.1 referencing 0.37.0 regex 2025.11.3 requests 2.32.5 rich 14.2.0 rich-toolkit 0.17.0 rignore 0.7.6 rouge 1.0.1 rpds-py 0.30.0 ruff 0.14.8 safehttpx 0.1.7 safetensors 0.7.0 scipy 1.15.3 SecretStorage 3.3.1 semantic-version 2.10.0 sentencepiece 0.2.1 sentry-sdk 2.47.0 setuptools 59.6.0 shellingham 1.5.4 simplejson 3.20.2 six 1.16.0 sniffio 1.3.1 sortedcontainers 2.4.0 soundfile 0.13.1 soxr 1.0.0 ssh-import-id 5.11 starlette 0.50.0 sympy 1.14.0 tensorboard 2.20.0 tensorboard-data-server 0.7.2 tiktoken 0.12.0 timm 1.0.22 tokenizers 0.21.4 tomli 2.3.0 tomlkit 0.13.3 torch 2.7.1 torchaudio 2.7.1 torchvision 0.22.1 tqdm 4.67.1 transformers 4.53.2 transformers-stream-generator 0.0.5 triton 3.3.1 trl 0.20.0 typer 0.20.0 typing_extensions 4.15.0 typing-inspection 0.4.2 tzdata 2025.2 ufw 0.36.1 unattended-upgrades 0.1 urllib3 2.6.1 uvicorn 0.38.0 uvloop 0.22.1 vllm 0.10.0 wadllib 1.3.6 watchfiles 1.1.1 websockets 15.0.1 Werkzeug 3.1.4 wheel 0.37.1 xformers 0.0.31 xgrammar 0.1.21 xxhash 3.6.0 yarl 1.22.0 zipp 1.0.0 zstandard 0.25.0

Additional context Add any other context about the problem here(在这里补充其他信息) 希望能够得到反馈,十分感谢

houleisai avatar Dec 17 '25 07:12 houleisai

数据格式啥样的?

slin000111 avatar Dec 18 '25 02:12 slin000111

数据格式啥样的?

训练数据包含图片和文本,组织格式是按照swift所提供的标准的多模态的格式进行组织的

Image

示例如下: {"messages": [{"role": "system", "content": "You are a forensic analyst specializing ..........."}, {"role": "user", "content": "Given the news content: 'A Victorian court decided on Friday that former AFL player agent Ricky Nixon can publish his tellall book despite Kim Duthie s push to ban it' and the associated image , please perform a compreh............."}, {"role": "assistant", "content": "News tam..............."}], "images": ["datasets/swap/995762-043201.jpg"], "solution": {"text": "A Victorian court decided on Friday that former AFL player agent Ricky Nixon can publ.........."}}

houleisai avatar Dec 18 '25 03:12 houleisai

前面的环境,方便改成torch 2.8.0, deepspeed 0.16.9跑一下吗?

slin000111 avatar Dec 18 '25 06:12 slin000111

前面的环境,方便改成torch 2.8.0, deepspeed 0.16.9跑一下吗? 更新环境后仍显示该问题,

Image Image Training started at Thu Dec 18 03:08:01 PM CST 2025 Log file: run sh: `/usr/bin/python3 -m torch.distributed.run --nproc_per_node 1 /usr/local/lib/python3.10/dist-packages/swift/cli/sft.py --model /mnt/LLaVA-OneVision-1.5-8B-Instruct --train_type full --dataset /mnt/rl_1_image/train_label_updated.jsonl --torch_dtype bfloat16 --freeze_llm false --freeze_vit false --freeze_aligner false --max_steps 40000 --per_device_train_batch_size 1 --learning_rate 1e-5 --vit_lr 5e-6 --aligner_lr 5e-6 --gradient_accumulation_steps 2 --gradient_checkpointing true --vit_gradient_checkpointing true --packing false --save_steps 10000 --logging_steps 5 --max_length 10000 --warmup_ratio 0.05 --dataloader_num_workers 8 --dataset_num_proc 8 --save_total_limit 20 --save_only_model true --deepspeed zero3 --output_dir /mnt/swift_fake/LLaVA_first_label --loss_scale all --model_type llava_onevision1_5 --attn_impl flash_attn` [INFO:swift] Successfully registered `/usr/local/lib/python3.10/dist-packages/swift/llm/dataset/data/dataset_info.json`. [INFO:swift] rank: 0, local_rank: 0, world_size: 1, local_world_size: 1 [INFO:swift] Setting args.lazy_tokenize: True [INFO:swift] additional trainable_parameters: ['model.visual.merger'] [INFO:swift] Using deepspeed: {'fp16': {'enabled': 'auto', 'loss_scale': 0, 'loss_scale_window': 1000, 'initial_scale_power': 16, 'hysteresis': 2, 'min_loss_scale': 1}, 'bf16': {'enabled': 'auto'}, 'zero_optimization': {'stage': 3, 'offload_optimizer': {'device': 'none', 'pin_memory': True}, 'offload_param': {'device': 'none', 'pin_memory': True}, 'overlap_comm': False, 'contiguous_gradients': True, 'sub_group_size': 1000000000.0, 'reduce_bucket_size': 'auto', 'zero_quantized_weights': False, 'zero_quantized_gradients': False, 'stage3_prefetch_bucket_size': 'auto', 'stage3_param_persistence_threshold': 'auto', 'stage3_max_live_parameters': 1000000000.0, 'stage3_max_reuse_distance': 1000000000.0, 'stage3_gather_16bit_weights_on_model_save': True}, 'gradient_accumulation_steps': 'auto', 'gradient_clipping': 'auto', 'steps_per_print': 2000, 'train_batch_size': 'auto', 'train_micro_batch_size_per_gpu': 'auto', 'wall_clock_breakdown': False} [2025-12-18 15:08:11,392] [INFO] [real_accelerator.py:254:get_accelerator] Setting ds_accelerator to cuda (auto detect) [2025-12-18 15:08:12,985] [INFO] [comm.py:669:init_distributed] cdb=None [2025-12-18 15:08:12,985] [INFO] [comm.py:700:init_distributed] Initializing TorchBackend in DeepSpeed with backend nccl [INFO:swift] output_dir: [INFO:swift] Global seed set to 42 [INFO:swift] args: TrainArguments( _n_gpu=-1, acc_strategy=token, accelerator_config={'dispatch_batches': False}, adafactor=False, adalora_beta1=0.85, adalora_beta2=0.85, adalora_deltaT=1, adalora_init_r=12, adalora_orth_reg_weight=0.5, adalora_target_r=8, adalora_tfinal=0, adalora_tinit=0, adam_beta1=0.9, adam_beta2=0.95, adam_epsilon=1e-08, adapter_act=gelu, adapter_length=128, adapters=[], add_version=True, agent_template=None, aligner_lr=5e-06, attn_impl=flash_attn, auto_find_batch_size=False, average_tokens_across_devices=False, batch_eval_metrics=False, bf16=True, bf16_full_eval=False, bnb_4bit_compute_dtype=torch.bfloat16, bnb_4bit_quant_storage=None, bnb_4bit_quant_type=nf4, bnb_4bit_use_double_quant=True, boft_block_num=0, boft_block_size=4, boft_dropout=0.0, boft_n_butterfly_factor=1, cached_dataset=[], check_model=True, ckpt_dir=None, columns={}, create_checkpoint_symlink=False, custom_dataset_info=[], custom_register_path=[], data_seed=42, dataloader_drop_last=False, dataloader_num_workers=8, dataloader_persistent_workers=False, dataloader_pin_memory=True, dataloader_prefetch_factor=None, dataset=[''], dataset_num_proc=8, dataset_shuffle=True, ddp_backend=None, ddp_broadcast_buffers=None, ddp_bucket_cap_mb=None, ddp_find_unused_parameters=None, ddp_timeout=18000000, debug=None, deepspeed={'fp16': {'enabled': 'auto', 'loss_scale': 0, 'loss_scale_window': 1000, 'initial_scale_power': 16, 'hysteresis': 2, 'min_loss_scale': 1}, 'bf16': {'enabled': 'auto'}, 'zero_optimization': {'stage': 3, 'offload_optimizer': {'device': 'none', 'pin_memory': True}, 'offload_param': {'device': 'none', 'pin_memory': True}, 'overlap_comm': False, 'contiguous_gradients': True, 'sub_group_size': 1000000000.0, 'reduce_bucket_size': 'auto', 'zero_quantized_weights': False, 'zero_quantized_gradients': False, 'stage3_prefetch_bucket_size': 'auto', 'stage3_param_persistence_threshold': 'auto', 'stage3_max_live_parameters': 1000000000.0, 'stage3_max_reuse_distance': 1000000000.0, 'stage3_gather_16bit_weights_on_model_save': True}, 'gradient_accumulation_steps': 'auto', 'gradient_clipping': 'auto', 'steps_per_print': 2000, 'train_batch_size': 'auto', 'train_micro_batch_size_per_gpu': 'auto', 'wall_clock_breakdown': False}, deepspeed_autotp_size=None, device_groups=None, device_map=None, disable_tqdm=None, do_eval=False, do_predict=False, do_train=False, download_mode=reuse_dataset_if_exists, ds3_gather_for_generation=True, early_stop_interval=None, enable_channel_loss=False, enable_dft_loss=False, eval_accumulation_steps=None, eval_dataset=[], eval_dataset_args=None, eval_delay=0, eval_do_concat_batches=True, eval_generation_config=None, eval_limit=None, eval_on_start=False, eval_steps=10000.0, eval_strategy=no, eval_use_evalscope=False, eval_use_gather_object=False, external_plugins=[], extra_eval_args=None, fourier_n_frequency=2000, fourier_scaling=300.0, fp16=False, fp16_backend=auto, fp16_full_eval=False, fp16_opt_level=O1, freeze_aligner=False, freeze_llm=False, freeze_parameters=[], freeze_parameters_ratio=0.0, freeze_parameters_regex=None, freeze_vit=False, fsdp=, fsdp_config=None, fsdp_min_num_params=0, fsdp_transformer_layer_cls_to_wrap=None, full_determinism=False, galore_cos_threshold=0.4, galore_gamma_proj=2, galore_optim_per_parameter=False, galore_proj_bits=4, galore_proj_group_size=256, galore_proj_quant=False, galore_proj_type=std, galore_quantization=False, galore_queue_size=5, galore_rank=128, galore_scale=1.0, galore_target_modules=None, galore_update_proj_gap=50, galore_with_embedding=False, generation_config=None, generation_max_length=None, generation_num_beams=None, gradient_accumulation_steps=2, gradient_checkpointing=True, gradient_checkpointing_kwargs=None, greater_is_better=False, group_by_length=False, half_precision_backend=auto, hqq_axis=None, hub_always_push=False, hub_model_id=None, hub_private_repo=None, hub_revision=None, hub_strategy=every_save, hub_token=, ignore_args_error=False, ignore_data_skip=False, include_for_metrics=[], include_inputs_for_metrics=False, include_num_input_tokens_seen=False, include_tokens_per_second=False, init_strategy=None, init_weights=True, interleave_prob=None, jit_mode_eval=False, label_names=None, label_smoothing_factor=0.0, lazy_tokenize=True, learning_rate=1e-05, length_column_name=length, liger_kernel_config=None, lisa_activated_layers=0, lisa_step_interval=20, llamapro_num_groups=None, llamapro_num_new_blocks=4, load_args=False, load_best_model_at_end=False, load_data_args=False, load_from_cache_file=False, local_rank=0, local_repo_path=None, log_level=passive, log_level_replica=warning, log_on_each_node=True, logging_dir=runs, logging_first_step=True, logging_nan_inf_filter=True, logging_steps=5, logging_strategy=steps, logprobs=False, lora_alpha=32, lora_bias=none, lora_dropout=0.05, lora_dtype=None, lora_ga_batch_size=2, lora_ga_direction=ArB2r, lora_ga_iters=2, lora_ga_max_length=1024, lora_ga_scale=stable, lora_ga_stable_gamma=16, lora_modules=[], lora_rank=8, lorap_lr_ratio=None, loss_scale=all, loss_type=None, lr_scheduler_kwargs=None, lr_scheduler_type=cosine, max_epochs=None, max_grad_norm=1.0, max_length=10000, max_memory={}, max_model_len=None, max_new_tokens=64, max_pixels=None, max_steps=40000, metric=None, metric_for_best_model=loss, model=/mnt/foundational_model/LLaVA-OneVision-1.5-8B-Instruct, model_author=None, model_kwargs={}, model_name=None, model_revision=None, model_type=llava_onevision1_5, modules_to_save=[], mp_parameters=, neftune_noise_alpha=None, new_special_tokens=[], no_cuda=False, norm_bbox=None, num_beams=1, num_labels=None, num_train_epochs=3.0, optim=adamw_torch, optim_args=None, optim_target_modules=None, optimizer=None, output_dir=/mnt/v10-20251218-150813, overwrite_output_dir=False, packing=False, packing_length=None, padding_free=False, padding_side=right, past_index=-1, per_device_eval_batch_size=1, per_device_train_batch_size=1, predict_with_generate=False, prediction_loss_only=False, problem_type=None, push_to_hub=False, push_to_hub_model_id=None, push_to_hub_organization=None, push_to_hub_token=, quant_bits=None, quant_method=None, ray_exp_name=None, ray_scope=last, reft_args=None, reft_intervention_type=LoreftIntervention, reft_layer_key=None, reft_layers=None, reft_rank=4, remove_unused_columns=True, repetition_penalty=None, report_to=['tensorboard'], response_prefix=None, restore_callback_states_from_checkpoint=False, resume_from_checkpoint=None, resume_only_model=False, rope_scaling=None, router_aux_loss_coef=0.0, run_name=/mnt/v10-20251218-150813, save_on_each_node=False, save_only_model=True, save_safetensors=True, save_steps=10000.0, save_strategy=steps, save_total_limit=20, seed=42, sequence_parallel_size=1, shuffle_buffer_size=1000, skip_memory_metrics=True, sortish_sampler=False, split_dataset_ratio=0.0, stop_words=[], stopping_strategy=first_exhausted, stream=False, streaming=False, strict=False, swanlab_exp_name=None, swanlab_lark_secret=None, swanlab_lark_webhook_url=None, swanlab_mode=cloud, swanlab_project=None, swanlab_token=, swanlab_workspace=None, system=None, target_modules=['all-linear'], target_parameters=None, target_regex=None, task_type=causal_lm, temperature=0.0, template=llava_onevision1_5, template_backend=swift, tf32=None, top_k=None, top_logprobs=None, top_p=None, torch_compile=False, torch_compile_backend=None, torch_compile_mode=None, torch_dtype=torch.bfloat16, torch_empty_cache_steps=None, torchdynamo=None, tpu_metrics_debug=False, tpu_num_cores=None, train_dataloader_shuffle=True, train_type=full, trainable_parameters=['model.visual.merger'], trainable_parameters_regex=None, truncation_strategy=delete, tuner_backend=peft, use_chat_template=True, use_cpu=False, use_dora=False, use_flash_ckpt=False, use_galore=False, use_hf=False, use_ipex=False, use_legacy_prediction_loop=False, use_liger_kernel=False, use_logits_to_keep=None, use_mps_device=False, use_ray=False, use_rslora=False, use_swift_lora=False, val_dataset=[], val_dataset_shuffle=False, vera_d_initial=0.1, vera_dropout=0.0, vera_projection_prng_key=0, vera_rank=256, vit_gradient_checkpointing=True, vit_lr=5e-06, warmup_ratio=0.05, warmup_steps=0, weight_decay=0.1, zero_hpz_partition_size=None, ) /usr/local/lib/python3.10/dist-packages/torch/distributed/distributed_c10d.py:4807: UserWarning: No device id is provided via `init_process_group` or `barrier `. Using the current device set by the user. warnings.warn( # warn only once Using a slow image processor as `use_fast` is unset and a slow processor was saved with this model. `use_fast=True` will be the default behavior in v4.52, even if the model was saved with a slow processor. This will result in minor differences in outputs. You'll still be able to use a slow processor with `use_fast=False`. You have video processor config saved in `preprocessor.json` file which is deprecated. Video processor configs should be saved in their own `video_preprocessor.json` file. You can rename the file or load and save the processor back which renames it automatically. Loading from `preprocessor.json` will be removed in v5.0. [INFO:swift] attn_impl: flash_attn [INFO:swift] model_kwargs: {'device_map': None, 'torch_dtype': torch.bfloat16} [2025-12-18 15:08:14,889] [INFO] [config.py:735:__init__] Config mesh_device None world_size = 1 You are attempting to use Flash Attention 2.0 with a model not initialized on GPU. Make sure to move the model to GPU after initializing it on CPU with `model.to('cuda')`. [2025-12-18 15:08:15,302] [INFO] [partition_parameters.py:348:__exit__] finished initializing model - num_params = 698, num_elems = 8.53B

Loading checkpoint shards: 0%| | 0/4 [00:00<?, ?it/s] Loading checkpoint shards: 25%|██▌ | 1/4 [00:01<00:03, 1.12s/it] Loading checkpoint shards: 50%|█████ | 2/4 [00:02<00:02, 1.08s/it] Loading checkpoint shards: 75%|███████▌ | 3/4 [00:03<00:01, 1.08s/it] Loading checkpoint shards: 100%|██████████| 4/4 [00:03<00:00, 1.14it/s] Loading checkpoint shards: 100%|██████████| 4/4 [00:03<00:00, 1.05it/s] [INFO:swift] model_info: ModelInfo(model_type='llava_onevision1_5', model_dir='foundational_model/LLaVA-OneVision-1.5-8B-Instruct', torch_dtype=torch.bfloat16, max_model_len=32768, quant_method=None, quant_bits=None, rope_scaling=None, is_moe_model=False, config=Llavaonevision1_5Config { "architectures": [ "LLaVAOneVision1_5_ForConditionalGeneration" ], "auto_map": { "AutoConfig": "configuration_llavaonevision1_5.Llavaonevision1_5Config", "AutoModel": "modeling_llavaonevision1_5.LLaVAOneVision1_5_ForConditionalGeneration", "AutoModelForCausalLM": "modeling_llavaonevision1_5.LLaVAOneVision1_5_ForConditionalGeneration" }, "hidden_size": 4096, "image_token_id": 151655, "model_type": "llavaonevision1_5", "pad_token_id": 151643, "text_config": { "attention_bias": false, "attention_dropout": 0.0, "head_dim": 128, "hidden_act": "silu", "hidden_size": 4096, "image_token_id": null, "initializer_range": 0.02, "intermediate_size": 12288, "layer_types": [ "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention", "full_attention" ], "max_position_embeddings": 32768, "max_window_layers": 36, "model_type": "LLaVAOneVision1_5_text", "num_attention_heads": 32, "num_hidden_layers": 36, "num_key_value_heads": 8, "rms_norm_eps": 1e-06, "rope_scaling": null, "rope_theta": 1000000.0, "sliding_window": null, "torch_dtype": "bfloat16", "use_cache": true, "use_sliding_window": false, "video_token_id": null, "vocab_size": 151936 }, "torch_dtype": "bfloat16", "transformers_version": "4.53.2", "video_token_id": 151656, "vision_config": { "depth": 24, "embed_dim": 1024, "hidden_act": "gelu", "hidden_size": 1024, "in_channels": 3, "initializer_range": 0.02, "intermediate_size": 4096, "layer_norm_eps": 1e-05, "model_type": "rice_vit", "num_heads": 16, "patch_size": 14, "spatial_merge_size": 2, "temporal_patch_size": 1, "text_hidden_size": 4096, "torch_dtype": "bfloat16" }, "vision_start_token_id": 151652, "vocab_size": 151936 } , task_type='causal_lm', num_labels=None) [INFO:swift] model.generation_config: GenerationConfig { "bos_token_id": 151643, "eos_token_id": 151645, "max_new_tokens": 64, "pad_token_id": 151643, "repetition_penalty": 1.05 }

[INFO:swift] default_system: 'You are a helpful assistant.' [INFO:swift] max_length: 10000 [INFO:swift] response_prefix: '' [INFO:swift] agent_template: hermes [INFO:swift] norm_bbox: norm1000 [INFO:swift] Setting ROOT_IMAGE_DIR: None. You can adjust this hyperparameter through the environment variable: ROOT_IMAGE_DIR. [INFO:swift] Setting QWENVL_BBOX_FORMAT: legacy. You can adjust this hyperparameter through the environment variable: QWENVL_BBOX_FORMAT. [INFO:swift] Start time of running main: 2025-12-18 15:08:19.181050 [INFO:swift] swift.version: 3.10.0

Map (num_proc=8): 0%| | 0/207611 [00:00<?, ? examples/s] Map (num_proc=8): 1%| | 2000/207611 [00:00<00:11, 18685.66 examples/s] Map (num_proc=8): 16%|█▋ | 34000/207611 [00:00<00:00, 190274.68 examples/s] Map (num_proc=8): 32%|███▏ | 66000/207611 [00:00<00:00, 246398.43 examples/s] Map (num_proc=8): 47%|████▋ | 98000/207611 [00:00<00:00, 272922.19 examples/s] Map (num_proc=8): 63%|██████▎ | 130000/207611 [00:00<00:00, 286720.56 examples/s] Map (num_proc=8): 78%|███████▊ | 162000/207611 [00:00<00:00, 295193.53 examples/s] Map (num_proc=8): 94%|█████████▍| 194952/207611 [00:00<00:00, 305291.99 examples/s] Map (num_proc=8): 100%|██████████| 207611/207611 [00:00<00:00, 243528.91 examples/s]

Map (num_proc=8): 0%| | 0/207611 [00:00<?, ? examples/s] Map (num_proc=8): 0%| | 1000/207611 [00:00<00:23, 8757.69 examples/s] Map (num_proc=8): 8%|▊ | 17000/207611 [00:00<00:02, 77804.68 examples/s] Map (num_proc=8): 16%|█▌ | 33000/207611 [00:00<00:01, 98411.13 examples/s] Map (num_proc=8): 24%|██▎ | 49000/207611 [00:00<00:01, 107638.94 examples/s] Map (num_proc=8): 31%|███▏ | 65000/207611 [00:00<00:01, 112554.93 examples/s] Map (num_proc=8): 39%|███▉ | 81000/207611 [00:00<00:01, 115643.58 examples/s] Map (num_proc=8): 47%|████▋ | 97000/207611 [00:01<00:01, 60494.12 examples/s] Map (num_proc=8): 54%|█████▍ | 113000/207611 [00:01<00:01, 71986.00 examples/s] Map (num_proc=8): 62%|██████▏ | 129000/207611 [00:01<00:00, 82388.02 examples/s] Map (num_proc=8): 70%|██████▉ | 145000/207611 [00:01<00:00, 91034.22 examples/s] Map (num_proc=8): 78%|███████▊ | 161000/207611 [00:01<00:00, 98645.31 examples/s] Map (num_proc=8): 85%|████████▌ | 177000/207611 [00:01<00:00, 104048.20 examples/s] Map (num_proc=8): 93%|█████████▎| 193000/207611 [00:02<00:00, 108442.16 examples/s] Map (num_proc=8): 100%|██████████| 207611/207611 [00:02<00:00, 90948.46 examples/s] [INFO:swift] train_dataset: Dataset({ features: ['messages', 'images'], num_rows: 207611 }) [INFO:swift] val_dataset: None [INFO:swift] [INPUT_IDS] [151644, 8948, 198, 2610, 525, 264, 54221, 18237, 57294, 304, 7377, 3687, 53248, 13, 4615, 3383, 374, 311, 23643, 3669, 3589, 369, 11929, 315, 33686, 304, 2176, 5335, 323, 23534, 1467, 13, 151645, 198, 151644, 872, 198, 22043, 279, 3669, 2213, 25, 364, 25300, 98971, 323, 3539, 9809, 1644, 309, 15552, 29903, 8910, 311, 12322, 1435, 6, 323, 279, 5815, 2168, 220, 151652, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151655, 151653, 11, 4486, 2736, 264, 15817, 53248, 6358, 510, 16, 13, 29901, 421, 279, 4453, 3669, 1509, 702, 1012, 25476, 42768, 448, 320, 9693, 33100, 340, 17, 13, 64547, 279, 943, 315, 25476, 60718, 320, 333, 894, 340, 18, 13, 95210, 279, 54215, 5537, 304, 279, 2168, 320, 61456, 30618, 3745, 13934, 340, 19, 13, 64547, 54215, 4244, 304, 279, 1467, 151645, 198, 151644, 77091, 198, 14373, 25476, 42768, 25, 902, 198, 88452, 712, 943, 25, 2713, 198, 1906, 54215, 5537, 25, 6857, 198, 1178, 54215, 4244, 25, 6857, 151645] [INFO:swift] [INPUT] <|im_start|>system You are a forensic analyst specializing in digital media authenticity. Your task is to analyze news items for signs of manipulation in both images and accompanying text.<|im_end|> <|im_start|>user Given the news content: 'Paul Hutchinson and Colette Aram DNA advances helped to capture him' and the associated image <|vision_start|>[151655 * 160]<|vision_end|>, please perform a comprehensive authenticity analysis:

  1. Determine if the entire news item has been tampered with (yes/no)
  2. Identify the type of tampering (if any)
  3. Locate the manipulated region in the image (provide bounding box coordinates)
  4. Identify manipulated words in the text<|im_end|> <|im_start|>assistant News tampered: no Tamper type: orig Image manipulated region: none Text manipulated words: none<|im_end|> [INFO:swift] [LABELS_IDS] [-100, 8948, 198, 2610, 525, 264, 54221, 18237, 57294, 304, 7377, 3687, 53248, 13, 4615, 3383, 374, 311, 23643, 3669, 3589, 369, 11929, 315, 33686, 304, 2176, 5335, 323, 23534, 1467, 13, 151645, 198, 151644, 872, 198, 22043, 279, 3669, 2213, 25, 364, 25300, 98971, 323, 3539, 9809, 1644, 309, 15552, 29903, 8910, 311, 12322, 1435, 6, 323, 279, 5815, 2168, 220, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, -100, 11, 4486, 2736, 264, 15817, 53248, 6358, 510, 16, 13, 29901, 421, 279, 4453, 3669, 1509, 702, 1012, 25476, 42768, 448, 320, 9693, 33100, 340, 17, 13, 64547, 279, 943, 315, 25476, 60718, 320, 333, 894, 340, 18, 13, 95210, 279, 54215, 5537, 304, 279, 2168, 320, 61456, 30618, 3745, 13934, 340, 19, 13, 64547, 54215, 4244, 304, 279, 1467, 151645, 198, 151644, 77091, 198, 14373, 25476, 42768, 25, 902, 198, 88452, 712, 943, 25, 2713, 198, 1906, 54215, 5537, 25, 6857, 198, 1178, 54215, 4244, 25, 6857, 151645] [INFO:swift] [LABELS] [-100 * 1]system You are a forensic analyst specializing in digital media authenticity. Your task is to analyze news items for signs of manipulation in both images and accompanying text.<|im_end|> <|im_start|>user Given the news content: 'Paul Hutchinson and Colette Aram DNA advances helped to capture him' and the associated image [-100 * 162], please perform a comprehensive authenticity analysis:
  5. Determine if the entire news item has been tampered with (yes/no)
  6. Identify the type of tampering (if any)
  7. Locate the manipulated region in the image (provide bounding box coordinates)
  8. Identify manipulated words in the text<|im_end|> <|im_start|>assistant News tampered: no Tamper type: orig Image manipulated region: none Text manipulated words: none<|im_end|> [INFO:swift] The TrainArguments will be saved in: /mntv10-20251218-150813/args.json [INFO:swift] model: LLaVAOneVision1_5_ForConditionalGeneration( (model): LLaVAOneVision1_5_Model( (visual): RiceTransformerPretrainedModel( (patch_embed): RicePatchEmbed( (proj): Conv2d(3, 1024, kernel_size=(14, 14), stride=(14, 14), bias=False) ) (rotary_pos_emb): RiceRotaryEmbedding() (pre_layernorm): LayerNorm((1024,), eps=1e-05, elementwise_affine=True) (blocks): ModuleList( (0-23): 24 x RiceBlock( (norm1): LayerNorm((1024,), eps=1e-05, elementwise_affine=True) (norm2): LayerNorm((1024,), eps=1e-05, elementwise_affine=True) (attn): RiceFlashAttention2( (qkv): Linear(in_features=1024, out_features=3072, bias=True) (proj): Linear(in_features=1024, out_features=1024, bias=True) ) (mlp): RiceMlp( (fc1): Linear(in_features=1024, out_features=4096, bias=True) (act): GELUActivation() (fc2): Linear(in_features=4096, out_features=1024, bias=True) ) ) ) (merger): RicePatchMerger( (ln_q): LayerNorm((1024,), eps=1e-05, elementwise_affine=True) (mlp): Sequential( (0): Linear(in_features=4096, out_features=4096, bias=True) (1): GELU(approximate='none') (2): Linear(in_features=4096, out_features=4096, bias=True) ) ) ) (language_model): LLaVAOneVision1_5_TextModel( (embed_tokens): Embedding(151936, 4096) (layers): ModuleList( (0-35): 36 x LLaVAOneVision1_5_DecoderLayer( (self_attn): LLaVAOneVision1_5_FlashAttention2( (q_proj): Linear(in_features=4096, out_features=4096, bias=False) (k_proj): Linear(in_features=4096, out_features=1024, bias=False) (v_proj): Linear(in_features=4096, out_features=1024, bias=False) (o_proj): Linear(in_features=4096, out_features=4096, bias=False) (q_norm): LLaVAOneVision1_5_RMSNorm((0,), eps=1e-06) (k_norm): LLaVAOneVision1_5_RMSNorm((0,), eps=1e-06) ) (mlp): LLaVAOneVision1_5_MLP( (gate_proj): Linear(in_features=4096, out_features=12288, bias=False) (up_proj): Linear(in_features=4096, out_features=12288, bias=False) (down_proj): Linear(in_features=12288, out_features=4096, bias=False) (act_fn): SiLU() ) (input_layernorm): LLaVAOneVision1_5_RMSNorm((0,), eps=1e-06) (post_attention_layernorm): LLaVAOneVision1_5_RMSNorm((0,), eps=1e-06) ) ) (norm): LLaVAOneVision1_5_RMSNorm((0,), eps=1e-06) (rotary_emb): LLaVAOneVision1_5_RotaryEmbedding() ) ) (lm_head): Linear(in_features=4096, out_features=151936, bias=False) ) [INFO:swift] model_parameter_info: LLaVAOneVision1_5_ForConditionalGeneration: 8527.2146M Params (8527.2146M Trainable [100.0000%]), 0.0001M Buffers. [INFO:swift] use_reentrant: True [INFO:swift] The logging file will be saved in: /mnt/v10-20251218-150813/logging.jsonl [INFO:swift] Successfully registered post_encode hook: ['LLaVAOneVision1_5_ForConditionalGeneration']. [WARNING:swift] prepare gradient_checkpointing failed: Gradient accumulation steps mismatch: GradientAccumulationPlugin has 1, DeepSpeed config has 2. Using DeepSpeed's value. Parameter Offload: Total persistent parameters: 641056 in 345 params

Train: 0%| | 0/40000 [00:00<?, ?it/s][INFO:swift] use_logits_to_keep: False loss_type=None was set in the config but it is unrecognised.Using the default loss: ForCausalLMLoss. [INFO:swift] last_model_checkpoint: None [INFO:swift] best_model_checkpoint: None [INFO:swift] images_dir: /mnt/LLaVA_first_label/v10-20251218-150813/images [rank0]: Traceback (most recent call last): [rank0]: File "/usr/local/lib/python3.10/dist-packages/swift/cli/sft.py", line 20, in [rank0]: sft_main() [rank0]: File "/usr/local/lib/python3.10/dist-packages/swift/llm/train/sft.py", line 352, in sft_main [rank0]: return SwiftSft(args).main() [rank0]: File "/usr/local/lib/python3.10/dist-packages/swift/llm/base.py", line 49, in main [rank0]: result = self.run() [rank0]: File "/usr/local/lib/python3.10/dist-packages/swift/ray/base.py", line 170, in wrapper [rank0]: return func(self, *args, **kwargs) [rank0]: File "/usr/local/lib/python3.10/dist-packages/swift/llm/train/sft.py", line 206, in run [rank0]: return self.train(trainer) [rank0]: File "/usr/local/lib/python3.10/dist-packages/swift/llm/train/sft.py", line 254, in train [rank0]: trainer.train(trainer.args.resume_from_checkpoint) [rank0]: File "/usr/local/lib/python3.10/dist-packages/swift/trainers/mixin.py", line 815, in train [rank0]: res = super().train(*args, **kwargs) [rank0]: File "/usr/local/lib/python3.10/dist-packages/transformers/trainer.py", line 2206, in train [rank0]: return inner_training_loop( [rank0]: File "/usr/local/lib/python3.10/dist-packages/transformers/trainer.py", line 2548, in _inner_training_loop [rank0]: tr_loss_step = self.training_step(model, inputs, num_items_in_batch) [rank0]: File "/usr/local/lib/python3.10/dist-packages/swift/trainers/trainers.py", line 412, in training_step [rank0]: return super().training_step(model, inputs, *args, **kwargs) [rank0]: File "/usr/local/lib/python3.10/dist-packages/transformers/trainer.py", line 3797, in training_step [rank0]: self.accelerator.backward(loss, **kwargs) [rank0]: File "/usr/local/lib/python3.10/dist-packages/accelerate/accelerator.py", line 2844, in backward [rank0]: self.deepspeed_engine_wrapped.backward(loss, sync_gradients=self.sync_gradients, **kwargs) [rank0]: File "/usr/local/lib/python3.10/dist-packages/accelerate/utils/deepspeed.py", line 270, in backward [rank0]: self.engine.backward(loss, **kwargs) [rank0]: File "/usr/local/lib/python3.10/dist-packages/deepspeed/utils/nvtx.py", line 20, in wrapped_fn [rank0]: ret_val = func(*args, **kwargs) [rank0]: File "/usr/local/lib/python3.10/dist-packages/deepspeed/runtime/engine.py", line 2216, in backward [rank0]: self._do_optimizer_backward(loss, retain_graph) [rank0]: File "/usr/local/lib/python3.10/dist-packages/deepspeed/runtime/engine.py", line 2162, in _do_optimizer_backward [rank0]: self.optimizer.backward(loss, retain_graph=retain_graph) [rank0]: File "/usr/local/lib/python3.10/dist-packages/deepspeed/utils/nvtx.py", line 20, in wrapped_fn [rank0]: ret_val = func(*args, **kwargs) [rank0]: File "/usr/local/lib/python3.10/dist-packages/deepspeed/runtime/zero/stage3.py", line 2293, in backward [rank0]: self.loss_scaler.backward(loss.float(), retain_graph=retain_graph) [rank0]: File "/usr/local/lib/python3.10/dist-packages/deepspeed/runtime/fp16/loss_scaler.py", line 63, in backward [rank0]: scaled_loss.backward(retain_graph=retain_graph) [rank0]: File "/usr/local/lib/python3.10/dist-packages/torch/_tensor.py", line 647, in backward [rank0]: torch.autograd.backward( [rank0]: File "/usr/local/lib/python3.10/dist-packages/torch/autograd/init.py", line 354, in backward [rank0]: _engine_run_backward( [rank0]: File "/usr/local/lib/python3.10/dist-packages/torch/autograd/graph.py", line 829, in _engine_run_backward [rank0]: return Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass [rank0]: File "/usr/local/lib/python3.10/dist-packages/torch/autograd/function.py", line 311, in apply [rank0]: return user_fn(self, *args) [rank0]: File "/usr/local/lib/python3.10/dist-packages/torch/utils/checkpoint.py", line 319, in backward [rank0]: torch.autograd.backward(outputs_with_grad, args_with_grad) [rank0]: File "/usr/local/lib/python3.10/dist-packages/torch/autograd/init.py", line 354, in backward [rank0]: _engine_run_backward( [rank0]: File "/usr/local/lib/python3.10/dist-packages/torch/autograd/graph.py", line 829, in _engine_run_backward [rank0]: return Variable._execution_engine.run_backward( # Calls into the C++ engine to run the backward pass [rank0]: RuntimeError: Trying to backward through the graph a second time (or directly access saved tensors after they have already been freed). Saved intermediate values of the graph are freed when you call .backward() or autograd.grad(). Specify retain_graph=True if you need to backward through the graph a second time or if you need to access saved tensors after calling backward.

Train: 0%| | 0/40000 [00:03<?, ?it/s] E1218 15:08:43.540000 25817 torch/distributed/elastic/multiprocessing/api.py:874] failed (exitcode: 1) local_rank: 0 (pid: 25839) of binary: /usr/bin/python3 Traceback (most recent call last): File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "/usr/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/usr/local/lib/python3.10/dist-packages/torch/distributed/run.py", line 905, in main() File "/usr/local/lib/python3.10/dist-packages/torch/distributed/elastic/multiprocessing/errors/init.py", line 357, in wrapper return f(*args, **kwargs) File "/usr/local/lib/python3.10/dist-packages/torch/distributed/run.py", line 901, in main run(args) File "/usr/local/lib/python3.10/dist-packages/torch/distributed/run.py", line 892, in run elastic_launch( File "/usr/local/lib/python3.10/dist-packages/torch/distributed/launcher/api.py", line 143, in call return launch_agent(self._config, self._entrypoint, list(args)) File "/usr/local/lib/python3.10/dist-packages/torch/distributed/launcher/api.py", line 277, in launch_agent raise ChildFailedError( torch.distributed.elastic.multiprocessing.errors.ChildFailedError:

/usr/local/lib/python3.10/dist-packages/swift/cli/sft.py FAILED

Failures: <NO_OTHER_FAILURES>

Root Cause (first observed failure): [0]: time : 2025-12-18_15:08:43 host : rank : 0 (local_rank: 0) exitcode : 1 (pid: 25839) error_file: <N/A> traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html

Training finished at Thu Dec 18 03:08:44 PM CST 2025

houleisai avatar Dec 18 '25 07:12 houleisai

--per_device_train_batch_size 1 \
--gradient_accumulation_steps 64 \

2 * A100. This works when --gradient_checkpointing false \

The-Martyr avatar Mar 01 '26 19:03 The-Martyr

我也是遇到同样的问题

randydl avatar Mar 16 '26 14:03 randydl

实测添加以下选项可解决该问题:

gradient_checkpointing_kwargs: '{"use_reentrant": false}'

randydl avatar Apr 10 '26 08:04 randydl