[PR #13725] [MERGED] x/imagegen: clean up image generation code #14364

Closed
opened 2026-04-13 00:51:47 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/13725
Author: @jmorganca
Created: 1/15/2026
Status: Merged
Merged: 1/16/2026
Merged by: @jmorganca

Base: mainHead: imagegen-fixes


📝 Commits (10+)

  • 4896240 fix: imagegen models now properly expire after keepalive timeout
  • 7273d99 fix: log errors in imagegen generate handler instead of discarding
  • 9e1d79a refactor: consolidate imagegen default constants
  • d9ae425 refactor: remove unused HasTensorLayers wrapper function
  • 8485b65 docs: clarify no-op interface methods in imagegen server
  • 9d07e26 fix: capture multiple stderr lines for better error reporting
  • 7528451 feat: add OpenAI-compatible size field and model-specific steps
  • 55ad77e refactor: let models declare their own default dimensions
  • 5c0233a refactor: unify imagegen with standard Completion interface
  • 70b5ae6 simplify runner request/response

📊 Changes

14 files changed (+260 additions, -504 deletions)

View changed files

📝 llm/server.go (+10 -0)
📝 server/routes.go (+58 -33)
📝 server/sched_test.go (+57 -27)
x/imagegen/api/handler.go (+0 -231)
x/imagegen/api/types.go (+0 -31)
📝 x/imagegen/cli.go (+6 -72)
📝 x/imagegen/cmd/engine/main.go (+2 -1)
📝 x/imagegen/manifest.go (+60 -0)
📝 x/imagegen/memory.go (+0 -5)
📝 x/imagegen/memory_test.go (+0 -7)
📝 x/imagegen/models/qwen_image/qwen_image.go (+2 -1)
📝 x/imagegen/models/zimage/zimage.go (+1 -1)
📝 x/imagegen/runner/runner.go (+2 -10)
📝 x/imagegen/server.go (+62 -85)

📄 Description

This is the first of a few PRs to clean up image generation code and integrate it better into the existing runner:

  1. Image generation models would not get unloaded
  2. The OpenAI-compatible API did not use the correct size parameter

There's still work to do to fix the /api/generate (or similar API to allow for image generation), a few branches in the scheduler to simplify.


🔄 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/13725 **Author:** [@jmorganca](https://github.com/jmorganca) **Created:** 1/15/2026 **Status:** ✅ Merged **Merged:** 1/16/2026 **Merged by:** [@jmorganca](https://github.com/jmorganca) **Base:** `main` ← **Head:** `imagegen-fixes` --- ### 📝 Commits (10+) - [`4896240`](https://github.com/ollama/ollama/commit/48962405286116953c85e94694addd0605785997) fix: imagegen models now properly expire after keepalive timeout - [`7273d99`](https://github.com/ollama/ollama/commit/7273d9925e1a15b1b5152c9a0c9570e937078b20) fix: log errors in imagegen generate handler instead of discarding - [`9e1d79a`](https://github.com/ollama/ollama/commit/9e1d79ac67f221c4148ab2d937a0ff3711db8d3e) refactor: consolidate imagegen default constants - [`d9ae425`](https://github.com/ollama/ollama/commit/d9ae425d54d12f858fee270f24f4bbdbaeaf79f7) refactor: remove unused HasTensorLayers wrapper function - [`8485b65`](https://github.com/ollama/ollama/commit/8485b6546e3f7c120f7b8ea4818ddbad2009c40e) docs: clarify no-op interface methods in imagegen server - [`9d07e26`](https://github.com/ollama/ollama/commit/9d07e26b628e5dc7c23c030db6cbc280b072e71d) fix: capture multiple stderr lines for better error reporting - [`7528451`](https://github.com/ollama/ollama/commit/7528451a1c7af696caabdd63651b4359d2577b04) feat: add OpenAI-compatible size field and model-specific steps - [`55ad77e`](https://github.com/ollama/ollama/commit/55ad77e236a1982393bb4da1549e419aad61eada) refactor: let models declare their own default dimensions - [`5c0233a`](https://github.com/ollama/ollama/commit/5c0233a27153011c990bb6a1325297bdc25569f2) refactor: unify imagegen with standard Completion interface - [`70b5ae6`](https://github.com/ollama/ollama/commit/70b5ae621622afe4a4316d0feb653654915dcf0e) simplify runner request/response ### 📊 Changes **14 files changed** (+260 additions, -504 deletions) <details> <summary>View changed files</summary> 📝 `llm/server.go` (+10 -0) 📝 `server/routes.go` (+58 -33) 📝 `server/sched_test.go` (+57 -27) ➖ `x/imagegen/api/handler.go` (+0 -231) ➖ `x/imagegen/api/types.go` (+0 -31) 📝 `x/imagegen/cli.go` (+6 -72) 📝 `x/imagegen/cmd/engine/main.go` (+2 -1) 📝 `x/imagegen/manifest.go` (+60 -0) 📝 `x/imagegen/memory.go` (+0 -5) 📝 `x/imagegen/memory_test.go` (+0 -7) 📝 `x/imagegen/models/qwen_image/qwen_image.go` (+2 -1) 📝 `x/imagegen/models/zimage/zimage.go` (+1 -1) 📝 `x/imagegen/runner/runner.go` (+2 -10) 📝 `x/imagegen/server.go` (+62 -85) </details> ### 📄 Description This is the first of a few PRs to clean up image generation code and integrate it better into the existing runner: 1. Image generation models would not get unloaded 2. The OpenAI-compatible API did not use the correct `size` parameter There's still work to do to fix the `/api/generate` (or similar API to allow for image generation), a few branches in the scheduler to simplify. --- <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-13 00:51:47 -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#14364