Skip to content

Exclude the imatrix from the local models route too - #9411

Merged
danielhanchen merged 7 commits into
mainfrom
studio-imatrix-local-model-routes
Aug 21, 2026
Merged

danielhanchen merged 7 commits into
mainfrom
studio-imatrix-local-model-routes

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Follow-up to #9409, which is merged. Two Codex items on that PR landed after the merge; both are real and are fixed here.

GET /models/local kept its own copy of the rule

routes/models.py defines its own _is_main_gguf_filename and _is_model_directory. Its docstring says "Same rule as hub.services.models.common", but the hub-side exclusion in #9409 did not reach it, so the model picker (GET /models/local -> collect_local_models -> _scan_models_dir / _dir_model_format) still surfaced a standalone imatrix_unsloth.gguf, or an imatrix-only folder, as a loadable GGUF model. Reachable whenever a unsloth/*-GGUF repo is fetched outside Studio into the models dir, since those repos ship the imatrix beside the weights.

Both now take the loader's _is_imatrix_path rather than a fourth spelling of the rule, matching how they already import _is_mtp_drafter.

The diffusion LoRA filter was wider than its purpose

The exclusion belongs to the .gguf fallback pick: an imatrix is a GGUF holding no adapter. #9409 applied it to the whole repo listing, which also filtered .safetensors candidates, so a LoRA repo whose only weight leads with the token (imatrix-tuned.safetensors) resolved to FileNotFoundError. A .safetensors is never an imatrix, so the candidate list is left alone and only the fallback is filtered.

Tests

Three cases added to studio/backend/tests/test_imatrix_gguf_filtering.py. The two bug cases fail without this change and pass with it; the third pins the behaviour that must not regress (an imatrix is still never the LoRA .gguf fallback).

ruff check studio passes; tests/test_imatrix_gguf_filtering.py and tests/test_diffusion_lora.py are green (57 passed).

GET /models/local keeps its own copies of these predicates in routes/models.py,
so #9409 left a standalone imatrix_unsloth.gguf, and an imatrix-only folder,
still offered in the picker as loadable GGUF models. _is_main_gguf_filename and
_is_model_directory now take the same _is_imatrix_path the loader uses instead
of a fourth spelling of the rule.

Narrow the diffusion LoRA filter to the .gguf fallback it was written for. An
imatrix is a GGUF holding no adapter; a .safetensors never is, so filtering the
whole listing also dropped safetensors candidates and a repo whose only weight
led with the token resolved to FileNotFoundError.
danielhanchen added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Aug 20, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

pre-commit-ci Bot and others added 3 commits August 20, 2026 16:37
The child scanners decide presence from any .gguf, not from the predicates, so
a models dir or LM Studio folder holding only imatrix_unsloth.gguf published a
row a loader cannot start. An interrupted download reaches that state easily:
the imatrix is the smallest file in the repo.

Presence now asks _servable_gguf_names, which drops an imatrix and keeps mmproj
and MTP drafters. Those are companions of a real model and the scanners have
always let them decide presence but never format, so that line stays where it
is.
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member 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: 3fc2dac696

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

continue

gguf_names = [p.name for p in child.glob("*.gguf") if not is_appledouble_metadata(p)]
gguf_names = _servable_gguf_names(child)

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 Do not let config bypass the imatrix filter

For an imatrix-only child that also contains config.json—the layout from the original report—_servable_gguf_names is empty, but _scan_models_dir still accepts the directory through the independent has_config disjunct on line 398; the nested LM Studio branch does the same on line 640. The folder therefore remains exposed by GET /models/local with model_format = None even though it has no loadable weights. Fresh evidence after the claimed fix is that the added scanner tests omit config.json, so they never exercise these surviving disjuncts.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Checked this against the scanner rather than the diff, and the config disjunct is not an imatrix filter to bypass. A child holding a config and nothing loadable has always been listed with model_format None, and it lists identically with no .gguf present at all:

ROW: CheckpointOnlyConfig | format: None      # config.json only
ROW: ImatrixPlusConfig    | format: None      # config.json + imatrix_unsloth.gguf

Removing the imatrix from that folder changes nothing, so the imatrix is not what produces the row. What produces it is the rule that a config folder stays visible while its weights are still downloading, and gating that on weights would hide every checkpoint mid-download. That is a different change from this one, with its own trade-off.

