[PR #13772] [MERGED] x/imagegen: add support for FLUX.2-klein model #45630

Closed
opened 2026-04-25 01:17:32 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/13772
Author: @jmorganca
Created: 1/19/2026
Status: Merged
Merged: 1/19/2026
Merged by: @jmorganca

Base: mainHead: jmorganca/flux2


📝 Commits (10+)

📊 Changes

20 files changed (+3285 additions, -380 deletions)

View changed files

📝 x/imagegen/cmd/engine/main.go (+57 -2)
📝 x/imagegen/image.go (+158 -0)
📝 x/imagegen/memory.go (+22 -11)
📝 x/imagegen/memory_test.go (+2 -3)
📝 x/imagegen/mlx/mlx.go (+21 -0)
x/imagegen/models/flux2/flux2.go (+539 -0)
x/imagegen/models/flux2/rope.go (+224 -0)
x/imagegen/models/flux2/scheduler.go (+149 -0)
x/imagegen/models/flux2/transformer.go (+562 -0)
x/imagegen/models/flux2/vae.go (+804 -0)
x/imagegen/models/qwen3/text_encoder.go (+390 -0)
📝 x/imagegen/models/qwen_image/qwen_image.go (+9 -12)
📝 x/imagegen/models/qwen_image_edit/qwen_image_edit.go (+7 -10)
📝 x/imagegen/models/zimage/text_encoder.go (+10 -280)
📝 x/imagegen/models/zimage/vae.go (+33 -14)
📝 x/imagegen/models/zimage/zimage.go (+29 -20)
📝 x/imagegen/runner/runner.go (+38 -24)
📝 x/imagegen/safetensors/loader.go (+10 -0)
📝 x/imagegen/tokenizer/tokenizer.go (+6 -4)
x/imagegen/vae/tiling.go (+215 -0)

📄 Description

Not fully optimized, this provides an implementation of FLUX.2-klein for image generation and image editing.

TODO in a future PR (before making this model available more broadly):

  1. Combine runner with z-image-turbo
  2. Clean up memory allocation in the pipeline
  3. Wire up image editing in API
  4. Test edge cases around memory utilization around image editing

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/13772 **Author:** [@jmorganca](https://github.com/jmorganca) **Created:** 1/19/2026 **Status:** ✅ Merged **Merged:** 1/19/2026 **Merged by:** [@jmorganca](https://github.com/jmorganca) **Base:** `main` ← **Head:** `jmorganca/flux2` --- ### 📝 Commits (10+) - [`c841e7b`](https://github.com/ollama/ollama/commit/c841e7b4df031e6551667312fe36f85e25fe3f26) wip flux2 - [`b995596`](https://github.com/ollama/ollama/commit/b995596a8cec8ece75e3eac4661219ef2e236168) fast-ish - [`bbaa837`](https://github.com/ollama/ollama/commit/bbaa837783692278c7281a59f19b173e50e7aa69) tiling - [`9e4492d`](https://github.com/ollama/ollama/commit/9e4492dcae83e7c52112b815be117d22e0a03128) load image metadata - [`34d94c0`](https://github.com/ollama/ollama/commit/34d94c0b588fdcdbaf6397179151a7044e82179b) cleanup - [`8bb3f6c`](https://github.com/ollama/ollama/commit/8bb3f6c6aba08403469113c0f16b12d473c11549) more cleanup - [`661e33f`](https://github.com/ollama/ollama/commit/661e33f093c31cc1aa1a0d98dce7fa4e998f8e70) simplify meta package - [`d766f24`](https://github.com/ollama/ollama/commit/d766f242e346f654c571c71e4db09438a82f7dcb) rebase - [`74136b0`](https://github.com/ollama/ollama/commit/74136b089d890f7860343188ff483041b1ac9677) remove comment - [`194ec5c`](https://github.com/ollama/ollama/commit/194ec5c83adb909e6a065bc3ed37f62be53e153d) use vae tiling for z-image-turbo ### 📊 Changes **20 files changed** (+3285 additions, -380 deletions) <details> <summary>View changed files</summary> 📝 `x/imagegen/cmd/engine/main.go` (+57 -2) 📝 `x/imagegen/image.go` (+158 -0) 📝 `x/imagegen/memory.go` (+22 -11) 📝 `x/imagegen/memory_test.go` (+2 -3) 📝 `x/imagegen/mlx/mlx.go` (+21 -0) ➕ `x/imagegen/models/flux2/flux2.go` (+539 -0) ➕ `x/imagegen/models/flux2/rope.go` (+224 -0) ➕ `x/imagegen/models/flux2/scheduler.go` (+149 -0) ➕ `x/imagegen/models/flux2/transformer.go` (+562 -0) ➕ `x/imagegen/models/flux2/vae.go` (+804 -0) ➕ `x/imagegen/models/qwen3/text_encoder.go` (+390 -0) 📝 `x/imagegen/models/qwen_image/qwen_image.go` (+9 -12) 📝 `x/imagegen/models/qwen_image_edit/qwen_image_edit.go` (+7 -10) 📝 `x/imagegen/models/zimage/text_encoder.go` (+10 -280) 📝 `x/imagegen/models/zimage/vae.go` (+33 -14) 📝 `x/imagegen/models/zimage/zimage.go` (+29 -20) 📝 `x/imagegen/runner/runner.go` (+38 -24) 📝 `x/imagegen/safetensors/loader.go` (+10 -0) 📝 `x/imagegen/tokenizer/tokenizer.go` (+6 -4) ➕ `x/imagegen/vae/tiling.go` (+215 -0) </details> ### 📄 Description Not fully optimized, this provides an implementation of FLUX.2-klein for image generation and image editing. TODO in a future PR (before making this model available more broadly): 1. Combine runner with z-image-turbo 2. Clean up memory allocation in the pipeline 3. Wire up image editing in API 4. Test edge cases around memory utilization around image editing --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-25 01:17:32 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#45630