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

Method process

lightx2v/disagg/services/decoder.py:194–315  ·  view source on GitHub ↗
(self, config)

Source from the content-addressed store, hash-verified

192 def process(self, config):
193 save_result_path = get_input_value(config, "save_result_path", None)
194 if not save_result_path:
195 raise ValueError("save_result_path is required for disaggregated generation requests")
196
197 seed_all(get_input_value(config, "seed"))
198 self.logger.info("Starting processing in DecoderService...")
199 room = config.get("data_bootstrap_room", 0)
200 decoder_metrics = config.setdefault("request_metrics", {}).setdefault("stages", {}).setdefault("decoder", {})
201 decoder_metrics["compute_start_ts"] = time.time()
202 strict_meta_hash_check = str(os.getenv("LIGHTX2V_STRICT_META_HASH", "0")).strip().lower() in {"1", "true", "yes", "on"}
203 room_buffers = self._rdma_buffers.get(room)
204 receiver = self.data_receiver.get(room)
205
206 if receiver is None:
207 raise RuntimeError(f"DataReceiver is not initialized in DecoderService for room={room}.")
208 if room_buffers is None:
209 raise RuntimeError(f"No RDMA buffer available in DecoderService for room={room}.")
210
211 def _buffer_view(buf: torch.Tensor, dtype: torch.dtype, shape: tuple[int, ...]) -> torch.Tensor:
212 view = torch.empty(0, dtype=dtype, device=buf.device)
213 view.set_(buf.untyped_storage(), 0, shape)
214 return view
215
216 def _sha256_tensor(tensor: Optional[torch.Tensor]) -> Optional[str]:
217 if tensor is None:
218 return None
219 data_tensor = tensor.detach()
220 if data_tensor.dtype == torch.bfloat16:
221 data_tensor = data_tensor.to(torch.float32)
222 data = data_tensor.contiguous().cpu().numpy().tobytes()
223 return hashlib.sha256(data).hexdigest()
224
225 if len(room_buffers) < 2:
226 raise RuntimeError("Phase2 RDMA buffers require [latents, meta] entries.")
227
228 meta_buf = room_buffers[1]
229
230 def _read_phase2_meta() -> tuple[dict, str]:
231 meta_bytes = _buffer_view(meta_buf, torch.uint8, (meta_buf.numel(),)).detach().contiguous().cpu().numpy().tobytes()
232 meta_str = meta_bytes.split(b"\x00", 1)[0].decode("utf-8", errors="ignore") if meta_bytes else ""
233 if not meta_str:
234 raise ValueError("missing latents metadata from transformer")
235 parsed = json.loads(meta_str)
236 if not isinstance(parsed, dict):
237 raise ValueError(f"phase2 metadata type mismatch: {type(parsed)}")
238 return parsed, meta_str
239
240 def _infer_latents_shape_from_config() -> tuple[int, int, int, int]:
241 z_dim = int(config.get("vae_z_dim", 16))
242 vae_stride = config.get("vae_stride", (4, 8, 8))
243 stride_t = int(vae_stride[0])
244 stride_h = int(vae_stride[1])
245 stride_w = int(vae_stride[2])
246 num_frames = int(get_input_value(config, "num_frames", 81))
247 target_height, target_width = map(int, get_input_value(config, "size", (480, 832)))
248
249 t_prime = 1 + (num_frames - 1) // stride_t
250 h_prime = int(math.ceil(target_height / stride_h))
251 w_prime = int(math.ceil(target_width / stride_w))

Callers 1

runMethod · 0.95

Calls 12

GET_DTYPEFunction · 0.90
wan_vae_to_comfyFunction · 0.90
save_to_videoFunction · 0.90
_buffer_viewFunction · 0.85
_sha256_tensorFunction · 0.85
infoMethod · 0.80
setdefaultMethod · 0.80
warningMethod · 0.80
getMethod · 0.45
toMethod · 0.45
deviceMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected