Skip to content

Commit 943bba5

Browse files
committed
[add]add skip-image-cache parameters
1 parent 5e8957d commit 943bba5

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

lightllm/server/embed_cache/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ def create_shm(name, data):
3232
mem_view = shared_memory.buf
3333
mem_view[:data_size] = data
3434
except FileExistsError:
35-
print("Warning create shm {} failed because of FileExistsError!".format(name))
35+
pass
36+
# print("Warning create shm {} failed because of FileExistsError!".format(name))
3637

3738

3839
def read_shm(name):

lightllm/server/multimodal_params.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,11 @@ def __init__(
137137
self,
138138
images: List[dict] = [],
139139
audios: List[dict] = [],
140+
skip_image_cache: bool = False,
140141
) -> None:
141142
self.images = [ImageItem(**i) for i in images]
142143
self.audios = [AudioItem(**a) for a in audios]
144+
self.skip_image_cache = skip_image_cache
143145
return
144146

145147
async def verify_and_preload(self, request: Request):

lightllm/server/visualserver/manager.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,12 @@ async def loop_for_fwd(self):
123123

124124
multimodal_params = group_req_indexes.multimodal_params
125125

126-
img_uuids = [img.uuid for img in multimodal_params.images]
127-
ready_image = obtain(self.cache_client.root.get_items_embed(img_uuids))
128-
129-
for img, ready in zip(multimodal_params.images, ready_image):
126+
img_uuids = list(dict.fromkeys(img.uuid for img in multimodal_params.images))
127+
if multimodal_params.skip_image_cache:
128+
ready_image = [False] * len(img_uuids)
129+
else:
130+
ready_image = obtain(self.cache_client.root.get_items_embed(img_uuids))
131+
for img, ready in zip(img_uuids, ready_image):
130132
if not ready:
131133
images_need_infer.append(img)
132134

lightllm/server/visualserver/model_infer/model_rpc.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,8 @@ def exposed_encode(self, images: List[ImageItem]):
100100
all_img_embeds = all_img_embeds.to(torch.device("cpu"))
101101

102102
if self.tp_rank_id == 0:
103-
ready_flags = obtain(self.cache_client.root.get_items_embed(uuids))
104103
ids_to_set = []
105-
for i, ready in enumerate(ready_flags):
104+
for i, ready in uuids:
106105
if ready:
107106
continue
108107
uid = uuids[i]

0 commit comments

Comments
 (0)