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

Class DecodeNode

lightllm/server/core/objs/sampling_params.py:226–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

224
225
226class DecodeNode(ctypes.Structure):
227 _fields_ = [
228 ("exists", ctypes.c_bool),
229 ("node_id_high", ctypes.c_uint64), # UUID 的高 64 位
230 ("node_id_low", ctypes.c_uint64), # UUID 的低 64 位
231 ("ip", ctypes.c_int32 * 4),
232 ("rpyc_port", ctypes.c_int),
233 ("max_new_tokens", ctypes.c_int),
234 # 记录当前请求使用的 pd_master 节点的 id
235 ("pd_master_node_id_high", ctypes.c_uint64),
236 ("pd_master_node_id_low", ctypes.c_uint64),
237 ]
238
239 def initialize(self, data_dict):
240 if data_dict is None:
241 self.exists = False
242 return
243
244 self.exists = True
245
246 pd_node_id = data_dict["node_id"]
247 self.node_id_high = (pd_node_id >> 64) & 0xFFFFFFFFFFFFFFFF
248 self.node_id_low = pd_node_id & 0xFFFFFFFFFFFFFFFF
249
250 ip_parts = [int(part) for part in data_dict["ip"].split(".")]
251 self.ip = (ctypes.c_int32 * 4)(*ip_parts)
252
253 self.rpyc_port = data_dict["rpyc_port"]
254 self.max_new_tokens = data_dict["max_new_tokens"]
255
256 pd_master_node_id = data_dict["pd_master_node_id"]
257 self.pd_master_node_id_high = (pd_master_node_id >> 64) & 0xFFFFFFFFFFFFFFFF
258 self.pd_master_node_id_low = pd_master_node_id & 0xFFFFFFFFFFFFFFFF
259
260 def to_dict(self):
261 if not self.exists:
262 return None
263 return {
264 "node_id": ((self.node_id_high << 64) | self.node_id_low),
265 "ip": ".".join(str(self.ip[i]) for i in range(4)),
266 "rpyc_port": self.rpyc_port,
267 "max_new_tokens": self.max_new_tokens,
268 "pd_master_node_id": ((self.pd_master_node_id_high << 64) | self.pd_master_node_id_low),
269 }
270
271
272class SamplingParams(ctypes.Structure):

Callers 2

initMethod · 0.70

Calls

no outgoing calls

Tested by 1