Skip to content

qwen-image-edit-2511推理速度 #808

@PhilChina

Description

@PhilChina

我是通过python调用LightX2VPipeline进行推理的,使用了pipe.enable_lora LoRA的权重,设置
pipe.create_generator(
attn_mode="flash_attn3",
resize_mode="adaptive",
infer_steps=4,
guidance_scale=1,
) 采样4步,我发现推理单张耗时在30s左右,与官方测试出来的1.2s 差的还挺多的,我想要确认的是是需要额外设置什么嘛
`
"""
Qwen-image-edit image-to-image generation example.
This example demonstrates how to use LightX2V with Qwen-Image-Edit model for I2I generation.
"""

import time

from lightx2v import LightX2VPipeline

Initialize pipeline for Qwen-image-edit I2I task

For Qwen-Image-Edit-2509, use model_cls="qwen-image-edit-2509"

pipe = LightX2VPipeline(
model_path="/Qwen-Image-Edit-2511/",
model_cls="qwen-image-edit-2511",
task="i2i",
)

Alternative: create generator from config JSON file

pipe.create_generator(

config_json="../configs/qwen_image/qwen_image_i2i_2511_lora.json"

)

Enable offloading to significantly reduce VRAM usage with minimal speed impact

Suitable for RTX 30/40/50 consumer GPUs

pipe.enable_offload(
cpu_offload=True,
offload_granularity="block", #["block", "phase"]
text_encoder_offload=True,
vae_offload=False,
)

Load distilled LoRA weights

pipe.enable_lora(
[
{"path": "/Qwen-Image-Edit-2511-Lightning/Qwen-Image-Edit-2511-Lightning-4steps-V1.0-bf16.safetensors", "strength": 1.0},
],
lora_dynamic_apply=False, # Support inference with LoRA weights, save memory but slower, default is False
)

Create generator manually with specified parameters

pipe.create_generator(
attn_mode="flash_attn3",
resize_mode="adaptive",
infer_steps=4,
guidance_scale=1,
)

Generation parameters

seed = 42
prompt = ""
negative_prompt = ""
image_path = ""
save_result_path = ""

Generate video and measure latency

start_time = time.perf_counter()
pipe.generate(
seed=seed,
image_path=image_path,
prompt=prompt,
negative_prompt=negative_prompt,
save_result_path=save_result_path,
)
elapsed = time.perf_counter() - start_time
print(f"[LightX2V] Inference time: {elapsed:.3f}s")

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions