Repository navigation
fix(cli): print one load or convert hint per GGUF model, not per shard - #339
Conversation
After a GGUF download the CLI printed `mlx convert -i <shard> -o <dir>-mlx` once per weight file. For a split set that is wrong in three ways: `mlx convert` reads only the file it is given, shards 2..N carry no architecture, and every line shared one output dir, so each run replaced the previous one. Qwen3.8 Flash Next (and DeepSeek V4.1 Flash) also need no conversion: their native loader opens shard 00001 and reads the rest. `ggufNextSteps` now collapses each split set to shard 00001, reads the GGUF architecture, and prints: - "Load directly" for families listed in `ggufArchitectures` (split sets only when the family allows splits), with an `--assets-repo` note when a family needs config.json + tokenizer.json beside the file - merge-then-convert for split sets with no split-aware loader - one convert line per model, with its own output dir when there are several - an "incomplete split" line when the selection lacks shards Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: db8f02b7d5
ℹ️ 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".
…sets-repo --assets-repo writes config.json/tokenizer.json to the output root, but the gemma4/muse loaders read them beside the GGUF. For a GGUF in a variant subfolder the old note sent the user to a fix that leaves loading broken. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a regex parseGgufFileName reads <stem>-NNNNN-of-NNNNN.gguf right to left: fixed five-digit count, '-of-', five-digit ordinal, '-'. Anything else is a single file. It also refuses an empty stem, which the old pattern accepted. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The split-name regex in supportedGgufName did the same job as the CLI's new parser. The parser now lives in model-discovery.ts (exported from @mlx-node/lm and the model-discovery subpath) and both call sites use it. Rules are unchanged: a split name must be shard 00001 of 1..1024 shards, and a family needs ggufDiscovery.split for more than one shard. The parser now accepts an empty stem, as resolve_gguf_shards and the old regex did. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Problem
After
mlx download model -m unsloth/Qwen3.8-Flash-Next-GGUF -g "*UD-Q4_K_XL*"the CLI printed:Each line is wrong:
mlx convertreads only the file it is given, so shard 1 alone gives a model with only its own tensorscrates/mlx-core/src/utils/gguf.rsconvert_gguf_to_safetensors_inner;docs/convert-quantize.mdtrap #13general.architecture(llama.cpp split puts metadata in split 0 only)-o, so each run replaces the last onepackages/cli/src/commands/convert.tscommitStagedOutputqwen4_exp/weights.rsindex_gguf;docs/qwen38-flash-next.mdFix
ggufNextSteps()replaces the per-file loop:Output for the Flash Next download now:
Only the printed hint changes. Download, sync, and marker logic are not touched.
Split-name parser (no regex)
parseGgufFileName()inpackages/lm/src/model-discovery.tsreads<stem>-NNNNN-of-NNNNN.ggufright to left (5-digit count,-of-, 5-digit ordinal,-). Anything else is a single file.ggufLoadEntries)supportedGgufName)/-(\d{5})-of-(\d{5})\.gguf$/iggufDiscovery.split)New discovery test: only shard 00001 of a qwen4exp split set is listed; a clef split set and an
-00002-of-00001name are refused.Other GGUF-name regexes stay (
QWEN35_XL_GGUF,BONSAI_PQ2_GGUF,GGUF_COMPANION_NAME): they match quant tags or tokens, not split names.Tests
__test__/cli/download-gguf-next-steps.test.ts: split collapse, direct split load (qwen4exp), merge path (qwen35 split), gemma4 assets note, unique-oper variant, unreadable header fallback, incomplete split.vp teston the 4 download test files: 75 passed.yarn typecheckandvp lint --type-aware --type-checkare clean.Not in this PR (found during research)
mlx servemodel discovery scans<modelsDir>/<entry>/*.ggufonly one level deep, so the nested layout<modelsDir>/qwen3.8-flash-next-gguf/UD-Q4_K_XL/*.ggufthatmlx downloadcreates is not found (packages/lm/src/model-discovery.tsmodelFileInventory). This needs a separate decision.🤖 Generated with Claude Code