Skip to content

fix(lm): discover GGUFs in a repository's variant folders - #341

Merged
Brooooooklyn merged 3 commits into
fix/download-gguf-load-hintfrom
fix/discovery-nested-gguf
Nov 9, 2026
Merged

Brooooooklyn merged 3 commits into
fix/download-gguf-load-hintfrom
fix/discovery-nested-gguf

Conversation

@Brooooooklyn

Copy link
Copy Markdown
Contributor

Stacked on #340, which is stacked on #339. Merge in order: #339, #340, then this PR. CI runs only on PRs to main, so this PR gets CI after GitHub retargets it.

Problem

mlx download model -m unsloth/Qwen3.8-Flash-Next-GGUF -g "*UD-Q4_K_XL*" keeps repo paths:

<modelsDir>/qwen3.8-flash-next-gguf/
  README.md, .mlx-download-complete.json
  UD-Q4_K_XL/Qwen3.8-Flash-Next-UD-Q4_K_XL-0000{1..4}-of-00004.gguf

discoverLocalChatModels read only <modelsDir>/*.gguf and <modelsDir>/<repo>/*.gguf. For this layout the repo folder has no config.json, so it was skipped and the model was invisible to mlx serve, mlx agent, and the dashboard coding-agent list. With a root config.json (from --assets-repo), the repo folder itself was registered as a model with no weights. DeepSeek V4.1 Flash uses the same layout.

Fix

Only the folder branch of discoverLocalChatModels changes (packages/lm/src/model-discovery.ts):

<modelsDir>/<repo>/
  primary safetensors        → as before (config.json path); never searched deeper
  top-level target GGUF      → as before
  else → scan <repo>/<variant>/*.gguf   (one level, sorted, no dot-folders)
           a variant target found → list it; <repo> itself is not a model
           none, root has a GGUF (mmproj only) → skipped, as before
           none                 → config.json path, as before
  • Names: the file stem, as before. A clash gets the <repo>- prefix, as before.
  • Sidecars (requiresAssets, Gemma4/Muse) are still checked beside the GGUF, which matches the loader.
  • An unreadable variant folder is reported through onEntryFailure and does not hide its siblings.

Real check

Discovery over my real ~/.mlx-node/models (75 models), old vs new: one added line, nothing else changed.

> Qwen3.8-Flash-Next-UD-Q4_K_XL-00001-of-00004  qwen3.8-flash-next-gguf/UD-Q4_K_XL/...-00001-of-00004.gguf  qwen4_exp

Tests

9 new cases in packages/lm/__test__/model-discovery.test.ts: Flash Next layout, root config.json, mmproj-only root, two variants with a clashing name, depth limit and top-level priority, skipped folders (MTP, dot, assets, safetensors-owned), symlinked and dangling variant links, Gemma sidecars beside the variant, unreadable variant. 7 of them fail on the old code; the other 2 are guards.

vp test on model-discovery, gguf-name, agent models, server discover, dashboard models: 161 passed. yarn typecheck and vp lint --type-aware --type-check are clean.

Not in this PR

The dashboard catalog checks (isModelPresent, isModelInstalled in packages/dashboard/src/models.ts) read only the model folder's top level. No catalog entry is nested today, so nothing is wrong now. They need the same rule if Flash Next or DeepSeek V4.1 Flash joins the catalog.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1a4822b7-a703-4cc1-88fb-fafcdba1f202

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T02:47:40.511169Z fca6503 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.

Base automatically changed from refactor/gguf-name-parsers to fix/download-gguf-load-hint November 9, 2026 01:41
Brooooooklyn and others added 2 commits November 9, 2026 10:46
`mlx download model -g "*UD-Q4_K_XL*"` keeps repo paths, so Qwen3.8 Flash
Next and DeepSeek V4.1 Flash land at <modelsDir>/<repo>/UD-Q4_K_XL/*.gguf.
Discovery read only <modelsDir>/<repo>/*.gguf, so mlx serve, mlx agent and
the dashboard agent list did not find them.

When a repository folder has no top-level target GGUF and no primary
safetensors, discovery now scans its variant folders, one level only,
sorted, with dot-folders skipped. A repository with a variant target is not
itself registered, even with a root config.json. Everything else keeps the
old path: top-level targets win, safetensors folders are never searched,
companion-only roots stay skipped, and sidecars are checked beside the GGUF.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
.staging/ holds the dashboard's unpublished download jobs and publish
backups; scanning it as a repository listed them as models, and the
staged copy could take the installed model's ID.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Brooooooklyn
Brooooooklyn merged commit b6ab507 into main Nov 9, 2026
10 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/discovery-nested-gguf branch November 9, 2026 05:43
Brooooooklyn added a commit that referenced this pull request Nov 9, 2026
Part of stack #349, on top of #341. CI runs after the PR below it merges
and GitHub retargets this one to `main`.

## Why Renovate's lock file maintenance (#328) never succeeds

#328 updated only `Cargo.lock`; its `renovate/artifacts` check fails on
`yarn.lock`. Renovate rebuilds `yarn.lock` from empty, and a fresh
resolve fails:

```
@yarnpkg/[email protected] (npm, 2026-09-24)
  dependencies.got = "patch:got@npm%3A11.8.2#~/.yarn/patches/got-npm-11.8.2-c1eb105458.patch"
→ YN0001: ENOENT .yarn/patches/got-npm-11.8.2-c1eb105458.patch
```

The patch file exists only in the Yarn repository. Our current lock
still holds `@yarnpkg/[email protected]`, so normal installs work; only a fresh
resolve fails. `@yarnpkg/core` is used only by the private
`@mlx-node/internal-tools`.

**Fix:** root resolution `"@yarnpkg/core/got": "npm:^11.8.6"`. It
replaces only that one dependency, with the plain npm `got` that our
lock already ships, and keeps `@yarnpkg/core` at its newest release.

## Refresh

| Change | Detail |
|---|---|
| `yarn.lock` | rebuilt from empty (Renovate's method); a full install
leaves it unchanged; `--immutable` passes |
| Caret ranges | 41 lower bounds in 14 `package.json` files raised to
npm latest; no major version changes exist |
| `examples/package.json` | `@napi-rs/image` exact pin `1.14.0` →
`1.16.0`; `ai`, `zod`, `@openrouter/ai-sdk-provider` ranges raised |
| Held | `@napi-rs/cli` `~3.8.6` (was `^3.8.6`); see below |
| Kept | `drizzle-orm` `1.0.0-rc.5-ab785fc` pin (npm `latest` 0.45.4 is
older); other exact pins are already latest |

The `@napi-rs/image` pin mattered: with `1.14.0` in `examples/` and
`^1.16.0` elsewhere, Yarn nested a copy in `examples/node_modules`.
`findNodeModules()` in `examples/grpo/lsp.ts` stops at the nearest
`node_modules`, so it could not find `@octokit` and
`examples/__tests__/lsp.test.ts` failed (75 tests).

## Checks (local)

- `yarn build:ts`, `yarn typecheck`, `vp lint --type-aware
--type-check`, dashboard `build:ui`: pass.
- Full `vp test --run`, compared with the base branch (#341) on the same
machine: same result on both (119 files pass; 125 files / 17 tests fail
on both, all `|addon|` tests that need a current native addon build,
which this machine does not have). No test fails only on this branch.
- Peer-dependency warnings after install are the same 3 as before.

## Why `@napi-rs/cli` is held at `~3.8.6`

`@napi-rs/cli` 3.10.0+ adds a `__napiBindingTarget` export to the
generated loader and `index.d.cts` (checked in the published 3.8.0 …
3.10.12 tarballs: first in 3.10.0). Neither committed declaration copy
has it, so `packages/core/build.ts` `assertDeclarationCopiesMatch()`
would fail every macOS native build. With `^3.8.6`, any fresh resolve
(Renovate's lock rebuild included) picks 3.10.x, so the range is
narrowed to the version this repo already builds with. The 3.10 upgrade
needs regenerated bindings and a full native build; that is a separate
change. (Found by Codex adversarial review.)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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