Skip to content
IonDenPublic

About

Tiny AutoEncoders (TAESD family) for diffusion latents on Apple Silicon — pure MLX. Live previews + low-memory decode for FLUX.1, FLUX.2 Klein, SD1.x, SDXL.

Topics

Resources

Contributing

Stars

13 stars

Watchers

1 watching

Forks

Repository files navigation

mlx-taef

mlx-taef

PyPI version Python 3.11+ License: MIT

Image models such as FLUX show nothing until the last of many steps. mlx-taef is a set of tiny decoders, written for MLX on Apple Silicon, that turn the model's in-progress data (its latent) into a viewable picture at any step.

You need it if you generate images with mflux, the MLX image-generation tool, and want to watch them form.

pip install mlx-taef
import mlx.core as mx
from mlx_taef import TAEF2

taef = TAEF2.from_pretrained()              # downloads + converts on first call
img = taef.decode(latents)                  # NHWC float in [0, 1]
img_uint8 = taef.decode_image(latents)      # uint8 NHWC ready for PIL

Which library do I need?

  • Live previews or low-memory decode: this library.
  • Faster generation itself: mlx-teacache, which skips redundant denoising steps when the schedule is cacheable. Its benchmarks page has its figures.
  • Both: use them together. The benchmarks page has the measured combination.

Install

pip install mlx-taef
# With the mflux preview callback:
pip install "mlx-taef[mflux]"

Or with uv:

uv add mlx-taef
# With mflux:
uv add "mlx-taef[mflux]"

Pin an exact version in a project that needs reproducibility:

pip install "mlx-taef==0.9.2"

Verify the install:

mlx-taef --help

What to know before you install:

  • Python 3.11 or newer, and Apple Silicon (mlx itself runs only on Apple Silicon). Python 3.10 users stay on mlx-taef 0.8.4, or move to Python 3.11 or newer.
  • The first from_pretrained() call, and creating a LivePreviewCallback, download the weights and convert them to MLX. Later calls reuse the cached copy. A failure during that download or conversion is not covered by on_error.
  • The base install pulls in no PyTorch. The mflux extra does, because mflux depends on it. In this repository, torch is used only to generate test fixtures.
  • The mflux extra accepts mflux 0.24 and every later release, with no upper bound. A CI job tests the newest mflux every Monday, and mlx-taef is changed only when something breaks. Tested up to mflux 0.24.0.
  • Pillow 13 or newer is required wherever mlx-taef needs Pillow; older releases are affected by GHSA-5x8w-8jj5-q52h.

Live previews with mflux

Register LivePreviewCallback on an mflux model and it saves a preview image every every steps (FLUX.2 Klein shown):

from mflux.models.common.config.model_config import ModelConfig
from mflux.models.flux2 import Flux2Klein
from mlx_taef.integrations.mflux import LivePreviewCallback

model = Flux2Klein(quantize=4, model_config=ModelConfig.flux2_klein_base_4b())
preview = LivePreviewCallback(
    flux=model,  # the variant (here TAEF2) is inferred from the model; pass variant= to override
    every=5,
    save_to="preview.png",
    # latent_height / latent_width are auto-detected from the generation config;
    # pass both only if you want to override.
)
model.callbacks.register(preview)
model.generate_image(
    prompt="a red apple on a wooden table",
    num_inference_steps=25,
    width=512,
    height=512,
    seed=42,
)

What decides whether the picture is right:

  • flux=model picks the matching decoder from the model's mflux config (the FLUX.1, FLUX.2 Klein, Z-Image, Qwen-Image and Krea 2 families). variant= overrides it. A model outside those families raises when the callback is created, before the preview decoder loads, and names the override. Forcing variant= on a model outside those families can give a wrong picture with no error.
  • TAEF2 decodes the latent exactly as mflux hands it to the callback. When you passed flux=model, versions before 0.8.2 applied the Flux2 VAE's batch-norm inverse first, and previews came out dark and oversaturated. It is off by default; auto_bn=True with flux=model, or explicit bn_mean= / bn_var=, turn it on and log a warning.
  • A model that offers its prediction of the finished image (Krea 2 today) gets that decoded instead of the noisy in-loop latent. preview_source="latents" turns this off.
  • If a preview fails, the callback by default logs one warning, stops previewing for that generation, and lets mflux finish the image. Pass on_error="raise" to fail fast. The next generation starts previewing again.
  • Previews are approximate. mflux still makes the final image with its full decoder.

Frame-by-frame GIFs, the command that builds them, and how the callback picks its decoder and handles errors are on the mflux live previews page. EXAMPLES.md holds captured frames, final images and, for most models, the measured gain, with runnable scripts in examples/.

Variants

mlx-taef ports madebyollin's TAESD family of tiny autoencoders to MLX, plus a port of taew2.1 for Qwen-Image and Krea 2. All share one API.

Variant latent_channels For HF source
TAESD 4 Stable Diffusion 1.x madebyollin/taesd
TAESDXL 4 Stable Diffusion XL madebyollin/taesdxl
TAEF1 16 FLUX.1 madebyollin/taef1
TAEF2 32 FLUX.2 Klein madebyollin/taef2
ZImage 16 Z-Image / Z-Image-Turbo (shares the FLUX.1 16-ch latent contract) reuses madebyollin/taef1
QwenImage 16 Qwen-Image / Qwen-Image-Edit (Wan 2.1 VAE 16-ch latent) ionden/taew2.1
Krea2 16 Krea 2 Turbo (generates on the Qwen-Image stack, shares its Wan 2.1 VAE) reuses ionden/taew2.1

Status

v0.9.2 — released on PyPI (2026-11-15). Setting LivePreviewCallback.save_to to a string after the callback is created now works the same as passing it to the constructor. Older releases are in the release history.

More

Questions and results go to GitHub Discussions; bugs go to Issues.

License

MIT. Mirrors upstream madebyollin/taesd license. Pretrained weights belong to their respective authors (madebyollin).

Acknowledgements

Sister projects

Other MLX libraries for Apple Silicon:

  • mlx-teacache — TeaCache residual caching to skip redundant FLUX denoising steps.
  • mlx-model-doctor — validate an MLX / Hugging Face model repo before you load it (config, tokenizer, safetensors, memory).
  • mlx-quant-fidelity — measure how much quality a quantization costs (KL divergence, top-token flips, perplexity delta).

By Denis Ineshin · ineshin.space

About

Tiny AutoEncoders (TAESD family) for diffusion latents on Apple Silicon — pure MLX. Live previews + low-memory decode for FLUX.1, FLUX.2 Klein, SD1.x, SDXL.

Topics

Resources

Contributing

Stars

13 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages