Skip to content

Unsloth Studio: pick, load and generate images on a linked instance - #18332

Open
danielhanchen wants to merge 4 commits into
studio-linked-instances-settingsfrom
studio-linked-instances-images
Open

danielhanchen wants to merge 4 commits into
studio-linked-instances-settingsfrom
studio-linked-instances-images

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Generate images on a linked machine from the Images page: the model picker gets a machine switch beside On Device, and picking @name lists that machine's image models. A pick loads there, and the page follows that machine until you pick a model on another one.

Split from #12093 and #12388 (by @LeoBorcherding), rebased on current main. Stacked on #18311.

What it does

  • Machine switch in the Images picker, shown to owners with at least one linked instance. On a linked machine the picker lists the image catalog with what is downloaded there and how it fits that machine's GPU pool; GGUF rows expand to the remote's own quant files.
  • The page follows the machine: status, load progress, generation, Stop, the queue, the gallery, LoRAs, ControlNets and embeddings go to the picked machine through /api/linked-instances/{id}/proxy/.... The trigger shows @name next to the model.
  • Guards: the machine never changes under a running load, generation or queued run; a Download only pick of a linked model is refused (it would download to this machine); a removed instance falls back to this machine.
  • First-use notice, once per instance address, before the first job goes there. It says prompts, files and images are processed on that machine, and adds that Cloudflare relays the traffic for a tunnel link.

Proxy

  • Owner-only, UI session only. It reaches only the Images routes (api/inference/images/...) and the model lists the picker reads (api/hub/cached-gguf, cached-models, gguf-variants, api/models/diffusion-*). Chat loads, downloads, settings, keys and training stay unreachable.
  • Relayed bodies keep only media types; anything else is sent as an attachment with nosniff and a sandbox CSP. Gallery URLs are rewritten to the proxy path, gallery ids are URL-encoded, and authenticated gallery fetches refuse any URL off this Studio, so the owner's token never goes to the remote.

Not in this PR

Chat on a linked machine. main replaced the chat model picker with the composer picker, so picking linked chat models needs its own design there; @name/model already works over the API (#18310).

Tests

  • Backend: tests/test_linked_instances.py (69 tests, including the proxy allowlist and relay rules) and the account matrix entries for the proxy routes.
  • Frontend: typecheck clean; npm test gives the same 2 failures as main (16,692 tests here).
  • Live run: a real Studio built from this branch, linked to a recording fake remote. In the Images picker the machine switch lists @wsl, switching shows its catalog with its GPU (RTX 4090, 24 GB), and picking Z-Image-Turbo shows the notice once. After confirming, the remote received POST /api/inference/images/load with unsloth/Z-Image-Turbo, followed by its load-progress, status, queue and gallery reads.

The Images model picker gets a machine switch beside On Device when the
owner has linked instances. Picking @name lists that machine's image
models; a pick loads there and the page (status, progress, queue,
gallery, LoRAs, ControlNets, embeddings) follows that machine through an
owner-only proxy limited to the Images routes and model lists. A
one-time notice per instance address says what is sent there. The page
falls back to this machine when the instance is removed, and never
switches machines under a running load, generation or queued run.

Split from #12093 and #12388.

Co-authored-by: LeoBorcherding <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

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

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-18T13:29:46.307046Z
We couldn’t complete this review. Comment @codex review to try again.
5d60555 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.

# Conflicts:
#	studio/frontend/src/features/model-picker/components/model-selector.tsx
danielhanchen added a commit that referenced this pull request Nov 18, 2026
…18357)

## Summary

Six tests in `unsloth_cli/tests/test_eval.py` fail on main since #18319:

```
FAILED test_dataset_task_avoids_explicit_yaml_name[True-.yaml]   (and the other 3 params)
FAILED test_standalone_yaml_is_copied_alone           - assert ['task_0.yaml'] == ['my_task.yaml']
FAILED test_eval_dataset_before_yaml_with_same_task_name - Error: unknown task 'qa'
```

They show up on every PR's CPU test run (for example on the staging runs
for #18332, #18334 and #18338).

## Cause

#18319 stages a standalone custom task YAML as `task_<n>.yaml` instead
of `<task name>.yaml`, so a task name like `../../x` cannot write
outside the staging directory. That change is correct. lm-eval names
tasks by the `task:` / `group:` key inside each file, not by the file
name: `lm_eval/tasks/_index.py` globs `**/*.yaml` and registers
`cfg["task"]` or `cfg["group"]` (checked against lm-eval 0.4.13). The
task name the user passes and sees is unchanged.

The tests were wrong in two ways:

- The fake `TaskManager` used by the CLI integration tests indexed tasks
by `p.stem`. Real lm-eval does not, so a correctly staged `task_1.yaml`
holding `task: qa` read as an unknown task.
- Two unit tests pinned the old staged file name (`custom/qa.yaml`,
`["my_task.yaml"]`).

## Fix

Test-only:

- The fake `TaskManager` now indexes each YAML under the include path by
its in-file `group:` / `task:` key, the same way lm-eval does.
- The two unit tests now check what lm-eval actually reads: exactly one
staged `.yaml`, whose content matches the source file and whose `task:`
key is the requested name.

## Verification

| `unsloth_cli/commands/eval.py` | old tests | these tests |
|---|---|---|
| main (#18319 staging) | 6 failed, 107 passed | 113 passed |
| before #18319 (`<name>.yaml` staging) | 113 passed | 113 passed |
| staged copy has the wrong `task:` key (sabotage) | n/a | 6 failed, 107
passed |

`tests/test_eval_custom_task_staging.py` from #18319 still passes. ruff
check is clean.
danielhanchen added a commit that referenced this pull request Nov 18, 2026
…18361)

## Summary

Two coverage tests in
`studio/backend/tests/test_mlx_inference_backend.py` fail against
current unsloth-zoo main:

```
FAILED test_the_stub_answers_every_helper_zoo_imports_from_inference
  AssertionError: zoo imports ['_first_resolved'] from mlx.inference and the stub cannot answer them
FAILED test_the_stub_accepts_every_call_zoo_makes_to_an_inference_helper
  AttributeError: _first_resolved
```

This shows up on the macOS MLX job for every PR (for example the staging
run for #18332).

## Cause

unslothai/unsloth-zoo#2586 (mlx-vlm 0.8.0 support) has
`unsloth_zoo/mlx/speculative.py` import `_first_resolved` from
`mlx.inference` for the Qwen4 head replay. `_first_resolved` tries
several binding contracts through `_resolved_bindings` and returns the
first that resolves.

The zoo change is correct. These two tests exist to flag a new helper
that the stub of `unsloth_zoo.mlx.inference` cannot answer, and they
did.

## Fix

Map `_first_resolved` to `_no_replay`, next to its sibling
`_resolved_bindings`. The stub has no Metal or QSA cache, so "no replay
can be bound" is the right answer, the same one the other head-replay
helpers give.

## Verification

Run on this Linux host. It has no `mlx_lm` / `mlx_vlm`, so 8 tests that
need them fail on both sides, unchanged:

| Tree (zoo main `e9728df56`) | Result |
|---|---|
| main | 10 failed: the 8 host-only ones plus the two above |
| this branch | 8 failed: the host-only ones only |

The branch also passes the two tests against zoo from before #2586. ruff
is clean.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant