Skip to content

Studio: send Decision API images to the MLX engine for Clef - #13126

Merged
danielhanchen merged 3 commits into
unslothai:mainfrom
Lyxot:mlx-decision-images-serving
Oct 9, 2026
Merged

danielhanchen merged 3 commits into
unslothai:mainfrom
Lyxot:mlx-decision-images-serving

Conversation

@Lyxot

@Lyxot Lyxot commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

What this changes

On Apple Silicon, Unsloth Studio now answers Decision API requests that carry images through the MLX engine for a Clef, where they previously always went to llama.cpp.

  • Auto and the MLX runtime send a request's images to the MLX engine when the model's MLX form is a Clef with its vision tower and processor (stock Clef repos; a local Clef folder whose config.json has vision_config and that has a processor config).
  • input_modalities reports image for such a model when MLX is ready.
  • The engine gets only the request's images array, which the route has already checked (count, PNG/JPEG, byte and pixel limits). Image parts inside a chat-message state keep a request off MLX exactly as before, so nothing unvalidated is decoded in the server process.
  • Every other model keeps today's routing: OpenJev, Lev, Nimble and Kev images still go to llama.cpp under Auto and are refused under the MLX runtime, and an unsloth-zoo that reads no images behaves as before.
  • The MLX runtime description in the Decision API settings is updated in all locales.

Depends on unslothai/unsloth-zoo#1645 for the engine support; without it this change is inert.

Validation

python -m pytest studio/backend/tests/test_decision_serving.py studio/backend/tests/test_decision_native.py -q
# 90 passed

The new routing decisions are covered by test_a_clef_with_its_vision_tower_reads_images_through_the_mlx_engine; each decision was checked by breaking it and confirming the test fails. On the engine side, real Clef Flash answers image requests on MLX in under a second.

Risks

  • For a local Clef whose llama.cpp export has no vision projector, input_modalities can report image while Auto still picks a resident llama.cpp server, which then refuses the image. That refusal predates this change.
  • The frontend change is locale strings only and was not exercised in a built UI.

On Apple Silicon a Clef whose MLX form has its vision tower and processor now answers requests with images through the MLX engine, under Auto and under the MLX runtime, and reports the image modality. The engine gets only the request's `images`, which the route has already checked; image parts inside a chat-message state keep a request off MLX as before. Every other model, and an unsloth-zoo that reads no images, keeps today's routing.
@Lyxot
Lyxot requested a review from danielhanchen as a code owner October 9, 2026 07:55
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-10-09T07:55:31.493305Z 6b34528 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-09T12:59:52.411118Z fcc82b2 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Lyxot Lyxot added the MLX label Oct 9, 2026
@Lyxot

Lyxot commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b34528a1d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

…vision projector

Under Auto a resident llama.cpp server kept every request, so an image for a Clef whose GGUF export has no vision projector was refused there although the model is reported as reading images through MLX. Such a request now goes to the MLX engine; text, and images the llama.cpp form can read, stay where they were.
@Lyxot

Lyxot commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: fcc82b2cb7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Lyxot

Lyxot commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator Author

Codex review converged at fcc82b2cb7: #13126 (comment)

What changed during review: under Auto, a request with images that MLX reads now goes to the MLX engine when the llama.cpp form of the entry has no vision projector, instead of staying on a resident llama.cpp server and being refused. Text requests, and images the llama.cpp form can read, keep their routing, so the advertised modality and the selected backend agree.

CI at fcc82b2cb7: 48 passed, 6 failed, none in decision code. Every failing job also fails on main at cc912813:

  • Frontend CI, "Locale parity": missing browser.* keys in the locale overlays, which this PR does not touch.
  • Core, "Core zoo" (3 lanes): CUDA-only tests of unsloth-zoo main on a CPU runner.
  • Backend CI, "Repo tests (CPU, studio)" and "(Python 3.13, a-k)": the failing test names are the same set that fails on main. One extra failure in the first run (test_openai_tool_passthrough ... proxy_disconnect_returns_499) passed on re-run.

studio/backend/tests/test_decision_serving.py and test_decision_native.py pass (90 tests).

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: fcc82b2cb7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen
danielhanchen merged commit e0e35a0 into unslothai:main Oct 9, 2026
SpatariuRares added a commit to SpatariuRares/unsloth that referenced this pull request Oct 18, 2026
…reads them

POST /v1/systemone validated images and then refused outright when the
configured model was a saved connection, and _connection_decide had no images
parameter to pass on. A multimodal System One server reached through a custom
connection could only be asked text questions, even though unslothai#13126 and unslothai#13471
gave the native Clef path images.

Images are forwarded now, but never on a guess: Studio cannot see what a
remote System One server accepts, so the owner declares it per connection
(input_modalities: ["text", "image"], stored for the configured connection
only, with a switch in Settings > API) and an undeclared connection keeps
refusing images with a message naming the setting. Declared or not,
_validate_images runs first, so a malformed, oversized, over-pixel or
non-PNG/JPEG image is refused before any provider is called, and remote URLs
are still never fetched. A provider that cannot read what it was sent fails
through _upstream_error as itself, with no silent text-only retry.

laya_runtime.input_modalities answers for a connection too, so
GET /api/settings/systemone, /v1/models and the try dialog agree with what
gets forwarded.

Try a decision gains an image example, "Read a screenshot", offered only when
the configured model reads images. Its PNG sits in its own module behind
import(), so the startup bundle never carries it.
SpatariuRares added a commit to SpatariuRares/unsloth that referenced this pull request Oct 18, 2026
…reads them

POST /v1/systemone validated images and then refused outright when the
configured model was a saved connection, and _connection_decide had no images
parameter to pass on. A multimodal System One server reached through a custom
connection could only be asked text questions, even though unslothai#13126 and unslothai#13471
gave the native Clef path images.

Images are forwarded now, but never on a guess: Studio cannot see what a
remote System One server accepts, so the owner declares it per connection
(input_modalities: ["text", "image"], stored for the configured connection
only, with a switch in Settings > API) and an undeclared connection keeps
refusing images with a message naming the setting. Declared or not,
_validate_images runs first, so a malformed, oversized, over-pixel or
non-PNG/JPEG image is refused before any provider is called, and remote URLs
are still never fetched. A provider that cannot read what it was sent fails
through _upstream_error as itself, with no silent text-only retry.

laya_runtime.input_modalities answers for a connection too, so
GET /api/settings/systemone, /v1/models and the try dialog agree with what
gets forwarded.

Try a decision gains an image example, "Read a screenshot", offered only when
the configured model reads images. Its PNG sits in its own module behind
import(), so the startup bundle never carries it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants