[PR #13659] [MERGED] Add z-image for image generation prototype #24861

Closed
opened 2026-04-19 17:51:02 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/13659
Author: @jmorganca
Created: 1/9/2026
Status: Merged
Merged: 1/10/2026
Merged by: @jmorganca

Base: mainHead: jmorganca/z-image


📝 Commits (10+)

  • 6263e16 imagegen: wire up z-image
  • c880eda fix mlx build tags and stub
  • f88287f add flags and more checks
  • 0ec682f add transfer code for image generation
  • 55bc749 undo change to server/internal/client
  • 9db0658 fix capability name
  • 2c4ad15 use json mime type for json files
  • 9364f55 fix build
  • 0b1bbf7 cleanup
  • 55b4331 add some basic compatibility tests to x/imagegen/server

📊 Changes

44 files changed (+6417 additions, -264 deletions)

View changed files

📝 Dockerfile (+0 -4)
📝 cmd/cmd.go (+23 -0)
progress/stepbar.go (+33 -0)
📝 runner/runner.go (+10 -2)
📝 server/images.go (+180 -3)
📝 server/images_test.go (+9 -0)
📝 server/layer.go (+5 -0)
📝 server/routes.go (+34 -0)
📝 server/sched.go (+51 -0)
📝 server/sched_test.go (+60 -0)
📝 types/model/capability.go (+7 -6)
📝 x/imagegen/README.md (+213 -38)
x/imagegen/api/handler.go (+235 -0)
x/imagegen/api/types.go (+31 -0)
x/imagegen/cli.go (+539 -0)
x/imagegen/client/create.go (+130 -0)
x/imagegen/cmd/engine/README.md (+35 -0)
📝 x/imagegen/cmd/engine/main.go (+1 -1)
x/imagegen/create.go (+183 -0)
x/imagegen/image.go (+107 -0)

...and 24 more files

📄 Description

This PR adds experimental support for image generation using the Z-Image model, powered by an MLX-based runner. This is not optimized. Both VRAM usage and generation speed will improve dramatically in future iterations. This is a start to iterate on.

New Components

All components are in x/imagegen/ as the tensor model format is still under development:

  1. CLI (x/imagegen/cli.go) - ollama run z-image "prompt" support with progress display
  2. API (x/imagegen/api/) - OpenAI-compatible /v1/images/generations endpoint
  3. Create/Format (x/imagegen/create.go, x/imagegen/client/) - Tensor model creation (currently client-side, not server-side)
  4. Transfer (x/imagegen/transfer/) - Optimized downloader/uploader for many-blob tensor format while adhering to OCI registry spec
  5. Runner (x/imagegen/runner/) - MLX-based image generation subprocess

These will be integrated into their respective parts of Ollama (cmd/, api/, server/) as we iterate on imagegen models and stabilize the format.

What's Missing

  • Only Z-Image model works currently
  • No Ollama-native API yet (only OpenAI-compatible)
  • Push is slow when publishing manifests (many blobs)
  • No unified diffusion pipeline (model-specific code) which we'd need to fix before adding optimizations

Usage

# import from safetensors
cd Z-Image-Turbo/
ollama create z-image-turbo

# Generate an image
ollama run z-image-turbo "a sunset over mountains"

# API
curl -s http://localhost:11434/v1/images/generations \
    -d '{"model": "z-image", "prompt": "a white cat"}' \
    | jq -r '.data[0].b64_json' | base64 -d > image.png

🔄 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/13659 **Author:** [@jmorganca](https://github.com/jmorganca) **Created:** 1/9/2026 **Status:** ✅ Merged **Merged:** 1/10/2026 **Merged by:** [@jmorganca](https://github.com/jmorganca) **Base:** `main` ← **Head:** `jmorganca/z-image` --- ### 📝 Commits (10+) - [`6263e16`](https://github.com/ollama/ollama/commit/6263e16a6efecad372f30cb94657bd048a79de37) imagegen: wire up z-image - [`c880eda`](https://github.com/ollama/ollama/commit/c880eda734bbcac686428ff154c628de381061d4) fix mlx build tags and stub - [`f88287f`](https://github.com/ollama/ollama/commit/f88287fbdf2fb5f00d4d4feff126571f5b35f32d) add flags and more checks - [`0ec682f`](https://github.com/ollama/ollama/commit/0ec682f6e3b96a18badd0c267c769902162ed324) add transfer code for image generation - [`55bc749`](https://github.com/ollama/ollama/commit/55bc749f47adede2db68e4c00cce001d7ae7548a) undo change to server/internal/client - [`9db0658`](https://github.com/ollama/ollama/commit/9db06585bd209283b83be5aa000b3d962c7cf639) fix capability name - [`2c4ad15`](https://github.com/ollama/ollama/commit/2c4ad15e2036ce7f494e8bfe3f5689e8023b2648) use json mime type for json files - [`9364f55`](https://github.com/ollama/ollama/commit/9364f552b66460e59e09ded8180f31055b2b2ff3) fix build - [`0b1bbf7`](https://github.com/ollama/ollama/commit/0b1bbf706c45b058a733a68d754f8988be0c304c) cleanup - [`55b4331`](https://github.com/ollama/ollama/commit/55b43318cec09bee8f879fbbfded3910baed25e5) add some basic compatibility tests to x/imagegen/server ### 📊 Changes **44 files changed** (+6417 additions, -264 deletions) <details> <summary>View changed files</summary> 📝 `Dockerfile` (+0 -4) 📝 `cmd/cmd.go` (+23 -0) ➕ `progress/stepbar.go` (+33 -0) 📝 `runner/runner.go` (+10 -2) 📝 `server/images.go` (+180 -3) 📝 `server/images_test.go` (+9 -0) 📝 `server/layer.go` (+5 -0) 📝 `server/routes.go` (+34 -0) 📝 `server/sched.go` (+51 -0) 📝 `server/sched_test.go` (+60 -0) 📝 `types/model/capability.go` (+7 -6) 📝 `x/imagegen/README.md` (+213 -38) ➕ `x/imagegen/api/handler.go` (+235 -0) ➕ `x/imagegen/api/types.go` (+31 -0) ➕ `x/imagegen/cli.go` (+539 -0) ➕ `x/imagegen/client/create.go` (+130 -0) ➕ `x/imagegen/cmd/engine/README.md` (+35 -0) 📝 `x/imagegen/cmd/engine/main.go` (+1 -1) ➕ `x/imagegen/create.go` (+183 -0) ➕ `x/imagegen/image.go` (+107 -0) _...and 24 more files_ </details> ### 📄 Description This PR adds experimental support for image generation using the Z-Image model, powered by an MLX-based runner. **This is not optimized.** Both VRAM usage and generation speed will improve dramatically in future iterations. This is a start to iterate on. ### New Components All components are in `x/imagegen/` as the tensor model format is still under development: 1. **CLI** (`x/imagegen/cli.go`) - `ollama run z-image "prompt"` support with progress display 2. **API** (`x/imagegen/api/`) - OpenAI-compatible `/v1/images/generations` endpoint 3. **Create/Format** (`x/imagegen/create.go`, `x/imagegen/client/`) - Tensor model creation (currently client-side, not server-side) 4. **Transfer** (`x/imagegen/transfer/`) - Optimized downloader/uploader for many-blob tensor format while adhering to OCI registry spec 5. **Runner** (`x/imagegen/runner/`) - MLX-based image generation subprocess These will be integrated into their respective parts of Ollama (`cmd/`, `api/`, `server/`) as we iterate on imagegen models and stabilize the format. ### What's Missing - Only Z-Image model works currently - No Ollama-native API yet (only OpenAI-compatible) - Push is slow when publishing manifests (many blobs) - No unified diffusion pipeline (model-specific code) which we'd need to fix before adding optimizations ### Usage ```bash # import from safetensors cd Z-Image-Turbo/ ollama create z-image-turbo # Generate an image ollama run z-image-turbo "a sunset over mountains" # API curl -s http://localhost:11434/v1/images/generations \ -d '{"model": "z-image", "prompt": "a white cat"}' \ | jq -r '.data[0].b64_json' | base64 -d > image.png ``` --- <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-19 17:51:02 -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#24861