InternLM / lmdeploy

LMDeploy is a toolkit for compressing, deploying, and serving LLMs.
https://lmdeploy.readthedocs.io/en/latest/
Apache License 2.0
4.6k stars 420 forks source link

[Bug] run out of tokens error when using llama3-llava-next-8b-hf #2382

Closed binzhang01 closed 2 months ago

binzhang01 commented 2 months ago

Checklist

Describe the bug

First, I try to use llava-hf/llama3-llava-next-8b-hf. short prompt + 500333 image, the result is right. short prompt + 640640 image, the bug shows: 2024-08-26 23:37:30,352 - lmdeploy - ERROR - Truncate max_new_tokens to 128 2024-08-26 23:37:30,353 - lmdeploy - ERROR - run out of tokens. session_id=0. and the result is None. transformers can load llava-hf/llama3-llava-next-8b-hf and produce right result. lmdeploy + lmms-lab/llama3-llava-next-8b can produce right result. the code is

import json
import time
from lmdeploy import pipeline, GenerationConfig
from lmdeploy.vl import load_image
pipe = pipeline('/data/llama3-llava-next-8b-hf')
prompt1="""
        Write a detailed description about the image.
        """
prompt2 = """
        Write a detailed description.
        """
generate_config=GenerationConfig(max_new_tokens=512, temperature=1.0)
image = load_image('../../images/sample_img_7.jpeg') # error case, image is 640*640
response = pipe((prompt2, image), gen_config=generate_config)
print(response.text)

Reproduction

None

Environment

sys.platform: linux
Python: 3.8.19 (default, Mar 20 2024, 19:58:24) [GCC 11.2.0]
CUDA available: True
MUSA available: False
numpy_random_seed: 2147483648
GPU 0,1,2,3,4,5,6,7: NVIDIA GeForce RTX 4090
CUDA_HOME: /usr/local/cuda-11.8/
NVCC: Cuda compilation tools, release 11.8, V11.8.89
GCC: gcc (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0
PyTorch: 2.3.1+cu118
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.3.6 (Git Hash 86e6af5974177e513fd3fee58425e1063e7f1361)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - LAPACK is enabled (usually provided by MKL)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - CUDA Runtime 11.8
  - 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_37,code=sm_37;-gencode;arch=compute_90,code=sm_90
  - CuDNN 8.7
  - Magma 2.6.1
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.8, CUDNN_VERSION=8.7.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_QNNPACK -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.3.1, 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.18.1+cu118
LMDeploy: 0.5.3+
transformers: 4.44.1
gradio: Not Found
fastapi: 0.112.1
pydantic: 2.8.2
triton: 2.3.1
NVIDIA Topology: 
        GPU0    GPU1    GPU2    GPU3    GPU4    GPU5    GPU6    GPU7    CPU Affinity    NUMA Affinity   GPU NUMA ID
GPU0     X      NODE    NODE    NODE    SYS     SYS     SYS     SYS     0-63    0               N/A
GPU1    NODE     X      NODE    NODE    SYS     SYS     SYS     SYS     0-63    0               N/A
GPU2    NODE    NODE     X      NODE    SYS     SYS     SYS     SYS     0-63    0               N/A
GPU3    NODE    NODE    NODE     X      SYS     SYS     SYS     SYS     0-63    0               N/A
GPU4    SYS     SYS     SYS     SYS      X      NODE    NODE    NODE    64-127  1               N/A
GPU5    SYS     SYS     SYS     SYS     NODE     X      NODE    NODE    64-127  1               N/A
GPU6    SYS     SYS     SYS     SYS     NODE    NODE     X      NODE    64-127  1               N/A
GPU7    SYS     SYS     SYS     SYS     NODE    NODE    NODE     X      64-127  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

2024-08-26 23:37:30,352 - lmdeploy - ERROR - Truncate max_new_tokens to 128
2024-08-26 23:37:30,353 - lmdeploy - ERROR - run out of tokens. session_id=0.
lzhangzz commented 2 months ago

@binzhang01 Can you share the full log with TM_LOG_LEVEL=INFO?

binzhang01 commented 2 months ago

@binzhang01 Can you share the full log with TM_LOG_LEVEL=INFO?

i try this in .py: os.environ['TM_LOG_LEVEL'] = 'INFO' and in bash: export TM_LOG_LEVEL=INFO but got same output: 2024-08-27 01:34:56,928 - lmdeploy - ERROR - Truncate max_new_tokens to 128 2024-08-27 01:34:56,929 - lmdeploy - ERROR - run out of tokens. session_id=0.

lvhan028 commented 2 months ago

@RunningLeon may help answering the question

RunningLeon commented 2 months ago

@binzhang01 hi, pls increase session_len in backend config. You can refer to https://lmdeploy.readthedocs.io/en/latest/multi_modal/vl_pipeline.html#set-sampling-parameters

binzhang01 commented 2 months ago

@binzhang01 hi, pls increase session_len in backend config. You can refer to https://lmdeploy.readthedocs.io/en/latest/multi_modal/vl_pipeline.html#set-sampling-parameters

thanks! problem solved. set the session_len=4096 is ok.