Skip to content

[Feature] Unsloth Studio / Desktop: unsloth list-npu-models lists the AMD NPU models with download and memory-fit state - #18049

Merged
danielhanchen merged 7 commits into
unslothai:mainfrom
LeoBorcherding:studio/cli-npu-list
Nov 18, 2026
Merged

danielhanchen merged 7 commits into
unslothai:mainfrom
LeoBorcherding:studio/cli-npu-list

Conversation

@LeoBorcherding

@LeoBorcherding LeoBorcherding commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

unsloth chat and unsloth inference take an NPU model by its -FLM id, but nothing in the CLI told you which ids exist. unsloth list-npu-models prints the catalog the app shows: the Hugging Face name (same name as the model picker since #17610), the -FLM id, the size, whether it's downloaded (or how far a resumable download got), and whether it fits the memory the NPU can map on this PC.

Memory the NPU can map on this PC: 122.9 GB

NAME                 ID                SIZE     DOWNLOADED  FITS IN MEMORY
Qwen3-0.6B-NPU2      qwen3-0.6b-FLM    0.7 GB   yes         yes
D3-Edge-NPU2         d3-edge-FLM       0.6 GB   no          yes
Gemma3-1B-NPU2       gemma3-1b-FLM     1.2 GB   no          yes
...
Chat with one: unsloth chat <ID>

Where the data comes from:

  • Unsloth Studio running: its /api/npu/status and /api/npu/models, so the names, sizes and the memory_needed_gb / fits_memory fields are the backend's own. It only reads; it never enables the runtime or starts a download.
  • Unsloth Studio not running: the same status the backend computes, read in-process without starting the NPU runtime, so a missing NPU, an NPU turned off with UNSLOTH_STUDIO_ENABLE_NPU, or FastFlowLM not installed is still named. When the runtime is ready it says to start Unsloth Studio, because the -FLM catalog comes from Lemonade, which only Unsloth Studio runs.

Every case it can't list is one line and exit 1, like list-checkpoints' errors. It sits next to list-checkpoints as a top-level command; no --json, since no list command has one.

Before / after on a real NPU

Same AMD DevLab runner, same job, Unsloth Studio installed from main and from this branch (run).

Before (main): No such command 'list-npu-models'.

before

After: no runtime yet, with and without Unsloth Studio running (exit 1, one line); then unsloth inference qwen3-0.6b-FLM enables the runtime and downloads the model; then the full listing with that model downloaded and the rest not (exit 0); then, with Unsloth Studio stopped, the one-line "isn't running" message.

after

machine kernel amdxdna / NPU firmware FastFlowLM / Lemonade commit
AMD DevLab X2-LA03-S03-D01, Ryzen AI MAX+ 395 (NPU Strix Halo), Ubuntu 24.04, 124 GiB 7.0.0-43-generic 2.25.260102.56 / 1.1.2.65 1.0.12 / 2026.44.1 (as Unsloth Studio installs them) da9006c (main e73b085 for before)

Tests

unsloth_cli/tests/test_npu_cli.py: the listing with downloaded, partly downloaded and not downloaded rows and fits / doesn't fit / unknown; no NPU, NPU turned off, an XDNA 1 NPU, FastFlowLM not installed, runtime installed but not enabled; no Unsloth Studio with a missing NPU, a missing runtime and a ready one; a dropped connection; and the real backend status() answering without starting the runtime. test_cli_lazy_commands.py gets the new command in its fixed order.

Full CLI suite: 2669 passed, 4 failed; the same 4 (test_doctor_mcp.py) fail on main.

Backend suite: no file under studio/ changes; on a Mac the full run hangs in the same test on main and on this branch.

Not covered

  • No "doesn't fit" or "partly downloaded" row on hardware: the runner has 124 GiB, so every catalog model fits, and nothing was interrupted. Both are unit-tested only.
  • Windows (where the NPU gets about half of RAM) not run.
  • A remote UNSLOTH_STUDIO_URL is refused, same as unsloth chat: the CLI only sends its self-issued token to a local Unsloth Studio.
  • With Unsloth Studio running, listing asks it for the catalog, which starts its Lemonade server if the runtime is enabled but idle, the same as opening the Hub.

# Conflicts:
#	unsloth_cli/tests/test_npu_cli.py
@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 commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: 🔄 Running

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

Review Status Commit Review trigger
📝 Code Review 🔄 Running since 2026-11-18T08:02:19.352080Z 9a0121a 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.

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

ℹ️ 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 thread unsloth_cli/_npu.py
Comment on lines +91 to +92
repo = str(model.get("hf_repo") or "").strip()
return repo.rsplit("/", 1)[-1] or str(model.get("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 Preserve display names for locally converted NPU models

When Studio has locally converted Q4NX models, its catalog includes rows with local.folder but no hf_repo (see LemonadeNpuBackend._local_rows). This helper therefore prints the generated local-npu-q4nx-<hash>-q4nx-FLM identifier in both NAME and ID. For exports stored under <run>/npu-q4nx, the actual run/model name disappears entirely, so users cannot identify which ID belongs to which fine-tuned model. Handle local.folder before the Hugging Face fallback, matching Studio’s npuDisplayName/npuLocalLabel behavior in studio/frontend/src/features/npu/display-name.ts.

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.

Fixed in 3697f93: converted rows are listed by their folder name (the save folder for /npu-q4nx), as npuDisplayName does.

@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: Didn't find any major issues. 🎉

Reviewed commit: 3697f932aa

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

Copy link
Copy Markdown

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

Reviewed commit: 9a0121a975

ℹ️ 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 c6b95ce into unslothai:main Nov 18, 2026
danielhanchen added a commit that referenced this pull request Nov 18, 2026
)

## Record the NPU detector's file load in the risky-loader baseline

The risky-loader lint in `Source lint` fails on `main` since #18049. It
shows up on unrelated PRs, for example #17550:

```
1 risky loader call site(s) not in the baseline:
  unsloth_cli/_npu.py:88  [dynamic-import] spec_from_file_location
```

### Cause

#18049 added `npu_detected()` to `unsloth_cli/_npu.py`. The CLI uses it
to reuse Studio's stdlib-only NPU detector without importing the Studio
backend. It loads the file through
`importlib.util.spec_from_file_location`, which
`scripts/lint_risky_loaders.py` flags until the call site is reviewed
and recorded.

### Why it is safe

The path is fixed: `Path(__file__).resolve().parents[1] /
"studio/backend/utils/hardware/npu.py"`. That is a file shipped in the
same package, and no user, network or checkpoint input chooses it. Any
failure, including a missing file, is caught and returns `False`.

So the lint's own guidance applies: record the call site with a reason
rather than change the code.

### Fix

One new entry in `scripts/risky_loaders_baseline.json`, generated with
`python scripts/lint_risky_loaders.py --update`. The generated `REVIEW
ME` placeholder is replaced with the reason above. No other entry moves,
and no code changes.

### Verification

- `python scripts/lint_risky_loaders.py`: fails on `main` on this call
site and passes with this change. `--self-test` passes too.
- The repo's risky-loader tests pass: 46 passed.
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.

2 participants