Skip to content

[Feature] AMD NPU: all NPU PRs and follow-ups stacked for testing together - #17519

Closed
LeoBorcherding wants to merge 147 commits into
unslothai:mainfrom
LeoBorcherding:studio/npu-stack-all
Closed

LeoBorcherding wants to merge 147 commits into
unslothai:mainfrom
LeoBorcherding:studio/npu-stack-all

Conversation

@LeoBorcherding

@LeoBorcherding LeoBorcherding commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

All eleven AMD NPU PRs plus four follow-ups merged onto main in one branch, so the whole NPU experience can be tried and reviewed together. Draft: review and merge the individual PRs; this one is for testing them as a set.

# PR What it does
1 #17512 Lemonade's output in its own log (Settings > Logs) and the real reason a model failed to load
2 #17511 NPU context sized to free RAM instead of a flat 8192
3 #17509 Strix Halo VRAM shows the carve-out, not carve-out plus shared RAM
4 #17513 Newer models that run on a Ryzen AI laptop listed first
5 #17514 Hugging Face model cards for NPU models in the Hub
6 #17515 Model picker for the Q4NX convert card
7 #17510 Power mode, prefill chunk length and image pre-resize for NPU models
8 #17505 FastFlowLM and Lemonade versions under Settings > Engines
9 #17506 Drop the FastFlowLM / Lemonade version line from the picker and Hub
10 #17507 NPU models footer as a full picker row
11 #17508 Resident NPU model memory in the live monitor, plus an NPU card (device, driver, load)
12 #17520 AMD Windows GPU utilization on comma-decimal locales
13 #17521 Q4NX converter pin with the stock Qwen3.5 GGUF fix
14 #17522 Q4NX export options on every machine
15 #17523 VRAM tile no longer Unknown beside an unreadable integrated GPU
16 #17525 Hub ?npu= links open the NPU model, and the card notes its pinned revision
17 #17526 NPU downloads: free-space check, cancel, one download per model across processes, verifying/finishing states
18 #17530 Search and Code off by default on NPU models (a tool list turns off Qwen3.8 speculation, ROCm/FastFlowLM#1016)
19 #17531 Warning when a model needs more memory than the NPU can map (Windows: about half of RAM)
20 #17532 Chat titles no longer run on the NPU model
21 #17533 Q4NX export refuses model sizes FastFlowLM has no kernels for
22 #17534 Q4NX export reads the GGUF header once and prefers quants the converter packs directly
23 #17535 Downloaded NPU models in Settings > Storage, with delete
24 #17539 FastFlowLM's own error on a failed load, plus one line of advice for the known ones (stacks on #17512)

Merge notes, beyond the plain merges:

Checked at 0b27683 on Windows 11, Ryzen 9 9950X + 2x R9700, no NPU: frontend typecheck clean (with tests), npm run build succeeds, 109 NPU/Hub/title/export frontend tests pass, backend NPU + FastFlowLM download + Q4NX + log tests 276 passed; the 12 failures are symlink setups in test_npu_detect, test_export_npu_q4nx and test_export_q4nx_accounts (WinError 1314: this box has no symlink privilege). Not run on a Ryzen AI NPU yet.

Testing Qwen3.8-27B and Qwen3.6-35B MoE on a Ryzen AI NPU

Both fail on a Strix laptop and nothing in the code explains it yet: the 27B download (18 GB) never finished, and the 35B MoE (22 GB) fails to load every time. Lemonade hides FastFlowLM's own error unless it runs at debug (lemonade-sdk/lemonade#4131), so this run is to get the real reason.

  1. NPU visible (Linux): ls /dev/accel/ shows accel0, and lsmod | grep amdxdna lists the driver.
  2. Install this branch: git clone -b studio/npu-stack-all https://github.com/LeoBorcherding/unsloth && cd unsloth && bash install.sh --local, then unsloth studio -p 8888.
  3. In Unsloth Studio, model picker > NPU models: download and load qwen3.8-mtp-27b-FLM (or qwen3.8-dflash2-27b-FLM, the faster variant) and qwen3.6-moe-35b-a3b-FLM, with context left on Auto. Search and Code now start off on NPU models; leave them off for the speed check, then turn one on to see the difference in tok/s. Note free disk before the 27B download (df -h ~).
  4. If a load fails, the error now carries FastFlowLM's own reason ([Bug] AMD NPU: a failed model load hides FastFlowLM's own error, so the user only sees "Failed to load X model!" #17539 turns Lemonade's debug output on for the length of the load); also save Settings > Logs > the lemonade-*.log file.
  5. Run the same models through FastFlowLM directly, so its own error prints:
    FLM_MODEL_PATH=~/.unsloth/studio/lemonade/flm \
      $(find ~/.unsloth/studio/lemonade/cache/bin -name flm -type f | head -1) \
      run qwen3.6-moe:35b-a3b
    
    and the same with qwen3.8-mtp:27b. If find comes back empty, send ls -R ~/.unsloth/studio/lemonade/cache/bin.

Please send: the error text, the lemonade-*.log, the flm output, free -g and df -h ~.

