Skip to content

Add FLUX.2-dev support with Mistral text encoder - #45

Closed
marcelcotta wants to merge 1 commit into
antirez:mainfrom
marcelcotta:flux2-dev
Closed

Add FLUX.2-dev support with Mistral text encoder#45
marcelcotta wants to merge 1 commit into
antirez:mainfrom
marcelcotta:flux2-dev

Conversation

@marcelcotta

Copy link
Copy Markdown

Summary

  • Adds full FLUX.2-dev (32B) inference support using Mistral-Small-3.2-24B as text encoder (layers 10/20/30, 15360-dim output + pooled embedding)
  • Guidance-distilled: embeds guidance scale directly in transformer (no CFG needed), default 30 steps with guidance 3.5
  • Auto-detected from transformer config (guidance_embeds: true)

New files

  • iris_mistral.c/h — Mistral-Small-3.2-24B encoder implementation
  • iris_mistral_tokenizer.c — Mistral BPE tokenizer (SentencePiece-style)

Transformer changes

  • Guidance and text pooled embedders (time_text_embed.* weight naming)
  • Tensor name fallback chain for dev vs klein weight files
  • Chunked attention for large sequences (keeps GPU score matrix small)
  • Multiref RoPE caching across denoising steps
  • BF16/F16 warmup dispatch for M1/M2 vs M3+ hardware

Other changes

  • Batch generation mode (-N flag) and --step-dir for file-based step previews
  • SDPA forward declaration for macOS 14 SDK compatibility
  • README documentation (architecture, download, memory, usage)

Test plan

  • Build with make mps / make blas
  • Run with existing Klein 4B model (regression test)
  • Download FLUX.2-dev weights and run: ./iris -d flux-2-dev -p "a cat" -o /tmp/test.png
  • Verify auto-detection works from model config
  • Test batch mode: ./iris -d flux-klein-4b -p "a cat" -N 3 -o /tmp/batch.png

FLUX.2-dev is a 32B parameter model by Black Forest Labs that uses a
different architecture from the existing Klein variants:

- Text encoder: Mistral-Small-3.2-24B (layers 10/20/30, 15360-dim output
  + pooled embedding), instead of Qwen3
- Guidance: embedded directly in the transformer via a guidance embedder
  (guidance-distilled), no Classifier-Free Guidance needed
- Defaults: 30 steps, guidance scale 3.5

New files:
- iris_mistral.c/h: Mistral-Small-3.2-24B encoder implementation
- iris_mistral_tokenizer.c: Mistral BPE tokenizer (SentencePiece-style)

Transformer changes:
- Guidance and text pooled embedders (time_text_embed naming convention)
- Tensor name fallback for dev vs klein weight files
- Chunked attention for large sequences (keeps score matrix small)
- Multiref RoPE caching across denoising steps
- BF16/F16 warmup dispatch for M1/M2 vs M3+ hardware

Other changes:
- Auto-detection via guidance_embeds config field
- Batch generation mode (-N flag) and --step-dir for file-based previews
- SDPA forward declaration for macOS 14 compatibility
- README documentation for model architecture, download, and usage
@marcelcotta
marcelcotta deleted the flux2-dev branch February 27, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant