Apple Silicon Unified Memory • MLX Metal Acceleration

Native Apple Silicon FLUX.1 in Safe Rust

A 100% pure Rust port of Black Forest Labs' FLUX.1 architecture, powered by MLX. Features dual-stream MMDiT blocks, 3D rotary embeddings, flow-matching Euler ODE solver, and high-speed tiled VAE decoding with zero Python runtime overhead.

FLUX.1 MMDiT Architecture

Multimodal Diffusion Transformer architecture designed for text-to-image synthesis

🔀

Dual-Stream MMDiT

19 joint transformer blocks allowing simultaneous bidirectional cross-attention between 4096-dim T5 prompt embeddings and 64-channel latent image patches.

⚡

Single-Stream Blocks

38 concatenated transformer blocks where text tokens and image patch tokens fuse into a single self-attention sequence for unified multimodal diffusion.

📐

3D RoPE Coordinates

Multi-dimensional Rotary Position Embeddings split across axes [16, 56, 56] encoding spatial row, column, and frame positioning.

🌊

Flow-Matching Euler

Linear vector field integration with empirical trajectory shift factor μ and terminal stretch parameter σterminal = 0.02.

Interactive Flow-Matching ODE Solver

Simulate the exact diffusion trajectory sigmas and timesteps calculated by FlowMatchEulerDiscreteScheduler

Step Sigma (σt) Timestep (t) Δt (dt) Trajectory Phase

3D Rotary Position Embedding (RoPE) Visualizer

Explore the rotational frequency projections across axes [16, 56, 56] summing to head dimension 128

Axis 0 (Temporal, Dim: 16)

Axis 1 (Row Y, Dim: 56)

Axis 2 (Col X, Dim: 56)

Patch Packing & Memory Calculator

Calculate token sequence lengths, patch dimensions, and unified RAM requirements

Target Width
Target Height
Precision
128 × 128 Spatial Latents (H/8 × W/8)
64 × 64 Patch Grid (H/16 × W/16)
4,096 Image Sequence Tokens
~8.4 GB Est. Peak Unified RAM

Performance & Mathematical Accuracy Telemetry

Verified against Python reference mflux and continuous analytical invariant tests

Workload / Invariant mflux-rs (Rust) mflux (Python) Speedup / Parity Status
Flux.1-schnell 4 Steps (1024x1024) 1.82 s total 3.45 s total 1.89x faster PASS
Single DiT Transformer Step 385 ms 760 ms 1.97x faster PASS
Exponential Time-Shift Limit (t → 1.0) 1.000000 1.000000 Δ < 1e-6 PASS
Time-Shift Curvature Monotonicity Strict Monotonic Analytical Formula 0 Inversions PASS
Latent Space Packing Bijection 100% Bit-Exact Exact Permutation Δ = 0.000000 PASS
Box-Muller Gaussian Noise Distribution μ ≈ 0.0, σ² ≈ 1.0 N(0, 1) |μ| < 0.05, |σ² - 1| < 0.1 PASS

Command Line Usage

Fast, scriptable CLI built directly into the binary

bash - mflux CLI
# Generate with FLUX.1-schnell in 4 steps
mflux generate --prompt "A cinematic shot of a cyberpunk city in rain" --model schnell --steps 4

# Generate with FLUX.1-dev with guidance scale 3.5
mflux generate --prompt "Studio portrait of an astronaut on Mars" --model dev --steps 25 --guidance 3.5 --output mars.png

# Benchmark step latency on Apple Silicon Metal
mflux bench --model schnell --steps 4

# Inspect model parameters and memory footprint
mflux info --model dev