Skip to content

Commit ea0fe0d

Browse files
author
sangchengmeng
committed
[fix]0402-2
1 parent 57372e5 commit ea0fe0d

File tree

6 files changed

+17
-10
lines changed

6 files changed

+17
-10
lines changed

lightllm/server/core/objs/sampling_params.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ class SamplingParams(ctypes.Structure):
249249
("top_p", ctypes.c_float),
250250
("top_k", ctypes.c_int),
251251
("ignore_eos", ctypes.c_bool),
252+
# the max number of image patches to be used in the internvl model, for the test
252253
("image_max_patch_num", ctypes.c_int),
253254
("max_new_tokens", ctypes.c_int),
254255
("min_new_tokens", ctypes.c_int),

lightllm/server/embed_cache/impl/naive_memory_cache.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ class Record(object):
2222
token_id: int
2323
token_num: int
2424

25-
2625
@CacheManagerFactory.register("naive")
2726
class InMemoryCache(CacheManager):
27+
2828
def __init__(self, args) -> None:
2929
self._records = dict()
3030
self._md5_to_record = dict()
@@ -36,8 +36,9 @@ def __init__(self, args) -> None:
3636
self.lock = threading.Lock()
3737

3838
from lightllm.server.tokenizer import get_tokenizer
39-
40-
tokenizer = get_tokenizer(args.model_dir, args.tokenizer_mode, trust_remote_code=args.trust_remote_code)
39+
tokenizer = get_tokenizer(
40+
args.model_dir, args.tokenizer_mode, trust_remote_code=args.trust_remote_code
41+
)
4142
self.cur_token_id = tokenizer.vocab_size + 10000
4243

4344
def _clear(self):
@@ -69,6 +70,7 @@ def alloc(self, md5sum: str, token_num: int) -> dict:
6970
self._clear()
7071
if self.occupied >= self.capacity:
7172
return None
73+
7274
id = uuid.uuid1()
7375
id = id.int
7476
record = Record(
@@ -93,7 +95,11 @@ def alloc(self, md5sum: str, token_num: int) -> dict:
9395
record.visittime = t
9496
record.ref += 1
9597

96-
return {"id": record.id, "token_id": record.token_id, "token_num": record.token_num}
98+
return {
99+
"id": record.id,
100+
"token_id": record.token_id,
101+
"token_num": record.token_num
102+
}
97103

98104
def release(self, id: int) -> None:
99105
with self.lock:

lightllm/server/embed_cache/manager.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,7 @@ def start_cache_manager(port: int, args, pipe_writer):
6363
t = ThreadedServer(service, port=port)
6464
pipe_writer.send("init ok")
6565
t.start()
66+
67+
68+
if __name__ == "__main__":
69+
start_cache_manager(2233)

lightllm/server/embed_cache/utils.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
import base64
21
import torch
32
import numpy as np
43
from io import BytesIO
54
import multiprocessing.shared_memory as shm
6-
from PIL import Image
75

86

97
def tensor2bytes(t):

lightllm/server/httpserver/manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ async def _release_multimodal_resources(self, multimodal_params: MultimodalParam
152152
img.token_num = None
153153
return
154154

155-
def tokens(self, prompt, multimodal_params, samping_params=SamplingParams, kwargs=None):
155+
def tokens(self, prompt, multimodal_params, samping_params: SamplingParams, kwargs=None):
156156
kwargs = {} if kwargs is None else kwargs
157157
prompt_ids = self.tokenizer.encode(prompt, None, **kwargs)
158158
image_tokens = 0

lightllm/utils/image_utils.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import base64
2-
from io import BytesIO
32
from PIL import Image
4-
5-
from lightllm.server.multimodal_params import MultimodalParams, ImageItem
3+
from io import BytesIO
64

75

86
def image2base64(img_str: str):

0 commit comments

Comments
 (0)