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_accelerate-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (5.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

diffusion_rs_accelerate-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (5.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

diffusion_rs_accelerate-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (5.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file diffusion_rs_accelerate-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for diffusion_rs_accelerate-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 10d909a27c939942b5d8d3451d03900424c82727767949a5537503d637101700
MD5 17af034ae8541a71b8c1e1787194dccc
BLAKE2b-256 55f100b2323c2bc540eeea36f567541a43ae90065d195594ea65870352766d58

See more details on using hashes here.

File details

Details for the file diffusion_rs_accelerate-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for diffusion_rs_accelerate-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d019ea6b52fac1f3299f839ef95c8abdba46114bfd518cf82a1fa283bbb4cac4
MD5 13955bd324651eef77c640142798dc6f
BLAKE2b-256 fbb39b37550d072bdf6db575b3e8b42b08dfe33b66f0c3eb5b8d0f3318e26099

See more details on using hashes here.

File details

Details for the file diffusion_rs_accelerate-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for diffusion_rs_accelerate-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4cea6f1e07f89794beb1f9b9436ff063143916c33f5cd30b7dc9f5024aef8840
MD5 2ac434e269db118222bdb370c7989b25
BLAKE2b-256 c8017762725d7dedb4bd432761c7318a3a09c5d9b8fb8965d87b23f0155de3c3

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