diffusion-rs
Blazingly fast inference of diffusion models.
| Rust Documentation | Python Documentation | Discord |
Features
- Quantization
bitsandbytesformat (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
- See good first issues for a starting point!
- Collaborators will be invited based on past contributions
Metadata
Release files for diffusion-rs-metal 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| diffusion_rs_metal-0.1.0-cp312-cp312-macosx_11_0_arm64.whl | CPython 3.12 | CPython 3.12 | macOS 11.0+ ARM64 | Details |
| diffusion_rs_metal-0.1.0-cp311-cp311-macosx_11_0_arm64.whl | CPython 3.11 | CPython 3.11 | macOS 11.0+ ARM64 | Details |
| diffusion_rs_metal-0.1.0-cp310-cp310-macosx_11_0_arm64.whl | CPython 3.10 | CPython 3.10 | macOS 11.0+ ARM64 | Details |
Total release size: 17.1 MB
Release files / diffusion_rs_metal-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
| Download URL | diffusion_rs_metal-0.1.0-cp312-cp312-macosx_11_0_arm64.whl |
|---|---|
| Size | 5.7 MB |
| Tags | CPython 3.12 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
06126cce83fb9c82bd46b0c6e6dce148d021c5057404fe1a6d890fa4dc707c7b
|
|
BLAKE2b-256 checksum How to use checksums |
fbec507ed49f0750c3087afd0dcbca2045f9fa728a7ffa09f16c958f1e3b1d9a
|
| 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_metal-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | diffusion_rs_metal-0.1.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 5.7 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
a2ddcead867a9a0115450daaff83252aae13624ea1793016abdaa29df329fd10
|
|
BLAKE2b-256 checksum How to use checksums |
a0e77b59d4a1020198b30181b989a6303c36d8eb8465990f01bb9e7435b0909d
|
| 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_metal-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
| Download URL | diffusion_rs_metal-0.1.0-cp310-cp310-macosx_11_0_arm64.whl |
|---|---|
| Size | 5.7 MB |
| Tags | CPython 3.10 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
f8de2cf0ecc5e47d89c61b95b333162a753e7b3a342ace6c0947bed504d7ab41
|
|
BLAKE2b-256 checksum How to use checksums |
4369b566ef2dddcb5b99f6a757334f0e67aaf905e27213b70964db4b256100ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.7
|