# BWCache: Accelerating Video Diffusion Transformers through Block-Wise Caching

[![arXiv](https://img.shields.io/badge/arXiv-2509.13789-b31b1b.svg)](https://arxiv.org/abs/2509.13789)
[![ICLR 2026](https://img.shields.io/badge/ICLR-2026-blue.svg)](https://iclr.cc/Conferences/2026)
[![GitHub](https://img.shields.io/badge/GitHub-BWCache-green?logo=github)](https://github.com/hsc113/BWCache)

This repository contains the official implementation of **BWCache**, a training-free method to accelerate DiT-based video generation by dynamically caching and reusing features from DiT blocks across diffusion timesteps.

This work has been accepted by **ICLR 2026**.


## 📰 News

- **2025-09-25**: arXiv preprint released
- **2026-01-21**: Paper accepted by ICLR 2026
- **2026-02-27**: Code released


## 📊 Overview

![Overview](figs/struct_new3.png)

BWCache dynamically caches and reuses features from DiT blocks across diffusion timesteps. A similarity indicator triggers feature reuse only when the differences between block features at adjacent timesteps fall below a threshold, thereby minimizing redundant computations while maintaining visual fidelity.


## 🛠️ Installation

```bash
# Clone the repository
git clone https://github.com/hsc113/BWCache
cd BWCache

# Create environment
conda create -n bwcache python=3.10 -y
conda activate bwcache

# Install dependencies
pip install -r requirements.txt
```

**Requirements**: Python >= 3.10, PyTorch >= 1.13, CUDA >= 11.6


## 🚀 Usage

### Basic Usage

```python
from videosys import OpenSoraConfig, VideoSysEngine, OpenSoraBWCacheConfig

# Configure BWCache
bwcache_config = OpenSoraBWCacheConfig(
    thresh=0.15,        # Similarity threshold
    reuse_interval=3,   # Reuse interval
    last_step=1/2       # Last step ratio for recomputation
)

# Initialize pipeline with BWCache
config = OpenSoraConfig(
    enable_bwcache=True,
    bwcache_config=bwcache_config
)
engine = VideoSysEngine(config)

# Generate video
prompt="Sunset over the sea."
video = engine.generate(
    prompt=prompt,
    resolution="480p",
    aspect_ratio="9:16",
    num_frames="2s",
    seed=-1,
).video[0]

# Save video
engine.save_video(video, f"./outputs/{prompt}.mp4")
```


## 📝 TODO

- [ ] Add Wan 2.1 support
- [ ] Add HunyuanVideo support


## 📝 Citation

If you find BWCache useful for your research, please consider citing:

```bibtex
@misc{cui2025bwcacheacceleratingvideodiffusion,
      title={BWCache: Accelerating Video Diffusion Transformers through Block-Wise Caching},
      author={Hanshuai Cui and Zhiqing Tang and Zhifei Xu and Zhi Yao and Wenyi Zeng and Weijia Jia},
      year={2025},
      eprint={2509.13789},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      url={https://arxiv.org/abs/2509.13789},
}
```


## 📄 License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.


## 🙏 Acknowledgments

This repository is built based on [VideoSys](https://github.com/NUS-HPC-AI-Lab/VideoSys/tree/v2.0.1), [Diffusers](https://github.com/huggingface/diffusers), [Open-Sora](https://github.com/hpcaitech/Open-Sora), [Open-Sora-Plan](https://github.com/PKU-YuanGroup/Open-Sora-Plan), [Latte](https://github.com/Vchitect/Latte), [Wan 2.1](https://github.com/Wan-AI/Wan), and [HunyuanVideo](https://github.com/Tencent/HunyuanVideo). Thanks for their contributions!
