Skip to content

Studio: stop hiding every model pulled with ollama pull - #10222

Merged
Imagineer99 merged 5 commits into
unslothai:mainfrom
NilayYadav:fix-ollama-metadata-layers-withheld
Sep 4, 2026
Merged

Imagineer99 merged 5 commits into
unslothai:mainfrom
NilayYadav:fix-ollama-metadata-layers-withheld

Conversation

@NilayYadav

Copy link
Copy Markdown
Collaborator

Studio hides an Ollama model if its manifest holds a layer type it does not load, and that list includes the template, params, system, messages and prompt layers that almost every pulled model has. The On Device section and the chat picker end up empty with the files sitting on disk and nothing saying why.

Those layers only hold Modelfile settings that never reach the load anyway. The adapter layer stays hidden because it changes the weights. Tested with a real ollama pull of qwen2.5:0.5b: the list showed zero Ollama rows before and one after.

@NilayYadav
NilayYadav force-pushed the fix-ollama-metadata-layers-withheld branch from 1879e4e to 2da65bc Compare September 2, 2026 20:12
@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

Focus on whether admitting these five Ollama metadata layer types is correct and complete, and iterate with me until this converges — I will keep pushing fixes and re-requesting review until you have no open findings.

Specific things worth attacking:

  1. template, params, system, messages and prompt carry Modelfile settings (chat template, stop tokens, system prompt). The direct llama.cpp load ignores all of them and uses the GGUF's own template and defaults instead. Is silently dropping them the right trade against hiding the row entirely, and is there any case where the dropped setting changes output enough that the row is misleading rather than merely different?
  2. Completeness of the admitted set against ollama's current media types: model, embed, adapter, projector, prompt, template, system, params, messages, license, tensor, draft, json. adapter stays out because it changes weights. Are draft (speculative decoding, output-equivalent) or embed (deprecated since ollama 0.1.2, ignored by ollama itself) wrongly withheld?
  3. The same gate runs for inventory (skip the row) and for the load path (raise). Anything that should differ between those two callers?
  4. _dir_has_downloaded_model in routes/models.py counts a folder for a recommended-folder chip using only the presence of a resolvable image.model layer, without this gate. Does the PR leave those two in agreement?

@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: 8b6eb633b6

ℹ️ 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".

Comment on lines +61 to +65
"application/vnd.ollama.image.template",
"application/vnd.ollama.image.params",
"application/vnd.ollama.image.system",
"application/vnd.ollama.image.messages",
"application/vnd.ollama.image.prompt",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve behavior-bearing metadata before admitting it

When a tag was built with a custom Modelfile—such as a SYSTEM persona, seeded MESSAGES, a custom TEMPLATE, or PARAMETER stop values—admitting these layers exposes the tag as loadable even though _ollama_model_info_from_manifest materializes only the model and projector blobs. Selecting that named Ollama tag therefore silently runs the base GGUF without behavior that may define the model, and a missing template or stop sequence can also corrupt chat turn boundaries. Preserve these settings during the llama.cpp load, or continue withholding manifests whose settings cannot be shown to match the GGUF defaults.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not taking this one, and the turn-boundary half of it does not hold for the case the PR is about.

I checked the exemplar rather than reasoning about it. A real ollama pull qwen2.5:0.5b writes image.model 397,807,936 B, image.system 68 B, image.template 1,482 B, image.license 11,343 B. Reading both sides of that store:

  • the GGUF carries its own tokenizer.chat_template, and it renders the same <|im_start|>system / <|im_start|>user structure the ollama Go template does. The two are not byte-equal because they are different template languages, not because they frame turns differently.
  • the 68-byte image.system layer is You are Qwen, created by Alibaba Cloud. You are a helpful assistant., which is the same default string the GGUF's own template emits when no system message is supplied.

So for a pulled tag the template and system layers are a re-expression of what the GGUF already carries, and dropping them does not corrupt turn boundaries. The case where a template layer is load-bearing is a GGUF with no embedded chat template of its own, and there the exposure is not specific to Ollama: Studio already lists any such .gguf sitting in a models folder or an HF cache and loads it the same way. This gate was the only place in the product holding that file to a stricter bar, and holding it there costs every normally pulled model.

