| | --- |
| | license: apache-2.0 |
| | library_name: diffusers |
| | pipeline_tag: text-to-image |
| | --- |
| | # Scale-wise Distillation 3.5 Medium |
| | Scale-wise Distillation (SwD) is a novel framework for accelerating diffusion models (DMs) |
| | by progressively increasing spatial resolution during the generation process. |
| | <br>SwD achieves significant speedups (2.5× to 10×) compared to full-resolution models |
| | while maintaining or even improving image quality. |
| |  |
| |
|
| | Project page: https://yandex-research.github.io/swd <br> |
| | GitHub: https://github.com/yandex-research/swd <br> |
| | Demo: https://huggingface.co/spaces/dbaranchuk/Scale-wise-Distillation |
| |
|
| | ## Usage |
| | Upgrade to the latest version of the [🧨 diffusers library](https://github.com/huggingface/diffusers) |
| | ``` |
| | pip install -U diffusers |
| | ``` |
| |
|
| | and then you can run |
| | <br> (Probably, you will need to specify the visible device: %env CUDA_VISIBLE_DEVICES=0, for correct loading of LoRAs.) |
| | ```py |
| | import torch |
| | from diffusers import StableDiffusion3Pipeline |
| | from peft import PeftModel |
| | pipe = StableDiffusion3Pipeline.from_pretrained("stabilityai/stable-diffusion-3.5-medium", |
| | torch_dtype=torch.float16, |
| | custom_pipeline='quickjkee/swd_pipeline') |
| | pipe = pipe.to("cuda") |
| | lora_path = 'yresearch/swd-medium-6-steps' |
| | pipe.transformer = PeftModel.from_pretrained( |
| | pipe.transformer, |
| | lora_path, |
| | ) |
| | generator = torch.Generator().manual_seed(1) |
| | prompt = 'A dog holding a sign that reads Sample Faster' |
| | sigmas = [1.0000, 0.9454, 0.8959, 0.7904, 0.7371, 0.6022, 0.0000] |
| | scales = [32, 48, 64, 80, 96, 128] |
| | |
| | images = pipe( |
| | prompt, |
| | sigmas=torch.tensor(sigmas).to('cuda'), |
| | timesteps=torch.tensor(sigmas[:-1]).to('cuda') * 1000, |
| | scales=scales, |
| | guidance_scale=0.0, |
| | height=int(scales[0] * 8), |
| | width=int(scales[0] * 8), |
| | generator=generator, |
| | ).images |
| | ``` |
| | <p align="center"> |
| | <img src="medium.jpg" width="512px"/> |
| | </p> |
| |
|
| | ## Citation |
| |
|
| | ```bibtex |
| | @article{starodubcev2025swd, |
| | title={Scale-wise Distillation of Diffusion Models}, |
| | author={Nikita Starodubcev and Denis Kuznedelev and Artem Babenko and Dmitry Baranchuk}, |
| | journal={arXiv preprint arXiv:2503.16397}, |
| | year={2025} |
| | } |
| | ``` |