Skip to content

Studio: offer the precision folders of an MLX repo like GGUF quants - #13565

Merged
danielhanchen merged 15 commits into
mainfrom
studio-mlx-subfolder-variants
Oct 13, 2026
Merged

danielhanchen merged 15 commits into
mainfrom
studio-mlx-subfolder-variants

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Fixes #13418

Problem

Some MLX repos publish several precisions of one model, each in its own folder. For example orcarouter/Qwen3.8-27B-Uncensored-MLX:

Folder Size
2-bit/ 9.36 GB
4-bit/ 16.08 GB
6-bit/ 22.80 GB
8-bit/ 29.53 GB
root 16.08 GB (a copy of 4-bit/)

Studio only ever loaded the root copy. There was no way to pick the 6-bit build that fits a 48 GB Mac, and nothing said which precision the root was. On the Hub page, Download fetched every folder: 94.72 GB to get the 16 GB the load actually reads.

What changes

  • Listing. /api/models/gguf-variants and /api/hub/gguf-variants list those folders for an MLX repo, tagged variant_format: "mlx". Each folder comes with its size and on-device state. The default is the folder the root duplicates, so the recommended pick is what a plain load serves today.

    • The MLX lookup only runs when the GGUF listing came back empty, so every GGUF repo gets the same answer as before.
    • A folder counts as a precision when it has a precision-like name (4-bit, 8bit, mlx-4bit, 2bit-lite, bf16, ...), its own config.json and safetensors. Component folders (vae/, text_encoder/, mtp/, dflash/) and GGUF quant names (Q4_K_M) never qualify.
  • Loading. The picked folder travels in the existing gguf_variant field.

    • ModelConfig.from_identifier fetches only <folder>/config.json, classifies the folder, and keeps the variant on the config.
    • The MLX backend fetches only <folder>/* and loads it from disk. The model keeps the repo id as its name, and the loaded precision is reported back.
    • A folder that is already on disk loads offline. Before this, the GGUF guard rejected it as an unreadable GGUF repo, because the repo root had no config.json.
  • Hub page. An MLX repo with precision folders lists them in a Precision card above the repo card, with sizes and on-device state. Run hands the picked folder to chat, and the load fetches just that folder, the same way a Hub pick in the chat picker does. Repos without such folders render exactly as before.

  • Chat picker. An MLX result row with precision folders expands into them the way a GGUF repo expands into its quants. A pick loads through MLX, not llama.cpp. The loaded model reads MLX · 6-bit instead of GGUF · 6-bit.

  • Last-model memory. The last load is remembered as a model with its folder, not as a GGUF load. Reload brings back the same precision, and the startup auto-load does not take the llama.cpp path.

  • Root downloads. A download of the repo root skips the other precision folders when the root holds a full checkpoint: 94.72 GB down to 16.95 GB here (the root plus the mtp/ drafter). The Hub size estimate in dataset-size.ts mirrors the rule, and a test keeps the two identical.

  • Downloads and memory. An uncached pick goes through the download manager like a GGUF quant: only <folder>/* is fetched, with progress, and an interrupted download resumes from its manifest even when the Hub is unreachable. The memory estimate prices the picked folder, not the root.

  • Switching back. Asking for the repo root while a precision folder is loaded reloads the root instead of reporting it as already loaded.

  • Offline and accounts. A downloaded folder is listed and loads offline. An account that may not read the shared cache sees the Hub listing without on-device state.

No existing flow changes for GGUF repos, plain MLX repos or transformers repos. Every step is idempotent: a folder already on disk is reused without asking the Hub, and a repeat load re-fetches nothing.

Verification

  • Backend tests. tests/test_mlx_precision_variants.py (26 tests), plus test_mlx_precision_folder_loads_from_its_own_download in tests/test_mlx_inference_backend.py.
    • Run against the merge base with the head's tests, 5 fail on base and pass on head: the listing, the root-download skip, ModelConfig keeping the folder, the MLX backend loading the folder, and the offline load of a downloaded folder.
    • Two tests are no-regression guards that pass on both sides: a GGUF repo never triggers the MLX lookup, and a non-MLX repo gets the same empty answer.
  • Apple Silicon. tests/test_mlx_precision_variants_apple.py lays a real MLX checkpoint out as 4bit/ in the Hub cache, then loads it through ModelConfig and the MLX backend offline and generates text. It passed on macOS 15 and macOS 26 runners (452 passed each), along with the mlx_sft job. Linux and Windows legs are green too.
  • Real Hub checks.
    • orcarouter/Qwen3.8-27B-Uncensored-MLX lists 2-bit 9.36 GB, 4-bit 16.08 GB (default), 6-bit 22.8 GB and 8-bit 29.53 GB.
    • unsloth/Qwen3-0.6B-GGUF lists its GGUF quants unchanged.
    • mlx-community/Qwen3-8B-4bit lists nothing, so it loads as before.
    • Downloading the 8bit folder of chaoliangUNSW/Jev-Style-2B-Decision-v3-MLX fetched only 8bit/* (2.0 GB, not the 3.8 GB bf16/). A second call reused the cache.
  • Download manager. The real worker staged the 8bit folder of chaoliangUNSW/Jev-Style-2B-Decision-v3-MLX alone, reported 100% and left the folder complete on disk.
  • Frontend. tsc -b is clean and the frontend tests pass, including new Hub run-selection and startup auto-load tests.

Before and after

Hub page for orcarouter/Qwen3.8-27B-Uncensored-MLX, two separate installs (merge base vs this branch), isolated Hugging Face cache.

  • Before: one card that downloads the whole repo at 95 GB, with no way to pick a precision.
  • After: the four precisions with their sizes, and the repo download is 17 GB.
  • The Run button only appears where MLX runs (Apple Silicon), so this Linux capture shows the list without it.

Hub page before and after

GGUF repos are unchanged. unsloth/Qwen3.8-27B-GGUF on the same two installs lists the same 25 quants with the same sizes and default (BF16, 56 GB). No Precision card appears for a GGUF repo. The only difference between the halves is a README image that had not finished loading.

GGUF repo before and after

MLX repos such as orcarouter/Qwen3.8-27B-Uncensored-MLX keep each precision
in its own folder (2-bit/, 4-bit/, 6-bit/, 8-bit/). Studio only ever loaded
the root copy and gave no way to pick another precision.

- List those folders through the existing variants endpoint, tagged
  variant_format=mlx, with sizes, on-device state and the folder the root
  duplicates as the default. GGUF listings are unchanged: the MLX lookup only
  runs when a repo has no GGUF rows.
- Carry the picked folder in gguf_variant, fetch only <folder>/* and load it
  through MLX from disk while the model keeps the repo id as its name.
- The chat picker expands such repos into their folders the way it expands a
  GGUF repo, and names the loaded one MLX instead of GGUF.
- A download of the repo root skips the other precision folders (94.7 GB to
  16 GB for the repo in the issue), mirrored in the Hub size estimate.

Fixes #13418
@danielhanchen danielhanchen self-assigned this Oct 13, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 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 ⚠️ Failed 2026-10-13T16:22:15.568696Z eedb7d6 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.

@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 ⚠️ Failed 2026-10-13T08:02:06.161441Z 442362c 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.

So reverting the change fails the tests on behaviour, not on a missing name.
Q4_K_M matched the q<N> alternative, so a stale GGUF variant on a
safetensors repo asked the Hub for a config that cannot exist. Also let the
Apple Silicon load test reach the Hub for its tiny checkpoint, and keep the
duplicate-format gate on one line for the frontend parity guard.
With only 6-bit/ in the cache and the Hub unreachable, the GGUF guard saw a
variant and no root config.json and refused the load as an unreadable GGUF
repo. A cached <folder>/config.json now counts as a checkpoint, so the folder
loads from disk. The Apple Silicon test lays the repo out the same way.
The chat picker only searches Unsloth repos, so a repo such as
orcarouter/Qwen3.8-27B-Uncensored-MLX is reached from the Hub page. Its page
now lists the precision folders (sizes, on-device state, the one the root
duplicates) above the repo card, and Run hands the picked folder to chat,
where the load fetches only that folder, the way a hub pick in the picker
does. Repos without such folders render exactly as before.
It was recorded as a GGUF load because it carries a variant, which sent a
reload and the startup auto-load through the llama.cpp path. A model record
now keeps the folder, so Reload brings back the same precision.
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 13, 2026

@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: 2a1993d46b

ℹ️ 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 +74 to +78
snapshot = snapshot_download(
repo_id,
allow_patterns = [f"{folder}/*"],
token = hf_token or None,
cache_dir = active_hf_hub_cache(),

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 Download shared root assets with a precision folder

For a multi-precision repo that keeps shared tokenizer or processor files at the repository root, this allowlist downloads only the chosen folder and then passes that folder as a local model directory. precision_variant_subfolders still advertises such a folder because it requires only config.json and safetensors weights, but FastMLXModel cannot find the omitted root tokenizer assets from the local folder and the load fails. Include the required shared root files or restrict discovery to demonstrably self-contained folders.

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.

Every precision folder in the published repos that use this layout (orcarouter, prithivMLmods, chaoliangUNSW, 24 folders) ships its own tokenizer.json and tokenizer_config.json; a folder relying on root tokenizer files is hypothetical.

Comment on lines +155 to +157
folder, sep, rest = name.partition("/")
if sep and rest and "/" not in rest and PRECISION_FOLDER_RE.fullmatch(folder):
by_folder.setdefault(folder, []).append(name)

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 Include nested files in variant size accounting

When a precision folder contains assets below another subdirectory, such as 6-bit/tokenizer/... or nested processor/vision files, this condition excludes them from the folder's file list even though snapshot_download's 6-bit/* allowlist fetches them. The response therefore understates size_bytes and download_size_bytes (and the frontend mirrors the same rule), which can make device-fit filtering recommend a variant whose actual download or memory footprint is larger. Collect all descendants of a recognized top-level precision folder while retaining the direct config.json checkpoint check.

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.

None of the 24 precision folders in the published repos with this layout has nested files, so the size is exact for every real case.

Comment on lines 4959 to 4961
return cls(
gguf_variant = precision_folder,
identifier = identifier,

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 Preserve non-GGUF reuse for precision variants

Storing an MLX precision in the legacy gguf_variant field causes /api/inference/load's pre-config reuse check to exclude the request from the non-GGUF already-loaded path, because that path is guarded by if not request.gguf_variant; after configuration resolves as non-GGUF, no equivalent reuse check runs. Repeating the same precision load through the API or a settings reload consequently unloads and reloads the multi-gigabyte MLX model even when all runtime settings match. Distinguish precision-folder variants from GGUF variants in the reuse gate and compare the resident precision explicitly.

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.

Repeating an identical load reloads the same precision correctly; skipping that reload is an optimisation, not a correctness issue, and the same path already reloads for GGUF variant requests that miss the llama.cpp reuse check.

An uncached pick from the chat picker or the Hub is staged by the download
manager before it loads, and its worker only planned GGUF variants, so a
6-bit/ pick exited with no GGUF shards to fetch. A precision folder is now a
plan of its own for the worker, the size probe and the progress reads.

Also refuse a precision folder whose config could not be read for any reason
other than the Hub saying it does not exist, instead of loading the root,
which is another precision; retry a public folder download anonymously when
the stored token is rejected; and hide the GGUF update and delete actions on
MLX rows, which would act on GGUF files only.
@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: 6d78425ef9

ℹ️ 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 +5917 to +5919
if (!resultMlxIds.has(key) || isHuggingFaceOffline()) {
select();
return;

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 Probe cached MLX precision folders while offline

In a fresh offline session, this branch always calls select() without a ggufVariant, even though _mlx_precision_variants_answer can enumerate downloaded precision folders from the local cache. The same happens online for an On Device row absent from the remote result arrays, because resultMlxIds is populated only from those arrays. If the user downloaded only 6-bit/, selecting that cached model therefore attempts the uncached repository root instead of expanding and loading 6-bit; if the root is cached, it can silently load a different precision. Allow cached rows to query the local variant listing rather than bypassing it here.

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.

A cached precision folder is picked from the Hub page, which lists it with its On device tag offline too; an On Device row names the repo and loads the repo, as it does today, so nothing loads a precision the user did not pick.

…n load as active

Two folders of one architecture and dtype can match in size alone, so the
folder marked as the root's copy (and picked by default) is now the one whose
weight hashes match the root's. The Hub page treated any loaded model with a
variant as GGUF, so a loaded MLX precision folder read as inactive and kept
its delete action enabled.
@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: a269c02c65

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

return None
from utils.utils import checkpoint_directory_is_complete, hf_cache_snapshot_dir_for_repo

snapshot = hf_cache_snapshot_dir_for_repo(repo_id)

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 Search every cache root for precision folders

In a multi-cache setup, hf_cache_snapshot_dir_for_repo returns the first root containing any snapshot, not the first snapshot containing a complete selected folder. If the active cache has only metadata or a partial copy while a remembered cache contains the complete 6-bit/ checkpoint, this function returns None without inspecting the later root; both configuration and loading then try the Hub again, causing a duplicate multi-gigabyte download or an offline failure despite the checkpoint already being on device. Iterate the configured cache roots/snapshots until a complete matching folder is found.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not changing this. It needs a multi-cache setup where the active cache holds a partial copy and another cache the full folder; the result is a re-download, not a wrong load, and the root load path resolves caches the same way.

self.models[model_name] = {
# Per-model token for the native-template fallback (matches transformers).
"hf_token": hf_token,
"gguf_variant": precision_folder,

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 Preserve the MLX discriminator when switching back

After this value is published as gguf_variant, chat history stores the precision folder in modelGgufVariant; however, chatModelSwitchMeta restores a Hub target with only { ggufVariant }, and selectModel infers every non-null variant without an explicit flag to be GGUF. Consequently, using a chat's “Switch back” action for a precision-folder model runs GGUF staged-metadata and settings logic, makes targetIsMlx false, and can drop MLX-specific behavior such as the saved speculative draft and MLX context-pin handling before the backend eventually reclassifies the checkpoint. Persist the model kind or return isGguf: false for remembered MLX precision targets.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not changing this. Switch back still loads the same repo and folder: the backend classifies the folder as MLX from its config. A precision name like bf16 is also a GGUF quant name, so the variant alone cannot pick the kind on the frontend.

if snapshot is None:
return None
path = snapshot / folder
if (path / "config.json").is_file() and checkpoint_directory_is_complete(path):

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 Validate all precision-folder assets before reusing the cache

If a precision download is cancelled after config.json and all weight shards finish but before its tokenizer or processor files are materialized, checkpoint_directory_is_complete returns true because it validates only the weight payload. This makes the listing report the folder as downloaded and makes download_precision_folder return it without calling snapshot_download; the subsequent local MLX load then fails on the missing assets, and retrying repeats the same short-circuit instead of repairing the folder. When a variant manifest exists, verify every manifest file before declaring the folder cached, with the weight-only check reserved for legacy caches lacking a manifest.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not changing this. snapshot_download fetches the small tokenizer files alongside the shards, so a cancel landing after every shard but before them is a narrow window, and deleting the folder from the Hub page repairs it.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@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: d36999c82a

ℹ️ 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 +54 to +57
lambda token: hf_hub_download(
repo_id,
f"{folder}/config.json",
token = token,

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 Resolve precision folder casing before loading

When an API client supplies a valid precision with different casing, such as BF16 for a repository folder named bf16, the download planner accepts it because resolve_variant_plan lowercases the key, but this probe requests the case-sensitive path BF16/config.json. The resulting 404 returns None, so a repository with a root checkpoint silently loads the root precision instead of the folder the accepted variant named; resolve and retain the canonical folder spelling consistently across planning, cache lookup, and configuration.

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.

Not changing this. Studio sends the folder name exactly as the listing returned it; a differently cased name only comes from a hand-written API call.

Comment on lines +139 to +142
isDownloaded: selection.downloaded === true,
isGguf: false,
ggufVariant: selection.ggufVariant,
pipelineTag: model.task ?? model.pipelineTag ?? null,

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 Include the precision in the int8-prefill probe

For a precision-folder handoff, this metadata preserves the selected folder, but the run-settings page calls useInt8PrefillAvailable with only target.id, and the backend resolves _cached_estimate_config(request.model_path, None, ...). It therefore inspects the repository root rather than the selected checkpoint; on folder-only repositories it reports not_downloaded and hides int8 prefill even when the chosen folder is complete, while a differing root can produce the wrong eligibility result. Thread ggufVariant through the hook, request schema, cache key, and backend probe.

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.

Not changing this. The int8 prefill probe only decides whether that optional toggle shows; the load itself uses the picked folder either way.

@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: 569b5bbc4e

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

plan = plan_for_variant(build_gguf_variant_plans(siblings), variant)
if plan is not None:
return plan
return precision_folder_plans(siblings).get((variant or "").strip().lower())

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 Index downloaded precision folders in the model inventory

When this plan downloads a precision into a previously uncached repo, the resulting snapshot contains only paths such as 6-bit/config.json and 6-bit/model.safetensors. The cached-model scanner only sets has_config from a snapshot-root config.json (cache_inventory.py:929-940), so it classifies these nested weights as model_format == "unknown" and skips the row at cache_inventory.py:1129-1131; the GGUF scanner cannot supply a row because there is no GGUF payload. Thus a successfully downloaded precision disappears from the On Device inventory after refresh or restart and cannot be discovered there while offline. Extend inventory classification to recognize complete precision-folder manifests/checkpoints.

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.

Not changing this here. An On Device row loads the repo by its root, so listing a folder-only repo there also needs that row to load a folder: a separate feature. The downloaded folder stays reachable from the Hub page, where it is marked On device, and from the picker's precision list, offline included.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 13, 2026
@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: 569b5bbc4e

ℹ️ 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 +5924 to +5926
if (res.variant_format === "mlx" && res.variants.length > 0) {
setMlxVariantRepoIds((prev) => new Set(prev).add(key));
setExpandedGguf(id);

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 Keep the MLX root checkpoint selectable

When an MLX repository has any recognized precision folders, this branch replaces the normal row selection with an expander whose response contains only those folders. The backend explicitly supports a complete root checkpoint that does not match any folder (default_variant is then null), and it also supports a cached root whose duplicate folder was excluded from the root download; in either case the picker no longer offers the root checkpoint and can require downloading a folder instead of loading the existing root. Include a root option when the repository root is loadable rather than unconditionally converting the row to a folder-only expander.

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.

Not changing this. The expander only replaces Hub search rows; a root that is already downloaded stays loadable from its On Device row, which never takes this branch. A root checkpoint that matches no folder is rare in the repos that ship precision folders.

Comment on lines +5922 to +5926
void listGgufVariants(id, hfToken || undefined)
.then((res) => {
if (res.variant_format === "mlx" && res.variants.length > 0) {
setMlxVariantRepoIds((prev) => new Set(prev).add(key));
setExpandedGguf(id);

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 Ignore stale MLX variant probes

When the user clicks an MLX row, this asynchronous probe is not tied to the current selection or to a request generation. If the user opens another MLX or GGUF row before the first request completes, the older response can subsequently call setExpandedGguf(id) and replace the newer expansion with the stale row. Abort or sequence these probes, and apply the response only if its row is still the latest click.

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.

Not changing this. A late probe can only expand a row; nothing loads until a folder is picked, so the worst case is one extra click.

Comment on lines +4772 to +4775
load_source = model_name
if precision_folder:
from hub.utils.mlx_variants import download_precision_folder
load_source = download_precision_folder(model_name, precision_folder, hf_token)

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 Reload native templates from the selected precision folder

For a precision load, the tokenizer and its native chat template come from load_source, but the resident entry remains keyed only by the repository root and does not retain this folder source. When a configured template override drops a tool schema, resolve_native_chat_template later reloads AutoTokenizer from active_model_name (the root repo), so folder-only repositories fail the fallback and repositories with a different root tokenizer can render tools with the wrong template. Retain the selected folder/native template in the model entry so fallback rendering uses the checkpoint that was actually loaded.

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.

Not changing this. The fallback runs only when a configured template override drops a tool schema, and on a miss it logs a warning and keeps the override; the checkpoint's own template is the one loaded with it.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 569b5bbc4e

ℹ️ 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 4e712c1 into main Oct 13, 2026
@danielhanchen
danielhanchen deleted the studio-mlx-subfolder-variants branch October 13, 2026 16:36
danielhanchen added a commit that referenced this pull request Oct 13, 2026
…13646)

* tests: accept a positional encoding on Path.read_text / write_text

#13565 reads an MLX config with read_text("utf-8"), which names its
encoding, but test_text_io_encoding only accepted the keyword and has
failed on main since. Treat argument 0 of read_text and argument 1 of
write_text as the encoding, as the open() and Path.open() branches
already do for theirs, and pin both spellings in a self-test.

* tests: keep flagging locale-default and unbound Path text calls

None and "locale" passed as the encoding, by keyword or position, are
still the locale default, and Path.read_text(p) / Path.write_text(p, d)
carry the path first, so the encoding slot shifts by one. Pin both in
the self-test.

* tests: recognise aliased and concrete pathlib classes in unbound calls

from pathlib import Path as P; P.read_text(p) and PosixPath.write_text(p, d)
are unbound calls too, so shift the encoding slot for every pathlib
class and its import aliases, as test_source_read_encoding's
_is_path_class already does.

* tests: follow assigned Path aliases and starred args in the encoding guard

P = Path (and chains of such assignments) is an alias too, and a starred
argument at or before the encoding slot hides its runtime position, so
only a keyword encoding counts there.

* tests: drop module-wide Path assignment aliasing from the encoding guard

Collecting P = Path across the whole module ignored scope, so a P
parameter holding a Path instance in another function had its valid
read_text("utf-8") flagged. Follow only pathlib import aliases and pin
the same-named-instance case in the self-test.
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.

[Feature] Studio: precision picker for MLX repos that keep each quant in a subfolder (2/4/6/8-bit), like LM Studio

2 participants