File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
lightllm/server/embed_cache/impl Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -134,9 +134,18 @@ def _del_ref(self, md5_sum):
134134 self ._sorted_records .add (rec )
135135 return
136136
137+ def _judge_enough_token_cache (self , md5sum_list : list [str ], token_num_list : list [int ]) -> bool :
138+ tmp_dict = {}
139+ for md5 , token_num in zip (md5sum_list , token_num_list ):
140+ tmp_dict [md5 ] = token_num
141+ return sum (tmp_dict .values ()) < self .cpu_embed_cache_client .token_num / 3
142+
137143 def alloc (self , md5sum_list : list [str ], token_num_list : list [int ]) -> Optional [list [dict ]]:
138144 now = time .time ()
139145 with self .lock :
146+ if not self ._judge_enough_token_cache (md5sum_list = md5sum_list , token_num_list = token_num_list ):
147+ return "error not enough cache"
148+
140149 add_ref_m_list = []
141150 new_md5_dict = {}
142151 for m , token_need in zip (md5sum_list , token_num_list ):
You can’t perform that action at this time.
0 commit comments