InternLM / InternLM/lmdeploy

[Bug] 推理lora微调后的模型,报错:prompt.split(IMAGE_TOKEN),AttributeError: 'NoneType' object has no attribute 'split'

Open
#3,330 1 comment 0 reactions 1 assignee Claimed by @irexyc View on GitHub
Dominant language
Python
Stars
8.1k
Forks
748
Avg merge
6d 2h
Merged PRs (30d)
54

Description

### Checklist

- [ ] 1. I have searched related issues but cannot get the expected help.
- [ ] 2. The bug has not been fixed in the latest version.
- [ ] 3. Please note that if the bug-related issue you submitted lacks corresponding environment info and a minimal reproducible demo, it will be challenging for us to reproduce and resolve the issue, reducing the likelihood of receiving feedback.

### Describe the bug

Internvl2.5 lora微调模型已经合并,transformer和vllm均可以正常推理,但是用lmdeploy则报错,推理原始模型正常,具体报错如下:
2025-03-25 15:53:13,626 - lmdeploy - WARNING - async_engine.py:643 - GenerationConfig: GenerationConfig(n=1, max_new_tokens=512, do_sample=False, top_p=1.0, top_k=50, min_p=0.0, temperature=0.8, repetition_penalty=1.0, ignore_eos=False, random_seed=None, stop_words=None, bad_words=None, stop_token_ids=[151643, 151644, 151645], bad_token_ids=None, min_new_tokens=None, skip_special_tokens=True, spaces_between_special_tokens=True, logprobs=None, response_format=None, logits_processors=None, output_logits=None, output_last_hidden_state=None)
2025-03-25 15:53:13,626 - lmdeploy - WARNING - async_engine.py:644 - Since v0.6.0, lmdeploy add `do_sample` in GenerationConfig. It defaults to False, meaning greedy decoding. Please set `do_sample=True` if sampling decoding is needed
exception calling callback for
Traceback (most recent call last):
File "/home/wangfei/.conda/envs/lmdeploy/lib/python3.8/concurrent/futures/_base.py", line 328, in _invoke_callbacks
callback(self)
File "/home/wangfei/.conda/envs/lmdeploy/lib/python3.8/site-packages/lmdeploy/serve/async_engine.py", line 443, in
asyncio.run_coroutine_threadsafe(_infer(), loop).add_done_callback(lambda x: x.result())
File "/home/wangfei/.conda/envs/lmdeploy/lib/python3.8/concurrent/futures/_base.py", line 437, in result
return self.__get_result()
File "/home/wangfei/.conda/envs/lmdeploy/lib/python3.8/concurrent/futures/_base.py", line 389, in __get_result
raise self._exception
File "/home/wangfei/.conda/envs/lmdeploy/lib/python3.8/site-packages/lmdeploy/serve/async_engine.py", line 437, in _infer
await asyncio.gather(*tasks)
File "/home/wangfei/.conda/envs/lmdeploy/lib/python3.8/site-packages/lmdeploy/serve/async_engine.py", line 413, in _sync_resp
async for out in g:
File "/home/wangfei/.conda/envs/lmdeploy/lib/python3.8/site-packages/lmdeploy/serve/async_engine.py", line 663, in generate
prompt_input = await self._get_prompt_input(prompt,
File "/home/wangfei/.conda/envs/lmdeploy/lib/python3.8/site-packages/lmdeploy/serve/vl_async_engine.py", line 84, in _get_prompt_input
results = await self.vl_encoder.wrap_for_turbomind(results, self.chat_template, self.tokenizer,
File "/home/wangfei/.conda/envs/lmdeploy/lib/python3.8/site-packages/lmdeploy/vl/engine.py", line 103, in wrap_for_turbomind
result = self.model.to_turbomind(messages, chat_template, tokenizer, sequence_start)
File "/home/wangfei/.conda/envs/lmdeploy/lib/python3.8/site-packages/lmdeploy/vl/model/internvl.py", line 257, in to_turbomind
return self.to_turbomind_aux(messages, prompt, IMAGE_TOKEN, tokenizer, sequence_start)
File "/home/wangfei/.conda/envs/lmdeploy/lib/python3.8/site-packages/lmdeploy/vl/model/base.py", line 221, in to_turbomind_aux
segs = prompt.split(IMAGE_TOKEN)
AttributeError: 'NoneType' object has no attribute 'split'

### Reproduction

pipe(('describe this image', image))

### Environment

```Shell
sys.platform: linux
Python: 3.8.20 (default, Oct 3 2024, 15:24:27) [GCC 11.2.0]
CUDA available: True
MUSA available: False
numpy_random_seed: 2147483648
GPU 0,1,2,3,4,5,7: NVIDIA A800 80GB PCIe
GPU 6: NVIDIA A100-PCIE-40GB
CUDA_HOME: /usr/local/cuda
NVCC: Cuda compilation tools, release 12.4, V12.4.99
GCC: gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
PyTorch: 2.4.0+cu121
PyTorch compiling details: PyTorch built with:
- GCC 9.3
- C++ Version: 201703
- Intel(R) oneAPI Math Kernel Library Version 2022.2-Product Build 20220804 for Intel(R) 64 architecture applications
- Intel(R) MKL-DNN v3.4.2 (Git Hash 1137e04ec0b5251ca2b4400a4fd3c667ce843d67)
- OpenMP 201511 (a.k.a. OpenMP 4.5)
- LAPACK is enabled (usually provided by MKL)
- NNPACK is enabled
- CPU capability usage: AVX512
- CUDA Runtime 12.1
- NVCC architecture flags: -gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_90,code=sm_90
- CuDNN 90.1 (built against CUDA 12.4)
- Magma 2.6.1
- Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=12.1, CUDNN_VERSION=9.1.0, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -D_GLIBCXX_USE_CXX11_ABI=0 -fabi-version=11 -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOROCTRACER -DUSE_FBGEMM -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -O2 -fPIC -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Werror=bool-operation -Wnarrowing -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-stringop-overflow -Wsuggest-override -Wno-psabi -Wno-error=pedantic -Wno-error=old-style-cast -Wno-missing-braces -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=2.4.0, USE_CUDA=ON, USE_CUDNN=ON, USE_CUSPARSELT=1, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_GLOO=ON, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=1, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF, USE_ROCM_KERNEL_ASSERT=OFF,

TorchVision: 0.19.0+cu121
LMDeploy: 0.7.1+
transformers: 4.46.3
gradio: Not Found
fastapi: 0.115.11
pydantic: 2.10.6
triton: 3.0.0
NVIDIA Topology:
GPU0 GPU1 GPU2 GPU3 GPU4 GPU5 GPU6 GPU7 CPU Affinity NUMA Affinity GPU NUMA ID
GPU0 X NODE NODE SYS SYS SYS SYS SYS 0-95,192-287 0 N/A
GPU1 NODE X NODE SYS SYS SYS SYS NV6 0-95,192-287 0 N/A
GPU2 NODE NODE X SYS SYS SYS SYS SYS 0-95,192-287 0 N/A
GPU3 SYS SYS SYS X NODE NODE NODE NODE 96-191,288-383 1 N/A
GPU4 SYS SYS SYS NODE X NODE NODE NODE 96-191,288-383 1 N/A
GPU5 SYS SYS SYS NODE NODE X PHB NODE 96-191,288-383 1 N/A
GPU6 SYS SYS SYS NODE NODE PHB X NODE 96-191,288-383 1 N/A
GPU7 SYS NV6 SYS NODE NODE NODE NODE X 96-191,288-383 1 N/A

Legend:

X = Self
SYS = Connection traversing PCIe as well as the SMP interconnect between NUMA nodes (e.g., QPI/UPI)
NODE = Connection traversing PCIe as well as the interconnect between PCIe Host Bridges within a NUMA node
PHB = Connection traversing PCIe as well as a PCIe Host Bridge (typically the CPU)
PXB = Connection traversing multiple PCIe bridges (without traversing the PCIe Host Bridge)
PIX = Connection traversing at most a single PCIe bridge
NV# = Connection traversing a bonded set of # NVLinks
```

### Error traceback

```Shell

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.