Pure Rust inference engine for modern image generation and diffusion architectures
Rust
0
107 commits
updated Sep 18, 2026
aurora-rust-engine)Pure Rust inference engine for modern image generation and diffusion architectures
aurora-rust-engine is a standalone, lightweight, and memory-efficient AI inference engine written entirely in pure Rust using Candle, native FlashAttention-2 CUDA kernels, and hardware acceleration.
๐ Looking for full documentation? See the complete User & Developer Guide (USER_GUIDE.md) for SDK examples, REST API payloads, scheduler configurations, and VRAM optimization tips.
It provides a robust, zero-Python alternative for running generative diffusion models (Stable Diffusion XL, Pony XL, and future DiT/Flux architectures) with deterministic execution, in-memory zero-overhead LoRA weight merging, and sub-8GB VRAM footprint.
AutoModel::from_local and AutoModel::from_pretrained interface supporting both generative diffusion pipelines and autoregressive text models.FluxVaeEncoder & FluxVaeDecoder: Bit-exact VAE encoding and decoding with BatchNorm latent standardization..safetensors single-file checkpoints from Civitai and Hugging Face.step_at support for arbitrary start step), and DPM-Solver++ 2M Karras.cargo)cargo build --release --features cuda,flash-attn
cargo run --release --bin aurora_studio --features cuda,flash-attn,ui
Open http://127.0.0.1:7860 to access the complete pure Rust Diffusion Studio with a multi-model
dropdown, per-model generation defaults, real-time progressive latent preview streaming, session
history gallery, and GPU telemetry powered by Grio.
Models are declared in aurora_studio.json (no hard-coded paths) โ see the end-user guide:
๐ docs/AURORA_STUDIO_GUIDE.md.
cargo run --release --bin grand_benchmark --features cuda,flash-attn
cargo run --release --bin test_single_gen --features cuda,flash-attn
cargo run --release --bin test_lora --features cuda,flash-attn
cargo run --release --bin stress_test --features cuda,flash-attn
use candle_core::Device;
use aurora_rust_engine::{StableDiffusionXLPipeline, DiffusionParams};
fn main() -> anyhow::Result<()> {
let device = Device::new_cuda(0)?;
let mut pipeline = StableDiffusionXLPipeline::from_safetensors("checkpoint.safetensors", &device)?;
// Hot-merge LoRA directly into model weights (< 10 seconds, 0 MB extra VRAM)
pipeline.load_lora("style_lora.safetensors", 0.85)?;
let params = DiffusionParams {
prompt: "masterpiece, 1girl, cyberpunk city, vivid colors",
negative_prompt: Some("blurry, low quality"),
num_steps: 25,
guidance_scale: 6.0,
width: 1024,
height: 1024,
seed: 42,
};
let image = pipeline.generate(params, None)?;
image.save("output_lora.png")?;
// Unload LoRA to restore base checkpoint weights
pipeline.unload_all_loras()?;
Ok(())
}
use candle_core::Device;
use aurora_rust_engine::{StableDiffusionXLPipeline, Img2ImgParams};
fn main() -> anyhow::Result<()> {
let device = Device::new_cuda(0)?;
let mut pipeline = StableDiffusionXLPipeline::from_safetensors("checkpoint.safetensors", &device)?;
let input_img = image::open("input.png")?.to_rgb8();
let params = Img2ImgParams {
prompt: "masterpiece, 1girl, golden radiant armor, fiery glowing orange hair",
negative_prompt: Some("blurry, low quality"),
image: input_img,
strength: 0.60, // 0.0 = identity, 1.0 = full re-generation
num_steps: 30,
guidance_scale: 6.5,
seed: 42,
};
let result = pipeline.generate_img2img(params, None)?;
result.save("output_img2img.png")?;
Ok(())
}
use aurora_rust_engine::{InpaintParams, StableDiffusionXLPipeline, select_device};
fn main() -> anyhow::Result<()> {
let device = select_device()?;
let mut pipeline = StableDiffusionXLPipeline::from_single_file("sdxl_base.safetensors", device)?;
let base_image = image::open("input.png")?.to_rgb8();
let mask_image = image::open("mask.png")?.to_luma8(); // White = edit, Black = keep
let params = InpaintParams {
prompt: "a wizard hat with golden stars",
negative_prompt: Some("low quality, blurry"),
image: base_image,
mask: mask_image,
mask_blur: 8,
strength: 0.95,
num_steps: 30,
guidance_scale: 7.0,
seed: 42,
};
let result = pipeline.generate_inpaint(params, None)?;
result.save("output_inpaint.png")?;
Ok(())
}
use aurora_rust_engine::{compute_canny_edge_map, ControlNetModel, ControlNetParams, MultiControlNet, StableDiffusionXLPipeline, select_device};
fn main() -> anyhow::Result<()> {
let device = select_device()?;
let mut pipeline = StableDiffusionXLPipeline::from_single_file("sdxl_base.safetensors", device.clone())?;
// 1. Extract Canny edge map in Pure Rust (< 12ms)
let source_img = image::open("input.png")?.to_rgb8();
let edge_map = compute_canny_edge_map(&source_img, 100.0, 200.0);
// 2. Load ControlNet model and configure MultiControlNet container
let cnet = ControlNetModel::from_safetensors("controlnet_canny_sdxl.safetensors", &device, candle_core::DType::F16)?;
let mut multi_controlnet = MultiControlNet::new();
multi_controlnet.add(cnet, 0.85); // 0.85 conditioning strength
// 3. Generate with spatial edge alignment
let params = ControlNetParams::new("cyberpunk warrior, masterpiece, highly detailed", edge_map);
let result = pipeline.generate_controlnet(params, &multi_controlnet, None)?;
result.save("output_controlnet.png")?;
Ok(())
}
let (image, metrics) = pipeline.generate_with_metrics(params, None)?;
println!("{}", metrics.summary_report());
// Output: โฑ๏ธ [Telemetry] UNet: 15.37s (30 steps, 512.42 ms/step, 1.95 it/s) | VAE: 4.73s | Text: 2.33s | Total: 22.57s
Start the standalone async inference microservice:
cargo run --release --bin server --features cuda,flash-attn
GET http://127.0.0.1:8080/api/v1/healthPOST http://127.0.0.1:8080/api/v1/generate
{
"prompt": "futuristic cyberpunk pilot, 8k masterpiece",
"steps": 30,
"guidance_scale": 6.5,
"width": 1024,
"height": 1024
}
ws://127.0.0.1:8080/api/v1/ws| Pipeline Component | Standard Attention | FlashAttention-2 | Speedup |
|---|---|---|---|
| Attention Kernels (per step) | 186.0 ms | 19.6 ms | 9.5x |
| SDXL UNet Denoising (50 steps) | ~42.5 s (1.18 it/s) | 25.8 s (1.94 it/s) | 1.65x |
| Pure UNet Step Speed | ~850 ms/step | ~512 ms/step (1.95 it/s) | 1.65x |
| LoRA Hot Weight Merging Time | N/A | < 9.0 s | In-place |
| Img2Img VAE Encode Time | N/A | < 0.15 s | In-place |
| Inpainting Latent Blending | N/A | < 0.05 ms/step | Real-time |
| Pure Rust Canny Edge Extraction | N/A | < 12 ms | Real-time |
| Inference VRAM Allocation | 7.6 GB | 7.6 GB | 0 MB LoRA overhead |
See ROADMAP.md for full technical specifications and development milestones:
Licensed under Apache-2.0 / MIT.
107 commits
Rust
98.9%
Python
1.1%
Pure Rust inference engine for modern image generation and diffusion architectures
Rust
0
107 commits
updated Sep 18, 2026
aurora-rust-engine)Pure Rust inference engine for modern image generation and diffusion architectures
aurora-rust-engine is a standalone, lightweight, and memory-efficient AI inference engine written entirely in pure Rust using Candle, native FlashAttention-2 CUDA kernels, and hardware acceleration.
๐ Looking for full documentation? See the complete User & Developer Guide (USER_GUIDE.md) for SDK examples, REST API payloads, scheduler configurations, and VRAM optimization tips.
It provides a robust, zero-Python alternative for running generative diffusion models (Stable Diffusion XL, Pony XL, and future DiT/Flux architectures) with deterministic execution, in-memory zero-overhead LoRA weight merging, and sub-8GB VRAM footprint.
AutoModel::from_local and AutoModel::from_pretrained interface supporting both generative diffusion pipelines and autoregressive text models.FluxVaeEncoder & FluxVaeDecoder: Bit-exact VAE encoding and decoding with BatchNorm latent standardization..safetensors single-file checkpoints from Civitai and Hugging Face.step_at support for arbitrary start step), and DPM-Solver++ 2M Karras.cargo)cargo build --release --features cuda,flash-attn
cargo run --release --bin aurora_studio --features cuda,flash-attn,ui
Open http://127.0.0.1:7860 to access the complete pure Rust Diffusion Studio with a multi-model
dropdown, per-model generation defaults, real-time progressive latent preview streaming, session
history gallery, and GPU telemetry powered by Grio.
Models are declared in aurora_studio.json (no hard-coded paths) โ see the end-user guide:
๐ docs/AURORA_STUDIO_GUIDE.md.
cargo run --release --bin grand_benchmark --features cuda,flash-attn
cargo run --release --bin test_single_gen --features cuda,flash-attn
cargo run --release --bin test_lora --features cuda,flash-attn
cargo run --release --bin stress_test --features cuda,flash-attn
use candle_core::Device;
use aurora_rust_engine::{StableDiffusionXLPipeline, DiffusionParams};
fn main() -> anyhow::Result<()> {
let device = Device::new_cuda(0)?;
let mut pipeline = StableDiffusionXLPipeline::from_safetensors("checkpoint.safetensors", &device)?;
// Hot-merge LoRA directly into model weights (< 10 seconds, 0 MB extra VRAM)
pipeline.load_lora("style_lora.safetensors", 0.85)?;
let params = DiffusionParams {
prompt: "masterpiece, 1girl, cyberpunk city, vivid colors",
negative_prompt: Some("blurry, low quality"),
num_steps: 25,
guidance_scale: 6.0,
width: 1024,
height: 1024,
seed: 42,
};
let image = pipeline.generate(params, None)?;
image.save("output_lora.png")?;
// Unload LoRA to restore base checkpoint weights
pipeline.unload_all_loras()?;
Ok(())
}
use candle_core::Device;
use aurora_rust_engine::{StableDiffusionXLPipeline, Img2ImgParams};
fn main() -> anyhow::Result<()> {
let device = Device::new_cuda(0)?;
let mut pipeline = StableDiffusionXLPipeline::from_safetensors("checkpoint.safetensors", &device)?;
let input_img = image::open("input.png")?.to_rgb8();
let params = Img2ImgParams {
prompt: "masterpiece, 1girl, golden radiant armor, fiery glowing orange hair",
negative_prompt: Some("blurry, low quality"),
image: input_img,
strength: 0.60, // 0.0 = identity, 1.0 = full re-generation
num_steps: 30,
guidance_scale: 6.5,
seed: 42,
};
let result = pipeline.generate_img2img(params, None)?;
result.save("output_img2img.png")?;
Ok(())
}
use aurora_rust_engine::{InpaintParams, StableDiffusionXLPipeline, select_device};
fn main() -> anyhow::Result<()> {
let device = select_device()?;
let mut pipeline = StableDiffusionXLPipeline::from_single_file("sdxl_base.safetensors", device)?;
let base_image = image::open("input.png")?.to_rgb8();
let mask_image = image::open("mask.png")?.to_luma8(); // White = edit, Black = keep
let params = InpaintParams {
prompt: "a wizard hat with golden stars",
negative_prompt: Some("low quality, blurry"),
image: base_image,
mask: mask_image,
mask_blur: 8,
strength: 0.95,
num_steps: 30,
guidance_scale: 7.0,
seed: 42,
};
let result = pipeline.generate_inpaint(params, None)?;
result.save("output_inpaint.png")?;
Ok(())
}
use aurora_rust_engine::{compute_canny_edge_map, ControlNetModel, ControlNetParams, MultiControlNet, StableDiffusionXLPipeline, select_device};
fn main() -> anyhow::Result<()> {
let device = select_device()?;
let mut pipeline = StableDiffusionXLPipeline::from_single_file("sdxl_base.safetensors", device.clone())?;
// 1. Extract Canny edge map in Pure Rust (< 12ms)
let source_img = image::open("input.png")?.to_rgb8();
let edge_map = compute_canny_edge_map(&source_img, 100.0, 200.0);
// 2. Load ControlNet model and configure MultiControlNet container
let cnet = ControlNetModel::from_safetensors("controlnet_canny_sdxl.safetensors", &device, candle_core::DType::F16)?;
let mut multi_controlnet = MultiControlNet::new();
multi_controlnet.add(cnet, 0.85); // 0.85 conditioning strength
// 3. Generate with spatial edge alignment
let params = ControlNetParams::new("cyberpunk warrior, masterpiece, highly detailed", edge_map);
let result = pipeline.generate_controlnet(params, &multi_controlnet, None)?;
result.save("output_controlnet.png")?;
Ok(())
}
let (image, metrics) = pipeline.generate_with_metrics(params, None)?;
println!("{}", metrics.summary_report());
// Output: โฑ๏ธ [Telemetry] UNet: 15.37s (30 steps, 512.42 ms/step, 1.95 it/s) | VAE: 4.73s | Text: 2.33s | Total: 22.57s
Start the standalone async inference microservice:
cargo run --release --bin server --features cuda,flash-attn
GET http://127.0.0.1:8080/api/v1/healthPOST http://127.0.0.1:8080/api/v1/generate
{
"prompt": "futuristic cyberpunk pilot, 8k masterpiece",
"steps": 30,
"guidance_scale": 6.5,
"width": 1024,
"height": 1024
}
ws://127.0.0.1:8080/api/v1/ws| Pipeline Component | Standard Attention | FlashAttention-2 | Speedup |
|---|---|---|---|
| Attention Kernels (per step) | 186.0 ms | 19.6 ms | 9.5x |
| SDXL UNet Denoising (50 steps) | ~42.5 s (1.18 it/s) | 25.8 s (1.94 it/s) | 1.65x |
| Pure UNet Step Speed | ~850 ms/step | ~512 ms/step (1.95 it/s) | 1.65x |
| LoRA Hot Weight Merging Time | N/A | < 9.0 s | In-place |
| Img2Img VAE Encode Time | N/A | < 0.15 s | In-place |
| Inpainting Latent Blending | N/A | < 0.05 ms/step | Real-time |
| Pure Rust Canny Edge Extraction | N/A | < 12 ms | Real-time |
| Inference VRAM Allocation | 7.6 GB | 7.6 GB | 0 MB LoRA overhead |
See ROADMAP.md for full technical specifications and development milestones:
Licensed under Apache-2.0 / MIT.
107 commits
Rust
98.9%
Python
1.1%