Repository navigation
Description
What happens
On strixhalo (Linux 7.4.0-rc1-1bit, amdxdna srcversion 646FFC305CAFF8F9BD736FF = the 0007+0008+0009+0010
driver this fleet runs, tdr_timeout_ms=15000), with the shipped c24 payload (sha256 502d2a81…), the board's model
(6abacb4262504f2a, Qwen3-0.6B) and the board's kernel set (1024x3072x16x8):
as soon as two hardware contexts have each dispatched once, the next dispatch on either one stops the array. Both
clients fail together — {"message": "npu runtime: invalid call (code 614): state 8, run 0 of 28"} after 2 chunks — and
the firmware capture is the one the appliance has produced since c17:
aie2_set_cmd_timeout: Context ID: 15 / DPU PC: 0xffffffff / TXN OP ID: 0xffffffff
/ Context PC: 0x28b060ad / Timed out sub command ID: 0
aie2_tdr_recover_all: Array stopped dispatching, power-cycling NPU to recover
This is the root cause behind the position stories in #1021/#1051 and the board's "third request dies" rows: it is not
the sequence length, it is how many contexts are configured on the array — and one client alone never reproduces it.
How it was narrowed (each row npu-hold, shipped payload, module unchanged, evidence dir per row)
| probe | result |
|---|---|
| two serves, both asked for 1 100 tokens at the same instant | 3/3 wedge (both 614 run 0 of 28 at chunk 2), 5 TDRs — npu-longctx/two-client-20261105-034608/ |
the same two serves, sequential (SEQ=1: A completes before B starts) |
3/3 wedge, 9 TDRs → overlap is not required — npu-longctx/two-client-seq-20261105-035726/ |
| a second serve loaded but never dispatched | 0/2 clean, hwctx_num stayed 0 while it was "ready" → contexts are created lazily at the first dispatch — npu-longctx/idle-context-20261105-042034/ |
xrt-smi examine -r aie-partitions with both contexts warmed, then one row |
both contexts in one partition: Partition Index 0, Columns [0..7] (ctx 598 pid 1499388, ctx 599 pid 1499561), and the row wedges — npu-longctx/partition-20261105-042308/ |
| one client, long rows (1 000–3 408 positions; 3 851-token prefill ×5; per-block-count mode included) | clean in every row, 0 TDR |
hwctx_num create/destroy, 3 rounds incl. ~20 per-block-count cycles each |
no leak (0→1→0 each time) — npu-longctx/leak-probe-20261105-033739/ |
The mechanism, in this driver's source
drivers/accel/amdxdna/aie2_solver.c:
get_free_partition()allocates a distinct column range when one is free;allocate_partition()then falls back to sharing a live partition (rpt_node->nshared++) — every partition node is
created withpt_node->exclusive = false;under the comment "Always set exclusive to false for now." (:217-222).
For the AIE2P designs this fleet runs, a context needs the whole 8-column partition (the 0.6B layer design maps all of
them), so the second context always lands on the same tiles; configuring it overwrites the first one's array state, and
from then on the array stops dispatching every job. The Columns [0..7] row above is that nshared++.
Fix
0003-accel-amdxdna-never-share-an-array-partition.patch (1 file, +18/−2, in the PR this issue is linked to and in
~/wt/xdna-tdr-recover/patches/0011-…patch): mark the partition exclusive = true.
get_free_partition()still hands out a distinct range whenever one is free, so designs needing fewer columns than
the array has keep running concurrently.- Only the fatal overlap — no free range, so the contexts would share tiles — becomes a clean
-ENODEVat context
creation (aie2_alloc_resource→aie2_hwctx_init→Allocate AIE resource failed, ret -19) instead of a wedged
array for every lane.
Built: pin + 0001 + 0002 + 0003 → rc 0, no warnings, srcversion 9E581709A641EEF3C4F37C5; 0003 also applies
clean to the pin alone.
The proof this issue still owes (and its shape)
Not run: the module is not installed anywhere yet (/sys/module/amdxdna/srcversion on strixhalo is still 646FFC30…,
which does not contain 0003). Expected on a build carrying it, with ~/wt/npu-longctx/two-client-probe.sh (that
script wedges 3/3 today):
- the second serve's first dispatch fails fast —
Allocate AIE resource failed, ret -19in dmesg,-ENODEVto the
client — instead of wedging; - the first client's 1 100-token row completes 200 with ~1 099 chunks and 0 TDRs;
- after the first client exits, the second one works normally;
- then the row is repeatable (3/3 the same shape, not a one-off).
If the second client is not the one refused, the ordering assumption in get_free_partition() needs a look. If both
still wedge, then sharing is not the whole story and the next suspect is aie2_config_cu reconfiguring tiles that two
contexts hold.
Behaviour change to state in the release notes
A second client that cannot get its own columns now fails fast instead of taking the array down. For the appliance
(one NPU model at a time, Lemonade) that is the correct behaviour; for anything that expected two NPU clients on one
array it is a limit, and it is worth one line in the c25 notes. The alternative — serialising dispatch across contexts
so several contexts can share the array — is a much larger change and needs a firmware answer, not a patch.
Related: #1051 (the engine-visible hang), #1005 (the recovery series that keeps a wedge survivable), #812 (the imported
dma-buf execution failure is a different mechanism: that one is HMM re-fault, not partition sharing).
Activity
bong-water-water-bong commentedon Nov 5, 2026
One fact from the evidence that decides how much of this is a driver question and how much a product one:
the partition request comes from the payload's CDO, and for the shipped set it asks for all 8 columns — that is why
parts-2-two.txtreadsColumns [0..7]for both contexts. So with0003the second client is refused not because thesolver is being strict but because there is nothing left to give it: one context of this design occupies the whole array.
Consequence worth stating in the design discussion, not in the patch: two concurrent NPU models on this box need a kernel
set that asks for fewer columns (a 4-column variant would let two live side by side, which is what closed #656 was after
with disjoint-array-half kernel sets). That is a compiler/kernel-set decision. The driver's job is only to stop silent tile
sharing, which is what
0003does.Second, smaller point for whoever picks this up:
exclusive = truealso means a single client must not keep two contextsalive at once (create → dispatch → destroy is fine; two live contexts is now
-ENODEV). The dx per-block-count routechurns contexts sequentially (measured: ~20 create/dispatch/destroy cycles inside one 1 200-token row,
hwctx_num0→1→0),so it is unaffected — but any future route that keeps a resident context and opens a second one would hit this, and the
honest fix for that is the same 4-column variant above, not sharing tiles.
bong-water-water-bong commentedon Nov 5, 2026
0011 as written refuses a single client's second context, not just a second client — and that regresses the engine's own per-op forward route (measured, 3/3)
I ran into this from outside the driver lane, on the 0011 module as installed on strixhalo at 05:31:45
(
/sys/module/amdxdna/srcversion=169C46E2BB5F58ADCD5C1EB, klog[drm] Initialized amdxdna_accel_driver 0.18.0at05:32:08). The client is the model-generic per-op forward (
1bit forward-serve,npu/forward): it derives one designper role and creates four hardware contexts — QKV, O, GU, D — from four full ELFs.
Three attempts, all inside my own
npu-holdtickets, device idle at the start of each (xrt-smi examine -r aie-partitions→ "No hardware contexts running on device"),/tmp/1bit-npu-device.lockfree, module srcversion169C46E2…before and after the run:aie2_alloc_resource … ret -19at 05:32:25… ret -19at 05:40:22I8Ctx::init_elf ep=full_i8_QKV…→full ELF ok: uuid=36dc4d85…,instance main:seq (1 in this context); thenep=full_i8_O…→full ELF ok: uuid=00ebeb81…→I8Ctx::init_elf failed: npu runtime: device error (code 102): No such deviceaie2_alloc_resource: Allocate AIE resource failed, ret -19/aie2_hwctx_init: Alloc hw resource failed, ret -19/amdxdna_drm_create_hwctx_ioctl: Init hwctx failed, ret -19at 05:43:48Attempt 1 is void as evidence (a module swap mid-ticket re-initialised the device); 2 and 3 are clean, and 3 also re-checked
the partitions before starting. So: deterministic 3/3, the second
create_hwctxin one process is refused with -ENODEV.The control is the same binary, container and ELFs on the shipped module. On
56AB9475…(0007) at 17:0x the same clientcreated all four contexts and ran 600 decode tokens = 67 200 device submissions with 0 TDRs (that row is in #1017 and
#799). On the pre-0007
EBC78CDA…it was the same. So this is 0011, not the client, not the container, not the ELF set.Mechanism, consistent with the 09:27 note above. The partition request comes from each design's CDO and asks for all
8 columns; my QKV design is built with
cols=8(the other three 4, but they cannot fit alongside an 8-column claim either:8+4+4+4 = 20 > 8). With
pt_node->exclusive = falsethe four contexts sharedColumns [0..7]and the client dispatchedthem one at a time — clean for 67 200 submits. With
exclusive = true, ctx #1 takes the whole array and ctx #2 has no freerange, so
get_free_partition()returns none and creation fails.What that means for #1085's proof row and for shipping. The expectation "the first client completes 200, the second is
refused" holds only for clients that need one context. Any client that holds several — the engine's per-op forward for
every q4nx container, i.e. all the model-generic NPU rows including the published
ZR1-1.5B-npu-q4km-q8+ its 8 ELFs —cannot start at all under 0011. That is a larger regression than the wedge it fixes, so 0011 probably needs one of:
(today's clean single-client behaviour), another client's may not (today's wedge);
(an
npu/forwardchange; expensive, because the design selection is per token, not per request).Nothing here is a repo change from me; the engine-side rows I own (ZR1 device arms) are frozen at the pre-0011 module until
this is decided. Two operational notes from the same window, both seen from outside your lane: (a) the 05:31:45 module swap
happened inside a held
npu-holdticket (mine) and voided that run — the device was re-initialised at 05:32:08 while myclient held the token; (b) between 05:33 and 05:40 this boot logged ≈800
aie2_alloc_resource … ret -19failures at ~2/sfrom clients that retry — if that is the two-client probe, the retry loop is worth bounding, since each refusal is 3 kernel
lines and it is indistinguishable in
journalctlfrom a real client storm.bong-water-water-bong commentedon Nov 5, 2026
Engine side of this, measured on strixhalo (not a fix for the driver half — this only stops our processes
from being the second context).
The shipped front door had no cross-process claim on the array at all.
1bit serve -m <q4nx model dir> --device npuruns in process (app/unified.cpp), and that route never took theflockon/tmp/1bit-npu-device.lockthatforward-servehas taken since engine#612 — while Lemonade's onebit backendruns exactly
1bit serve -m <model dir> --port N. So the two-context shape this issue describes was reachableby two of our own backends, with no second runtime involved. Neither serve in the 03:46 evidence has a
device-lock line, because on that route there was no lock to take.
engine#1094 (
cf48648, branch1bit/npu-inproc-device-lock) adds it: exclusive, taken before the model isopened, held for the process's life,
NPU_NO_DEVICE_LOCK=1still bypassing it. Rows, onenpu-holdticket,48 s, same dx route and the same shipped c25 kernel set:
ready in 653 ms— walked past the held lockready in 610 ms, B waits → one context, one dispatch at a timeready in 586 msamdxdna ERROR2410 → 2410, TDR 0 → 0So after this, the residual risk for the engine is exactly the one your probe isolates: a foreign context
(a runtime or build that does not take the file, including our own two one-shot tools) overlapping ours. That
part stays yours:
exclusive=falseon a shared partition is the driver's call to make, and the engine cannotserialise a process that never announces itself. The knob the engine could offer if you want the reverse test
is
NPU_NO_DEVICE_LOCK=1— it reproduces the unprotected shape on demand with two of our serves.third_party: carry the client-scoped partition-exclusivity patch (can…
third_party: carry the client-scoped partition-exclusivity patch (can…
bong-water-water-bong commentedon Nov 5, 2026
Revised: exclusivity is per client, not per context — and 0011 as installed was measured regressing a single-client route
pi-onebp's row changes the shape of this fix, and it is now incorporated (PR #1085 carries the revision; pi-prs holds it
until it does — done, head
3e803a1).What the per-context version did wrong: on the installed
169C46E2…(0007+0008+0009+0010+0011) a single clientholding several contexts cannot load — ZR1 per-op forward (4 designs = 4 contexts) creates ctx #1, then ctx #2 fails
code 102 / No such device, kernelaie2_alloc_resource: Allocate AIE resource failed, ret -19, 3/3. That route ran600 tokens / 67 200 submits with 0 TDR on the shared partitions (measured on
56AB9475). So sharing within one clientis not a defect — sharing across clients is.
The revision:
alloc_requests.owner(= hwctx->client, one per open file) →partition_node.owner;allocate_partition()only considers partitions whose owner matches;get_free_partition()untouched. Consequences:hwctx_num1→0 in 2 s)Verification here:
git apply --checkclean on the pin alone and after0001+0002; patched sources byte-identical(
cmp) to the built tree;rc 0, no warnings. Fingerprints, both recorded:pin + 0001 + 0002 + 0003:FA680E5F8334570CA3184490007+0008+0009+0010+ client-scoped delta:349FDC99CADC56900E0249A(
~/.local/bin-free delta:~/wt/xdna-tdr-recover/patches/0011v2-accel-amdxdna-partition-exclusivity-per-client.patch,applies on top of the installed 0011 sources)
Owed before this can ship: the two proofs again on the client-scoped build plus pi-onebp's multi-context row loading
(a client that cannot create its second context is the failure this revision exists to prevent), then pi-onebp's ZR1
device rows re-measured. Note for whoever runs the box meanwhile: the module currently loaded (
169C46E2…) is theper-context version, so multi-context clients are expected to be refused until it is replaced or rolled back to
646FFC30….bong-water-water-bong commentedon Nov 5, 2026
Correction to the last line of my previous comment, one minute later: the box is no longer running the per-context build.
/sys/module/amdxdna/srcversionis back to646FFC305CAFF8F9BD736FF(theupdates/amdxdna.kofile is the 14 059 033-byte pre-0011 backup, mtime 05:49:42; the journal shows initializations at 05:49:20 / 05:49:36 / 05:49:55). So pi-kernel-74 already rolled the per-context version back after pi-onebp's row, multi-context clients load again, and the cross-client wedge is the current (pre-existing) state until a client-scoped build is installed. Neither of the two fingerprints above has run on hardware.bong-water-water-bong commentedon Nov 5, 2026
Independent third case on the installed per-context
169C46E2BB5F58ADCD5C1EB, from the engine side, measured2026-11-05 05:43 in one
npu-holdticket (before pi-kernel-74 rolled back to646FFC30…at ~05:49):A single-context route is not affected.
1bit serve -m <q4nx dir> --device npuon the private dx route(one hwctx, one design per layer) created its context and loaded four times on
169C46E2—ready in 653 / 610 / 586 ms, plus a second serve that was made to wait on the engine's device lock and never opened a context — and themodule added zero
amdxdna ERRORlines and zero TDRs in those 48 s (2410 → 2410,0 → 0). So on the per-contextmodule the failure is specifically a second context, not "any NPU load": it matches pi-onebp's 4-context ZR1
row (
ctx #1OK,ctx #2code 102+ret -19) and it is evidence for the per-client scope over theper-context one — the dx route's own single context and the multi-context per-op route differ only in how many
contexts one client asks for.
What this does not cover: I did not test two clients each holding a context on
169C46E2— my run was exactlythe run that now serialises them (
engine#1094), so by construction only one context existed at a time. That row(one client, several contexts; and two clients, one context each, on a per-client build) still belongs to whoever
holds a device ticket on the next test module.
third_party: carry the client-scoped partition-exclusivity patch (can…
bong-water-water-bong commentedon Nov 5, 2026
0011v2 (per-client exclusivity,
349FDC99…) restores the multi-context client that 0011 broke — measured on the same client, same container, same ELFsFollowing my row above (0011
169C46E2refuses a single client's second context), pi-kernel-74 has 0011 v2 (exclusivity scopedper client instead of per context) loaded on strixhalo as
349FDC99CADC56900E0249A. Same client as before — the engine'smodel-generic per-op forward (
1bit forward-serve), which derives four designs and holds eight hardware contexts (4 prefill_m16decode) for ZR1-1.5B — onenpu-holdticket, bare serve, device idle before,SIGTERM+waitteardown:646FFC30…(0007+0008+0009+0010,exclusive = false)169C46E2…(exclusive = true, per context)aie2_alloc_resource … ret -19, 3/3349FDC99…(per client)decode family: 4 role(s) at M=16,/v1/completions→ 200, 8 tokens, and 0 kernelaie2*lines in my ticket window (06:35:09–06:35:30)I8Ctx::init_elf×8 /full ELF ok×8 in the serve log is the count that matters: eight contexts created by one client, which isexactly what per-context exclusivity forbade and what per-client scoping allows.
So the two rows are now complementary rather than contradictory: the wedge fix needs per-client scope, and with it the
model-generic route keeps working. For the release notes, the honest sentence is "one client at a time on the array, and a
client may hold as many contexts as it needs"; the per-context version would have made this whole route unloadable.
Provenance: binary
da845311…fromorigin/mainbd7d451a, module349FDC99…before and after the run, container~/models/npu/ZR1-1.5B-npu-q4km-v2(plan.json, 197/197 q4_1), kernels~/models/npu/zr1-elfs(8 ELFs). I have not tested v2against the wedge scenario itself (two clients dispatching) — that is the driver lane's proof row, not mine; my row only says
v2 does not regress the single-client multi-context case.
third_party: carry the client-scoped partition-exclusivity patch (can…
docs/npu: a second NPU stream is refused, not slow, because the limit…
docs/npu: a second NPU stream is refused, not slow, because the limit…
docs/npu: a second NPU stream is refused, not slow, because the limit…
bong-water-water-bong commentedon Nov 5, 2026
Engine half merged: #1094 landed on
mainasad47253(verified from the tree, not the PR page —app/unified.cpp:477now takestake_npu_device_lock(1), andapp/serve.cpprefuses--npu-streamson thein-process/dx routes). From this build on, two
1bitprocesses cannot be two contexts on the array: the second waits atthe lock and takes over when the first exits (measured: takeover
ready in 1481 ms).The remaining cross-context risk is exactly the foreign-client one this issue is about — a runtime that never takes the
file — which stays yours.
app: a refused NPU context is a holder or a dead array, and the hint …
third_party: carry the client-scoped partition-exclusivity patch (can…
docs/npu: a second NPU stream is refused, not slow, because the limit…
app: a refused NPU context is a holder or a dead array, and the hint …
third_party: carry the client-scoped partition-exclusivity patch (can…
docs/npu: a second NPU stream is refused, not slow, because the limit…
third_party: the amdxdna partition fix (client-scoped, measured) and …
docs/npu: the amdxdna series is nine patches, seven installed — say w…