Expected: Qwen3.8-27B (both -mtp and -dflash2) stays capped at 8192 tokens (#13525, FastFlowLM side ROCm/FastFlowLM#1001); other NPU models now size their context to free RAM (#17511).

When a FastFlowLM load or NPU chat failed, Unsloth Studio kept only Lemonade's
one-line summary and left everything lemond printed at debug. Log what lemond
printed since the request started at warning on failure, and add its first
error line the summary does not already say to the error the user sees.
The NPU list followed the backend's alphabetical order, so d3 and Gemma sat
above Qwen3.8 and Qwen3.6. Qwen models now lead, newest version first, and
everything else keeps the backend's order after them.
…cker

The NPU list in the model picker ended with the runtime versions, which is
noise in a model chooser. The Hub's NPU list still shows them.
…Logs

Each lemond start writes logs/lemonade/lemonade-<epoch>-port-<port>.log beside the
llama-server logs, pruned the same way, so a failed NPU load can be read in full
from the Logs page instead of only the lines tailed into the server log.
… Strix laptop

Newest-Qwen-first put qwen3.6-moe 35B-A3B and qwen3.8 27B at the top, which fail to load
or take hours to download on a Ryzen AI laptop. Recommend qwen3.5 9B/4B, Gemma 4, gpt-oss,
LFM3 and the other new small models first; the rest keep Lemonade's order.
Under the All filter, the model picker ended with a thin 12px strip pressed
against the panel's rounded bottom edge. It is now a pill row like the
models above it, with the same hover and focus treatment and room below it.
The 8px gap above it is unchanged, so the floating Eject button keeps its
place.
…machines

Engines named llama.cpp, whisper.cpp, audio.cpp and MLX, but not the runtimes
behind AMD Ryzen AI NPU chat. The section now shows FastFlowLM and Lemonade
with the versions /api/npu/status already reports, only where the NPU runtime
is installed, read-only like MLX. Labels added to every locale.
FastFlowLM's model_list.json names each model's Hugging Face repo (and,
for some, a pinned revision). The NPU catalog now carries it as hf_repo /
hf_revision, and the Hub's NPU list opens the same split detail pane GGUF
models get: repo link, base model, size, capabilities, max context, the
row's Download/Run/Delete, and the README at that revision.
… shared RAM

On a carve-out APU the driver pool is the BIOS carve-out plus WDDM shared
memory, and that shared part is system RAM the RAM tile already counts.
The VRAM tile, device row and floating monitor now divide usage by the
carve-out and show the RAM the GPU can still borrow on its own line,
capped by free RAM. The GGUF row names the llama.cpp build and drops the
'Shared system RAM' label from a budget that is mostly the carve-out.
…outgrows

With no qualifying carve-out (a 2 GiB UMA slice with 34 GiB shared), the VRAM
tile fell back to the combined pool as bare VRAM. It keeps main's split label
there again; only a carve-out at least as large as its shared part reads as
the carve-out alone.
…size run settings

FastFlowLM tuning for AMD NPU models under Advanced settings, sent to
Lemonade as the flm_args recipe option. Each persists like any run
setting (saved sets, Always load, the server-shared override) and a
change makes /load reload instead of answering already_loaded.
Auto now picks the largest context whose bf16 KV cache (full-attention
layers only, read from FastFlowLM's config.json) plus FastFlowLM's prefix
cache fits the RAM left after the weights and a 2 GiB headroom, up to
65536 or the model's limit, never below 8192. A missing config.json keeps
8192. Pins still win; one above the estimate is logged and flagged in the
run settings.
The Q4NX convert card took a repo, a file and a base model as free text. It now
searches GGUF repos on the Hub (or lists the on-device GGUF models), lists the
repo's .gguf files with Q4_0, Q4_1 and Q4_K_M first and the rest marked as
re-quantized, fills the original model from the card's base_model, hides Hub
repos whose GGUF architecture the pinned converter does not map, and notes when
the architecture is unknown until conversion.
The Lemonade log now carries Unsloth Studio's side: the lemond command it started, each
load with its context size, and how a failed request ended. The server-log warning is a
structured record naming the Lemonade log file instead of a plain multi-line string.
Settings > System > Live monitor and the floating monitor get an NPU card when
/api/npu/status reports a supported XDNA 2 NPU: the device, its driver, and the
NPU model resident in system RAM. On Windows /api/system now reports
npu_load_percent from the GPU Engine counters of the NPU's own adapter, matched
by the LUID its PnP node carries; Linux has no counter for it, so the card shows
no load there.
oobabooga and others added 20 commits November 11, 2026 18:07
# Conflicts:
#	studio/backend/core/inference/npu_backend.py
An unreadable shared iGPU now sits under Shared with system RAM, but it has no free reading, so the VRAM tile and the floating monitor printed a dangling 'Estimated available: Unknown'. Keep the label and drop the estimate line when nothing reports free memory.
…nto studio/npu-stack-all

# Conflicts:
#	studio/frontend/src/components/floating-monitor.tsx
#	studio/frontend/src/features/settings/tabs/resources-tab.tsx
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.

3 participants