MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / run

Method run

lightx2v/disagg/services/decoder.py:345–472  ·  view source on GitHub ↗
(self, stop_event=None)

Source from the content-addressed store, hash-verified

343 self.vae_decoder = None
344
345 def run(self, stop_event=None):
346 req_queue = deque()
347 waiting_queue: Dict[int, dict] = {}
348 exec_queue = deque()
349
350 while True:
351 transfer_sizes = self.data_mgr.get_backlog_counts() if self.data_mgr is not None else {"request_pool": 0, "waiting_pool": 0}
352 sidecar_sizes = self._data_mgr_sidecar.get_pending_counts()
353 self._update_queue_metrics(
354 {
355 "req_queue": len(req_queue),
356 "waiting_queue": len(waiting_queue),
357 "exec_queue": len(exec_queue),
358 },
359 {
360 "request_pool": int(transfer_sizes.get("request_pool", 0)),
361 "waiting_pool": int(transfer_sizes.get("waiting_pool", 0)),
362 "sidecar_input_watch": int(sidecar_sizes.get("input_watch", 0)),
363 },
364 )
365
366 centralized_request_mode = str(os.getenv("IS_CENTRALIZED", "0")).strip().lower() in {"1", "true", "yes", "on"}
367 if centralized_request_mode:
368 config = self._centralized_request_mgr.receive_non_block(self._centralized_request_port)
369 if config is not None:
370 if not isinstance(config, dict) or "data_bootstrap_room" not in config:
371 self.logger.warning("Ignored incomplete request packet from ZMQ: %s", config)
372 continue
373 decoder_metrics = config.setdefault("request_metrics", {}).setdefault("stages", {}).setdefault("decoder", {})
374 decoder_metrics["request_received_ts"] = time.time()
375 self.logger.info("Received request config from ZMQ: %s", {k: v for k, v in config.items()})
376 req_queue.append(config)
377 else:
378 if self._phase2_rdma_buffer is None:
379 try:
380 self._ensure_phase2_request_buffer()
381 except Exception:
382 self.logger.exception("Failed to connect phase2 request RDMA buffer, will retry")
383
384 if self._phase2_rdma_buffer is not None:
385 packet = self._phase2_rdma_buffer.consume()
386 if packet is not None:
387 if isinstance(packet, dict) and "request_config" in packet:
388 config = dict(packet.get("request_config") or {})
389 config["transformer_node_address"] = packet.get("transformer_node_address", "127.0.0.1")
390 else:
391 config = packet
392 if not isinstance(config, dict) or "data_bootstrap_room" not in config:
393 self.logger.warning("Ignored incomplete phase2 packet from RDMA buffer: %s", packet)
394 continue
395 decoder_metrics = config.setdefault("request_metrics", {}).setdefault("stages", {}).setdefault("decoder", {})
396 decoder_metrics["request_received_ts"] = time.time()
397 self.logger.info("Received request config from RDMA buffer: %s", {k: v for k, v in config.items()})
398 req_queue.append(config)
399
400 if req_queue:
401 config = req_queue.popleft()
402 room = int(config.get("data_bootstrap_room", 0))

Callers 13

run_decoderFunction · 0.95
run_decoderFunction · 0.95
run_commandFunction · 0.45
detect_personsFunction · 0.45
estimate_poseFunction · 0.45
forwardMethod · 0.45
forwardMethod · 0.45
_run_infer_onceFunction · 0.45
mainFunction · 0.45
run_serverFunction · 0.45
__call__Method · 0.45

Calls 15

_update_queue_metricsMethod · 0.95
initMethod · 0.95
removeMethod · 0.95
processMethod · 0.95
releaseMethod · 0.95
get_backlog_countsMethod · 0.80
receive_non_blockMethod · 0.80
warningMethod · 0.80
setdefaultMethod · 0.80
infoMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected