Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lightx2v/models/runners/wan/edenlive_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ def _run_diffusion(self, step_indices=None):
on_chunk = None if self.chunk_callback is None else lambda pixels, index: self.chunk_callback(pixels, index, index == num_chunks - 1)
decoder = AsyncVAEChunkDecoder.from_config(self.config, device=AI_DEVICE, vae_decoder=self.vae_decoder, on_chunk=on_chunk, dispatch_in_worker=True)
streaming = decoder.is_async or self.config.get("streaming_vae", False) or on_chunk is not None
decode = self.vae_decoder.cached_decode_withflag
if ar.get("decode_to_cpu", False):
# Keep decoded chunks in host memory, so GPU memory no longer grows with the video length (chunk callbacks get CPU tensors).
def decode(*args):
return self.vae_decoder.cached_decode_withflag(*args).cpu()

try:
with no_sync_profiling(enabled=decoder.is_async):
for start in range(0, total, chunk):
Expand All @@ -319,7 +325,7 @@ def _run_diffusion(self, step_indices=None):
with ProfilingContext4DebugL1("🚀 infer_main_in_rerun"):
self.model.infer(self.inputs)
if streaming:
decoder.submit(self.vae_decoder.cached_decode_withflag, *decode_args)
decoder.submit(decode, *decode_args)
decoded_chunks = decoder.finish()
finally:
try:
Expand Down
2 changes: 2 additions & 0 deletions scripts/edenlive/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ The launchers use the quantized files prepared above. Checkpoints stored elsewhe

`SAVE_RESULT_PATH` selects the output MP4. `T5_CPU_OFFLOAD=true` reduces resident GPU memory by offloading T5; the performance results below use `false`.

The decoded chunks stay on the GPU until the end of a request, so GPU memory grows with the video length. For long clips, set `"decode_to_cpu": true` in `ar_config`: each decoded chunk is copied to host memory as it is produced. GPU memory then stays at its level for short clips, host memory grows instead, and chunk callbacks receive CPU tensors. The output is unchanged.

## LightX2V Acceleration

| Component | Optimization |
Expand Down
2 changes: 2 additions & 0 deletions scripts/edenlive/README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ bash scripts/edenlive/run_5090.sh

`SAVE_RESULT_PATH` 指定输出 MP4 路径。`T5_CPU_OFFLOAD=true` 通过卸载 T5 降低 GPU 常驻显存;下方性能测试使用 `false`。

解码后的分块在请求结束前一直保留在 GPU 上,因此显存会随视频长度增长。生成长视频时,可在 `ar_config` 中设置 `"decode_to_cpu": true`:每个分块解码后立即复制到主机内存。显存因此保持在短视频时的水平,改为占用主机内存,分块回调收到的是 CPU 张量。输出结果不变。

## LightX2V 加速

| 组件 | 优化 |
Expand Down