C.W.K.
Stream
Lesson 04 of 07 · published

Image Generation — Diffusion on the Mac

~14 min · diffusion, image-generation, stable-diffusion

Level 0Curious
0 XP0/51 lessons0/15 achievements
0/100 XP to next level100 XP to go0% complete

Diffusion on the Mac

Image generation in MLX runs through diffusion models — Stable Diffusion variants, FLUX (the current quality leader for many use cases), and the long tail of community-trained models. The MLX-native packaging effort is led by argmaxinc's mlx-FLUX work and the older mlx-examples/stable_diffusion reference, both of which target Apple Silicon's unified memory directly.

The fast path is argmaxinc/mlx-FLUX.1-schnell — a 4-step quality-leading diffusion model in MLX format. "Schnell" is German for "quick," and it lives up to it; you get full-quality generations in a fraction of the steps required by older Stable Diffusion variants.

The wall-clock you should expect

FLUX schnell 4-bit quantized on an M-Pro generates a 1024×1024 image in roughly 10–30 seconds; on M-Ultra closer to the 5–15 second range. That's a working iteration loop — you can sketch with a model in real-time-ish, no GPU rental needed.

The MLX vs CoreML decision for image generation

For the same model class on the same chip, MLX and CoreML perform similarly — sometimes within noise of each other. The decision isn't about raw speed; it's about workflow:

  • MLX — Python-first, easy to script and integrate into pipelines, full control over the diffusion sampler, easy A/B between quantization levels. Use this for research or any pipeline where Python is already the integration layer.
  • CoreML — Swift-first, easy to embed in macOS / iOS apps, optimized for on-device deployment. Use this when you're shipping a feature inside an app and need the App Store distribution + privacy guarantees.

Hosted APIs vs local generation

For commercial-grade image generation as a single user, a hosted API (Replicate, fal, OpenAI's image API) is often cheaper per image than running a local Mac that's idle most of the day. Local Mac generation wins when (1) the privacy or air-gap matters, (2) you're generating in volume and the per-image cost adds up, or (3) you want full control over the model and sampler. For one-off use, the hosted API is usually the right call; for a creative tool you use daily, the Mac wins on cumulative cost.

Code

Generate one image with FLUX schnell (MLX)·bash
# Run with the mlx-FLUX reference. The model is in ~/.cache/huggingface/hub/
# after first download (~3 GB for the 4-bit variant).
python -m mflux.generate \
  --model schnell \
  --quantize 4 \
  --steps 4 \
  --width 1024 --height 1024 \
  --seed 42 \
  --prompt "A red panda data scientist debugging code at 3am, anime style, soft lighting." \
  --output ./red-panda.png

# Wall-clock varies by chip:
#   M-Ultra : ~5-15 seconds for 1024x1024 schnell at 4 steps
#   M-Pro   : ~10-30 seconds for the same
Generate the same image programmatically·python
# Pattern (exact API depends on which mlx-FLUX wrapper you're using).
# argmaxinc/mlx-FLUX exposes a high-level Flux class; the canonical
# usage looks like:

from mflux import Flux1, Config

flux = Flux1.from_alias(
    alias="schnell",
    quantize=4,
)

image = flux.generate_image(
    seed=42,
    prompt="A red panda data scientist debugging code at 3am, anime style.",
    config=Config(num_inference_steps=4, height=1024, width=1024),
)

image.save("red-panda.png", export_json_metadata=True)

External links

Exercise

Generate three images with FLUX schnell at 4 steps using the same seed but three different prompts. Then generate the same prompt three times with three different seeds. Note how seed-stability gives you the same image across runs (useful for reproducible art) and how prompt changes drive composition. Two sentences on whether the wall-clock latency on your machine is fast enough for an iterative creative loop.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.