Skip to content

docs: the NPU runlist-failure contract (what a 614 does to the request and the process) - #1058

Merged
bong-water-water-bong merged 2 commits into
mainfrom
1bit/npu-docs-runlist
Nov 5, 2026
Merged

bong-water-water-bong merged 2 commits into
mainfrom
1bit/npu-docs-runlist

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Docs only. The engine has answered a failed runlist this way since #1021 and docs/npu.md did not mention it, so an
operator who sees

{"error":{"message":"npu runtime: invalid call (code 614): state 8, run 0 of 28"}}

in a client and a backend that exited 1 has nothing to read.

What the section says

  • how to read the message: the category is the hundreds digit of the code (6xx = a call made in the wrong state or on
    the wrong object), and run N of M is the index of the layer run inside that token's runlist that did not complete;
  • the contract: the request that hit the failure is answered with the error frame and the process then exits
    non-zero
    , rather than serving later requests on a hardware context whose state is dead — with the reason the engine
    cannot do better in-process (the c22 board's backend answered 614 to every subsequent request while a fresh process
    answered normally);
  • that the supervisor (Lemonade's backend watchdog, a systemd unit, the OS menu's launcher) is what rebuilds the
    context, so a client sees one failed request and the next lands on a working backend;
  • that if a fresh backend also cannot create a context, the device is the thing to look at: the driver refuses new
    contexts until amdxdna is reloaded, and backend restarts cannot fix that;
  • pointers to app/serve_watchdog.h (npu_run_failed()) and tests/serve_watchdog_test.cpp.

Behaviour only: no numbers, no model rows, no claim about how often a runlist fails. It deliberately does not
describe the firmware-side cause, which is still open.

tools/copyright.py --check rc 0. One file, docs.

…t and the process)

The engine has answered a failed runlist this way since #1021, and the doc said nothing about it, so an operator who sees
`npu runtime: invalid call (code 614): state 8, run 0 of 28` and a backend that exited 1 has nothing to read.

Documents: the error frame's shape and how to read it (category = hundreds digit, `run N of M` = the layer run inside the
token's runlist); that the failing request is answered and the process then exits instead of serving on a dead context
(the c22 board's backend answered 614 to every later request while a fresh process answered normally, so an in-process
retry is not available to the engine); that a supervisor rebuilds the context; and that when even a fresh backend cannot
create one the device needs the driver reloaded, which backend restarts cannot fix. Points at
`app/serve_watchdog.h` (`npu_run_failed`) and `tests/serve_watchdog_test.cpp`.

Behaviour only: no numbers, no model rows, and no claim about how often a runlist fails.
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

1021 - Partially compliant

Compliant requirements:

  • The PR implements the mechanism to detect NPU runtime failures and exit the process
  • The PR updates documentation to explain the behavior when a dispatch fails
  • The PR adds unit tests to verify the failure detection and exit behavior

Non-compliant requirements:

  • The PR does not include the actual implementation changes in app/serve_watchdog.h and app/unified.cpp as those are not part of the diff

Requires further human verification:

  • The actual implementation changes in app/serve_watchdog.h and app/unified.cpp need to be verified by a human reviewer to ensure they are correctly implemented
⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Documentation Clarity

The documentation section on "When a dispatch fails" is clear and comprehensive, explaining the behavior of the engine when an NPU dispatch fails. It correctly describes the error message format, the exit behavior, and the role of the supervisor in handling dead contexts. The inclusion of references to app/serve_watchdog.h and tests/serve_watchdog_test.cpp is helpful for developers to understand the implementation details.

### When a dispatch fails

A token's work is one runlist of the model's layer runs. When the NPU runtime reports that one of those runs did not
complete, `1bit unified` answers **the request that hit it** with an error frame and then exits non-zero — it does not
keep serving on that hardware context:

{"error":{"message":"npu runtime: invalid call (code 614): state 8, run 0 of 28"}}


The code's category is its hundreds digit (`6xx`: a call made in the wrong state or on the wrong object) and `run N of
M` is the index, inside the token's runlist, of the layer run that failed.

Exiting is deliberate: after such a failure the context's own state is dead, and every later request on the same process
fails the same way — measured on the c22 board, where the same backend answered 614 to every subsequent request while a
fresh process answered normally on the same device. The supervisor (Lemonade's backend watchdog, a systemd unit, the OS
menu's launcher) is the only one that can build a new context, so the engine hands it the problem instead of answering
with something that looks like a result. A client sees **one failed request**, and the next one lands on a working
backend.

If a *fresh* backend also fails, the device is the thing to look at rather than the engine: the driver refuses new
hardware contexts until `amdxdna` is reloaded, and says so in its own kernel message — restarting backends cannot fix it.
`app/serve_watchdog.h`'s `npu_run_failed()` is the classifier for this (the runtime's failed-runlist message), and
`tests/serve_watchdog_test.cpp` (ctest `serve_watchdog`, in CI) covers it without a device.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

VERDICT: READY at 270cd84a — docs only, and every claim in the section traces to a line of code I checked.

The contract as written matches the implementation:

  • "answers the request that hit it with an error frame and then exits non-zero" — handle_generate() (unified.cpp:158) takes an on_run_failed callback, and both call sites (:301, :335) fire it only when npu_run_failed(ex.what()) is true, i.e. the frame goes out first and the exit is requested after it.
  • the classifier it points at — app/serve_watchdog.h:59 is what.find("npu runtime:") != npos && (find("(code 614)") || find("ERT_CMD_STATE_TIMEOUT")). The doc's "match its own prefix plus either code, never a bare state 8" is exactly that, and the test pins it in both directions: expect_npu(true, "npu runtime: invalid call (code 614): state 8, run 0 of 28"), true for the ERT_CMD_STATE_TIMEOUT spelling, and false for a bare "npu runtime: state 8" and for code 500.
  • run N of M is the layer run inside the token's runlist — that is the string the runtime builds in npu_rt.cpp's fail(errc::runlist_failed, "state N, run M of K"), which I read while reviewing npu-kernels #26 tonight, and M is runs.size().
  • "the driver refuses new contexts until amdxdna is reloaded" — matches the -ENODEV cascade recorded in that same lane's evidence for the per-count fallback (aie2_hwctx_restart: … has no host buffer address, then every new context refused).
  • "tests/serve_watchdog_test.cpp (ctest serve_watchdog, in CI)" — real and registered; I built and ran it tonight as one of #1055's three tests (3/3 passed).

tools/copyright.py --check rc 0. The section sits in the unified-serve part of docs/npu.md next to the endpoint examples, which is where an operator who just pasted that 614 into a grep would land. No numbers, no model rows, no frequency claim — so nothing here can go stale behind a measurement, which is the right shape for a contract section.

One thing I would add if the file is touched again, not a change request: the section explains when a 6xx is fatal but not how to tell it apart from the 614 a client sees when the device is already wedged (the case where a fresh backend also fails). The last paragraph does say "if a fresh backend also fails, the device is the thing to look at", so the information is there — a one-line cross-reference from the "device is wedged" symptom to this section would close the loop for someone reading from the other end.

@bong-water-water-bong
bong-water-water-bong merged commit 0f0bb20 into main Nov 5, 2026
8 of 9 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/npu-docs-runlist branch November 5, 2026 03:16
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.

1 participant