Skip to main content

Blazingly fast inference of diffusion models.

Project description

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

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.

diffusion_rs_mkl-0.1.0-cp312-none-win_amd64.whl (9.3 MB view details)

Uploaded CPython 3.12Windows x86-64

diffusion_rs_mkl-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl (12.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

diffusion_rs_mkl-0.1.0-cp311-none-win_amd64.whl (9.3 MB view details)

Uploaded CPython 3.11Windows x86-64

diffusion_rs_mkl-0.1.0-cp311-cp311-manylinux_2_39_x86_64.whl (12.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.39+ x86-64

diffusion_rs_mkl-0.1.0-cp310-none-win_amd64.whl (9.3 MB view details)

Uploaded CPython 3.10Windows x86-64

diffusion_rs_mkl-0.1.0-cp310-cp310-manylinux_2_39_x86_64.whl (12.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.39+ x86-64

File details

Details for the file diffusion_rs_mkl-0.1.0-cp312-none-win_amd64.whl.

File metadata

File hashes

Hashes for diffusion_rs_mkl-0.1.0-cp312-none-win_amd64.whl
Algorithm Hash digest
SHA256 8f0ea6d14be598fafc1102d1a116e0a86b3aaec2f17480b4b729dec213e87c80
MD5 219e88634a455eeec97ea69febde275c
BLAKE2b-256 0cc0624fc1e56da96914de27a07c8d20b3268a3813fa6ecc0f13883e4430197a

See more details on using hashes here.

File details

Details for the file diffusion_rs_mkl-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for diffusion_rs_mkl-0.1.0-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 e74d03b52f9fd2ef4dbe154f80ead08c49a68d597778c5561477e002ec7549e8
MD5 40dfbe855dbeac7e3989650ba2107509
BLAKE2b-256 79bff5633fec9cc00b7d149930b500a177d26ae52fc3d8ee51d8ebc84a9c26ea

See more details on using hashes here.

File details

Details for the file diffusion_rs_mkl-0.1.0-cp311-none-win_amd64.whl.

File metadata

File hashes

Hashes for diffusion_rs_mkl-0.1.0-cp311-none-win_amd64.whl
Algorithm Hash digest
SHA256 32e226eff12eed8b1f482714b870d075275103864559c345092c01d76eb9a5af
MD5 fbfa885823321d68d237d98ecd8dd1b6
BLAKE2b-256 ab6ce89bf7eeef5b06210bed9ce0db828424b94c600e462dd2a94615232fd5e5

See more details on using hashes here.

File details

Details for the file diffusion_rs_mkl-0.1.0-cp311-cp311-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for diffusion_rs_mkl-0.1.0-cp311-cp311-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 1d94566250b9c89dcb0a33494947f9323e5e3805900504c3a315b10294eb2262
MD5 d9d40890fdf5562f922229904507d6a1
BLAKE2b-256 92c7432dbf1c8e3e7074e77d9cd8db00f001c49eea737ffffb4b30b9c57c5090

See more details on using hashes here.

File details

Details for the file diffusion_rs_mkl-0.1.0-cp310-none-win_amd64.whl.

File metadata

File hashes

Hashes for diffusion_rs_mkl-0.1.0-cp310-none-win_amd64.whl
Algorithm Hash digest
SHA256 30dc56d39ec67fc15841dacb3d6a3903a71765a03a9dd01812837f513031d144
MD5 d595bba0b528853f38442694d27310d7
BLAKE2b-256 ae5e52bfa53a14309f394615795d0df7d28b611e9b2074b258189ad835697211

See more details on using hashes here.

File details

Details for the file diffusion_rs_mkl-0.1.0-cp310-cp310-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for diffusion_rs_mkl-0.1.0-cp310-cp310-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 07cf7b646cee1a11b042960c1df1dc53c0015e9493ae49bacad68091a1674ab5
MD5 597f6b6747df7efc2a808e4a9d7d2c2a
BLAKE2b-256 4b57f5ebbdfd20ab6dae73a999f4350b7a314e6e5b866108fccb4ab6fb0b7e1a

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