llamafactory跑Qwen2.5-VL-3B-Instruct,报错atten mask dim should be 2 or 4, but got 3[FUNC:AnalyzeOptionalInput]
收藏回复举报
llamafactory跑Qwen2.5-VL-3B-Instruct,报错atten mask dim should be 2 or 4, but got 3[FUNC:AnalyzeOptionalInput]
t('forum.solved') 已解决
新人帖
发表于2025-06-26 15:08:08
0 查看

LLaMaFactory上对Qwen2.5-VL-3B-Instruct进行推理或者训练,输入纯文本数据没问题,输入图片就会报错

llamafactory环境信息如下:

- `llamafactory` version: 0.9.3 

- Platform: Linux-5.10.0-60.18.0.50.oe2203.aarch64-aarch64-with-glibc2.35 

- Python version: 3.11.12 

- PyTorch version: 2.4.0 (NPU) 

- Transformers version: 4.51.3 

- Datasets version: 2.19.2 

- Accelerate version: 0.34.0 

- PEFT version: 0.14.0 

- TRL version: 0.9.4 

- NPU type: Ascend910B3 

- CANN version: 8.0.0 

- vLLM version: 0.8.5 

- Default data directory: detected

 报错信息如下:

/usr/local/python3.11.12/lib/python3.11/site-packages/transformers/models/qwen2_5_vl/modeling_qwen2_5_vl.py:518: UserWarning: current tensor is running as_strided, don't perform inplace operations on the returned value. If you encounter this warning and have precision issues, you can try torch.npu.config.allow_internal_format = False to resolve precision issues. (Triggered internally at build/CMakeFiles/torch_npu.dir/compiler_depend.ts:128.) 

  hidden_states = hidden_states[window_index, :, :] 

[E626 07:03:38.408714317 compiler_depend.ts:422] call aclnnFlashAttentionScore failed, detail:EZ9999: Inner Error! 

EZ9999: [PID: 51679] 2025-06-26-07:03:38.498.920 atten mask dim should be 2 or 4, but got 3[FUNC:AnalyzeOptionalInput][FILE:flash_attention_score_tiling_general.cpp][LINE:1473] 

        TraceBack (most recent call last): 

       fail to analyze context info.[FUNC:GetShapeAttrsInfo][FILE:flash_attention_score_tiling_general.cpp][LINE:835] 

       Tiling failed 

       Tiling Failed. 

       Kernel Run failed. opType: 42, FlashAttentionScore 

       launch failed for FlashAttentionScore, errno:561103. 

 

[ERROR] 2025-06-26-07:03:38 (PID:51679, Device:0, RankID:-1) ERR01100 OPS call acl api failed 

Exception raised from operator() at build/CMakeFiles/torch_npu.dir/compiler_depend.ts:1715 (most recent call first): 

frame #0: c10::Error::Error(c10::SourceLocation, std::string) + 0xb0 (0xffffa4294e00 in /usr/local/python3.11.12/lib/python3.11/site-packages/torch/lib/libc10.so) 

frame #1: c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::string const&) + 0x6c (0xffffa4240858 in /usr/local/python3.11.12/lib/python3.11/site-packages/torch/lib/libc10.so) 

frame #2: <unknown function> + 0xc86f3c (0xfffdfb4b6f3c in /usr/local/python3.11.12/lib/python3.11/site-packages/torch_npu/lib/libtorch_npu.so) 

frame #3: <unknown function> + 0x162d9d4 (0xfffdfbe5d9d4 in /usr/local/python3.11.12/lib/python3.11/site-packages/torch_npu/lib/libtorch_npu.so) 

frame #4: <unknown function> + 0x77b5b4 (0xfffdfafab5b4 in /usr/local/python3.11.12/lib/python3.11/site-packages/torch_npu/lib/libtorch_npu.so) 

frame #5: <unknown function> + 0x77bdc8 (0xfffdfafabdc8 in /usr/local/python3.11.12/lib/python3.11/site-packages/torch_npu/lib/libtorch_npu.so) 

