Repository navigation
[Feature] AMD NPU: Settings > Storage counts and lists downloaded NPU models and deletes them per folder through Lemonade - #17535
Conversation
NPU models live under <studio home>/lemonade/flm, which no storage source covered. Add it as the npu_models source in the Models group, list its model folders by FastFlowLM checkpoint, and delete through lemond's /v1/delete (bulk and per folder) so Lemonade's registry stays right.
… FastFlowLM model
…holding the pull lock
[skip ci]
|
@codex review |
1 similar comment
|
@codex review |
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: 70d31f5fd4
ℹ️ 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".
| const isModels = (entry: (typeof cache.entries)[number]) => | ||
| entry.key === "hf_hub" || entry.key === "npu_models"; |
There was a problem hiding this comment.
Attribute NPU storage to the folder's actual disk
When UNSLOTH_STUDIO_HOME is on a different volume from the disk reported by /api/system, this counts its NPU models in the system disk's Models segment. describe_cache() only computes device-aware system_disk_bytes for Hugging Face caches, so the NPU entry receives null; diskBytes() then uses its full size because the NPU directory is outside hfCache.cacheHome. Consequently, models on another disk inflate system-disk usage attribution and incorrectly reduce the Other segment. Supply device-aware system_disk_bytes for npu_models, or otherwise check its volume before counting these bytes here.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this: Settings already counts every cache outside the Hugging Face folder (uv, pip, the compile caches under the Studio home) on the system disk; NPU models follow the same rule, and a Studio home on another volume moves those rows too.
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 99e342f1f2
ℹ️ 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".
| resident = self.resident() | ||
| if resident is not None and resident.model.id in model_ids: | ||
| raise NpuError(f"Unload {resident.model.id} before deleting this folder.") | ||
| with reserve(model_ids): |
There was a problem hiding this comment.
Lock the folder-level resident check against concurrent loads
When another tab loads a shared-folder twin during a Storage delete, the resident snapshot here can run before load() commits; the first delete() then waits for the load's _lock, but afterward only checks the exact model ID. For example, clearing gemma4-it:e2b can therefore delete the newly resident gemma4e-flash:e2b weights through the other ID before the loaded twin is refused. Unlike the already-fixed resident-at-start case, the additional concurrency evidence is that load() holds _lock while these group-level checks run outside it. Hold _lock across the folder-level residency check and all member deletes, including the corresponding bulk-clear path.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not changing this: Studio cannot load a -flash twin (single-turn models are kept out of the catalog and load() resolves only catalog ids), so the example cannot happen; the remaining case needs a second tab to start a load inside the delete itself.
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
# Conflicts: # studio/frontend/tests/npu-api.test.ts [skip ci]
# Conflicts: # studio/backend/core/inference/npu_backend.py # studio/backend/routes/npu.py # studio/frontend/src/features/npu/api.ts # studio/frontend/tests/npu-api.test.ts [skip ci]
# Conflicts: # studio/backend/core/inference/npu_backend.py [skip ci]
Settings > Storage had no NPU row, so FastFlowLM model downloads under the NPU model path were invisible and could only be removed from the NPU picker one chat model at a time. Embeddings, transcription and single-turn models, and partial pulls kept for resuming, had no way to be deleted at all.
Storage now measures the NPU model folder and lists each model folder with the checkpoint from FastFlowLM's manifest. Per-folder delete and bulk Clear go through lemond (
/v1/delete), neverrmtree, so its registry stays in sync with the disk. They cover every FastFlowLM model lemond lists, not just the chat catalog, plus any registered model with files on disk. Neither will delete a model while it's downloading, and a download asked for during a delete is refused right away rather than waiting on it. Folders lemond doesn't own are left alone.Tests
tests/test_npu_storage.pycovers size, listing, per-folder and bulk delete, hidden non-chat checkpoints, partial pulls, refusing during a pull, and refusing a pull during a delete without blocking. The frontendnpu-apiandnpu-storage-rowstests cover the client.Tested on Windows 11, Ryzen 9 9950X + 2x R9700, no NPU: backend unit tests with lemond and the FastFlowLM manifest mocked. Not run on a Ryzen AI NPU.
Screenshots
NPU spoofed: fake Lemonade/FastFlowLM on a Windows 11 PC with no NPU; no speed numbers. Before | after: fork phase stack, phase 2
945ba98| phase 33669e68. Shot at3669e68; this PR's head has since moved to43ef4b7(backend and test changes only). Light mode, mint theme, glass on, same on both sides.Before | after: Settings > Storage gets an "AMD NPU models" row with a warning that Clear deletes them. It reads 0 B because the fake lemond writes no model files.

Also checked by building Unsloth Studio from this PR's merge base (left) and head (right), on the same spoofed AMD NPU:
Settings > System > Storage > Details: downloaded NPU models are listed with their size and folder, with a clear action.