Views
No views yet
1git clone https://github.com/Tacossp/BLADE
2cd BLADE1# Install using uv (Recommended)
2uv pip install -r requirements.txt
3
4# Or use pip
5pip install -r requirements.txt1git clone https://github.com/mit-han-lab/Block-Sparse-Attention.git
2cd Block-Sparse-Attention
3pip install packaging
4pip install ninja
5python setup.py install
6cd ..1# Download from Hugging Face
2git lfs install
3git clone https://huggingface.co/zai-org/CogVideoX-5b cogvideox/CogVideoX-5b1# Download from Hugging Face
2git clone https://huggingface.co/Wan-AI/Wan2.1-T2V-1.3B-Diffusers wanx/wan1.3b1# Download pre-trained weights
2git clone https://huggingface.co/GYP666/BLADE pretrained_weightsBLADE/
├── cogvideox/
│ └── CogVideoX-5b/ # Base model weights for CogVideoX
├── wanx/
│ └── wan1.3b/ # Base model weights for WanX
└── pretrained_weights/ # Pre-trained weights for BLADE
├── BLADE_cogvideox_weight/
└── BLADE_wanx_weight/1cd cogvideox
2python train/inference.py \
3 --lora_path ../pretrained_weights/cogvideox_checkpoints/your_checkpoint \
4 --gpu 0--lora_path: Path to the LoRA weights file.--gpu: The ID of the GPU device to use (Default: 0).cogvideox/outputs/inference/ directory.1cd wanx
2python train/inference.py \
3 --lora_path ../pretrained_weights/wanx_checkpoints/your_checkpoint \
4 --gpu 0wanx/outputs/ directory.1cd utils
2python process_prompts_cogvideox.py \
3 --input_file your_prompts.txt \
4 --output_dir ../cogvideox/prompts \
5 --model_path ../cogvideox/CogVideoX-5b \
6 --batch_size 32 \
7 --save_separate--input_file: A .txt file containing prompts, with one prompt per line.--output_dir: The directory to save the output embeddings.--model_path: Path to the CogVideoX model.--batch_size: The batch size for processing.--save_separate: Whether to save each embedding as a separate file.1cd utils
2python process_prompts_wanx.pyutils/all_dimension_aug_wanx.txt and generate the corresponding embeddings.1cd cogvideox
2bash train_tdm_1.sh1# If not training with 8 GPUs, you must modify CUDA_VISIBLE_DEVICES and the num_processes in config.yaml
2CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 accelerate launch \
3 --config_file train/config.yaml \
4 train/train_cogvideo_tdm.py \
5 --pretrained_model_name_or_path CogVideoX-5b \ # Path to the base model
6 --mixed_precision bf16 \ # Use mixed-precision for reduced memory usage
7 --train_batch_size 5 \ # Training batch size
8 --gradient_accumulation_steps 4 \ # Number of gradient accumulation steps
9 --learning_rate 1e-4 \ # Learning rate for the student model
10 --learning_rate_g 1e-4 \
11 --learning_rate_fake 5e-4 \ # Learning rate for the fake model
12 --lambda_reg 0.5 \ # Regularization weight
13 --k_step 8 \ # Target number of steps for distillation
14 --cfg 3.5 \ # Classifier-Free Guidance scale
15 --eta 0.9 \ # ETA parameter for DDIM
16 --use_sparsity true \ # Enable sparse attention
17 --rank 64 \
18 --lora_alpha 64 \ # LoRA configuration
19 --max_train_steps 300 \ # Maximum number of training steps
20 --checkpointing_steps 15 \ # Interval for saving checkpoints
21 --gradient_checkpointing \ # Use gradient checkpointing to save memory
22 --enable_slicing \
23 --enable_tiling # VAE memory optimization1cd wanx
2bash train_wanx_tdm.shBLADE/
├── README.md # Project documentation
├── requirements.txt # List of Python dependencies
│
├── cogvideox/ # Code related to CogVideoX
│ ├── CogVideoX-5b/ # Directory for base model weights
│ ├── train/ # Training scripts
│ │ ├── inference.py # Inference script
│ │ ├── train_cogvideo_tdm.py # Training script
│ │ ├── train_tdm_1.sh # Script to launch training
│ │ ├── modify_cogvideo.py # Model modification script
│ │ └── config.yaml # Training configuration file
│ ├── prompts/ # Preprocessed prompts and embeddings
│ └── outputs/ # Output from training and inference
│
├── wanx/ # Code related to WanX
│ ├── wan1.3b/ # Directory for base model weights
│ ├── train/ # Training scripts
│ │ ├── inference.py # Inference script
│ │ ├── train_wanx_tdm.py # Training script
│ │ ├── train_wanx_tdm.sh # Script to launch training
│ │ └── modify_wan.py # Model modification script
│ ├── prompts/ # Preprocessed prompts and embeddings
│ └── outputs/ # Output from training and inference
│
├── utils/ # Utility scripts
│ ├── process_prompts_cogvideox.py # Data preprocessing for CogVideoX
│ ├── process_prompts_wanx.py # Data preprocessing for WanX
│ └── all_dimension_aug_wanx.txt # Training prompts for WanX
│
├── Block-Sparse-Attention/ # Sparse attention library
│ ├── setup.py # Compilation and installation script
│ ├── block_sparse_attn/ # Core library code
│ └── README.md # Library usage instructions
│
└── ds_config.json # DeepSpeed configuration file1@misc{gu2025videobladeblocksparseattentionmeets,
2 title={BLADE: Block-Sparse Attention Meets Step Distillation for Efficient Video Generation},
3 author={Youping Gu and Xiaolong Li and Yuhao Hu and Bohan Zhuang},
4 year={2025},
5 eprint={2508.10774},
6 archivePrefix={arXiv},
7 primaryClass={cs.CV},
8 url={https://arxiv.org/abs/2508.10774},
9}