[Bug] ERROR - engine.py:904 - Task <MainLoopBackground> failed
- Dominant language
- Python
- Stars
- 8.1k
- Forks
- 748
- Avg merge
- 6d 2h
- Merged PRs (30d)
- 54
Description
### Checklist
- [x] 1. I have searched related issues but cannot get the expected help.
- [x] 2. The bug has not been fixed in the latest version.
- [x] 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
概率推理无法结束,并且报错
并且cache_max_entry_count的设置不是很懂。vllm是直接设置最大值的百分比。简单直接有效。
这里这个值不是很懂。即便设置成cache_max_entry_count=0.20, quant_policy=4, (模型会占用24GB*2/3 的显存。所以数值用1-2/3)
依然会得到下列信息
2025-02-12 21:25:08,496 - lmdeploy - WARNING - model_agent.py:70 - device<0> No enough memory. update max_prefill_token_num=2048
并且概率可以正常推理和无法结束的推理以及报错。
理论上 32B的4bit模型在24GB的机子上 如果是float16推理理论上最大token数量为12,288。但是由于电脑使用中会占用一些导致不足12,288。并且在vllm通过设置最大token数量和gpu_memory_utilization也可以得到验证。
但是这里已经使用quant_policy=4 了。最大token数量可以简单的乘以4吗?还是不行呢?
无论如何设置cache_max_entry_count都会得到
2025-02-12 21:25:08,496 - lmdeploy - WARNING - model_agent.py:70 - device<0> No enough memory. update max_prefill_token_num=2048
或者直接报错。那么24GB显存跑32B 4bit模型 session_len最大应该是多少呢?按照float16 算?
以后最大token数量会被修改吗?以及为什么显存占用大概还剩下3GB多一些?
报错信息放在后面
### Reproduction
```python
import kagglehub
# export KAGGLEHUB_CACHE=/mnt/d/Users/Admin/.cache/kagglehub
# MODEL_NAME = "shelterw/deepseek-r1/transformers/deepseek-r1-distill-qwen-14b-awq"
MODEL_NAME = "shelterw/deepseek-r1/transformers/deepseek-r1-distill-qwen-32b-awq"
MODEL_PATH = kagglehub.model_download(MODEL_NAME)
print("Path to model files:", MODEL_PATH)
from lmdeploy import pipeline, GenerationConfig, TurbomindEngineConfig, PytorchEngineConfig
pipe = pipeline(MODEL_PATH,
# backend_config=TurbomindEngineConfig(
backend_config=PytorchEngineConfig(
# max_batch_size=32,
enable_prefix_caching=True,
cache_max_entry_count=0.30,
session_len=32768,
quant_policy=4,
))
gen_config = GenerationConfig(top_p=0.8,
top_k=40,
temperature=0.8,
do_sample=True,
max_new_tokens=30000,
# stop_words=[","],
)
questions = ["三家公司从Dodola岛运营航班。每家公司的航班时间表不同。第一家航空公司每100天出发一次,第二家每120天出发一次,第三家每150天出发一次。最大的正整数$d$是多少,使得不论各家航空公司的出发时间如何,都存在$d$个连续的没有航班从Dodola岛出发的日子?"]*2
response = pipe(questions,
gen_config=gen_config)
print(response)
```
### Environment
```Shell
sys.platform: linux
Python: 3.12.7 | packaged by Anaconda, Inc. | (main, Oct 4 2024, 13:27:36) [GCC 11.2.0]
CUDA available: True
MUSA available: False
numpy_random_seed: 2147483648
GPU 0: NVIDIA GeForce RTX 4090
CUDA_HOME: /usr/local/cuda-12.6
NVCC: Cuda compilation tools, release 12.6, V12.6.77
GCC: gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
PyTorch: 2.5.1+cu124
PyTorch compiling details: PyTorch built with:
- GCC 9.3
- C++ Version: 201703
- Intel(R) oneAPI Math Kernel Library Version 2023.1-Product Build 20230303 for Intel(R) 64 architecture applications
- Intel(R) MKL-DNN v3.5.3 (Git Hash 66f0cb9eb66affd2da3bf5f8d897376f04aae6af)
- OpenMP 201511 (a.k.a. OpenMP 4.5)
- LAPACK is enabled (usually provided by MKL)
- NNPACK is enabled
- CPU capability usage: AVX2
- CUDA Runtime 12.4
- 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
- Magma 2.6.1
- Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=12.4, 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 -DLIBKINETO_NOXPUPTI=ON -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-strict-overflow -Wno-strict-aliasing -Wno-stringop-overflow -Wsuggest-override -Wno-psabi -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, TORCH_VERSION=2.5.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.20.1+cu124
LMDeploy: 0.7.0.post3+fe9df7a
transformers: 4.48.2
gradio: 5.13.1
fastapi: 0.115.4
pydantic: 2.8.2
triton: 3.1.0
NVIDIA Topology:
GPU0 CPU Affinity NUMA Affinity GPU NUMA ID
GPU0 X 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
2025-02-12 21:25:08,566 - lmdeploy - WARNING - tokenizer.py:425 - Detected duplicate bos token 151646 in prompt, this will likely reduce response quality, one of them will beremoved
2025-02-12 21:32:36,793 - lmdeploy - ERROR - engine.py:904 - Task failed
Traceback (most recent call last):
File "/root/anaconda3/lib/python3.12/site-packages/lmdeploy/pytorch/engine/engine.py", line 899, in __task_callback
task.result()
File "/root/anaconda3/lib/python3.12/site-packages/lmdeploy/pytorch/engine/engine.py", line 842, in _async_loop_background
assert len(running) > 0
^^^^^^^^^^^^^^^^
AssertionError
```
@lvhan028
Contributor guide
Assessment
This issue has not been assessed yet.