The remedy as written also reinstates the defect. "Continue withholding manifests whose settings cannot be shown to match the GGUF defaults" is, in practice, withholding everything: proving a Go template and a Jinja template agree is not something the read-only inventory walk can do, and it would put a GGUF header read into scan_ollama_dir, which is the hot path the codebase deliberately keeps free of them (classification already does its header reads later, off the scan, in a thread).

The other remedy — actually carrying SYSTEM, TEMPLATE and PARAMETER stop into the llama.cpp load — is the right thing to want, and it is a feature rather than a fix: it needs Go-template translation and a params mapping, and it changes loads that work today. Worth its own PR; it should not gate restoring visibility for models that are already on disk.

The trade is stated where the decision is made, in the comment above _OLLAMA_METADATA_LAYER_MEDIA_TYPES.

Comment on lines +69 to +70
_OLLAMA_ADMITTED_LAYER_MEDIA_TYPES = (
_OLLAMA_LOADABLE_LAYER_MEDIA_TYPES | _OLLAMA_METADATA_LAYER_MEDIA_TYPES

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Admit ignorable draft and legacy embed layers

When a valid manifest includes application/vnd.ollama.image.draft or the legacy application/vnd.ollama.image.embed, this allowlist still classifies it as unsupported, so inventory hides the otherwise usable primary model and direct resolution rejects it. A draft model only accelerates output-equivalent speculative decoding, while Ollama itself has ignored the deprecated embed layer since 0.1.2, so dropping either does not prevent llama.cpp from loading the primary GGUF; the recommended-folder probe will nevertheless count such a manifest and can expose a chip whose picker is empty.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 703b9f829. Both are now admitted, in their own set rather than folded into the Modelfile-metadata one, because the reason differs: a draft model only feeds speculative decoding, which is output-equivalent by construction, and image.embed has been dead since ollama 0.1.2 and is ignored by ollama's own load (server/images.go logs "embeddings in modelfiles have been deprecated and will be ignored").

test_an_ignorable_layer_does_not_hide_the_primary_model covers each of the two. It fails on the previous head for both parameters and passes now.

The chip/picker point is right and is worth stating precisely: _dir_has_downloaded_model counts a folder on a resolvable image.model layer alone, without this gate, so before this PR it advertised a chip for every normally pulled model while scan_ollama_dir returned nothing for it. That disagreement is what the PR closes. It survives only for image.adapter and unknown future layers now, which is the intended conservative direction.

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

@codex review

703b9f829 takes the P2: image.draft and image.embed are admitted now, in their own set, with a parametrized test that fails on the previous head for both.

I did not take the P1, and the reply on that thread has the measurements — the short version is that a pulled tag's image.template and image.system re-express what the GGUF already carries, so dropping them does not move turn boundaries, and the proposed remedy would withhold every pulled model again.

This is the last round I plan unless something new lands, so please concentrate on whether the new set is wrong rather than restating the metadata trade: is a draft or embed layer ever load-bearing for the primary model, and does admitting them open any path where a row lists but cannot resolve?

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

GitHub Actions reproduction

Both branches run the same generated workflow, the same probe, the same runner image and the same ollama 0.33.2 binary, and differ only in the three files this PR touches. Each one does a real ollama pull qwen2.5:0.5b onto the runner and then asks Studio's own scan_ollama_dir() what it sees in that directory — no synthetic manifest anywhere in the loop.

What the pull actually wrote, identical on both sides:

layer bytes
application/vnd.ollama.image.model 397,807,936
application/vnd.ollama.image.system 68
application/vnd.ollama.image.template 1,482
application/vnd.ollama.image.license 11,343
  • main (c9f98db) — failing run:

    Skipping Ollama manifest .../manifests/registry.ollama.ai/library/qwen2.5/0.5b with unsupported
    runtime layers: application/vnd.ollama.image.system, application/vnd.ollama.image.template
    scan_ollama_dir() returned 0 row(s)
    REPRO-RESULT=DEFECT-REPRODUCED
    

    397 MB of weights on disk, zero rows, and the only trace is a debug log.

  • main + this PR at 703b9f829 — passing run:

    scan_ollama_dir() returned 1 row(s)
      display_name = 'qwen2.5:0.5b (494.03M Q4_K_M)'
      source       = ollama   format = gguf   runtime = llama_cpp
    resolved: .../ollama-store/.studio_links/20811e3646/qwen2.5-0.5b.gguf
    gguf size on disk: 397,807,936 bytes
    REPRO-RESULT=FIXED
    

    The row resolves through the real load path (materialize_ollama_model_ref) to a .gguf link over the same 397,807,936 bytes, so it is loadable and not just visible.

Unit-level A/B on the same trees: the two added tests fail on main and pass on the head, with the other 21 in the file unmoved (2 failed, 21 passed → 27 passed after this round's additions).

The negative side fails at the intended assertion, not on setup — both jobs completed the install, the pull and the probe.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 703b9f829c

ℹ️ 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".

@NilayYadav

Copy link
Copy Markdown
Collaborator Author

Studio UI before/after

Two isolated Studio installs on one machine — merge base c9f98dbd5 and head 703b9f829 — both pointed at the same OLLAMA_MODELS directory, holding one real ollama pull qwen2.5:0.5b. Same viewport (1500×1000, Chromium), same scene, same search term. Only the installed code differs.

PR 10222 On Device before/after

The On Device list, filtered to qwen:

  • BEFORE: every row is a Qwen3 safetensors entry out of the HF cache. The pulled model is on disk and absent from the list.
  • AFTER: qwen2.5:0.5b (494.03M Q4_K_M) sits in the list with an Ollama · GGUF · 0.5B subtitle, and its detail pane opens with On device · GGUF · Ollama and a live Run button.

Read from each photographed server's own /api/hub/local:

fact before after
rows_ollama 0 1
ollama_display_names [] ["qwen2.5:0.5b (494.03M Q4_K_M)"]
load_id is an ollama-manifest: ref [] [true]
rows_total 64 65

One caveat on reading the picture: the word "qwen" appears on both sides, because this box's HF cache holds a dozen Qwen3 repos. The row that moves is the Ollama one, which is what rows_ollama and ollama_display_names above count.

Also worth recording, since it is a property of the row rather than of the list: the Ollama row's task classifies as None, because _gguf_path_task keys on a .gguf suffix and an Ollama row's path is the extensionless content-addressed blob. It costs nothing here — the chat picker filters on NON_CHAT_TASKS, an exclusion set, so a null task still passes and the row reaches chat — but it does keep these rows out of the task-scoped pickers. That is pre-existing and orthogonal to this PR; it only becomes observable once the rows exist at all. Worth its own change.

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed against main: the loadable set in studio/backend/hub/services/models/ollama.py only admits model, projector and license, so the template and system layers a normal ollama pull writes drop the row entirely at the scan. Will get this reviewed.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 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-09-03T15:33:29.955960Z 60cce62 New commits
ℹ️ 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.

@Imagineer99 Imagineer99 self-assigned this Sep 3, 2026
@Imagineer99

Copy link
Copy Markdown
Member

Tested this against the current PR head with a real ollama pull qwen2.5:0.5b.

Before, Studio found nothing. After, the model showed up and resolved to the original GGUF, while unsupported layers stayed blocked.

Also confirmed in the UI: 0 rows before, 1 after. The PR fixes the reported issue without weakening the existing layer checks.

@Imagineer99

Copy link
Copy Markdown
Member

Tested against the current head with a real Ollama pull. The issue reproduces on base and is fixed here, while unsupported layers remain rejected. CI is green. Looks good to merge.

@Imagineer99
Imagineer99 merged commit 04bce46 into unslothai:main Sep 4, 2026
37 checks passed
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.

4 participants