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.5.0-cp314-cp314-manylinux_2_38_x86_64.whl (33.1 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.38+ x86-64

cache_dit_cu13-1.5.0-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.5.0-cp313-cp313-manylinux_2_38_x86_64.whl (33.1 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.38+ x86-64

cache_dit_cu13-1.5.0-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.5.0-cp312-cp312-manylinux_2_38_x86_64.whl (33.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.38+ x86-64

cache_dit_cu13-1.5.0-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.5.0-cp311-cp311-manylinux_2_38_x86_64.whl (33.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.38+ x86-64

cache_dit_cu13-1.5.0-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.5.0-cp310-cp310-manylinux_2_38_x86_64.whl (33.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.38+ x86-64

cache_dit_cu13-1.5.0-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.5.0-cp314-cp314-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for cache_dit_cu13-1.5.0-cp314-cp314-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 a816ffd97f006d012a7596aca39b114dfcf10391d67a5016b0d90389dbeaf6e5
MD5 3dda951b5f64d76cfac2d56f92fcd4df
BLAKE2b-256 8b22823e9b82fd7d1f765a7bf09dac6edbe5ec0db2d1c34d150fddc262c0ab93

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cache_dit_cu13-1.5.0-cp314-cp314-manylinux_2_32_x86_64.whl
Algorithm Hash digest
SHA256 222a46a7899567217574acdf635d6712223734684f54a8ebb5d5b77931c0b81c
MD5 e48f730f3a28ac4a2ee0c190b0b9a457
BLAKE2b-256 0bb67de3f7f8ec5153e79eab6fecee6555c2d9d8b106e64e99e9bcb22a797810

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cache_dit_cu13-1.5.0-cp313-cp313-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 c94b982f8bca93195e67f78de3a138c143cb98aef9f5eea1a9ca077a894578bd
MD5 e66fb05de39d4d4d786ecff26d2efc1b
BLAKE2b-256 5dac4810c3d95cb354b90edf3bb7d98658835d2dd616fc061f3ee56f933e339d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cache_dit_cu13-1.5.0-cp313-cp313-manylinux_2_32_x86_64.whl
Algorithm Hash digest
SHA256 36d8c39d0ce71adc39f50ebb669e88525972146be65894b0140a21c24bf9a6d5
MD5 dac87929dbd01a5703a518df2722bc48
BLAKE2b-256 0a9bec9b1713f8d3ba950b76fe0adf820281f501347d57fa6a94c12e79d0fa7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cache_dit_cu13-1.5.0-cp312-cp312-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 3b7608ba87308ad58aeae91014f316ed198dceb82b46476e103714f5f69708e9
MD5 3c0e093b92a1c67015ef849fdb0cad7a
BLAKE2b-256 b33cecaad1617a0889f97c5c8ba5253051f1ea61e2204a4d6815160e2ae5b458

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cache_dit_cu13-1.5.0-cp312-cp312-manylinux_2_32_x86_64.whl
Algorithm Hash digest
SHA256 02ec0d225a27fc9ee6a9ba4cfaae63fb4fa1bbd62d339024e59f1cf981dec28e
MD5 22367ca5a39a8d67983842ca643ae2e7
BLAKE2b-256 999de68edb0e8d4a97547f718b14516d7a4495801ec9e31fea53b7caf867016e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cache_dit_cu13-1.5.0-cp311-cp311-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 f951f048e9ebadaac62d3fa19b9fe21c0494ae7a824cbd5dbfffdb8dc930cb71
MD5 15f420cff3ca38ec0a7bc295275f26f0
BLAKE2b-256 ddb4be07ef7bb3a3f63c76886c34ff2474c6e1c4a8e6eb132dfc8a361ae655b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cache_dit_cu13-1.5.0-cp311-cp311-manylinux_2_32_x86_64.whl
Algorithm Hash digest
SHA256 5567e33ae834d23e40aaf1b2e02325872600dd2ca958db95d1b74510266b68c7
MD5 f83542bd4685f91362d6f01eb11a0e7b
BLAKE2b-256 5b0265baf3a7c8d3982b6993f718cd7f994c29a1bebdfc950c131594c229937e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cache_dit_cu13-1.5.0-cp310-cp310-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 acac08a6dba2f238805c9819c2a4b5b7b60d75bef69e56b382a81218923eea6c
MD5 31bb7fd31fcaaff3aa954be6494f5ee4
BLAKE2b-256 5bddb3ad676bec69198ca50f6029cb527bf02b8abf7ef3dde1b8504b75a98604

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cache_dit_cu13-1.5.0-cp310-cp310-manylinux_2_32_x86_64.whl
Algorithm Hash digest
SHA256 00df6f091bf737e5c28505251e50ec03cc7c659d0b8f411848a3e773b126a1df
MD5 65a21f69016404f400a95afa61e6b412
BLAKE2b-256 a4502b60a91ad701a90e30c2ed3b35413d962193e9435537e418415dd6df543d

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