Skip to content
Merged
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
1 change: 1 addition & 0 deletions lightx2v/models/runners/z_image/z_image_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ def run_vae_decoder(self, latents):
gc.collect()
return images

@ProfilingContext4DebugL1("RUN pipeline")
def run_pipeline(self, input_info):
self.input_info = input_info

Expand Down
2 changes: 0 additions & 2 deletions scripts/bench/run_lightx2v_qwen_2512_with_warmup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import os
import sys
from datetime import datetime

lightx2v_path = "/path/to/LightX2V"
model_path = "/path/to/Qwen/Qwen-Image-2512"

sys.path.append(lightx2v_path)
os.environ["PROFILING_DEBUG_LEVEL"] = "2"

from lightx2v import LightX2VPipeline # noqa: E402

Expand Down
2 changes: 0 additions & 2 deletions scripts/bench/run_lightx2v_qwen_edit_2511_with_warmup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import os
import sys
from datetime import datetime

lightx2v_path = "/path/to/LightX2V"
model_path = "/path/to/Qwen/Qwen-Image-Edit-2511"

sys.path.append(lightx2v_path)
os.environ["PROFILING_DEBUG_LEVEL"] = "2"

from lightx2v import LightX2VPipeline # noqa: E402

Expand Down
2 changes: 0 additions & 2 deletions scripts/bench/run_lightx2v_wan22_t2v_8gpu_with_warmup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
# torchrun --nproc_per_node=8 run_lightx2v_wan22_t2v_8gpu_with_warmup.py

import os
import sys
from datetime import datetime

lightx2v_path = "/path/to/LightX2V"
model_path = "/path/to/Wan-AI/Wan2.2-T2V-A14B"

sys.path.append(lightx2v_path)
os.environ["PROFILING_DEBUG_LEVEL"] = "2"

from lightx2v import LightX2VPipeline # noqa: E402

Expand Down
54 changes: 54 additions & 0 deletions scripts/bench/run_lightx2v_z_image_turbo_with_warmup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import sys
from datetime import datetime

lightx2v_path = "/path/to/LightX2V"
model_path = "/path/to/Tongyi-MAI/Z-Image-Turbo"

sys.path.append(lightx2v_path)

from lightx2v import LightX2VPipeline # noqa: E402

ts = datetime.now().strftime("%y%m%d%H%M")

model_cls = "z_image"

task = "t2i"


pipe = LightX2VPipeline(
model_path=model_path,
model_cls=model_cls,
task=task,
)

pipe.create_generator(config_json=f"{lightx2v_path}/configs/z_image/z_image_turbo_t2i.json")


# Generation parameters
seed = 42
prompt = "A fantasy landscape with mountains and a river, detailed, vibrant colors"

negative_prompt = " "

target_shape = [1024, 1024]

save_result_path = f"{lightx2v_path}/save_results/{model_cls}_{task}_{ts}.png"

# warmup
pipe.generate(
seed=seed,
prompt=prompt,
target_shape=target_shape,
negative_prompt=negative_prompt,
save_result_path=save_result_path,
)

# Generate video
pipe.generate(
seed=seed,
prompt=prompt,
target_shape=target_shape,
negative_prompt=negative_prompt,
save_result_path=save_result_path,
return_result_tensor=True,
)
Comment on lines +37 to +54
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There are a couple of improvements that can be made here:

  1. The arguments passed to pipe.generate are almost identical for the warmup and the actual generation call, leading to code duplication. To improve maintainability, you can store the common arguments in a dictionary and unpack them during the calls.
  2. The comment on line 46, # Generate video, is misleading since this is a text-to-image (t2i) task that generates a .png file. It should be changed to # Generate image.

Here's a suggestion that addresses both points:

generate_args = {
    "seed": seed,
    "prompt": prompt,
    "target_shape": target_shape,
    "negative_prompt": negative_prompt,
    "save_result_path": save_result_path,
}

# warmup
pipe.generate(**generate_args)

# Generate image
pipe.generate(**generate_args, return_result_tensor=True)