Added test_a_config_beside_an_imatrix_lists_for_the_reason_a_lone_config_does in 7c2f356 to assert exactly that pair, so the boundary is deliberate and locked rather than an omission. The imatrix-only case with no config is dropped, which is the part the imatrix does cause.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

danielhanchen added a commit to shimmyshimmer/unsloth-staging-4 that referenced this pull request Aug 20, 2026
_dir_has_downloaded_model exists so a Recommended chip never opens an empty
picker, and it says so: weight detection mirrors the local scanner. Once the
scanners stopped surfacing an imatrix-only folder, an unfiltered probe here
advertised one.
@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: ce10789a59

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

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: c1ba0731b6

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

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 20, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Aug 20, 2026
@danielhanchen
danielhanchen merged commit 347da6d into main Aug 21, 2026
43 of 46 checks passed
@danielhanchen
danielhanchen deleted the studio-imatrix-local-model-routes branch August 21, 2026 06:45
danielhanchen added a commit that referenced this pull request Aug 22, 2026
…ls.py needs

A second break on main, which the hang above was hiding: the job never reached
the summary, so these two never reported.

#9411 added _is_imatrix_path to the import block at the top of routes/models.py
and to _dir_has_downloaded_model, without telling the two tests that stand in
for that module. test_export_absolute_paths builds a ModuleType for
utils.models.model_config and gets ImportError at the import block;
test_recommended_folders_has_model AST-extracts the real function into a
namespace it assembles by hand and gets NameError when the function runs.

The extracted-function test takes the real helper, the way it already takes the
real is_appledouble_metadata: importing utils.models.model_config costs 0.14s
and pulls in neither torch nor transformers, and a stub would let the exclusion
that function depends on regress unnoticed. The ModuleType double gets a lambda
beside its siblings, since export path discovery is what that file tests.
danielhanchen added a commit that referenced this pull request Aug 22, 2026
…ext one (#9515)

* Unwedge Backend CI: one deadlocked test, and a timer that names the next one

test_codex_proof_rollback_leaves_a_concurrent_save_alone drove two
update_provider_config calls at the same provider concurrently, with the first
parked inside a stubbed remember_catalog_account until the second one finished.
serialize_provider_config holds a per-provider asyncio.Lock across the whole
handler, so the second call could never start, and the await that would have
released the first sat behind it. The event loop then had nothing to run and no
timer to wake it, and the test never returned.

Backend CI has been red on main since that test landed. The step timings say the
suite was never the problem: the last green run finished "Backend tests" in 393s,
and the first red run reached 95% of the same suite in 5m30s and then emitted
nothing for the remaining 37 minutes before the job cap fired.

The interleaved write now goes at providers_db directly. That is the shape the
rollback actually defends against, since the route lock already forbids a second
concurrent save on the same provider, and the assertions are unchanged: reverting
_restore_metadata to restore the whole pre-request snapshot still fails the test.
The parked handshake is now an Event the stub sets rather than a hundred turns of
asyncio.sleep(0) and a read of Event._waiters.

Backend CI also gets pytest-timeout and --timeout=330 on its pytest steps. A job
cap reports "cancelled" and names nothing, which is what let this sit for forty
hours; a per-test cap fails the test by name in minutes. 330s is 4x the slowest
real test in the suite, test_the_newest_revision_survives_a_tied_run_LONGER_than_the_cap
at 82.5s, with 76s and 25s next below it.

* Give the two model_config test doubles the imatrix helper routes/models.py needs

A second break on main, which the hang above was hiding: the job never reached
the summary, so these two never reported.

#9411 added _is_imatrix_path to the import block at the top of routes/models.py
and to _dir_has_downloaded_model, without telling the two tests that stand in
for that module. test_export_absolute_paths builds a ModuleType for
utils.models.model_config and gets ImportError at the import block;
test_recommended_folders_has_model AST-extracts the real function into a
namespace it assembles by hand and gets NameError when the function runs.

The extracted-function test takes the real helper, the way it already takes the
real is_appledouble_metadata: importing utils.models.model_config costs 0.14s
and pulls in neither torch nor transformers, and a stub would let the exclusion
that function depends on regress unnoticed. The ModuleType double gets a lambda
beside its siblings, since export path discovery is what that file tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant