Skip to content

[Feature] AMD NPU: write Lemonade's output to its own log like llama-server, and show why a model failed to load - #17512

Merged
danielhanchen merged 19 commits into
unslothai:mainfrom
LeoBorcherding:studio/npu-load-logs
Nov 14, 2026
Merged

danielhanchen merged 19 commits into
unslothai:mainfrom
LeoBorcherding:studio/npu-load-logs

Conversation

@LeoBorcherding

@LeoBorcherding LeoBorcherding commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

When a FastFlowLM model failed to load on the AMD NPU, from the model picker or from chat, Unsloth Studio / Desktop showed only Lemonade's one-line summary, for example "Failed to load qwen3.6-moe:35b-a3b model!". The backend log had the same line as a lemonade SSE error event warning, and everything lemond printed about the failure was logged at debug only, so nobody could tell whether it was memory, context size, the driver or a bad download.

The fix

  • Unsloth Studio counts the lines it drains from lemond and takes a mark before each NPU load and chat request. When the load or chat fails, it logs at warning what lemond printed since that mark (at most 40 lines). Successful requests stay at debug, and Lemonade's info-level output carries no prompt or reply text.
  • The error the user sees gets lemond's first error line that the summary doesn't already say (for example "FastFlowLM process has terminated with exit code 1"). When there's nothing new to add, it points at the Logs page.
  • Each lemond start now also writes its output to logs/lemonade/lemonade-<epoch>-port-<port>.log, pruned like the llama-server logs, and Settings > Logs lists it under a new lemonade family. A failed NPU load can be read in full there.

Known limit: at the pinned Lemonade (v2026.44.1), FastFlowLM's own console output goes to NUL unless lemond runs at debug (fastflowlm_server.cpp#L226, process_windows.cpp#L270-L279). This PR doesn't switch lemond to debug: at that level it also logs message-content previews and starts flm pull with inherited console handles on Windows. So a reason only FastFlowLM prints (such as running out of NPU memory) still doesn't reach Unsloth Studio. Filed upstream as lemonade-sdk/lemonade#4131.

How it was tested

  • Windows 11 desktop with no NPU; lemond's output is faked by feeding the real drain loop.
  • New tests/test_npu_failure_output.py covers a failed /v1/load and a failed NPU chat (streaming and JSON), the per-start log file and its listing in Settings > Logs; test_npu_chat_route.py gains the chat cases. The new tests fail on main and pass here. test_log_bounds.py knows the new family and its pruning.
  • Backend NPU and log suites: 140 passed, 75 skipped on Windows (test_npu_backend.py is POSIX-only and passes under WSL).

Not tested: no run on a Ryzen AI NPU, so lemond's real output for a failed FastFlowLM load isn't captured. The console format comes from Lemonade's LOG_FORMAT, not a live log.

Screenshots

NPU spoofed: fake Lemonade/FastFlowLM on a Windows 11 PC with no NPU; no speed numbers. Before | after: fork phase stack, phase-0 base 5d5c138 | phase 1 ac3e06e. This PR's head dddfe69 is part of ac3e06e. Light mode, mint theme, glass on, same on both sides.

Before | after: a failed load of qwen3.8-mtp-27b-FLM now adds lemond's reason ("FastFlowLM process has terminated with exit code 1") to the bare "Failed to load" toast.
17512

After only (the base has no Lemonade log): Settings > Logs lists Lemonade's own log, filtered here to that failed load.
17512

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.
…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.
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.
@LeoBorcherding LeoBorcherding changed the title [Bug] AMD NPU: a failed model load shows no reason and keeps Lemonade's output out of the logs [Feature] AMD NPU: write Lemonade's output to its own log like llama-server, and show why a model failed to load Nov 11, 2026
LeoBorcherding added a commit to oobabooga/unsloth that referenced this pull request Nov 12, 2026
A refused request (ours, or the proxy's own preflight: an MCP image, a video, the confirm gate) no longer opens a window, which marked a running load's window as shared and hid FastFlowLM's load error. The window now opens at the first read of the upstream stream.
@danielhanchen danielhanchen self-assigned this Nov 13, 2026
danielhanchen added a commit to LeoBorcherding/unsloth that referenced this pull request Nov 13, 2026
…or-reasons

# Conflicts:
#	studio/backend/core/inference/lemonade_server.py
#	studio/backend/routes/inference.py
#	studio/backend/tests/test_npu_chat_route.py
#	studio/backend/tests/test_npu_failure_output.py
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 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-13T20:06:23.462077Z 9cbfc42 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

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: bd2233e035

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

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 9cbfc4259a

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

# Conflicts:
#	studio/backend/core/inference/npu_backend.py

[skip ci]
@danielhanchen
danielhanchen merged commit 202fc65 into unslothai:main Nov 14, 2026
danielhanchen added a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 14, 2026
…he user only sees "Failed to load X model!" (unslothai#17539)

Stacks on unslothai#17512; the diff here also shows its commits until it merges.

When an NPU model fails to load, Lemonade answers `Failed to load
<model> model!` and nothing else. FastFlowLM does print the reason, but
lemond only relays a backend's output when the backend was started at
debug (lemonade-sdk/lemonade#4131), so unslothai#17512's reason lookup only ever
sees lemond's generic lines.

Running lemond at debug all the time isn't an option: it logs chat
content at that level, and flm prints part of every request body. So
lemond is switched to debug over `/internal/set` for the duration of one
`/v1/load` and back to info after. Outside a load, the relayed backend
lines and any debug lines are dropped before they reach the Lemonade log
or the tail. A load that overlaps a chat stays at info. `log_level:
info` is pinned in the config, since `/internal/set` saves what it's
given.

Known FastFlowLM failures also get one line of advice after the raw
line: NPU out of memory (ROCm/FastFlowLM#904), no hardware context
(`CREATE_HWCTX`), model files from an older FastFlowLM
(ROCm/FastFlowLM#685), and flm.exe blocked by Smart App Control
(`0xC0E90002`, ROCm/FastFlowLM#973). No UI changes.

Known limit: lemond writes debug message content raw onto the same
stdout as its own records. If a chat joins while a load is in flight,
and its content has a line that itself starts with a complete lemond log
prefix (date, time, `[Info] (Tag)`), that line is kept in the local
Lemonade log. Telling the two apart needs lemond to forward backend
output without debug (lemonade-sdk/lemonade#4131).

## Tests
`tests/test_npu_failure_output.py` feeds lemond's and flm's lines
through `_drain`: each known failure gets its advice after the raw line,
an unknown one gets none, flm output is kept only during a load, chat
content stays out of the log when a chat overlaps a load or either level
change, and a restart never inherits debug.

Tested on Windows 11, Ryzen 9 9950X + 2x R9700, no NPU: the unit tests
above, with lemond and flm output simulated. The matched strings come
from FastFlowLM's source and the linked issues, not from a failure
reproduced here. Not run on a Ryzen AI NPU.

---------

Co-authored-by: imagineer99 <[email protected]>
Co-authored-by: Daniel Han <[email protected]>
Co-authored-by: Daniel Han <[email protected]>
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