Skip to content

Studio: list every GGUF build that shares a quant in a custom folder - #13957

Merged
danielhanchen merged 37 commits into
unslothai:mainfrom
oobabooga:worktree-custom-folder-gguf-builds
Oct 16, 2026
Merged

danielhanchen merged 37 commits into
unslothai:mainfrom
oobabooga:worktree-custom-folder-gguf-builds

Conversation

@oobabooga

@oobabooga oobabooga commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Fixes #13926.

Problem

#13899 taught the quant regex NVFP4, so every file in the reporter's custom folder (Qwen3.8-27B-NVFP4-MTP-HIGHEST.gguf, -LOW, -MEDIUM, -MID-HIGH, -MID-HIGH_enru) now gets the key NVFP4. The lister keeps one file per key, so the picker shows a single NVFP4 row that loads -HIGHEST, and the other four cannot be selected. Before #13899 each file was its own row. Differently named builds at standard quants in custom folders already collapsed the same way, for example Llama-3-8B-Instruct-Q4_K_M.gguf beside Llama-3-8B-abliterated-Q4_K_M.gguf.

Fix

Outside the HF cache, list_local_gguf_variants now keys files with gguf_variant_keys_by_checkpoint, which deletion already uses to tell builds that share a quant apart.

  • The first build keeps the bare quant key, so existing selections still open the same file. Each other build is keyed by its file stem, which the loader already accepts.
  • Each build is labelled with its file name, for example NVFP4 · Qwen3.8-27B-NVFP4-MTP-HIGHEST.
  • /gguf-variants now returns the chosen row's own key as default_variant, instead of deriving it again from the filename. Without this, a folder with a torn a-Q4_K_M-00001-of-00002.gguf and a whole z-Q4_K_M.gguf would default to Q4_K_M, the torn build.

