### Install Additional Dependencies Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/ori_sparse_attention/TurboDiffusion/README.md Install the required packages for rCM/SLA training. ```bash pip install megatron-core hydra-core wandb webdataset pip install --no-build-isolation transformer_engine[pytorch] ``` -------------------------------- ### Install FastVideo with uv Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/README.md Create a new Python 3.12 environment using uv and install the FastVideo package. ```bash # Create and activate a new uv environment uv venv --python 3.12 --seed source .venv/bin/activate # Install FastVideo uv pip install fastvideo ``` -------------------------------- ### Setup FVD environment Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/benchmarks/fvd/README.md Performs a one-time setup per pod or environment before running CLI commands. ```bash bash benchmarks/scripts/setup_fvd.sh ``` -------------------------------- ### Standard installation Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo-kernel/README.md Initialize submodules and run the build script for local development. ```bash git submodule update --init --recursive cd fastvideo-kernel ./build.sh ``` -------------------------------- ### Install ROCm Flash-Attention Source: https://github.com/amd-agi/hummingbirdxt/blob/main/README.md Install the ROCm-specific flash-attention library from source. ```bash git clone https://github.com/ROCm/flash-attention.git cd flash-attention python setup.py install ``` -------------------------------- ### Install SpargeAttn for SageSLA Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/ori_sparse_attention/TurboDiffusion/README.md Install the SpargeAttn dependency to enable the fast SLA forward pass based on SageAttention. ```bash pip install git+https://github.com/thu-ml/SpargeAttn.git --no-build-isolation ``` -------------------------------- ### Generate video with example.py Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/README.md Create a file named example.py to initialize the VideoGenerator and produce a video from a text prompt. Ensure VSA kernels are installed before running this script. ```python import os from fastvideo import VideoGenerator def main(): os.environ["FASTVIDEO_ATTENTION_BACKEND"] = "VIDEO_SPARSE_ATTN" # Create a video generator with a pre-trained model generator = VideoGenerator.from_pretrained( "FastVideo/FastWan2.1-T2V-1.3B-Diffusers", num_gpus=1, # Adjust based on your hardware ) # Define a prompt for your video prompt = "A curious raccoon peers through a vibrant field of yellow sunflowers, its eyes wide with interest." # Generate the video video = generator.generate_video( prompt, output_path="my_videos/", # Controls where videos are saved save_video=True ) if __name__ == '__main__': main() ``` -------------------------------- ### Launch Step Distillation Training Source: https://github.com/amd-agi/hummingbirdxt/blob/main/README.md Start the training pipeline using the provided shell script. ```bash bash running_scripts/train/dmd.sh ``` -------------------------------- ### Install via Conda Environment Source: https://github.com/amd-agi/hummingbirdxt/blob/main/README.md Create and activate a Conda environment with Python 3.10 and install dependencies. ```bash conda create -n hummingbirdxt python=3.10 conda activate hummingbirdxt pip install -r requirements.txt ``` -------------------------------- ### Download Teacher Model Source: https://github.com/amd-agi/hummingbirdxt/blob/main/README.md Install the required huggingface_hub transfer tools and download the Wan2.2-TI2V-5B teacher model. ```bash pip install "huggingface_hub[hf_transfer]" HF_HUB_ENABLE_HF_TRANSFER=1 --local-dir wan_models/Wan2.2-TI2V-5B ``` -------------------------------- ### Compile TurboDiffusion from source Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/ori_sparse_attention/TurboDiffusion/README.md Clone the repository, initialize submodules, and install in editable mode. ```bash git clone https://github.com/thu-ml/TurboDiffusion.git cd TurboDiffusion git submodule update --init --recursive pip install -e . --no-build-isolation ``` -------------------------------- ### Install TurboDiffusion via pip Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/ori_sparse_attention/TurboDiffusion/README.md Create a conda environment and install the package using pip. ```bash conda create -n turbodiffusion python=3.12 conda activate turbodiffusion pip install turbodiffusion --no-build-isolation ``` -------------------------------- ### Import and use attention kernels Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo-kernel/README.md Example usage of Sliding Tile Attention, Video Sparse Attention, and VMoBA kernels. ```python from fastvideo_kernel import sliding_tile_attention, video_sparse_attn, moba_attn_varlen # Example: Sliding Tile Attention out = sliding_tile_attention(q, k, v, window_sizes, text_len) # Example: Video Sparse Attention (with Triton fallback) out = video_sparse_attn(q, k, v, block_sizes, block_sizes, topk=5) # Example: VMoBA out = moba_attn_varlen(q, k, v, cu_seqlens_q, cu_seqlens_k, ...) ``` -------------------------------- ### Set CUDA toolchain paths Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo-kernel/README.md Set the CUDA_HOME and CUDACXX environment variables before installation. ```bash export CUDA_HOME=/usr/local/cuda export CUDACXX=$CUDA_HOME/bin/nvcc ``` -------------------------------- ### Benchmark VSA TFLOPs Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo-kernel/README.md Run the VSA benchmark script after building and installing the package. ```bash cd fastvideo-kernel python benchmarks/bench_vsa.py --batch_size 1 --num_heads 16 --head_dim 128 --q_seq_lens 49152 --topk 64 ``` -------------------------------- ### Run FVD benchmark Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/benchmarks/fvd/README.md Executes the benchmark script which automatically installs dependencies and runs the evaluation. ```bash bash benchmarks/scripts/run.sh ``` -------------------------------- ### Example TurboDiffusion TUI Session Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/ori_sparse_attention/TurboDiffusion/turbodiffusion/serve/README.md A sample interaction showing prompt entry, parameter adjustment via /set, and exiting the server. ```text ┌──────────────────────────────────────────┐ │ TurboDiffusion TUI Server │ │ Mode: T2V (text-to-video) │ │ Model: Wan2.1-1.3B | Resolution: 480p │ └──────────────────────────────────────────┘ Type /help for commands. Use \ for newline in prompts. > A cat sitting on a windowsill \ ... watching the rain fall outside output [output/generated_video.mp4]: Generating video... Done: output/generated_video.mp4 > /set num_steps 2 num_steps = 2 > /quit Goodbye! ``` -------------------------------- ### Launch Methods for TurboDiffusion Server Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/ori_sparse_attention/TurboDiffusion/turbodiffusion/serve/README.md Various ways to launch the server, including as a Python module, an installed CLI, or via existing inference scripts. ```bash # 1. Python module PYTHONPATH=turbodiffusion python -m turbodiffusion.serve [args] # 2. Installed CLI (after pip install -e .) PYTHONPATH=turbodiffusion turbodiffusion-serve [args] # 3. Via existing inference scripts with --serve flag PYTHONPATH=turbodiffusion python turbodiffusion/inference/wan2.1_t2v_infer.py --serve [args] PYTHONPATH=turbodiffusion python turbodiffusion/inference/wan2.2_i2v_infer.py --serve [args] ``` -------------------------------- ### Launch TurboDiffusion TUI Server for T2V and I2V Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/ori_sparse_attention/TurboDiffusion/turbodiffusion/serve/README.md Start the server in either text-to-video (T2V) or image-to-video (I2V) mode using the specified model checkpoints. ```bash # T2V mode (text-to-video) PYTHONPATH=turbodiffusion python -m turbodiffusion.serve \ --mode t2v \ --dit_path checkpoints/TurboWan2.1-T2V-1.3B-480P.pth # I2V mode (image-to-video) PYTHONPATH=turbodiffusion python -m turbodiffusion.serve \ --mode i2v \ --high_noise_model_path checkpoints/TurboWan2.2-I2V-14B-720P-high.pth \ --low_noise_model_path checkpoints/TurboWan2.2-I2V-14B-720P-low.pth ``` -------------------------------- ### Initialize ODE for Long Video Training Source: https://github.com/amd-agi/hummingbirdxt/blob/main/README.md Optionally initialize ODE weights by navigating to the long_video directory and running the initialization script. ```bash cd long_video bash train_ode.sh ``` -------------------------------- ### Enter Training Directory Source: https://github.com/amd-agi/hummingbirdxt/blob/main/README.md Navigate to the training directory before executing training commands. ```bash cd train ``` -------------------------------- ### Download Wan2.1 Pretrained Checkpoints Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/ori_sparse_attention/TurboDiffusion/README.md Download the Wan2.1 pretrained checkpoints, VAE, and text encoder to the assets/checkpoints directory. ```bash # make sure git lfs is installed git clone https://huggingface.co/worstcoder/Wan assets/checkpoints ``` -------------------------------- ### Execute inference script Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/README.md Run the previously created example.py script using the python command. ```bash python example.py ``` -------------------------------- ### Download all quality tiers Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo/tests/ssim/README.md Downloads reference videos for all quality tiers. ```bash python fastvideo/tests/ssim/reference_videos_cli.py download --quality-tier all ``` -------------------------------- ### Display reference_videos_cli.py help Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo/tests/ssim/README.md Displays the help menu for the reference videos CLI tool. ```bash python fastvideo/tests/ssim/reference_videos_cli.py --help ``` -------------------------------- ### Download VAE and Text Encoder Checkpoints Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/ori_sparse_attention/TurboDiffusion/README.md Download the required VAE and umT5 text encoder checkpoints for both Wan2.1 and Wan2.2 models. ```bash mkdir checkpoints cd checkpoints wget https://huggingface.co/Wan-AI/Wan2.1-T2V-1.3B/resolve/main/Wan2.1_VAE.pth wget https://huggingface.co/Wan-AI/Wan2.1-T2V-1.3B/resolve/main/models_t5_umt5-xxl-enc-bf16.pth ``` -------------------------------- ### Launch DMD Training Source: https://github.com/amd-agi/hummingbirdxt/blob/main/README.md Execute the DMD training script for the HummingbirdXTX model. ```bash bash train_dmd.sh ``` -------------------------------- ### Download Quantized Model Checkpoints Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/ori_sparse_attention/TurboDiffusion/README.md Download quantized model checkpoints for RTX 5090 or similar GPUs. ```bash # For Wan2.1-T2V-1.3B wget https://huggingface.co/TurboDiffusion/TurboWan2.1-T2V-1.3B-480P/resolve/main/TurboWan2.1-T2V-1.3B-480P-quant.pth # For Wan2.2-I2V-14B wget https://huggingface.co/TurboDiffusion/TurboWan2.2-I2V-A14B-720P/resolve/main/TurboWan2.2-I2V-A14B-high-720P-quant.pth wget https://huggingface.co/TurboDiffusion/TurboWan2.2-I2V-A14B-720P/resolve/main/TurboWan2.2-I2V-A14B-low-720P-quant.pth ``` -------------------------------- ### Run Docker Container Source: https://github.com/amd-agi/hummingbirdxt/blob/main/README.md Execute the Docker container with necessary hardware and system permissions. ```bash docker run -it \ --shm-size=900g \ --name hm \ --network host \ --ipc=host \ --cap-add=SYS_PTRACE \ --security-opt seccomp=unconfined \ --device=/dev/kfd \ --device=/dev/dri \ --group-add video \ -e HSA_OVERRIDE_GFX_VERSION=11.0.0 \ -v /home:/home \ panisobe/dmd_flash_image_2_release:latest ``` -------------------------------- ### Run Rocm-VSA Training Source: https://github.com/amd-agi/hummingbirdxt/blob/main/README.md Navigate to the training directory and execute the training script. ```bash cd ./HummingbirdXT_VSA/train bash running_scripts/train/dmd.sh ``` -------------------------------- ### Display download command help Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo/tests/ssim/README.md Displays help for the download subcommand. ```bash python fastvideo/tests/ssim/reference_videos_cli.py download --help ``` -------------------------------- ### Run FVD CLI with custom configuration Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/benchmarks/fvd/README.md Executes the FVD benchmark using specific paths, video counts, and extraction strategies. ```bash python -m benchmarks.fvd.cli \ --real-path data/real/ \ --gen-path outputs/gen/ \ --num-videos 1024 \ --num-frames 32 \ --clip-strategy random \ --batch-size 32 \ --seed 42 \ --extractor clip ``` -------------------------------- ### Download Wan2.1-14B-synthesized Datasets Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/ori_sparse_attention/TurboDiffusion/README.md Download the synthesized datasets to the assets/datasets directory. ```bash # make sure git lfs is installed git clone https://huggingface.co/datasets/worstcoder/Wan_datasets assets/datasets ``` -------------------------------- ### Display copy-local command help Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo/tests/ssim/README.md Displays help for the copy-local subcommand. ```bash python fastvideo/tests/ssim/reference_videos_cli.py copy-local --help ``` -------------------------------- ### Display upload command help Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo/tests/ssim/README.md Displays help for the upload subcommand. ```bash python fastvideo/tests/ssim/reference_videos_cli.py upload --help ``` -------------------------------- ### Run Single-Node Training Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/ori_sparse_attention/TurboDiffusion/README.md Execute the training script using torchrun with the specified configuration and environment variables. ```bash WORKDIR="/path/to/TurboDiffusion" cd $WORKDIR export PYTHONPATH=turbodiffusion # the "IMAGINAIRE_OUTPUT_ROOT" environment variable is the path to save experiment output files export IMAGINAIRE_OUTPUT_ROOT=${WORKDIR}/outputs CHECKPOINT_ROOT=${WORKDIR}/assets/checkpoints DATASET_ROOT=${WORKDIR}/assets/datasets/Wan2.1_14B_480p_16:9_Euler-step100_shift-3.0_cfg-5.0_seed-0_250K # your Wandb information export WANDB_API_KEY=xxx export WANDB_ENTITY=xxx registry=registry_sla experiment=wan2pt1_1pt3B_res480p_t2v_SLA torchrun --nproc_per_node=8 \ -m scripts.train --config=turbodiffusion/rcm/configs/${registry}.py -- experiment=${experiment} \ model.config.teacher_ckpt=${CHECKPOINT_ROOT}/Wan2.1-T2V-1.3B.dcp \ model.config.tokenizer.vae_pth=${CHECKPOINT_ROOT}/Wan2.1_VAE.pth \ model.config.text_encoder_path=${CHECKPOINT_ROOT}/models_t5_umt5-xxl-enc-bf16.pth \ model.config.neg_embed_path=${CHECKPOINT_ROOT}/umT5_wan_negative_emb.pt \ dataloader_train.tar_path_pattern=${DATASET_ROOT}/shard*.tar ``` -------------------------------- ### Directory structure for preprocessing models Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/long_video/wan22/modules/animate/preprocess/UserGuider.md The preprocessing process requires specific models for pose detection, mask extraction, and image editing. Place these models in the specified directory structure under your checkpoint path. ```text /path/to/your/ckpt_path/ ├── det/ │ └── yolov10m.onnx ├── pose2d/ │ └── vitpose_h_wholebody.onnx ├── sam2/ │ └── sam2_hiera_large.pt └── FLUX.1-Kontext-dev/ ``` -------------------------------- ### Download Unquantized Model Checkpoints Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/ori_sparse_attention/TurboDiffusion/README.md Download unquantized model checkpoints for H100 or similar GPUs with more than 40GB of memory. ```bash # For Wan2.1-T2V-1.3B wget https://huggingface.co/TurboDiffusion/TurboWan2.1-T2V-1.3B-480P/resolve/main/TurboWan2.1-T2V-1.3B-480P.pth # For Wan2.2-I2V-14B wget https://huggingface.co/TurboDiffusion/TurboWan2.2-I2V-A14B-720P/resolve/main/TurboWan2.2-I2V-A14B-high-720P.pth wget https://huggingface.co/TurboDiffusion/TurboWan2.2-I2V-A14B-720P/resolve/main/TurboWan2.2-I2V-A14B-low-720P.pth ``` -------------------------------- ### Run Video Generation Inference Source: https://github.com/amd-agi/hummingbirdxt/blob/main/README.md Execute text-to-video or image-to-video inference scripts. ```bash cd infer bash run_t2v.sh # for text-to-video task bash run_i2v.sh # for image-to-video task ``` -------------------------------- ### Pull Docker Image Source: https://github.com/amd-agi/hummingbirdxt/blob/main/README.md Download the pre-built Docker image for reproducibility. ```bash docker pull panisobe/dmd_flash_image_2:latest ``` -------------------------------- ### Configure Lightweight VAE Decoder Source: https://github.com/amd-agi/hummingbirdxt/blob/main/README.md Add these parameters to the inference commands to enable the Lightweight VAE decoder. ```bash --vae_model ${VAE_PATH_ROOT}/wan22_v1_tiling_16_12 --t_block_size 16 --t_stride 12 ``` -------------------------------- ### Download full quality reference videos Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo/tests/ssim/README.md Downloads full_quality reference videos for the specified device folder. ```bash python fastvideo/tests/ssim/reference_videos_cli.py download --quality-tier full_quality --device-folder H200_reference_videos ``` -------------------------------- ### Upload all quality tiers Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo/tests/ssim/README.md Uploads reference videos for all quality tiers. Requires an HF token to be set. ```bash python fastvideo/tests/ssim/reference_videos_cli.py upload --quality-tier all ``` -------------------------------- ### Run TurboDiffusion Inference with Python Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/ori_sparse_attention/TurboDiffusion/README.md Execute video generation using the provided inference script with specific model paths and generation parameters. This command uses the SageSLA attention type and enables quantization for linear layers. ```bash python turbodiffusion/inference/wan2.2_i2v_infer.py \ --model Wan2.2-A14B \ --low_noise_model_path checkpoints/TurboWan2.2-I2V-A14B-low-720P-quant.pth \ --high_noise_model_path checkpoints/TurboWan2.2-I2V-A14B-high-720P-quant.pth \ --resolution 720p \ --adaptive_resolution \ --image_path assets/i2v_inputs/i2v_input_0.jpg \ --prompt "POV selfie video, ultra-messy and extremely fast. A white cat in sunglasses stands on a surfboard with a neutral look when the board suddenly whips sideways, throwing cat and camera into the water; the frame dives sharply downward, swallowed by violent bursts of bubbles, spinning turbulence, and smeared water streaks as the camera sinks. Shadows thicken, pressure ripples distort the edges, and loose bubbles rush upward past the lens, showing the camera is still sinking. Then the cat kicks upward with explosive speed, dragging the view through churning bubbles and rapidly brightening water as sunlight floods back in; the camera races upward, water streaming off the lens, and finally breaks the surface in a sudden blast of light and spray, snapping back into a crooked, frantic selfie as the cat resurfaces." \ --num_samples 1 \ --num_steps 4 \ --quant_linear \ --attention_type sagesla \ --sla_topk 0.1 \ --ode ``` -------------------------------- ### Run 1.3B Model Long Video Generation Source: https://github.com/amd-agi/hummingbirdxt/blob/main/README.md Execute the inference script for the 1.3B model. ```bash cd long_video bash infer_1_3b.sh ``` -------------------------------- ### Clone Repository Source: https://github.com/amd-agi/hummingbirdxt/blob/main/README.md Clone the HummingbirdXT repository to your local machine. ```bash git clone https://github.com/AMD-AGI/HummingbirdXT.git cd HummingbirdXT ``` -------------------------------- ### Run FVD CLI with standard protocols Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/benchmarks/fvd/README.md Uses predefined protocols for evaluation, defaulting to the i3d feature extractor. ```bash python -m benchmarks.fvd.cli \ --real-path data/real/ \ --gen-path outputs/gen/ \ --protocol fvd2048_16f # or fvd2048_128f, quick_test, etc. ``` -------------------------------- ### Upload full quality reference videos Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo/tests/ssim/README.md Uploads full_quality reference videos for the specified device folder. Requires an HF token to be set. ```bash python fastvideo/tests/ssim/reference_videos_cli.py upload --quality-tier full_quality --device-folder H200_reference_videos ``` -------------------------------- ### Build for ROCm Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo-kernel/README.md Run the build script with the --rocm flag for environments without a CUDA compilation toolchain. ```bash cd fastvideo-kernel ./build.sh --rocm ``` -------------------------------- ### Run 5B Model Long Video Generation Source: https://github.com/amd-agi/hummingbirdxt/blob/main/README.md Execute the inference script for the 5B model. ```bash cd long_video bash infer.sh ``` -------------------------------- ### Copy local reference videos for full quality Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo/tests/ssim/README.md Copies local reference videos for the full_quality tier for the specified device folder. ```bash python fastvideo/tests/ssim/reference_videos_cli.py copy-local --quality-tier full_quality --device-folder H200_reference_videos ``` -------------------------------- ### Run FVD CLI with feature caching Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/benchmarks/fvd/README.md Speeds up repeated evaluations by saving or loading real features from the specified directory path. ```bash python -m benchmarks.fvd.cli \ --real-path data/real/ \ --gen-path outputs/gen/ \ --protocol fvd2048_16f \ --cache-real-features fvd-cache/extractor_name # Directory path (will save/load fvd-cache/extractor_name/extractor-name_real_features.pkl) ``` -------------------------------- ### Configure FVDConfig options Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/benchmarks/fvd/README.md Defines the key parameters for the FVD evaluation process. ```python num_videos=2048, # Videos to evaluate num_frames_per_clip=16, # Frames per clip clip_strategy='beginning', # beginning|random|uniform|middle|sliding frame_stride=1, # Frame subsampling batch_size=32, # GPU batch size device='cuda', # cuda|cpu cache_real_features=None, # Cache path for speed seed=42, # Reproducibility extractor='i3d', # i3d|clip|videomae ``` -------------------------------- ### FastVideo Training Directory Structure Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo/train/README.md The directory structure for the new modular training infrastructure in fastvideo/train/. ```text fastvideo/train/ ├── models/ # Per-model plugins (wan/, hunyuan/, ...) ├── methods/ # Training methods (fine_tuning/, distribution_matching/, ...) ├── callbacks/ # Validation, grad clipping, etc. ├── entrypoint/ # CLI entry points (train.py, dcp_to_diffusers.py) ├── trainer.py # Core training loop └── utils/ # Config parsing, dataloader, etc. ``` -------------------------------- ### Copy local reference videos for default quality Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo/tests/ssim/README.md Copies local reference videos for the default quality tier for the specified device folder. ```bash python fastvideo/tests/ssim/reference_videos_cli.py copy-local --quality-tier default --device-folder H200_reference_videos ``` -------------------------------- ### Configure FastVideo Kernel CMake Project Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo-kernel/CMakeLists.txt This CMakeLists.txt file sets up the project, detects the GPU backend (ROCM or CUDA), and locates Python and PyTorch dependencies. It dynamically retrieves Torch include paths using a Python execution process. ```cmake cmake_minimum_required(VERSION 3.26 FATAL_ERROR) project(fastvideo-kernel LANGUAGES CXX) # Prefer environment variable (used by CI or pip install git+repo_addr) if CMake var is not explicitly set. if(NOT DEFINED GPU_BACKEND AND DEFINED ENV{GPU_BACKEND}) set(GPU_BACKEND "$ENV{GPU_BACKEND}") endif() if(GPU_BACKEND STREQUAL "ROCM") enable_language(HIP) else() enable_language(CUDA) # Ensure CUDA toolkit targets (CUDA::cudart, CUDA::cuda_driver, etc.) are available. find_package(CUDAToolkit REQUIRED) endif() # Import common utils if needed, but we keep it simple for now # Find Python and Torch find_package(Python COMPONENTS Interpreter Development.Module REQUIRED) # Robustly find Torch include paths using Python execute_process( COMMAND "${Python_EXECUTABLE}" -c "import torch; from torch.utils.cpp_extension import include_paths; print(';'.join(include_paths()))" OUTPUT_VARIABLE TORCH_INCLUDE_PATHS OUTPUT_STRIP_TRAILING_WHITESPACE ) list(APPEND TORCH_INCLUDE_DIRS ${TORCH_INCLUDE_PATHS}) # Find Torch package (still useful for libraries) find_package(Torch REQUIRED) # Include directories include_directories( ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/include/cutlass/include ${CMAKE_SOURCE_DIR}/include/tk/include ${CMAKE_SOURCE_DIR}/include/tk/prototype ${CMAKE_SOURCE_DIR}/csrc ${CMAKE_SOURCE_DIR}/csrc/turbodiffusion ${TORCH_INCLUDE_DIRS} ) # --------------------------- # ThunderKittens (TK) toggles # --------------------------- ``` -------------------------------- ### Wan2.1-I2V-14B-480P-Diffusers Generation Parameters Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo/tests/ssim/README.md Configuration parameters for the Wan2.1-I2V-14B-480P-Diffusers model. ```json Wan2.1-I2V-14B-480P-Diffusers: { "num_gpus": 2, "model_path": "Wan-AI/Wan2.1-I2V-14B-480P-Diffusers", "height": 480, "width": 832, "num_frames": 45, "num_inference_steps": 6, "guidance_scale": 5.0, "embedded_cfg_scale": 6, "flow_shift": 7.0, "seed": 1024, "sp_size": 2, "tp_size": 1, "vae_sp": True, "fps": 24, "neg_prompt": "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards", "text-encoder-precision": "fp32" } ``` -------------------------------- ### Wan2.1-T2V-1.3B-Diffusers Generation Parameters Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo/tests/ssim/README.md Configuration parameters for the Wan2.1-T2V-1.3B-Diffusers model. ```json Wan2.1-T2V-1.3B-Diffusers: { "num_gpus": 2, "model_path": "Wan-AI/Wan2.1-T2V-1.3B-Diffusers", "height": 480, "width": 832, "num_frames": 45, "num_inference_steps": 20, "guidance_scale": 3, "embedded_cfg_scale": 6, "flow_shift": 7.0, "seed": 1024, "sp_size": 2, "tp_size": 1, "vae_sp": True, "fps": 24, "neg_prompt": "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards", "text-encoder-precision": "fp32" } ``` -------------------------------- ### Log build configuration status Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo-kernel/CMakeLists.txt Prints the current status of the CUDA architecture list and the ThunderKittens kernel build setting. ```cmake message(STATUS "TORCH_CUDA_ARCH_LIST (cmake/env): ${TORCH_CUDA_ARCH_LIST}") message(STATUS "FASTVIDEO_KERNEL_BUILD_TK: ${FASTVIDEO_KERNEL_BUILD_TK}") ``` -------------------------------- ### Execute FVD programmatically Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/benchmarks/fvd/README.md Uses the FVDConfig class to compute metrics within a Python script. ```python from benchmarks.fvd import compute_fvd_with_config, FVDConfig config = FVDConfig.fvd2048_16f() # or custom config results = compute_fvd_with_config('data/real/', 'outputs/gen/', config) print(f"FVD: {results['fvd']:.2f}") ``` -------------------------------- ### Convert Checkpoints to Distributed Checkpoint Format Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/ori_sparse_attention/TurboDiffusion/README.md Convert .pth teacher checkpoints to .dcp format required by FSDP2. ```bash python -m torch.distributed.checkpoint.format_utils torch_to_dcp assets/checkpoints/Wan2.1-T2V-1.3B.pth assets/checkpoints/Wan2.1-T2V-1.3B.dcp ``` -------------------------------- ### Run SSIM tests with full quality Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo/tests/ssim/README.md Executes pytest for SSIM tests using the full quality configuration parameters. ```bash pytest fastvideo/tests/ssim/ -vs --ssim-full-quality ``` -------------------------------- ### Validate Quality with lora_inference_comparison.py Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/scripts/lora_extraction/README.md Compares the quality of the merged model against the fine-tuned reference model using SSIM and LPIPS metrics. ```bash python lora_inference_comparison.py \ --base merged_model \ --ft FastVideo/FastWan2.2-TI2V-5B-FullAttn-Diffusers \ --adapter NONE \ --output-dir results \ --prompt "A cat sitting on a windowsill" \ --seed 42 \ --height 480 \ --width 480 \ --num-frames 49 \ --num-inference-steps 32 \ --compute-ssim \ --compute-lpips ``` -------------------------------- ### Override HF reference repository Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo/tests/ssim/README.md Runs SSIM tests while overriding the default Hugging Face reference repository. ```bash pytest fastvideo/tests/ssim/ -vs --ssim-reference-repo ``` -------------------------------- ### Skip auto-download of missing references Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo/tests/ssim/README.md Runs SSIM tests while skipping the automatic download of missing reference videos. ```bash pytest fastvideo/tests/ssim/ -vs --skip-ssim-reference-download ``` -------------------------------- ### Configure FASTVIDEO_KERNEL_BUILD_TK variable Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo-kernel/CMakeLists.txt Sets the build configuration for ThunderKittens kernels with options for AUTO, ON, or OFF. ```cmake set(FASTVIDEO_KERNEL_BUILD_TK "AUTO" CACHE STRING "Build ThunderKittens kernels: AUTO/ON/OFF") set_property(CACHE FASTVIDEO_KERNEL_BUILD_TK PROPERTY STRINGS AUTO ON OFF) ``` -------------------------------- ### Run I2V Inference Script Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/ori_sparse_attention/TurboDiffusion/README.md Set the PYTHONPATH to run the I2V inference script. ```bash export PYTHONPATH=turbodiffusion ``` -------------------------------- ### FastHunyuan-diffusers Generation Parameters Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo/tests/ssim/README.md Configuration parameters for the FastHunyuan-diffusers model. ```json FastHunyuan-diffusers: { "num_gpus": 2, "model_path": "data/FastHunyuan-diffusers", "height": 720, "width": 1280, "num_frames": 45, "num_inference_steps": 6, "guidance_scale": 1, "embedded_cfg_scale": 6, "flow_shift": 17, "seed": 1024, "sp_size": 2, "tp_size": 1, "vae_sp": true, "fps": 24 } ``` -------------------------------- ### Merge LoRA Adapter with merge_lora.py Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/scripts/lora_extraction/README.md Merges a previously extracted LoRA adapter into a base model to create a combined model. ```bash python merge_lora.py \ --base Wan-AI/Wan2.2-TI2V-5B-Diffusers \ --adapter adapter_r32.safetensors \ --ft FastVideo/FastWan2.2-TI2V-5B-FullAttn-Diffusers \ --output merged_model ``` -------------------------------- ### Run T2V Inference Script Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/ori_sparse_attention/TurboDiffusion/README.md Execute the inference script for T2V models. Ensure the appropriate flags are used based on whether the checkpoint is quantized. ```bash export PYTHONPATH=turbodiffusion # Arguments: # --dit_path Path to the finetuned TurboDiffusion checkpoint # --model Model to use: Wan2.1-1.3B or Wan2.1-14B (default: Wan2.1-1.3B) # --num_samples Number of videos to generate (default: 1) # --num_steps Sampling steps, 1–4 (default: 4) # --sigma_max Initial sigma for rCM (default: 80); larger choices (e.g., 1600) reduce diversity but may enhance quality # --vae_path Path to Wan2.1 VAE (default: checkpoints/Wan2.1_VAE.pth) # --text_encoder_path Path to umT5 text encoder (default: checkpoints/models_t5_umt5-xxl-enc-bf16.pth) # --num_frames Number of frames to generate (default: 81) # --prompt Text prompt for video generation # --resolution Output resolution: "480p" or "720p" (default: 480p) # --aspect_ratio Aspect ratio in W:H format (default: 16:9) # --seed Random seed for reproducibility (default: 0) # --save_path Output file path including extension (default: output/generated_video.mp4) # --attention_type Attention module to use: original, sla or sagesla (default: sagesla) # --sla_topk Top-k ratio for SLA/SageSLA attention (default: 0.1), we recommend using 0.15 for better video quality # --quant_linear Enable quantization for linear layers, pass this if using a quantized checkpoint # --default_norm Use the original LayerNorm and RMSNorm of Wan models python turbodiffusion/inference/wan2.1_t2v_infer.py \ --model Wan2.1-1.3B \ --dit_path checkpoints/TurboWan2.1-T2V-1.3B-480P-quant.pth \ --resolution 480p \ --prompt "A stylish woman walks down a Tokyo street filled with warm glowing neon and animated city signage. She wears a black leather jacket, a long red dress, and black boots, and carries a black purse. She wears sunglasses and red lipstick. She walks confidently and casually. The street is damp and reflective, creating a mirror effect of the colorful lights. Many pedestrians walk about." \ --num_samples 1 \ --num_steps 4 \ --quant_linear \ --attention_type sagesla \ --sla_topk 0.1 ``` -------------------------------- ### BibTeX Citation for FastVideo Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/README.md Use these BibTeX entries to cite the FastVideo research work in academic publications. ```bibtex @article{zhang2025vsa, title={Vsa: Faster video diffusion with trainable sparse attention}, author={Zhang, Peiyuan and Chen, Yongqi and Huang, Haofeng and Lin, Will and Liu, Zhengzhong and Stoica, Ion and Xing, Eric and Zhang, Hao}, journal={arXiv preprint arXiv:2505.13389}, year={2025} } @article{zhang2025fast, title={Fast video generation with sliding tile attention}, author={Zhang, Peiyuan and Chen, Yongqi and Su, Runlong and Ding, Hangliang and Stoica, Ion and Liu, Zhengzhong and Zhang, Hao}, journal={arXiv preprint arXiv:2502.04507}, year={2025} } ``` -------------------------------- ### TurboDiffusion citation Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo-kernel/README.md BibTeX citation for the TurboDiffusion kernels. ```bibtex @article{zhang2025turbodiffusion, title={TurboDiffusion: Accelerating Video Diffusion Models by 100-200 Times}, author={Zhang, Jintao and Zheng, Kaiwen and Jiang, Kai and Wang, Haoxu and Stoica, Ion and Gonzalez, Joseph E and Chen, Jianfei and Zhu, Jun}, journal={arXiv preprint arXiv:2512.16093}, year={2025} } ``` -------------------------------- ### Report ThunderKittens kernel status Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo-kernel/CMakeLists.txt Outputs the final status of the ThunderKittens kernel build to the console. ```cmake if(ENABLE_TK_KERNELS) message(STATUS "ThunderKittens kernels: ENABLED") else() message(STATUS "ThunderKittens kernels: DISABLED (will use Triton fallbacks at runtime)") endif() ``` -------------------------------- ### Sync TORCH_CUDA_ARCH_LIST from environment Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo-kernel/CMakeLists.txt Checks for the TORCH_CUDA_ARCH_LIST environment variable if the CMake variable is not defined. ```cmake if(NOT DEFINED TORCH_CUDA_ARCH_LIST AND DEFINED ENV{TORCH_CUDA_ARCH_LIST}) set(TORCH_CUDA_ARCH_LIST "$ENV{TORCH_CUDA_ARCH_LIST}") endif() ``` -------------------------------- ### Extract LoRA Adapter with extract_lora.py Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/scripts/lora_extraction/README.md Extracts a LoRA adapter from a fine-tuned model relative to a base model. The script automatically handles architectural differences by falling back to direct safetensors loading if pipeline loading fails. ```bash python extract_lora.py \ --base Wan-AI/Wan2.2-TI2V-5B-Diffusers \ --ft FastVideo/FastWan2.2-TI2V-5B-FullAttn-Diffusers \ --out adapter_r32.safetensors \ --rank 32 ``` -------------------------------- ### Determine ENABLE_TK_KERNELS status Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo-kernel/CMakeLists.txt Logic to enable or disable ThunderKittens kernels based on user input or automatic detection of Hopper architecture. ```cmake set(ENABLE_TK_KERNELS OFF) if(FASTVIDEO_KERNEL_BUILD_TK STREQUAL "ON") set(ENABLE_TK_KERNELS ON) elseif(FASTVIDEO_KERNEL_BUILD_TK STREQUAL "OFF") set(ENABLE_TK_KERNELS OFF) else() # AUTO: detect Hopper if possible. if(TORCH_CUDA_ARCH_LIST) # Accept common spellings: 9.0a, 90a, sm_90a. string(REGEX MATCH "(^|[; ,])((9\.0a)|(90a)|(sm_90a))([; ,]|$)" _HAS_90A "${TORCH_CUDA_ARCH_LIST}") if(_HAS_90A) set(ENABLE_TK_KERNELS ON) endif() else() # Best-effort local detection (works when a CUDA device is visible). execute_process( COMMAND "${Python_EXECUTABLE}" -c "import torch; import sys; \nprint('1' if (torch.cuda.is_available() and torch.version.cuda and torch.cuda.get_device_capability()[0] >= 9) else '0')" OUTPUT_VARIABLE _LOCAL_HAS_HOPPER OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET ) if(_LOCAL_HAS_HOPPER STREQUAL "1") set(ENABLE_TK_KERNELS ON) endif() endif() endif() ``` -------------------------------- ### Configure FastVideo Kernel Build Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo-kernel/CMakeLists.txt This CMake configuration defines the build process for the FastVideo extension, including compiler flags, source file management, and library linking. It conditionally includes TK kernels and ensures proper linking against Torch and CUDA libraries. ```cmake # Always try to build the extension if CUDA is available, but conditionally add sources/flags set(BUILD_CXX_KERNELS ON) # Compiler flags set(CUDA_FLAGS "-DNDEBUG" "-O3" "-std=c++20" "--use_fast_math" "--expt-extended-lambda" "--expt-relaxed-constexpr" "-Xcompiler=-fno-strict-aliasing" "-Xcompiler=-fPIC" "-DTORCH_COMPILE" "-Xnvlink=--verbose" "-Xptxas=--verbose" "-Xptxas=--warn-on-spills" ) # If TK is enabled, ensure we target Hopper. This is required even on GPU-less builders (CI). if(ENABLE_TK_KERNELS) if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES OR CMAKE_CUDA_ARCHITECTURES STREQUAL "") set(CMAKE_CUDA_ARCHITECTURES "90a" CACHE STRING "CUDA architectures" FORCE) endif() list(APPEND CUDA_FLAGS "-DKITTENS_HOPPER") message(STATUS "CMAKE_CUDA_ARCHITECTURES: ${CMAKE_CUDA_ARCHITECTURES}") endif() if(BUILD_CXX_KERNELS) # Source files set(EXTENSION_SOURCES csrc/common_extension.cpp csrc/turbodiffusion/gemm/gemm.cu csrc/turbodiffusion/norm/rmsnorm.cu csrc/turbodiffusion/norm/layernorm.cu csrc/turbodiffusion/quant/quant.cu ) # Conditionally add TK kernels if(ENABLE_TK_KERNELS) list(APPEND EXTENSION_SOURCES csrc/attention/st_attn_h100.cu csrc/attention/block_sparse_h100.cu ) endif() # Combined FastVideo Extension # Using name 'fastvideo_kernel_ops' to distinguish from the python package namespace Python_add_library(fastvideo_kernel_ops MODULE USE_SABI ${SKBUILD_SABI_VERSION} WITH_SOABI ${EXTENSION_SOURCES} ) # Build compile definitions list set(COMPILE_DEFS TORCH_EXTENSION_NAME=fastvideo_kernel_ops) if(ENABLE_TK_KERNELS) list(APPEND COMPILE_DEFS TK_COMPILE_ST_ATTN TK_COMPILE_BLOCK_SPARSE) endif() target_compile_definitions(fastvideo_kernel_ops PRIVATE ${COMPILE_DEFS}) target_compile_options(fastvideo_kernel_ops PRIVATE $<$:${CUDA_FLAGS}> ) # Link against Torch libraries to avoid undefined symbols at import time # (e.g., torch::autograd vtables) when loading the extension module. target_link_libraries(fastvideo_kernel_ops PRIVATE ${TORCH_LIBRARIES}) # Also link against libtorch_python to satisfy Python-binding symbols # (e.g., torch::PyWarningHandler) required by torch/extension.h. execute_process( COMMAND "${Python_EXECUTABLE}" -c "import torch; from pathlib import Path; p=Path(torch.__file__).parent/'lib'; m=sorted(p.glob('libtorch_python*')); print(str(m[0]) if m else '')" OUTPUT_VARIABLE TORCH_PYTHON_LIBRARY_PATH OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET ) if(TORCH_PYTHON_LIBRARY_PATH) message(STATUS "TORCH_PYTHON_LIBRARY_PATH: ${TORCH_PYTHON_LIBRARY_PATH}") target_link_libraries(fastvideo_kernel_ops PRIVATE "${TORCH_PYTHON_LIBRARY_PATH}") else() message(WARNING "Could not locate libtorch_python; fastvideo_kernel_ops may fail to import.") endif() # Link CUDA runtime + driver explicitly (fixes missing symbols like cuGetErrorString at import time) if(NOT GPU_BACKEND STREQUAL "ROCM") target_link_libraries(fastvideo_kernel_ops PRIVATE CUDA::cudart CUDA::cuda_driver) endif() # We install it to fastvideo_kernel/_C so we can load it to register the ops install(TARGETS fastvideo_kernel_ops LIBRARY DESTINATION fastvideo_kernel/_C) endif() ``` -------------------------------- ### Declare Required GPUs for SSIM Test Source: https://github.com/amd-agi/hummingbirdxt/blob/main/HummingbirdXT_VSA/amd_VSA/FastVideo/fastvideo/tests/ssim/README.md Add this module-level constant to the top of a test file to specify the number of GPUs required. If omitted, the test defaults to 1 GPU. ```python REQUIRED_GPUS = 2 ```