Skip to content

Commit cb7fd6d

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

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
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: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ def __init__(self, args) -> None:
3737

3838
from lightllm.server.tokenizer import get_tokenizer
3939

40-
tokenizer = get_tokenizer(args.model_dir, args.tokenizer_mode, trust_remote_code=args.trust_remote_code)
40+
tokenizer = get_tokenizer(
41+
args.model_dir, args.tokenizer_mode, trust_remote_code=args.trust_remote_code
42+
)
4143
self.cur_token_id = tokenizer.vocab_size + 10000
4244

4345
def _clear(self):
@@ -69,6 +71,7 @@ def alloc(self, md5sum: str, token_num: int) -> dict:
6971
self._clear()
7072
if self.occupied >= self.capacity:
7173
return None
74+
7275
id = uuid.uuid1()
7376
id = id.int
7477
record = Record(
@@ -93,7 +96,11 @@ def alloc(self, md5sum: str, token_num: int) -> dict:
9396
record.visittime = t
9497
record.ref += 1
9598

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

98105
def release(self, id: int) -> None:
99106
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

0 commit comments

Comments
 (0)