@@ -142,12 +142,9 @@ async def _alloc_resource(self, item: Union[ImageItem, AudioItem]):
142142 async def _alloc_multimodal_resources (self , multimodal_params : MultimodalParams , sampling_params : SamplingParams ):
143143 # 只有 P 和 NORMAL 节点需要真的管理多模态资源
144144 if self .pd_mode .is_P_or_NORMAL ():
145- # Acquire the lock so that two concurrent requests cannot both
146- # allocate more records than the cache_capacity.
147- # For example, if cache_capacity is 10 and each request has 6 images,
148- # without the lock one request might allocate 5 images,
149- # then another request allocates 5 more images, filling cache_capacity,
150- # and both wait for space to free, causing a deadlock.
145+ # 这里的锁是为了 防止多个含有多张图片的请求 同时申请的record数量 大于cache_capacity,从而造成死锁的问题。
146+ # 如果不加任何锁,假如请求1和请求2都有6张图片,而cache_capacity为10,
147+ # 那么如果某一时刻shm中存在请求1的5张图和请求2的5张图,将会资源竞争产生死锁。
151148 async with self ._resource_lock :
152149 for img in multimodal_params .images :
153150 self .tokenizer .init_imageitem_extral_params (img , multimodal_params , sampling_params )
@@ -169,7 +166,6 @@ async def _release_multimodal_resources(self, multimodal_params: MultimodalParam
169166 if multimodal_params is not None :
170167 for img in multimodal_params .images :
171168 if img .uuid is not None :
172- logger .info (f"Releasing id { img .uuid } " )
173169 self .cache_client .root .release (img .uuid )
174170 # 将 uuid 等 赋值为 None, 防止因为abort等异常情况造成重复释放异常
175171 img .uuid = None
@@ -602,7 +598,6 @@ async def recycle_resource_loop(self):
602598 release_req_status : List [ReqStatus ] = []
603599 for req_status in self .req_id_to_out_inf .values ():
604600 if req_status .can_release ():
605- logger .info (f"req_status { req_status .group_req_objs .group_req_id } can release" )
606601 release_req_status .append (req_status )
607602 for req_status in release_req_status :
608603 self .req_id_to_out_inf .pop (req_status .group_req_objs .group_req_id , None )
0 commit comments