Skip to main content

Cache-DiT: A PyTorch-native Inference Engine with Cache, Parallelism, Quantization and CPU Offload for DiTs.

Project description

⚡️🎉A PyTorch-native Inference Engine with Cache,
Parallelism, Quantization and CPU Offload for DiTs
Featured|HelloGitHub

**🤗Why Cache-DiT❓❓**Cache-DiT is built on top of the 🤗Diffusers library and now supports nearly ALL DiTs from Diffusers. It provides hybrid cache acceleration (DBCache, TaylorSeer, SCM, etc.) and comprehensive parallelism optimizations, including Context Parallelism, Tensor Parallelism, hybrid 2D or 3D parallelism, and dedicated extra parallelism support for Text Encoder, VAE, and ControlNet.

Cache-DiT is compatible with compilation, CPU Offloading, and quantization, fully integrates with SGLang Diffusion, vLLM-Omni, TensorRT-LLM, ComfyUI, and runs natively on NVIDIA GPUs, Ascend NPUs and AMD GPUs. Cache-DiT is fast, easy to use, and flexible for various DiTs (online docs at 📘cache-dit.io).

⚡️9x speedup by Cache-DiT with Cache, Context Parallelism and Compilation

🚀Quick Start: Cache, Parallelism and Quantization

First, you can install the cache-dit from PyPI or install from source:

uv pip install -U cache-dit # PyPI, stable release.
uv pip install git+https://github.com/vipshop/cache-dit.git # latest.

Then, try to accelerate your DiTs with just ♥️one line♥️ of code ~

>>> import cache_dit
>>> from diffusers import DiffusionPipeline
>>> pipe = DiffusionPipeline.from_pretrained(...).to("cuda")
>>> cache_dit.enable_cache(pipe) # Cache Acceleration with One-line code.
>>> from cache_dit import DBCacheConfig, ParallelismConfig
>>> cache_dit.enable_cache( # Or, Hybrid Cache Acceleration + Parallelism.
...   pipe, cache_config=DBCacheConfig(), # w/ default
...   parallelism_config=ParallelismConfig(ulysses_size=2))
>>> from cache_dit import DBCacheConfig, ParallelismConfig, QuantizeConfig
>>> cache_dit.enable_cache( # Or, Hybrid Cache + Parallelism + Quantization.
...   pipe, cache_config=DBCacheConfig(), # w/ default
...   parallelism_config=ParallelismConfig(ulysses_size=2),
...   quantize_config=QuantizeConfig(quant_type=...))
>>> output = pipe(...) # Then, just call the pipe as normal.

🚀Quick Start: SVDQuant (W4A4) PTQ/DQ workflow

First, install Cache-DiT with SVDQuant support (Experimental):

# Required: CUDA 13.0+, PyTorch 2.11+, Ubuntu 22.04+.
uv pip install -U cache-dit-cu13 # PyPI, stable release.
CACHE_DIT_BUILD_SVDQUANT=1 uv pip install -e ".[quantization]" # latest.

Then, try to quantize your model with just ♥️a few lines♥️ of code ~

>>> from cache_dit import QuantizeConfig
>>> pipe = DiffusionPipeline.from_pretrained(...).to("cuda")
>>> # DQ: "...{dtype}_r{rank}_dq", PTQ: "...{dtype}_r{rank}"
>>> pipe.transformer = cache_dit.quantize(
...   pipe.transformer, quant_config=QuantizeConfig(
...   # ✅ NO calibration needed for SVDQ DQ in Cache-DiT! 🎉
...   quant_type="svdq_{int4|nvfp4}_r{32|64|128|256|...}_dq",
...   svdq_kwargs={"smooth_strategy": "few_shot"})) 
>>> output = pipe(...) # Then, just call the pipe as normal.

🚀Quick Start: Bucket-style Layerwise CPU Offload

Bucket-style Layerwise Offload w/ nearly zero (<5%🎉) latency overhead ~