HF cache snapshots still list one build per quant (#13327), because their keys must match the remote listing and are stored in download manifests and pins. gguf_variant_key is unchanged.

Verification

Studio before and after the change, with a custom folder holding the issue's five filenames (copies of a small real GGUF):

main this PR
Picker, custom folder row one NVFP4 row five NVFP4 · <build> rows, all "downloaded"
Loading each listed key only -HIGHEST reachable each key started llama-server on its own file

The new tests fail on main and pass with the change. Five existing tests for HF snapshots now build their snapshot under an HF cache path instead of a plain temp directory; their assertions are unchanged. Across 108 GGUF-related backend test files, 8877 passed. One timing test unrelated to GGUF listing failed (test_tunnel_safe_long_post.py), and it passes when its file runs alone.

Before / after

A custom LM Studio-style folder holding five copies of a small GGUF under the issue's filenames (Qwen3.8-27B-NVFP4-MTP-HIGHEST/LOW/MEDIUM/MID-HIGH/MID-HIGH_enru.gguf), Studio built at the merge base and at this branch. The quant menu goes from one NVFP4 row to five NVFP4 · Qwen3.8-27B-NVFP4-MTP-<build> rows (the menu truncates the build name; /api/models/gguf-variants returns the full labels). Loading each listed key started llama-server on that key's own file; before, only -HIGHEST was reachable.

Model Hub quant menu for the custom folder, before and after

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 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-16T20:03:54.280461Z ffa7884 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.

@carlitogwapito

Copy link
Copy Markdown
Contributor

I put together a small test-only commit that may be useful alongside this change. It adds one file, with no production changes.

Two controls I'd keep with the grouping update:

  • Two split builds with separate keys retain their own byte totals and first shards across all 24 input orderings.
  • A partial override map still derives the unmapped build's normal key; omitted, None and empty maps keep the existing one-family result.

All three focused tests passed against the unchanged pure grouping/key helpers from 587b7010, in isolation. I didn't load Studio or a model, and the full backend suite and repository-pinned hooks weren't run. The commit is based directly on this PR head, so it can be picked up without another PR carrying the feature.

@mahiatlinux mahiatlinux self-assigned this Oct 16, 2026
@oobabooga

Copy link
Copy Markdown
Member Author

Reached Codex review convergence at oobabooga#381.

@mahiatlinux

mahiatlinux commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Review and repair evidence

Tested head: 367e2bf07258097bf07f7974ce05639079401e78

Observed behavior

  • At current-main merge base 67f7ab90f3d3be3160f7956bb8a6d4e5f5c479f9, the issue's five NVFP4 files collapsed to one selectable row.
  • At the repaired head, all five files are separate rows, every listed key resolves to its own file, and the menu labels name each build.
  • Review found and fixed two additional reachable collisions: a bare-named split family whose stem equals the legacy quant, and an ordinary custom path containing a models--* segment that is not an HF snapshot.
  • A negative-control mutation restored both defects and made both new regressions fail for the original reasons.
  • Codex review found and fixed a third reachable issue: each split custom-folder row now reads native context metadata from its own first GGUF shard instead of inheriting one directory-level value. Its regression failed before the repair and passes with distinct 4096 and 8192 contexts afterward.
  • A second Codex round found and fixed direct-file sibling context aliasing and the media auto-switch index's use of the old quant-collapsing lister. Negative controls reproduced both: the sibling inherited 4096 instead of 8192, and local-image:beta-q4_k_m was absent.
  • A third Codex round found and fixed a partial-sibling edge case: collision detection now includes incomplete rows while per-row context sources remain restricted to ready rows. Before the repair the ready sibling inherited 1024; afterward it retains its own 8192 context.
  • A fourth Codex round found and fixed two serving-path issues: generated build stems now switch away from a different resident sibling, while split-aware media indexing preserves legacy fallback aliases such as :fp16. Both new negative controls failed before the repair and pass afterward.
  • The follow-up audit carried exact build identity through admission and model-management unload. A fifth Codex round then found and fixed filename identity for same-token media residents, compatibility-alias collisions with current exact keys, and aggregate-shard defaults that disagreed with variantless local loads. All four associated negative controls failed before repair and pass afterward.
  • A sixth Codex round aligned bare local resolver defaults with variantless loads, removed torn custom-folder shard families from the published index, kept quant-directory siblings inside the media default scope, and made generic resident tags read only the warmed resolver snapshot. All four controls failed before repair and pass afterward.

UI evidence

The UI comparison uses the PR branch merge base above and behavior head 2110c54864. Both sides used the same deterministic files, a 1500x1000 viewport, isolated Studio homes and caches, and Chrome for Testing 151.0.7922.34 on Ubuntu 26.04.1 x86_64. Later commits change backend metadata, serving/admission, media indexing, and model management, not the rendered selector shown here.

Before and after custom GGUF build selector

Observed facts: variant_count: 1 -> 5, every_after_file_selectable: false -> true. The before menu has one NVFP4 option; the after menu has five NVFP4 · <build> options.

Verification

  • Python 3.13.14, six changed GGUF modules: 484 passed, 1 warning
  • Python 3.11.15, the same modules: 484 passed, 1 warning
  • OpenAI auto-download and media catalog modules on the final code: 220 passed, 1 warning on Python 3.13.14 and 3.11.15
  • Final resolver, media, scope, and video selection set: 340 passed, 1 warning on Python 3.13.14 and 3.11.15
  • Focused local-resolver selection set: 15 passed, 784 deselected on Python 3.13.14 and 3.11.15
  • Video, media auto-switch, and account isolation with an isolated home: 144 passed, 1 skipped, 1 warning
  • Llama-compatible management routes on Python 3.13.14 and 3.11.15: 166 passed, 1 skipped, 1 warning on each
  • Current-main audio filename conflict-resolution regressions: 16 passed, 193 deselected
  • Custom discovery: 50 passed, 1 skipped
  • Offline-cache and imatrix suites: 262 passed
  • MTP companion suite: 289 passed
  • Video GGUF suite: 37 passed
  • Cached-route and BPW-row suites: 258 passed, 1 skipped
  • Broader model-services collection: 410 passed, 1 skipped, 5 failed; all five are the same existing SimpleNamespace.source fixture failures on the captured base and original PR head.
  • Pinned formatter fixed point on the final seventeen-file diff, five-slice comment-only AST gate, final whitespace check, and focused secret scan: clean
  • Current main integration: 23bbee09b1 merged cleanly after the earlier filename-selector resolution; the tested repaired head includes it

Performance on 1,000 synthetic paths was 10.807 ms/call at the original PR head and 15.328 ms/call after the collision guard, an additional 4.521 ms in the filesystem listing path.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 16, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 16, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 16, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@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: Something went wrong. Try again later by commenting “@codex review”.

Failed to sample tokens
ℹ️ 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

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@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: ffa788416f

ℹ️ 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 +451 to +455
variants = [
variant
for variant in variants
if getattr(variant, "filename", None)
and _split_set_is_loadable(Path(load_dir) / variant.filename)

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 withheld keys when every split build is torn

When a custom folder contains only incomplete split sets, this filtering removes every variant, after which _local_gguf_entry returns None and discards the withheld keys it just computed. If one build is still resident in llama.cpp while its files and every sibling become torn (for example, shard 2 is deleted after loading), the refreshed index then has no negative entry; _loaded_satisfies("local/model:beta-Q4_K_M") sees the matching base, finds neither a pin nor a withheld marker, and treats the non-quant-shaped suffix as satisfied, so resident alpha weights can serve a beta request. Keep a withheld-only index record, or otherwise retain these negative build keys, even when no build is currently loadable.

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 fixing: this needs shard files deleted under a loaded model until every build in the folder is torn; keeping an entry with no servable build would advertise an unloadable model.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Oct 16, 2026
@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: Something went wrong. Try again later by commenting “@codex review”.

Failed to sample tokens
ℹ️ 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

Copy link
Copy Markdown
Member

@codex review

1 similar comment
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 16, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Something went wrong. Try again later by commenting “@codex review”.

Failed to sample tokens
ℹ️ 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 db0e78c into unslothai:main Oct 16, 2026
VTplus added a commit to VTplus/unsloth that referenced this pull request Oct 17, 2026
…uping

Merge origin/main (e795149, 102 upstream commits) and combine both
index features in _LocalGgufEntry: parked scan-folder copies stay listed
as alternates beside an incomplete cache skeleton, and the resolver now
also groups every GGUF build that shares a quant in a custom folder
(unslothai#13957).
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 25, 2026
…s NVFP4 (unslothai#14733)

## Problem

unslothai#13899 made `NVFP4` a quant token (`(?:MX|NV)FP[0-9]+`) so the Nemotron
3.5 Super `NVFP4/` folder resolves to its weights. The token is matched
anywhere in the name, so in community repos whose model name contains
`-NVFP4-` it became the first quant token of every file and every file
got the variant key `NVFP4`. The picker keeps one row per key, so all
but one build became unselectable, and
`...-NVFP4-Experts-Only-Q8_0.gguf` was keyed `NVFP4` instead of `Q8_0`.

Rows in the HF picker (real Hub listings):

| Repo | Files | Before unslothai#13899 | main | This PR |
|---|---|---|---|---|
| esatapedico/Qwen3.8-27B-NVFP4-MTP-GGUF | 9 | 9 | 1 | 9 |
| michaelw9999/Qwen3.6-35B-A3B-NVFP4-MTP-GGUF | 2 | 2 | 1 | 2 |
| llmfan46/Qwen3.6-35B-A3B-uncensored-heretic-NVFP4-Experts-Only-GGUF |
2 | 2 | 1 | 2 |
| utautako/Qwen3.8-27B-NVFP4-MTP-Q8attn-GGUF | 2 | 2 | 1 | 2 |
| CompiledThoughts/Qwen3.8-Flash-Next-NVFP4-Q8_0 | 1 | 1 (`Q8_0`) | 1
(`NVFP4`) | 1 (`Q8_0`) |

## Change

`NVFP` now names the quant only where llama.cpp naming puts the type:
last in the name, with only a bpw modifier, a shard suffix or the
extension after it (`Model-NVFP4.gguf`,
`NVFP4/Model-NVFP4-00001-of-00003.gguf`, `Model-UD-NVFP4.gguf`,
`Model-NVFP4_MOE.gguf`, a stored `NVFP4` key). An `NVFP` followed by
more name parts is part of the model name, so those files get exactly
the keys they had before unslothai#13899 (the stem, or `Q8_0` where a later token
names the quant).

The rule is a lookahead on the `NVFP` alternative, applied to every copy
of the quant regex so the picker, download plans, size listing, load
resolution and the frontend label agree: `utils/gguf_names.py`
(`GGUF_QUANT_RE`, the shared pattern that `hub/utils/gguf.py`,
`core/inference/llama_cpp.py` and `utils/models/model_config.py` now
import), `_extract_quant_label` in `utils/models/model_config.py`,
`hub/services/models/gguf_variants.py`, and `model-identity.ts`.

`MXFP` is unchanged: it was a token before unslothai#13899 and still matches
anywhere, so keys stored for MXFP repos (`MXFP4`, `MXFP4_MOE`,
`...-MXFP4-BF16`) keep resolving.

## Tests

- New `tests/test_gguf_nvfp4_model_name_variants.py` (49 tests): row
counts and keys for the five listings above, each key resolving to
exactly its own file in `_resolve_variant_gguf_files` and in
`build_gguf_variant_plans`, all regex mirrors agreeing, plus
unsloth-style names (`NVFP4/` shards, `-NVFP4.gguf`, `-MXFP4_MOE`,
`UD-MXFP4_MOE`, bpw suffix) and NVFP4-suffixed drafters. On main 29 fail
(the 20 unsloth-style and drafter cases pass on both); on this branch
all 49 pass.
- New `frontend/tests/gguf-nvfp4-quant-label.test.ts` (2 tests): 1 fails
on main, both pass here. `model-identity.test.ts` and
`audio-loaded-quant-key.test.ts` pass.
- Related backend GGUF suites (variant rows, bpw rows, split builds,
delete keeps sibling builds, local resolution, dependency keys, resolve
quant, Nemotron 3.5, MTP drafter, imatrix, routing, preflight, offline
cache, LTX-2.5, cached routes, companions, cache switch): 1238 passed,
12 failed, 2 skipped on this branch. The 12 failures are the same test
ids on main (8 in `test_mtp_drafter_companion.py` need the `gguf`
package, 2 in `test_cached_gguf_routes.py`, 2 in
`test_video_ltx25_gguf.py`) and are unrelated.
- `test_a_custom_folder_lists_every_build_at_one_quant` (unslothai#13957) used
these Qwen3.8 NVFP4-MTP names as its shared-quant fixture and pinned the
first build to the `NVFP4` key. It now uses names that end in `-NVFP4`,
so it still covers a custom folder splitting builds at one NVFP4 quant,
and passes on main and here; the real Qwen3.8 names in a custom folder
are covered by a new test that lists each build under its own name.

## Not covered

- Two different model stems that both end in `-NVFP4` in one HF repo
still share the `NVFP4` row, the same as two stems at `Q4_K_M` today:
remote and HF cache listings keep one key per quant by design, and only
custom folders split such builds.
- A key saved on main for one of the affected repos (`NVFP4`) no longer
names a file there. For a Hub repo it was already ambiguous, since it
picked one build out of all of them. For a custom folder (unslothai#13957) it
named the first build, so that saved selection has to be picked again.
Keys saved before unslothai#13899 load as they did then.
- The frontend `chat-adapter.ts` regex never learned `NVFP` and is
untouched.


## Before / after

Model Hub picker for `esatapedico/Qwen3.8-27B-NVFP4-MTP-GGUF`, merge
base `c9fab474c` vs head `47e9858b9`, two isolated Studio installs.
Before: one `NVFP4` row (16 GB) for the nine builds. After: nine rows,
one per build, each at its own size (ORIG 34 GB down to VERY-LOW 16 GB).
The variants API agrees: 1 row -> 9 rows.

![Picker rows before and
after](https://raw.githubusercontent.com/danielhanchen/unsloth-staging-2/pr-media/pr/14733/pr14733_picker-3ef19635760f.png)

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
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.

[Bug] unsloth lost models

4 participants