Skip to main content

diffusion-rs

Blazingly fast inference of diffusion models.

| Rust Documentation | Python Documentation | Discord |

Features

  • Quantization
    • bitsandbytes format (fp4, nf4, and int8)
    • GGUF (2-8 bit quantization)
  • Easy: Strong support for running 🤗 DDUF models.
  • Strong Apple Silicon support: support for the Metal, Accelerate, and ARM NEON frameworks
  • Support for NVIDIA GPUs with CUDA
  • AVX support for x86 CPUs
  • Allow acceleration of models larger than the total VRAM size with offloading

Please do not hesitate to contact us with feature requests via Github issues!

Upcoming features

  • 🚧 LoRA support
  • 🚧 CPU + GPU inference with automatic offloading to allow partial acceleration of models larger than the total VRAM

Installation

Check out the installation guide for details about installation.

Examples

After installing, you can try out these examples!

Download the DDUF file here: wget https://huggingface.co/DDUF/FLUX.1-dev-DDUF/resolve/main/FLUX.1-dev-Q4-bnb.dduf

CLI:

diffusion_rs_cli --scale 3.5 --num-steps 50 dduf -f FLUX.1-dev-Q4-bnb.dduf

More CLI examples here.

Python:

More Python examples here.

from diffusion_rs import DiffusionGenerationParams, ModelSource, Pipeline
from PIL import Image
import io

pipeline = Pipeline(source=ModelSource.DdufFile("FLUX.1-dev-Q4-bnb.dduf"))

image_bytes = pipeline.forward(
    prompts=["Draw a picture of a sunrise."],
    params=DiffusionGenerationParams(
        height=720, width=1280, num_steps=50, guidance_scale=3.5
    ),
)

image = Image.open(io.BytesIO(image_bytes[0]))
image.show()

Rust crate:

Examples with the Rust crate: here.

use std::time::Instant;

use diffusion_rs_core::{DiffusionGenerationParams, ModelSource, Offloading, Pipeline, TokenSource};
use tracing::level_filters::LevelFilter;
use tracing_subscriber::EnvFilter;

let filter = EnvFilter::builder()
    .with_default_directive(LevelFilter::INFO.into())
    .from_env_lossy();
tracing_subscriber::fmt().with_env_filter(filter).init();

let pipeline = Pipeline::load(
    ModelSource::dduf("FLUX.1-dev-Q4-bnb.dduf")?,
    false,
    TokenSource::CacheToken,
    None,
    None,
)?;

let start = Instant::now();

let images = pipeline.forward(
    vec!["Draw a picture of a sunrise.".to_string()],
    DiffusionGenerationParams {
        height: 720,
        width: 1280,
        num_steps: 50,
        guidance_scale: 3.5,
    },
)?;

let end = Instant::now();
println!("Took: {:.2}s", end.duration_since(start).as_secs_f32());

images[0].save("image.png")?;

Support matrix

Model Supports DDUF Supports quantized DDUF
FLUX.1 Dev/Schnell ✅ ✅

Contributing

  • Anyone is welcome to contribute by opening PRs
  • Collaborators will be invited based on past contributions

Metadata

Release files for diffusion-rs-mkl 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for diffusion-rs-mkl 0.1.0
File
diffusion_rs_mkl-0.1.0-cp312-none-win_amd64.whl CPython 3.12 none Windows x86-64 Details
diffusion_rs_mkl-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.39+ x86-64 Details
diffusion_rs_mkl-0.1.0-cp311-none-win_amd64.whl CPython 3.11 none Windows x86-64 Details
diffusion_rs_mkl-0.1.0-cp311-cp311-manylinux_2_39_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.39+ x86-64 Details
diffusion_rs_mkl-0.1.0-cp310-none-win_amd64.whl CPython 3.10 none Windows x86-64 Details
diffusion_rs_mkl-0.1.0-cp310-cp310-manylinux_2_39_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.39+ x86-64 Details

Total release size: 65.1 MB

Release files / diffusion_rs_mkl-0.1.0-cp312-none-win_amd64.whl

Download URL diffusion_rs_mkl-0.1.0-cp312-none-win_amd64.whl
Size 9.3 MB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
8f0ea6d14be598fafc1102d1a116e0a86b3aaec2f17480b4b729dec213e87c80
BLAKE2b-256 checksum
How to use checksums
0cc0624fc1e56da96914de27a07c8d20b3268a3813fa6ecc0f13883e4430197a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / diffusion_rs_mkl-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl

Download URL diffusion_rs_mkl-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl
Size 12.4 MB
Tags CPython 3.12 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
e74d03b52f9fd2ef4dbe154f80ead08c49a68d597778c5561477e002ec7549e8
BLAKE2b-256 checksum
How to use checksums
79bff5633fec9cc00b7d149930b500a177d26ae52fc3d8ee51d8ebc84a9c26ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / diffusion_rs_mkl-0.1.0-cp311-none-win_amd64.whl

Download URL diffusion_rs_mkl-0.1.0-cp311-none-win_amd64.whl
Size 9.3 MB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
32e226eff12eed8b1f482714b870d075275103864559c345092c01d76eb9a5af
BLAKE2b-256 checksum
How to use checksums
ab6ce89bf7eeef5b06210bed9ce0db828424b94c600e462dd2a94615232fd5e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / diffusion_rs_mkl-0.1.0-cp311-cp311-manylinux_2_39_x86_64.whl

Download URL diffusion_rs_mkl-0.1.0-cp311-cp311-manylinux_2_39_x86_64.whl
Size 12.4 MB
Tags CPython 3.11 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
1d94566250b9c89dcb0a33494947f9323e5e3805900504c3a315b10294eb2262
BLAKE2b-256 checksum
How to use checksums
92c7432dbf1c8e3e7074e77d9cd8db00f001c49eea737ffffb4b30b9c57c5090
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / diffusion_rs_mkl-0.1.0-cp310-none-win_amd64.whl

Download URL diffusion_rs_mkl-0.1.0-cp310-none-win_amd64.whl
Size 9.3 MB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
30dc56d39ec67fc15841dacb3d6a3903a71765a03a9dd01812837f513031d144
BLAKE2b-256 checksum
How to use checksums
ae5e52bfa53a14309f394615795d0df7d28b611e9b2074b258189ad835697211
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release files / diffusion_rs_mkl-0.1.0-cp310-cp310-manylinux_2_39_x86_64.whl

Download URL diffusion_rs_mkl-0.1.0-cp310-cp310-manylinux_2_39_x86_64.whl
Size 12.4 MB
Tags CPython 3.10 Linux glibc 2.39+ x86-64
SHA-256 checksum
How to use checksums
07cf7b646cee1a11b042960c1df1dc53c0015e9493ae49bacad68091a1674ab5
BLAKE2b-256 checksum
How to use checksums
4b57f5ebbdfd20ab6dae73a999f4350b7a314e6e5b866108fccb4ab6fb0b7e1a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.7

Release history Release notifications | RSS feed

This release

0.1.0 This release

6 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page