>>> import cache_dit
>>> cache_dit.layerwise_offload(
...   pipe, # nn.Module: pipe, transformer, text_encoder, etc.
...   onload_device="cuda",
...   offload_device="cpu",
...   async_transfer=True,
...   transfer_buckets=4,
...   persistent_buckets=64,
...   persistent_bins=8,
...   prefetch_limit=True,
...   max_copy_streams=4,
...   max_inflight_prefetch_bytes="8gib")
>>> output = pipe(...) # Then, just call the pipe as normal.

For more advanced features, please refer to our online documentation at 📘cache-dit.io.

🌐Community Integration

©️Acknowledgements

Special thanks to vipshop's Computer Vision AI Team for supporting testing and deployment of this project. We learned and reused codes from: Diffusers, SGLang, vLLM-Omni, Nunchaku, xDiT and TaylorSeer.

©️Citations

@misc{cache-dit@2025,
  title={Cache-DiT: A PyTorch-native Inference Engine with Cache, Parallelism, Quantization and CPU Offload for DiTs.},
  url={https://github.com/vipshop/cache-dit.git},
  note={Open-source software available at https://github.com/vipshop/cache-dit.git},
  author={DefTruth, vipshop.com, etc.},
  year={2025}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

cache_dit_cu13-1.3.12-cp314-cp314-manylinux_2_38_x86_64.whl (30.9 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.38+ x86-64

cache_dit_cu13-1.3.12-cp314-cp314-manylinux_2_32_x86_64.whl (30.9 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.32+ x86-64

cache_dit_cu13-1.3.12-cp313-cp313-manylinux_2_38_x86_64.whl (30.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.38+ x86-64

cache_dit_cu13-1.3.12-cp313-cp313-manylinux_2_32_x86_64.whl (30.9 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.32+ x86-64

cache_dit_cu13-1.3.12-cp312-cp312-manylinux_2_38_x86_64.whl (30.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.38+ x86-64

cache_dit_cu13-1.3.12-cp312-cp312-manylinux_2_32_x86_64.whl (30.9 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.32+ x86-64

cache_dit_cu13-1.3.12-cp311-cp311-manylinux_2_38_x86_64.whl (30.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.38+ x86-64

cache_dit_cu13-1.3.12-cp311-cp311-manylinux_2_32_x86_64.whl (30.9 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.32+ x86-64

cache_dit_cu13-1.3.12-cp310-cp310-manylinux_2_38_x86_64.whl (30.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.38+ x86-64

cache_dit_cu13-1.3.12-cp310-cp310-manylinux_2_32_x86_64.whl (30.9 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.32+ x86-64

File details

Details for the file cache_dit_cu13-1.3.12-cp314-cp314-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for cache_dit_cu13-1.3.12-cp314-cp314-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 1286b205292ab32c2e534c260d4d9e5f0aff69cb12ef51fa324f8062e84304b6
MD5 d3afcbf1453815106f021efe7ada209a
BLAKE2b-256 e0abbe66a0df74cb6f930bbd7824a9748bbf54ab88ef37cf826f8fa8f3cda83f

See more details on using hashes here.

File details

Details for the file cache_dit_cu13-1.3.12-cp314-cp314-manylinux_2_32_x86_64.whl.

File metadata

File hashes

Hashes for cache_dit_cu13-1.3.12-cp314-cp314-manylinux_2_32_x86_64.whl
Algorithm Hash digest
SHA256 e5b4820796829b1b0697156bd67c9424ce4a09088267d9cf60d7d6955a0b65eb
MD5 42393d30ef041911543157cd2a6ca415
BLAKE2b-256 3303e29ed89be515ffba188abe926eba3f710c62d0194697a528cd8bc10e2adc

See more details on using hashes here.

File details

Details for the file cache_dit_cu13-1.3.12-cp313-cp313-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for cache_dit_cu13-1.3.12-cp313-cp313-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 05a7a98de423bbdba2c294c9e1ff05a676248cb7e429b7b4f8eead557a282120
MD5 da1c2943e3ae24e9995becd33cad252a
BLAKE2b-256 fdc290013d81a22dce18ed3648805b7f1c4bda04879e36391cdd7ef91adcac80

See more details on using hashes here.

File details

Details for the file cache_dit_cu13-1.3.12-cp313-cp313-manylinux_2_32_x86_64.whl.

File metadata

File hashes

Hashes for cache_dit_cu13-1.3.12-cp313-cp313-manylinux_2_32_x86_64.whl
Algorithm Hash digest
SHA256 174fbe3b7f97e37fcefa9804a8f00b4cf71f69aba305dcdd3b597771ae2f267d
MD5 6dfd879def1b0fe58ad1d6a498e0cbdd
BLAKE2b-256 96200a033a791099ea7a1ad9717e20a32a233e1c3924348f0d618d3d9e314366

See more details on using hashes here.

File details

Details for the file cache_dit_cu13-1.3.12-cp312-cp312-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for cache_dit_cu13-1.3.12-cp312-cp312-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 bdf8009703d18c6885c88205c0800a01c01e8666cada0a8c2af0995440c4d284
MD5 49041c0ea653716895f10d130f2ec262
BLAKE2b-256 0e94bf4faa26346b85009983a4838ef9e5a1293fc42a723088aeb6dc848e34b8

See more details on using hashes here.

File details

Details for the file cache_dit_cu13-1.3.12-cp312-cp312-manylinux_2_32_x86_64.whl.

File metadata

File hashes

Hashes for cache_dit_cu13-1.3.12-cp312-cp312-manylinux_2_32_x86_64.whl
Algorithm Hash digest
SHA256 7657da30c3a744eff792baa5508ec864088bdf1d47ab5d16ddd0a18d0f061cd2
MD5 069264ea14844ec45d6bdc7a58ca3641
BLAKE2b-256 67d58421479a7bfc98e16863032d43d58a43b975774888c9a657e9f096a5f185

See more details on using hashes here.

File details

Details for the file cache_dit_cu13-1.3.12-cp311-cp311-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for cache_dit_cu13-1.3.12-cp311-cp311-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 78b03f9c20f4f4ac06a567b07e731de5de84d6739a765ad6a598e4e2479d492f
MD5 4cd5fba6e5468eaefed25f709e034b13
BLAKE2b-256 a91b33f9781ff20acd859af4c5c7bb66056216f6bead4832bd51491a5e4de4b1

See more details on using hashes here.

File details

Details for the file cache_dit_cu13-1.3.12-cp311-cp311-manylinux_2_32_x86_64.whl.

File metadata

File hashes

Hashes for cache_dit_cu13-1.3.12-cp311-cp311-manylinux_2_32_x86_64.whl
Algorithm Hash digest
SHA256 fc7534f15c6fcaeeea4e0f4233b53ba8a17b878eeb05688c74af1f52510f68c0
MD5 f6b15ad9ba7be165d6a943c0b56cf621
BLAKE2b-256 bdc78d0ad3d932a3a98d30ae962aa2a3426790a8474c08d67e0914208b53b085

See more details on using hashes here.

File details

Details for the file cache_dit_cu13-1.3.12-cp310-cp310-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for cache_dit_cu13-1.3.12-cp310-cp310-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 e65914535a4b638e24db463417037e4bab893107bde5d50a867d5a4003b908f6
MD5 8ef6f80864f81fe6047bddd633d9d04d
BLAKE2b-256 fc44c3c01681b83cb6780c64d12dce0ecb7892c14974280be8e8a2c44b65247e

See more details on using hashes here.

File details

Details for the file cache_dit_cu13-1.3.12-cp310-cp310-manylinux_2_32_x86_64.whl.

File metadata

File hashes

Hashes for cache_dit_cu13-1.3.12-cp310-cp310-manylinux_2_32_x86_64.whl
Algorithm Hash digest
SHA256 306326e5a9654841857128de208786374ee7c807f5d69ea613f21da4eb0a0f6a
MD5 bc3fc34e8313efd0175f9885109ca1a4
BLAKE2b-256 c5ab3f854ccdb5bd2bbefef865f55cd08d67d2ecd8a85b083ba61c48c8cf0dbe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page