LightX2V

repository·main·Indexed 23 days ago

https://github.com/modeltc/lightx2v

A lightweight inference framework for high-performance image and video generation (T2V, I2V, T2I, I2I). It focuses on efficiency through quantization (FP8, NVFP4), distillation, and optimized parallelism. The framework supports models such as BAGEL-7B-MoT, Qwen-Image (2511/2512), and Wan2.1/2.2, providing tools for deployment via Gradio and a Python API through the LightX2VPipeline class.

Tokens
89.1K
Snippets
210
Records
420
Agent score
81%

What's inside lightx2v

  1. Overview of lightx2v_platform

    main
    lightx2v_platform is a functional platform designed to be independent of the core lightx2v library. Its primary purpose is to align inference interfaces for non-NVIDIA chip backends. Developers looking to support a new chip backend should focus their implementation efforts exclusively within lightx2v_platform.
  2. Overview of the Model Conversion Tool

    main

    The Model Conversion Tool is a utility for managing model weights. It provides capabilities for:

    • Format Conversion: Switching between PyTorch (.pth) and SafeTensors (.safetensors) formats.
    • Quantization: Reducing model size using INT8, FP8, NVFP4, MXFP4, MXFP6, and MXFP8.
    • Architecture Conversion: Converting weights between LightX2V and Diffusers architectures.
    • LoRA Merging: Loading and merging multiple LoRA formats into the base model.
    • Multi-Model Support: Specialized support for wan_dit, hunyuan_dit, qwen_image_dit, wan_t5, and wan_clip.
    • Flexible Saving: Options for single-file, block-based, or chunked saving.
    • Parallel Processing: Accelerated conversion for large models.
  3. Overview of LightX2V Server

    main
    The LightX2V server is a distributed video and image generation service built with FastAPI. It is designed for high-throughput workloads using a multi-process architecture with GPU support. The server manages a task queue system that handles both image-to-video (I2V) and text-to-image tasks, supporting distributed inference across multiple GPUs via torchrun.
  4. Overview of LightX2V

    main

    LightX2V is a lightweight image and video generation inference framework designed for high-performance synthesis. It provides a unified platform for various generation tasks, where 'X2V' denotes the transformation of input modalities (X, such as text or images) into vision output (Vision).

    Supported tasks include:

    • Text-to-Video (T2V)
    • Image-to-Video (I2V)
    • Text-to-Image (T2I)
    • Image-Editing (I2I)

    Users can access models via the LightX2V HuggingFace repository or try the framework online via LightX2V Studio.

  5. BAGEL Feature Scope

    main

    Supported

    • python -m lightx2v.infer --model_cls bagel --task t2i
    • python -m lightx2v.infer --model_cls bagel --task i2i
    • PNG saving
    • seed control
    • T2I aspect_ratio presets
    • target_shape overrides
    • Service in-memory image return via return_result_tensor=True

    Not Supported

    • Mask editing
    • Multiple input images
    • Visual understanding
    • Thinking text output
    • NF4 or INT8 quantization
    • Multi-GPU dispatch
  6. Supported Models and Ecosystem

    main

    LightX2V supports a wide range of models including:

    • Official Models: LTX-2.3, LTX-2, HunyuanVideo-1.5, Wan2.1 & Wan2.2, SeedVR2, and Qwen-Image series.
    • Distilled/Quantized Models (Recommended for 4-step inference): LightLingBot-Video, Wan2.1/2.2 Distill Models, and Wan-NVFP4.
    • Lightweight Autoencoders: Specialized autoencoders for fast inference and low memory footprint.
    • Autoregressive Models: Wan2.1-T2V-CausVid, Self-Forcing, and Matrix-Game-2.0.
  7. Overview of LightX2V supported model formats

    main

    LightX2V supports three primary model formats for video generation inference:

    1. Wan Official Models: Directly compatible with complete models released by Wan-AI (versions 2.1 and 2.2). These provide the highest quality using original BF16/FP32 precision and include all necessary components (DIT, T5, CLIP, VAE).
    2. Single-File Models: Optimized models released by LightX2V, which may include quantized versions for reduced memory footprint.
    3. LoRA Models: Distilled LoRAs released by LightX2V that can be loaded onto base models.
  8. What is Autoregressive Distillation in LightX2V

    main

    Autoregressive distillation is a research-oriented feature in LightX2V designed to accelerate inference. It reduces the required inference steps from the standard 40-50 steps down to 8 steps. This technique enables infinite-length video generation by utilizing KV Cache technology.

    Note: Currently, LightX2V only supports autoregressive models for Text-to-Video (T2V). Users should be aware that current performance and acceleration improvements may be mediocre, as it is primarily intended as a long-term research direction.

  9. What is Disaggregation Mode in LightX2V

    main

    Disaggregation Mode splits a large generative model's inference pipeline (e.g., Wan, Qwen Image) into three distinct stages: Encoder, Transformer, and Decoder. This is designed to solve Out-of-Memory (OOM) issues on memory-constrained GPUs by ensuring each node only loads its specific subset of the model.

    The Three-Stage Pipeline

    • Encoder (disagg_mode="encoder"): Loads Text Encoder, Image Encoder, and VAE Encoder. It sends encoded data via Phase1 (using Mooncake transport) to the Transformer.
    • Transformer (disagg_mode="transformer"): Loads only the DiT (Diffusion Transformer). It receives Phase1 data, runs denoising, and if a decoder_engine_rank is configured, sends latents via Phase2 to the Decoder.
    • Decoder (disagg_mode="decode"): Loads only the VAE Decoder. It receives Phase2 data, runs the VAE decode, and is responsible for task completion and storing the final result path.

    Key Benefits

    • Memory Efficiency: Reduces per-node resident memory requirements.
    • Concurrency: Different stages can process different requests simultaneously, improving throughput.
    • Transport: Uses Mooncake (RDMA or TCP) for efficient tensor transfer between stages.