frame #6: <unknown function> + 0x77853c (0xfffdfafa853c in /usr/local/python3.11.12/lib/python3.11/site-packages/torch_npu/lib/libtorch_npu.so) 

frame #7: <unknown function> + 0xbb90c (0xffffa42cb90c in /usr/local/python3.11.12/lib/python3.11/site-packages/torch/lib/libc10.so) 

frame #8: <unknown function> + 0x7d5b8 (0xffffae99d5b8 in /lib/aarch64-linux-gnu/libc.so.6) 

frame #9: <unknown function> + 0xe5edc (0xffffaea05edc in /lib/aarch64-linux-gnu/libc.so.6) 

 

Exception in thread Thread-8 (generate): 

Traceback (most recent call last): 

  File "/usr/local/python3.11.12/lib/python3.11/threading.py", line 1045, in _bootstrap_inner 

    self.run() 

  File "/usr/local/python3.11.12/lib/python3.11/threading.py", line 982, in run 

    self._target(*self._args, **self._kwargs) 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 116, in decorate_context 

    return func(*args, **kwargs) 

           ^^^^^^^^^^^^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/transformers/generation/utils.py", line 2465, in generate 

    result = self._sample( 

             ^^^^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/transformers/generation/utils.py", line 3431, in _sample 

    outputs = self(**model_inputs, return_dict=True) 

              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl 

    return self._call_impl(*args, **kwargs) 

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl 

    return forward_call(*args, **kwargs) 

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/accelerate/hooks.py", line 170, in new_forward 

    output = module._old_forward(*args, **kwargs) 

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/transformers/models/qwen2_5_vl/modeling_qwen2_5_vl.py", line 1757, in forward 

    image_embeds = self.visual(pixel_values, grid_thw=image_grid_thw) 

                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl 

    return self._call_impl(*args, **kwargs) 

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl 

    return forward_call(*args, **kwargs) 

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/transformers/models/qwen2_5_vl/modeling_qwen2_5_vl.py", line 546, in forward 

    hidden_states = blk(hidden_states, cu_seqlens=cu_seqlens_now, position_embeddings=position_embeddings) 

                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl 

    return self._call_impl(*args, **kwargs) 

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl 

    return forward_call(*args, **kwargs) 

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/accelerate/hooks.py", line 170, in new_forward 

    output = module._old_forward(*args, **kwargs) 

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/transformers/models/qwen2_5_vl/modeling_qwen2_5_vl.py", line 339, in forward 

    hidden_states = hidden_states + self.attn( 

                                    ^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl 

    return self._call_impl(*args, **kwargs) 

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl 

    return forward_call(*args, **kwargs) 

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/accelerate/hooks.py", line 170, in new_forward 

    output = module._old_forward(*args, **kwargs) 

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/transformers/models/qwen2_5_vl/modeling_qwen2_5_vl.py", line 311, in forward 

    attn_output = self.proj(attn_output) 

                  ^^^^^^^^^^^^^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1553, in _wrapped_call_impl 

    return self._call_impl(*args, **kwargs) 

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1562, in _call_impl 

    return forward_call(*args, **kwargs) 

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/accelerate/hooks.py", line 170, in new_forward 

    output = module._old_forward(*args, **kwargs) 

             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

  File "/usr/local/python3.11.12/lib/python3.11/site-packages/torch/nn/modules/linear.py", line 117, in forward 

    return F.linear(input, self.weight, self.bias) 

           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 

RuntimeError: The Inner error is reported as above. The process exits for this inner error, and the current working operator name is aclnnFlashAttentionScore. 

Since the operator is called asynchronously, the stacktrace may be inaccurate. If you want to get the accurate stacktrace, pleace set the environment variable ASCEND_LAUNCH_BLOCKING=1. 

Note: ASCEND_LAUNCH_BLOCKING=1 will force ops to run in synchronous mode, resulting in performance degradation. Please unset ASCEND_LAUNCH_BLOCKING in time after debugging. 

[ERROR] 2025-06-26-07:03:38 (PID:51679, Device:0, RankID:-1) ERR00100 PTA call acl api failed. 

我要发帖子