Repository navigation
npu: one unloadable design costs that shape, not the whole device leg - #779
Conversation
…e leg init() failed the whole State on the first init_elf that returned false, so a single bad entry in ONEBIT_EP_NPU_ELFS -- an ELF from another kernel family, or a design M that does not match -- turned the device off for every shape while the session kept printing the host gate's |d| = 0. Measured: adding one m16 design the runtime refuses made all 12 QDQ proof cases fall back and blame that ELF. A refused design is now recorded with its reason and skipped; the remaining designs load as before, and the shape that was refused reports 'no QDQ kernel for KxN: I8Ctx init_elf failed for <path> (MxKxN)'. If every configured design is refused the State still fails, with the first reason. Gate (device, npu-hold): with the refused ELF in the list, full_i8_O_K2048_N1024 and full_i8_D_K3072_N1024 still reach the array and both are |d| = 0 against the CPU EP; host ctest 6/6.
PR Reviewer Guide 🔍(Review updated until commit ec8c1cc)Here are some key observations to aid the review process:
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
Reviewed as code and compiled; the fix is the right one and it closes a failure mode that was invisible by design.
Ran: g++-16 -DONEBIT_NPU_RUNTIME_OWN -std=c++26 -O1 -fsyntax-only -Inpu -Inpu/ort -Inpu/forward/include -Inpu/forward/engine-src npu/ort/onebit_npu_gemm.cpp → rc 0 (CI builds neither NPU lane, so this is the only
compile evidence that exists for it). tools/copyright.py --check → rc 0. Build/CodeQL/pr_agent green on the head.
As code, the change is exactly the contract it describes:
init()records a refused design as{k, n, why}andcontinues befores.kernels.push_back, so the remaining
designs load ands.ok = true— the "one bad entry costs that design" behaviour.- the per-shape error now appends the recorded reason (
no QDQ kernel for KxN: I8Ctx init_elf failed for <path> (MxKxN)), which is what makes a fallback diagnosable instead of a mystery; - a configuration in which every design is refused still fails the
State(s.kernels.empty() && !spec.empty()→
first reason), so the "device is off" state is never reported as if nothing had been configured; - the
q8_unavailablememo still short-circuits a repeat attempt (bad.k == k && bad.n == n), so the ~50 ms
ELF-parse-per-call trap the comment documents is not reintroduced; - the reason string is carried, not recomputed, so it stays the one from the design that failed.
Why this mattered more than a cosmetic fix: the old shape failed the whole State silently while the QDQ proof
still printed its host gate's |d| = 0 — i.e. a run with the device leg disabled was indistinguishable from a healthy
one. That is the same class of "green that measures nothing" the zero-cases guard exists for, one level up.
Not verified by me: the device evidence — the "12 of 12 cases fell back, all blaming one ELF" before/after pair,
the device-busy = 0 and amdxdna … ERROR = 0 rows, and the qdq-elfrobust-check.sh runs. Those need the NPU under
npu-hold; the lane ran them and they are the right shape (before and after, same harness). One extra check I would
have liked, offered rather than required: a case where all configured designs are refused, since that branch is the
one no measurement exercises and it decides whether the device reads as broken or as unconfigured.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
Confirmation at c4e76fbf after update-branch (main's #768 squash merged in; both author commits 62113a1 + 5f6de1f
unchanged). Re-ran the compile at the new head rather than assuming the merge was inert:
$ g++-16 -DONEBIT_NPU_RUNTIME_OWN -std=c++26 -fsyntax-only … npu/ort/onebit_npu_gemm.cpp
rc 0
Everything else stands as reviewed at 5f6de1f6: a refused design is recorded with its reason and skipped before
s.kernels.push_back, the per-shape error names the ELF, an all-refused configuration still fails the State, and the
q8_unavailable memo still short-circuits the re-parse. The device evidence remains the lane's; the all-refused branch
is still the one no measurement exercises. tprs-ready stays.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
Confirmation at b4f23fd1 after update-branch: their own files are byte-identical to the head I verdicted — verified with
git diff --stat <previous head> b4f23fd1 -- <this PR's paths> → empty, the merge brought #768's and #775's squashes
(7f4e98a, e55096b) and nothing else. Content as reviewed (onebit_npu_gemm), build green. tprs-ready stays.
|
Persistent review updated to latest commit 5af778e |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
Confirmation at 5af778e4: the PR's own paths are byte-identical to the head I verdicted
(git diff --stat b4f23fd1 5af778e4 -- npu/ort/onebit_npu_gemm.cpp docs/onnx.md → empty). The refused-design path
(record the reason, skip that design, name the ELF per shape, fail only when every design is refused, keep the re-parse
memo) is unchanged and compiled clean at that head. tprs-ready stays.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
Confirmation at ec8c1cc5 after the waiter's rebase onto main (90c998a = #776 merged): this PR's own paths are
byte-identical to the head I verdicted — git diff --stat <previous head> ec8c1cc5 -- <its paths> → empty. Content as
reviewed, build green. tprs-ready stays.
|
Persistent review updated to latest commit ec8c1cc |
What this fixes
init()failed the whole NPUStateon the firstinit_elfthat returned false. One bad entry inONEBIT_EP_NPU_ELFS— an ELF from another kernel family, or a designMthat does not match — thereforeturned the device leg off for every shape in the session, silently: the QDQ proof still printed its
host gate's
|d| = 0, so the run looked exactly like a healthy one with the device in use.Measured before the fix (
npu-hold, QDQ proof,ONEBIT_EP_QDQdefault): three designs configured, the thirdunloadable. 12 of 12 cases fell back, all of them blaming that one ELF:
full_i8_O_K2048_N1024andfull_i8_D_K3072_N1024were configured, loadable, and never used.What it does now
A refused design is recorded with its reason and skipped; the remaining designs load as before. The shape that
was refused reports the cause itself:
If every configured design is refused the
Statestill fails, with the first reason, so a fully unusableconfiguration is not reported as "no QDQ kernel for KxN" on every call.
Two files:
npu/ort/onebit_npu_gemm.cppand one sentence indocs/onnx.mdwhereONEBIT_EP_NPU_ELFSisdescribed (the behaviour is user-visible).
Measured gate (strixhalo,
npu-hold -l qdq, M=128 designs)Both stages on the array,
device-busy = 0, andjournalctl -k | grep -c 'amdxdna.*ERROR'= 0 in the twominutes after each ticket.
~/wt/qdq-elfrobust-check.sh good— the configuration that already worked is untouched:~/wt/qdq-elfrobust-check.sh refused— the same two designs plus one entry the runtime cannot load(
/bin/true: a valid ELF, not an NPU design, so the sameinit_elfbranch with an input that is not acandidate for wedging firmware — see the note at the end):
Host build:
ctest6/6 (ort_info,onebit_ep_proof,onebit_ep_proof_cpu_fallback,onebit_ep_qdq_proof,onebit_ep_qdq_proof_unfused,onebit_ep_qdq_proof_only_qdq);ONEBIT_EP_NPU=ONconfiguration compiles;
tools/copyright.py --checkrc 0.What this PR does not do
kernel family) can ever be loaded by this EP is a separate question, and the answer so far is a refusal at
init_elf.ABORT die at 93C, exit 143) while other lanes were heating the package; the two tickets above are the complete runs. Afailed grep pattern of mine in the first
refusedrun is what produced the rerun, and the assertion itmissed was verified against that run's own trace (
/tmp/onebit_ep_trace.1606010.log) rather than a thirddevice run.
Why
/bin/trueand not the foreign ELF that raised thisThe bug was found while testing whether an
m16design from another lane could serve Qwen3-0.6B's k/v shape(1024×1024). That design is refused by the runtime and was present in the ticket that preceded a firmware TDR
incident on the shared array; it is a suspect in an investigation that is not finished, and there is nothing
left to learn from loading it again — the refusal is already recorded. The regression test therefore uses an
input that exercises the identical branch (
init_elfreturning false) without being a candidate for wedgingfirmware. The foreign ELF stays off the array.