MCPcopy
hub / github.com/ModelTC/LightLLM / alloc_req_id

Method alloc_req_id

lightllm/server/httpserver/manager.py:233–254  ·  view source on GitHub ↗
(self, sampling_params, is_health_req: bool = False)

Source from the content-addressed store, hash-verified

231 return
232
233 def alloc_req_id(self, sampling_params, is_health_req: bool = False):
234 # 请求的 id 可以由外部传入,也可以由内部生成,但是由外部传入的时候,要自己保证全局唯一性
235 # 否则会造成异常问题。目前限制 NORMAL 模式都使用内部id替换, P 和 D 模式按需设置
236 # health 请求 request_id 为负数,直接返回
237 if is_health_req:
238 return sampling_params.group_request_id
239 if self.pd_mode == NodeRole.NORMAL:
240 if not self.is_multinode_tp:
241 group_request_id = self.id_gen.generate_id()
242 else:
243 if self.node_rank == 0:
244 group_request_id = self.id_gen.generate_id()
245 else:
246 assert sampling_params.group_request_id != -1
247 group_request_id = sampling_params.group_request_id
248 sampling_params.group_request_id = group_request_id
249 elif self.pd_mode == NodeRole.P or self.pd_mode == NodeRole.D:
250 assert sampling_params.group_request_id is not None, "p d mode, group_request_id must be setting"
251 group_request_id = sampling_params.group_request_id
252 else:
253 assert False, "dead code path"
254 return group_request_id
255
256 async def generate(
257 self,

Callers 1

generateMethod · 0.95

Calls 1

generate_idMethod · 0.80

Tested by

no test coverage detected