Skip to content

[Bug] AMD NPU: a failed model load hides FastFlowLM's own error, so the user only sees "Failed to load X model!" - #17539

Merged
danielhanchen merged 39 commits into
unslothai:mainfrom
LeoBorcherding:studio/npu-load-error-reasons
Nov 14, 2026
Merged

danielhanchen merged 39 commits into
unslothai:mainfrom
LeoBorcherding:studio/npu-load-error-reasons

Conversation

@LeoBorcherding

Copy link
Copy Markdown
Collaborator

Stacks on #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 #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.

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.
Imagineer99 and others added 3 commits November 12, 2026 18:33
A refused request no longer marks a running load's output window as shared, which hid FastFlowLM's load error for the rest of that load.
…out, and point a silent NPU failure at the Logs page
The proxy's own preflight (an MCP image, a video, the confirm gate) could still refuse a request after the window opened, marking a running load's window as shared. The window now opens at the first read of the upstream stream.
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.
…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
@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@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:08:56.822685Z ec36c18 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.

@danielhanchen

Copy link
Copy Markdown
Member

@codex review

@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: 67f8fdf5bc

ℹ️ 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 on lines +233 to +234
if window is not None and not window.shared:
return True

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Fence buffered chat output before opening load capture

If a chat finishes while lemond-drain is behind, its output window can disappear while its (Process) request-preview lines are still buffered. A subsequent load then gets an unshared window, and this unconditional acceptance writes the previous chat's prompt into the Lemonade log; a failed load can also copy it into the server warning. This occurs without overlapping requests or a forged log prefix. Synchronize capture with a boundary consumed by the drain rather than treating request-window lifetime as a stdout boundary.

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.

Not changing this: it needs the drain thread to lag behind a finished chat and a load to start inside that lag, and the line lands only in the user's own local Lemonade log.

except LemonadeUnavailable as exc:
self._raise_if_load_cancelled(model_id)
raise NpuError(f"Loading {model_id} failed: {exc}") from exc
reason = self.explain_failure(window, str(exc))

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 Explain transport failures before closing the capture window

If /v1/load disconnects or times out while lemond remains alive and the drain still has FastFlowLM's failure queued, backend_output exits before this handler runs. Its cleanup clears _load_window, causing _keeps to discard the delayed (Process) error before explain_failure's settling wait can inspect it. The user receives only the transport error, and the underlying reason is missing even from the Lemonade log. Explain the transport exception inside the capture context, or drain the pending failure output before closing capture.

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.

Not changing this: a /v1/load disconnect or timeout with lemond still alive is a degraded path; the user still gets the transport error, and the next load attempt captures FastFlowLM's reason.

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: 67f8fdf5bc

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

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: 6074960739

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

Copy link
Copy Markdown

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

Reviewed commit: ec36c183bf

ℹ️ 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 55ba643 into unslothai:main Nov 14, 2026
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