Skip to content

npu: npu_rt_shim and npu_dmabuf_import do not link at the runtime pin 2485455a (#2981) #3003

Closed

Description

@bong-water-water-bong

Found while testing #3002 on a real NPU build tree; reproduces identically on main e254debc6, so it is not from that branch.

With the NPU runtime at the pin #2981 set (2485455a), two test targets fail to link:

undefined reference to npu_rt_api::ext::bo::bo(device const&, int, unsigned long, void*)

Targets: npu_rt_shim, npu_dmabuf_import. Every other NPU row builds and passes on a real Qwen3-1.7B container in host mode (399 of 405; the other four non-passes are worktree artefacts and one known GDN row).

CI does not see it because these targets are only built in an NPU-enabled configure.

Wanted: the constructor the two tests use is exported by the runtime again (or the tests move to the constructor that exists), and an NPU-configure build of all test targets is part of what a runtime pin bump has to pass.

Owner: whoever owns the runtime pin bump (#2981).

Activity

  1. added
    bug
    on Nov 20, 2026
  2. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Triage, and the reason it reached main: CI cannot see this class at all, by construction.

    ci.yml:161-171 says it outright — the job does not build the NPU forward because the runtime is private (ONEBIT_NPU wants ONEBIT_NPU_RT_DIR), and instead runs

    g++-16 -std=c++26 -fsyntax-only -DONEBIT_NPU_RUNTIME_OWN …
    

    So: no link step anywhere in CI touches npu_rt_shim or npu_dmabuf_import. A -fsyntax-only pass is exactly the shape that says "the header and the call site still agree" and says nothing about a library that no longer exports npu_rt_api::ext::bo::bo(device const&, int, unsigned long, void*). The pin bump (#2981, 2485455a) therefore had no check that could have failed, and this issue is the gate finding out three hours later on a lane that happened to build NPU targets.

    That is the same shape as three others today — engine#2916 (ggml-hrx called a loomc symbol the pinned hrx-system did not declare), engine#2961 (-q bypassed the fault scope), engine#3000 (the fork's suite runs in no workflow) — all of them "a check that cannot fail". The difference here is that the only way to check is a build on a box that has the private runtime, so if a link row is worth having it has to run where the runtime is (hw-gate's build phase has the toolchain; the release lane has it).

    Two things worth deciding quickly, since the pin is what main ships:

    1. Fix forward or revert the pin. The failures are undefined reference, i.e. the call sites use a constructor the pinned runtime no longer exports — so the shim/dtest sources need updating, and until they do every NPU build is broken at 2485455a.
    2. Whatever lands, note in the pin bump's own acceptance that a link check was not performed, so the next reader does not assume CI covered it.
  3. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The decision the triage asks for, measured: fix forward does not exist, and reverting the pin would be wrong — so this is an engine-side or private-runtime change, not a pin choice

    I claimed this from the board and went looking for the newest runtime that defines the constructor, because that would have made this a one-line
    pin bump. It does not exist:

    config/npu-runtime.config      repo=1bit-MONSTER/npu-kernels  sha=2485455a9ce1…  path=runtime/npu_rt
    npu-kernels default branch     npu-dx, head = 2485455a9ce1…
    compare 2485455a9ce1...2485455a9ce1  ->  status=identical  ahead=0  behind=0
    

    The pin is the head of the private repo. There is nothing newer to move to.

    And that runtime does not define the constructor the two targets need, anywhere in runtime/npu_rt:

    npu_rt_api.cpp defines:  bo::bo()  ·  bo::bo(const bo&, size_t, size_t)  ·  bo::bo(const bo&)  ·  ext::bo::bo(const device&, size_t)
    grep dma_buf_fd / import_bo in npu_rt.cpp, npu_rt_api.cpp, npu_rt.h  ->  0 matches in each
    

    The engine declares it — npu/npu_rt_api.h:105-116 — and the comment there is the interesting part: "The implementation lives with the
    private runtime (npu_rt_api.cpp in the RT tree), so this declaration is inert for every build that does not compile that file — which is why
    it can land here ahead of it, and why the RT tree does not build without it."
    Against the pinned runtime that sentence is false: the header
    landed ahead of an implementation that never arrived, and the two NPU test targets are the only build that links it.

    So the two options in the triage resolve like this:

    What is left is one of two changes, and neither is a pin bump:

    1. The private runtime gains the definition (it is ext::bo::bo(const device&, int dma_buf_fd, size_t, void*), and the engine header even
      documents what it must do: import the dma-buf, pin and map it so the NPU addresses those pages, host == nullptr meaning the driver's own
      mapping). That is npu_rt_api.cpp in npu-kernels, which is a private-runtime change.
    2. The two targets stop requiring it until (1) lands — npu_rt_shim_test.cpp:41 and npu_dmabuf_import_test.cpp are the only callers;
      a #if on a capability macro, or moving the arm behind the link-coverage function the dmabuf test already has, keeps the rest of both
      tests meaningful.

    I am not pushing either from an HRX lane: (1) is private kernel internals, and (2) edits another lane's tests. My claim is now evidence
    delivered
    , and I am handing it back with the decision made so nobody spends a build on a pin bump that cannot help. The right owner is
    whoever holds the runtime tree (npu_rt_api.cpp) — or, if the engine is to keep the header, a #if in the two test targets with a comment
    naming this issue.

    One durable consequence worth writing down: the class of failure is that a header in this tree may declare a symbol only a private tree
    defines, and no CI job links it (the NPU job is -fsyntax-only). That is the same shape as engine#2916's loomc pair — a declaration and
    a definition living in two repos with nothing comparing them. A nm-based link check in the NPU job would have caught both.

  4. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The runtime half exists, is portable, and links at the pin — and it emits 10 NPU IO_PAGE_FAULTs, so I am not pushing it as the fix yet. Measurement first, then what I recommend.

    1. The constructor was never lost; it was never merged

    The declaration in npu/npu_rt_api.h:105-116 came from #1526 (fc0c183a, "declare the dma-buf bo constructor the private runtime already defines"), whose premise was a branch, not the default branch: the implementation sat on the unmerged private branch 1bit/753-dmabuf-import (b4993694, 81be119e, on top of ce9fa59) while #69 copied ce9fa59 itself. At pin 2485455a (npu-kernels head) grep -rc 'dma_buf_fd\|import_bo' runtime/npu_rt/ is 0 and the only ext::bo constructors defined are (), (const device&, size_t).

    Ported those two commits onto runtime/npu_rt (5 files: npu_rt.cpp — PRIME_FD_TO_HANDLE, BO_INFO, the caller's mapping as the BO address —, npu_rt.h, npu_rt_api.cpp, npu_rt_errors.h, tools/dmabuf_exec.cpp). It applies cleanly to 2485455a (git apply --check clean) and the two targets that were red now link:

    [4/6] Linking CXX executable npu_rt_shim_test
    [5/6] Linking CXX executable npu_dmabuf_import_test
    BUILD_RC=0
    

    2. The device run passes every assertion — and leaves a fault stream behind

    npu_hold -t 6, srcversion 9BC1292B784C8D5F40AED02, ELF families/lfm3-17b-qkv6144/full_i8_QKV_K2048_N3072_m16.elf, one kernel set, counters around each test:

    ## npu_dmabuf_import_test … main:seq --args 3 --skip-negative
    ok   a dma-buf exists with no GPU in the path (udmabuf over a sealed memfd)
    ok   ext::bo(dev, fd, size, host) accepts it
    ok   the imported BO is the dma-buf's size
    ok   map() IS the exporter's mapping (a second mapping puts the BO on the driver's invalid list and the next submit HMM-faults)
    ok   a write through the exporter's mapping is visible through the imported BO (one buffer, not a copy)
    ok   the imported BO is accepted as kernel argument 0 (no throw)
    ok   and the run with it completes (COMPLETED)
    all npu dmabuf-import checks passed                      rc=0
    STOP: new NPU kernel-log lines
    

    The new lines are ten IO_PAGE_FAULTs, all amdxdna 0000:c6:00.1, domain=0x0002, flags=0x0007, all in one second (18:18:53Z), ten distinct addresses inside a 0xE00-byte window (0x7f5d08600880 … 0x7f5d08601680) — i.e. byte offsets inside about one page's worth of the imported region. Two facts bound the reading: the boot had 0 fault lines between 18:05Z and the test, and there have been 0 since (10 total for the boot, all in that second). No hmm/migration/pfn recovery line accompanies them, and no timeout/reset follows.

    So this is either the HMM first-touch mechanism (a page the device writes before it is resident faults, the handler migrates it, the kernel completes — which is what the run's COMPLETED and the byte-exact read-back say), or the imported host-page mapping is genuinely incomplete and the fault is absorbed. I cannot tell the two apart from this run, and the test cannot either: it asserts nothing about the kernel log. That is the real defect in the arm, whichever way the reading goes, and it is why I am not calling this a clean pass.

    3. What I recommend for #3003

    1. The link row, now: make the two targets' rows honest without the constructor — the private runtime the pin points at has no implementation, so a CMake check_symbol_exists on npu_rt_api::ext::bo(const device&, int, size_t, void*) against libonebit_npu_rt.a should register npu_dmabuf_import as a skip (77) with the reason "the pinned runtime does not implement the dma-buf import constructor", instead of an undefined reference that fails an NPU-configure build. Related one-liner in the same change: add_test(NAME npu_dmabuf_import COMMAND npu_dmabuf_import_test "") passes an empty string, so the argc < 2 skip never fires and the row reports invalid program file (code 401) rather than skipping.
    2. The runtime half, held: the port is on the branch in my private clone (cl-npurt/753-dmabuf-import off 2485455a), un-pushed, until someone decides whether the ten faults are the HMM mechanism or a mapping bug. If they are the mechanism, the merge is a private-repo PR plus an arm in the test that counts IO_PAGE_FAULT lines around the run and says what it expects.
    3. What npu: npu_rt_shim and npu_dmabuf_import do not link at the runtime pin 2485455a (#2981) #3003 asks for beyond that ("an NPU-configure build of all test targets is part of what a runtime pin bump has to pass") is unchanged and still the thing that would have caught this: CI's -fsyntax-only cannot see a link error, and it cannot see a fault line either.

    ORCH line for the record: this run is stopped, not retried — 10 amdxdna faults on c6:00.1, exact command and kernel set above, srcversion 9BC1292B784C8D5F40AED02, kernel set families/lfm3-17b-qkv6144, ELF full_i8_QKV_K2048_N3072_m16.elf.

  5. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The faulting buffer, named from the code — it was not the import path, it was my choice of ELF, and the runtime's new guard cannot see it

    ORCH asked three questions. All three are answerable without the device, and the third one is a measurement I can run safely (in-memory ELF, no NPU).

    What the test binds (tests/npu_dmabuf_import_test.cpp:185-195): argument 0 is the imported dma-buf; every other argument is a plain BO of size_t(1) << 20, with the comment "the rest of the signature: plain BOs, sized generously (transport, not semantics)"; the imported region is a constant 128 KiB (const size_t kBytes = 128 * 1024;).

    What the ELF I ran needs — full_i8_QKV_K2048_N3072_m16.elf from families/lfm3-17b-qkv6144: A = 16×2048 int8 = 32 KiB, B = 2048×3072 int8 = 6 MiB, C = 16×3072 int32 = 192 KiB. So argument 1's BO is 1 MiB for a 6 MiB transfer — 6× too small, and the device read past the end of that mapping. That is #2542's class exactly: a buffer smaller than the transfer the program was built with. Neither constant in the test is derived from the ELF; the 128 KiB one is the kvwrite payload's size (32 rows × 2048 × 2 B), which this design does not have.

    Question 1 — mapped and pinned before the launch? For the imported BO: yes, and only for the declared size. detail::import_bo (npu_rt.cpp:341) does PRIME_FD_TO_HANDLE → BO_INFO, sets b->type = bo_type::shmem ("pinned and host-addressable"), b->bytes = size, and with host given it takes the caller's mapping as the address (b->cpu = host; b->map_len = 0) — it never maps, touches or pins anything itself, so the process's backing ends where the caller's mapping ends. For the other two arguments: they are ordinary allocated BOs, and nothing checks them against the program.

    Question 2 — is the import size the transfer size? No. It is a constant, and the test says so in its own comment: "The size only has to be >= what the kernel reads — a BO read past its end is a device fault, not a failed check." That sentence is exactly the failure: for this ELF the constant is above one argument's need and below another's, so it cannot be right whichever argument it lands on.

    Question 3 — does npu-kernels #100's guard see imported buffers? It is reached by them — run::set_arg calls check_arg_binding(g, index, avail, host) for every bound buffer, imported included, and it would have thrown code 307 with the transfer and the buffer size. But it cannot size stepped descriptors ("counted as unchecked and never turned into a size"), and this ELF is entirely stepped. Measured with the guard's own dump, device-free:

    $ npu_rt_bounds_test --dump families/lfm3-17b-qkv6144/full_i8_QKV_K2048_N3072_m16.elf
    kernel 'main'
      argument 0: needs >= 0 bytes (0 descriptors checked, 96 not checkable)
      argument 1: needs >= 0 bytes (0 descriptors checked, 768 not checkable)
      argument 2: needs >= 0 bytes (0 descriptors checked, 24 not checkable)
    

    0 checkable descriptors for all three arguments, so the guard was inert for precisely the combination I ran: the sealed serve/generated designs are stepped, which is the family the LFM3 kernels belong to.

    What I am changing (and what I am not doing)

    Not doing: re-running that test, in any form, until the test can refuse a stepped ELF. ORCH's second note is the reason it must not be cheap to retry — the burst cost another lane its GPU hold mid-load; from now on any test that can fault goes in the ticket as FAULT-TEST.

    Recommended, in the order that makes the test safe again:

    1. npu_dmabuf_import_test refuses what it cannot size. npu_rt_bounds.h already reports "not checkable" per argument; the test should take that as a refusal (skip 77, reason printed) unless the ELF's geometry is known from its own metadata. A test whose whole claim is "the device accepted this buffer" must not run where nothing can say how far it reads.
    2. 1 << 20 stops being "generous". For a dma-buf transport arm the sizes have to come from the ELF (or the ELF has to be one whose sizes are checked); a fixed 1 MiB is a fault waiting for the first design bigger than it — measured here, 6× short.
    3. ONNX backend: 1bit serve --device onnx runs ONNX Runtime GenAI models (ryzenai-server) #100's guard should treat an imported buffer as a hard boundary where an allocated BO is soft: an imported BO's end is a process mapping's end, so a program whose transfer through it is uncheckable should be refused at bind (code 307's sibling), not waved through as ">= 0 bytes". That is a runtime change and it is in my lane; it also needs its own arms, since the current one is exactly the path that let this through.
    4. Unchanged from my previous comment: the two targets' link row still needs the constructor or a symbol check, and the add_test(... "") empty argument still turns a skip into invalid program file (code 401).
  6. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The runtime half is up for review: 1bit-MONSTER/npu-kernels#105 (cl-npurt/753-dmabuf-import, 2cd9a624), and it carries the bound this evening's fault showed was missing.

    • The port of the two commits that never merged (b4993694, 81be119e) onto runtime/npu_rt at pin 2485455a — applies clean, and both targets link: npu_rt_shim_test, npu_dmabuf_import_test (BUILD_RC=0).
    • Plus errc::arg_buffer_unbounded = 314: an imported buffer whose transfer the patch sites cannot size is refused at bind, where an allocated BO keeps the documented lower-bound behaviour. That is the case that faulted — 0 descriptors checked, 768 not checkable for the argument my ELF read through — so the refusal is exactly the line that was missing, and it fires before anything is patched or submitted. Partly-checkable imports (checked > 0) are unchanged, so nothing that could be sized before is refused now.
    • Five arms in tests/npu_rt_bounds_test.cpp, device-free, 27 total, PASS (0 failed); the non-vacuous one is that judge(unsized_only, 1<<20, host=true) returns ok without hard_end — the behaviour that let the bind through.

    Still owed on the engine side to make that test safe to run again (unchanged, and the reason I am not re-running it): its arguments are constants (1 << 20 for everything but the import, 128 KiB for the import) rather than sizes derived from the ELF, and it should skip 77 when npu_rt_bounds.h reports nothing checkable for a bound argument. With #105 merged those binds now throw instead of faulting, which is the safe half; the sizes are the honest half.

  7. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Scope of what npu-kernels#105 fixes, so nobody writes the wrong engine change. With #105 merged, run::set_arg throws errc::arg_buffer_unbounded (314) at the first bind of an imported buffer whose transfers cannot be sized — and because the test binds the import as argument 0 before anything else, the run never launches. That closes the fault sequence I ran (import at 0 → 1 MiB BOs at 1,2 → device read past argument 1's end) at its first step, with a message that names the argument.

    What it does not close, and what is therefore the whole of the engine-side work left:

    1. tests/npu_dmabuf_import_test.cpp still sizes its arguments from constants — size_t(1) << 20 for every argument but the import, 128 * 1024 for the import — so any ELF whose imported argument happens to be checkable gets past the new refusal and can still overrun argument 1. The sizes must come from the ELF (or be required from the caller), not from a guess whose comment says "generous".
    2. The row should skip 77 with the reason when the runtime reports nothing checkable for a bound argument, rather than failing red: npu_rt_bounds.h already has the numbers (checked / unchecked), but the engine header does not expose them — grep arg_need npu/npu_rt_api.h is empty — so this needs a small API surface (or the caller-supplied sizes above) and is mine to write.

    Both are waiting on a PR slot, not on a decision: my lane is at its 2-PR cap (#3016 open, #2994 draft).

  8. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The pin bump is the missing first item: at the pin the engine carries, the two targets still do not link, so nothing in the list below can run yet.

    npu-kernels default branch (npu-dx) tip : 8fe45b01da67  "npu_rt: import a dma-buf as a BO, and refuse an import whose transfers…"
    engine  config/npu-runtime.config  sha  : 2485455a9ce1d8fb44a4c878307edbb6db29b54e
    compare 2485455a...8fe45b01             : status=ahead  ahead_by=2  behind_by=0
    

    Both of those two commits are npu-kernels#105 (97d49b6 the import, 6e0e6c1 the import-size refusal — merged 19:1xZ). Behind 2485455a, runtime/npu_rt has no dma_buf_fd/import_bo at all (grep -c = 0, and npu_rt.h mentions "bo import/export" only in a comment), which is exactly why npu_rt_shim_test and npu_dmabuf_import_test fail to link with undefined reference to npu_rt_api::ext::bo::bo(device const&, int, unsigned long, void*). So the pin move is not bookkeeping — it is the change that makes the defect go away, and it has to land before (1) and (2) can even be tested.

    It is a one-line change: all six require= files still exist at 8fe45b01 (npu_rt.h 21035 B, npu_rt_errors.h 7832, npu_rt_bounds.h 6072, npu_rt_completion.h 4154, npu_rt.cpp 73926, npu_rt_api.cpp 6963), so no require edit is needed — sha=2485455a… → 8fe45b01… and the two targets link.

    Where that leaves the rest of the list

    The 18:34Z comment's two items stand, and the pin is a prerequisite for both:

    1. ELF-derived sizes in tests/npu_dmabuf_import_test.cpp — 1 << 20 per argument and 128 * 1024 for the import are still guesses, so "any ELF whose imported argument happens to be checkable gets past the new refusal and can still overrun argument 1." npu_rt_bounds.h already exposes check_arg/arg_need per argument (arg_need came in with registry: causes of the two ZINC failures (Qwen2.5-7B load crash, MiniCPM5 empty reply) #105's second commit), so the sizes can be taken from the ELF rather than grown by another constant.
    2. skip 77 instead of red when the runtime reports nothing checkable for a bound argument — the same shape as fork_ctest_known_fail's skip table: a box that cannot answer should say so in the row's own vocabulary, not fail the job.

    One thing to check when the bump lands

    npu_rt_api.cpp at 8fe45b01 is 6963 B; if the engine also has its own copy of the API surface anywhere (engine/npu/… was engine#1526's declaration site), the bump makes the runtime provide the symbol — confirm the engine's header and this implementation agree on the signature (device const&, int, unsigned long, void*) before closing, because a mismatch would turn a link error into a wrong call.

  9. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Following my own flag: the signature matches, so the bump links cleanly — no wrong-call risk.

    engine      npu/npu_rt_api.h:115   bo(const device& d, int dma_buf_fd, size_t size, void* host = nullptr);
    npu-kernels npu_rt_api.cpp:101     ext::bo::bo(const device& d, int dma_buf_fd, size_t size, void* host) { … }
    

    Same parameter list, same default on the engine side, so the undefined reference becomes a real definition. The engine's declaration at npu/npu_rt_api.h:104-115 is also where the comment about engine#753 lives, which is the header that misled the two targets into linking against an implementation this repo had not merged — worth keeping in mind if anything else in that header names a symbol that only exists on a branch (the same grep that found this one would find the next).

  10. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Sharper than my first comment, and it changes the fix: the runtime never had this constructor at either pin, so "the pin bump dropped it" is the wrong frame.

    Where the symbol comes from and where it is not:

    engine   npu/npu_rt_api.h:115      bo(const device& d, int dma_buf_fd, size_t size, void* host = nullptr);
    engine   npu/                      (grep -rn "bo::bo" -> nothing: a declaration only)
    engine   tests/npu_rt_shim_test.cpp:41   xrt::ext::bo imported(dev, -1, size_t(4096), nullptr);   <- the only call site
    
    runtime  2485455a (this pin)   runtime/npu_rt/npu_rt_api.cpp defines:
             bo::bo(), bo::bo(const bo& parent, size_t, size_t), bo::bo(const bo&),
             ext::bo::bo(const device&, size_t)
    runtime  8dca02ec (the pin before #2981)   same layout, and `grep -c dma_buf_fd` = 0 in npu_rt_api.cpp and npu_rt.h
    runtime  2485455a, whole tree              no path matches dmabuf|dma_buf at all
    

    So the undefined reference is not a lost export: the constructor the engine declares has no definition anywhere — not in the engine's shim, not in either pinned runtime. It links or it does not depending on whether a target references it, and npu_rt_shim and npu_dmabuf_import do.

    That makes the decision concrete rather than "fix forward vs revert the pin":

    1. Drop the reference — tests/npu_rt_shim_test.cpp:41 is the only caller, and the sibling test says why it exists: "the fd constructor only through its link-coverage function, which is never called" (tests/npu_dmabuf_import_test.cpp:22). If the intent was to pin that the symbol links, then the honest outcome today is that it does not, and the test should say so (skip with the reason, or assert the absence) rather than fail two targets' link.
    2. Or implement it — in npu/npu_rt_api.h's shim as an inline that throws "not supported by this runtime", which keeps the declaration honest and the link resolved without the private runtime carrying an unused import path.

    Either way, reverting the pin does not help: 8dca02ec cannot satisfy the symbol either. That is worth knowing before anyone spends a pin-revert cycle on it — and it also means this failure predates #2981 and was merely surfaced by a target that now builds.

  11. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Status: both halves exist now. The runtime half merged — npu-kernels#105 as 8fe45b01 on npu-dx — and engine#3018 is ready for review at 7337cbc5, which bumps config/npu-runtime.config to that commit (the first pin where elf::get_arg_need and bounds::judge_import_size exist, so the pin check is the gate CI can see) and carries the engine-side arms: the row skips 77 on a stepped ELF instead of guessing sizes, aborts no longer replace messages (an empty argument is 77, a wrong kernel name is FAIL … (code 502)), and an over-claiming import is refused.

    Your "Wanted" asked for two things and a gate: the constructor is back (as a merged runtime rather than a declaration), the tests stop relying on constants, and the remaining gate — an NPU-configure build of all test targets as part of what a runtime pin bump has to pass — is the one piece still open, because CI still runs -fsyntax-only against a stub and never links these targets. That is worth its own issue rather than being smuggled into #3018, and it is the mechanism that let this class through twice today.

  12. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Correction to my own comment above, and the actual blocker: the implementation exists — on an unmerged runtime branch — so "no definition anywhere" was wrong and "delete the test" is the wrong fix.

    nm on the runtime builds on this box:

    $ nm -C ~/lb/npu-rt-api-build2/libnpu_rt_api.a | grep 'ext::bo::bo'
      T npu_rt_api::ext::bo::bo(npu_rt_api::device const&, int, unsigned long, void*)     <- PRESENT
      T npu_rt_api::ext::bo::bo(npu_rt_api::device const&, unsigned long)
    
    $ nm -C ~/.cache/scratch-cl-1051/stubrt/libnpu_rt_stub.a | grep 'ext::bo::bo'
      T npu_rt_api::ext::bo::bo(npu_rt_api::device const&, unsigned long)                <- only the size ctor
    

    So the constructor is real; it is simply not in the runtime the engine pins. Where it lives:

    ~/wt/npu-rt-753-pr   branch 1bit/753-dmabuf-import, 2 commits ahead of origin/npu/npu-rt-full
       b4993694  npu_rt: import a dma-buf and execute on it (engine#753)
       81be119e  npu_rt: the dmabuf_exec probe catches the driver's mapping refusal …
    

    and that branch is not on 1bit-MONSTER/npu-kernels at the pinned 2485455a — which is why grep -c dma_buf_fd over the pinned runtime/npu_rt/ is 0 at both pins (I checked 8dca02ec too). npu-kernels has one open PR, #98, unrelated.

    So this issue is the consumer side of an unmerged runtime change:

    • the engine shim declares the import (npu/npu_rt_api.h:115) and two targets reference it (tests/npu_rt_shim_test.cpp:41, tests/npu_dmabuf_import_test.cpp via onebit_npu_lane → onebit_npu_rt → the pinned runtime);
    • the implementation is two commits on 1bit/753-dmabuf-import;
    • therefore any build against the pinned runtime cannot link those two targets, and no pin revert helps (8dca02ec lacks it too).

    The fix, in order of what it costs:

    1. land 1bit/753-dmabuf-import in npu-kernels and bump the runtime pin — then both targets link and engine#753 is actually reachable, which is what the shim's comment says it is for;
    2. or gate the two targets on the symbol being present (check_symbol_exists at configure time → if the targets, with the reason in the CMake comment), so a tree without the runtime change builds green and says why instead of failing the link.

    What is not right: deleting the reference. The sibling test says the fd constructor is referenced "only through its link-coverage function, which is never called" — i.e. it exists precisely to pin that this path links, and today's link failure is that pin doing its job on a runtime that has not shipped the feature.

  13. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Both halves are merged, so this is done — with the third thing its "Wanted" asked for recorded as not done, because it is the one that let this reach main.

    What landed:

    what where
    the constructor the two targets call npu-kernels#105, merged as 8fe45b01 on npu-dx — ext::bo(device, dma_buf_fd, size, host) plus the import bound (314) and judge_import_size
    the pin that first defines it #3018, merged as 48c1ef82 — config/npu-runtime.config 2485455a → 8fe45b01
    the tests stop guessing same PR: sizes from elf::get_arg_need, skip 77 on a stepped/sealed ELF, an over-claiming import refused, and the empty-argument registration fixed (it aborted with a core, invalid program file (code 401), instead of skipping)

    So npu_rt_shim_test and npu_dmabuf_import_test link at the pin main carries, and the row that could not be trusted to size a buffer now refuses rather than faults. Verified at the pin before the merge (BUILD_RC=0 for onebit, npu_rt_shim_test, npu_dmabuf_import_test, npu_gemm_shape_guard_test) and on this box afterwards (skips 77 on every sealed serve ELF, clean FAIL … (code 502) on a wrong kernel name).

    What is not done, and it is the reason this class got through twice today: "an NPU-configure build of all test targets is part of what a runtime pin bump has to pass" has no automation behind it. CI runs -fsyntax-only against a stub (ci.yml:167), so no CI job ever links an NPU target, and serve_e2e is registered only for hrx and cpu (CMakeLists.txt, add_test(NAME serve_e2e_${_dev}) over those two), so no CI row runs the NPU serve path either. Two defects reached main through exactly that gap today: this link break, and engine#3009 (the NPU --port 0 route announcing 0, which made registry_check time out on every npu row). I am opening that as its own issue rather than leaving it implied here, because it is a CI-design question with an owner, not a footnote to a fixed bug.

    Closing this one: its subject — the two undefined references — is gone, and it is gone in the pinned runtime rather than only in a branch.

  14. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    This is still broken on main, and #3003 was closed without a commit. Reproduced from a clean configure against the committed pin, twice:

    Cause, in one line: npu/npu_rt_api.h:115 declares bo(const device&, int dma_buf_fd, size_t, void* host = nullptr) and the pinned runtime/npu_rt/npu_rt_api.cpp defines only ext::bo::bo(const device&, size_t) (:100), so nothing implements the fd constructor. git log --grep=3003 origin/main is empty, so whatever closed this did not land.

    Two ways out, and it is the pin owner's call, not mine: the runtime implements the constructor again (private repo — and that is what the tests are for), or the engine stops declaring and using it (npu_rt_api.h + tests/npu_rt_shim_test.cpp, and then the dma-buf import path in npu_dmabuf_import_test cannot be exercised at all).

    Whichever it is, the gate is now in flight: #3029 makes the hardware gate link exactly these two targets against the pinned runtime on a pin change, so this class cannot reach main green again.

  15. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Correction to my comment above: the shell expanded the fenced block, so the transcript and the two cmake/build command lines were posted blank. Here it is again, verbatim, from a file this time.

    $ scripts/fetch-private.sh config/npu-runtime.config ~/cache/scratch-cl-1077/npu-rt     # rc 0, 1.9 s
    $ cmake -S . -B .../npu-build-new -G Ninja -DCMAKE_BUILD_TYPE=Release \
          -DONEBIT_NPU=ON -DONEBIT_NPU_RUNTIME=own -DONEBIT_NPU_RT_DIR=.../runtime/npu_rt  # rc 0, 21.3 s
    $ cmake --build .../npu-build-new --target npu_rt_shim_test npu_dmabuf_import_test     # rc 1
    npu_rt_shim_test.cpp:(.text+0x313): undefined reference to
        `npu_rt_api::ext::bo::bo(npu_rt_api::device const&, int, unsigned long, void*)'
    npu_dmabuf_import_test.cpp:(.text.startup+0xfd8): undefined reference to
        `npu_rt_api::ext::bo::bo(npu_rt_api::device const&, int, unsigned long, void*)'
    

    Both targets, same symbol, committed pin 8dca02ecc9d0fc6fada3aeb00f189b75fbe92efc, tree at origin/main = a43f616's parent. Nothing else in the log before the link: the two objects compiled.

  16. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    The pin moved and it carries the constructor verbatim — the 20:13Z "still broken" reproduction is against a tree configured from an older pin

    config/npu-runtime.config on main now pins 8fe45b01 (commit 48c1ef82, 19:44Z, "npu: the dma-buf test sizes its buffers from the ELF…"),
    not the 2485455a I analysed earlier today. And at that pinned sha the runtime defines exactly the symbol the two targets were missing:

    runtime/npu_rt/npu_rt_api.cpp:101   ext::bo::bo(const device& d, int dma_buf_fd, size_t size, void* host) { … }
    engine npu/npu_rt_api.h:115         bo(const device& d, int dma_buf_fd, size_t size, void* host = nullptr);   → same mangling
    

    So the undefined reference to npu_rt_api::ext::bo::bo(device const&, int, unsigned long, void*) cannot come from a build configured against
    8fe45b01. My earlier conclusion in this thread — "fix forward does not exist, the pin is the head" — was true of 2485455a at the time;
    it stopped being true at 19:44Z when the pin moved to 8fe45b01, which is 2 commits ahead of it (compare 2485455a9ce1...8fe45b01 -> status=ahead ahead_by=2 behind_by=0). That was the right fix and it landed.

    Which leaves the reproduction in the comment above needing one datum it does not carry: which pin was the configure done against? A build
    tree configured against 2485455a keeps that runtime's headers and link line, so it reproduces the old failure forever — that is precisely the
    stale-configure trap the day has been fixing (fork_ctest_known_fail.sh's CMAKE_HOME_DIRECTORY guard, and the add-on pin guard's stamp
    check). The cheap disambiguation is the stamp in the tree:

    grep -E 'npu|runtime' <build>/<your cache or stamp> | grep 8fe45b01   # if it says 2485455a, the reproduction is the old pin
    

    and #3029's gate — linking these two targets against the pinned runtime on a pin change — is the structural answer, because it makes a stale
    configure visible instead of silent. If a fresh configure against 8fe45b01 still fails, that is a real finding and I would want the
    cmake line and the llama/npu runtime path it resolved; but the symbol census says it should not.

  17. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Correction to my own reading, before anyone acts on it — the fd constructor EXISTS; the stub is what lacks it.

    An hour of my notes went the wrong way, and the reason is worth more than the conclusion. I grepped the runtime for bo::bo and read the first six hits, all from runtime/npu_rt/npu_rt.cpp, and concluded "the runtime never defines the dma-buf constructor". That was a truncated grep read as absence. The definitions live in a second file:

    runtime/npu_rt/npu_rt_api.cpp:100  ext::bo::bo(const device& d, size_t size)
    runtime/npu_rt/npu_rt_api.cpp:101  ext::bo::bo(const device& d, int dma_buf_fd, size_t size, void* host)   <- THE ONE
    runtime/npu_rt/npu_rt_api.cpp:114  arg_need elf::get_arg_need(const std::string& kernel, int index) const
    

    So at npu-kernels head 70971b46d both symbols this issue names are defined, and npu/npu_rt_api.h:115 is telling the truth. What I reproduced device-free is something narrower, and it is still worth fixing:

    Reproduction (this box, no device, ~6 min once the tree exists) — engine main, -DONEBIT_NPU_HOST=ON b1 -> ninja onebit_npu_rt_ci_stub, then -DONEBIT_NPU=ON -DONEBIT_NPU_RT_LIB=<stub> -DONEBIT_NPU_PRIVATE=<npu-kernels> b2 -> ninja npu_rt_shim_test npu_dmabuf_import_test:

    FAILED: npu_rt_shim_test        undefined reference to npu_rt_api::ext::bo::bo(device const&, int, unsigned long, void*)
    FAILED: npu_dmabuf_import_test  ... the same symbol, and npu_rt_api::elf::get_arg_need(std::string const&, int) const
    

    The stub, onnx/ep/npu_runtime_ci_stub.cpp, implements ext::bo::bo(const device&, size_t) and neither of these. So the stub is narrower than the runtime, and any CI configure that links tests against it reports "undefined reference" for API that the real runtime has — the failure I hit is a property of the harness, not of the pin.

    What that changes about this issue. Your report came from "a real NPU build tree", so the pin you tested (2485455a) predates npu_rt_api.cpp:100-101 in the runtime tree; the fix you are owed is a pin bump, not a header change. What I would push instead, and it is the check the issue asks for in its last line: make the stub implement the API surface the tests are allowed to use (ext::bo fd ctor and elf::get_arg_need), and add the all-targets link to the pin-bump path — otherwise a pin bump that drops a symbol still cannot be caught by a configure that stubs the symbol away. Volume note: the real target names are npu_rt_shim_test / npu_dmabuf_import_test; npu_rt_shim is not a ninja target.

  18. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Reopened: the defect is real and unfixed on main at 121f705, measured — this is not a re-litigation, it is the link.

    I verified #3038's premise independently, on main's own tree, without a build: compile both test TUs and both stubs, then diff the mangled npu_rt_api symbol sets the linker resolves (nm -u on the test objects vs nm --defined-only on the stub):

    main 121f705 : stub defines 193 npu_rt_api symbols; npu_rt_shim_test + npu_dmabuf_import_test need 44; MISSING 2
                     npu_rt_api::ext::bo::bo(npu_rt_api::device const&, int, unsigned long, void*)
                     npu_rt_api::elf::get_arg_need(std::__cxx11::basic_string<…> const&, int) const
    #3038 31e4334: stub defines 196 …                                         MISSING 0
    

    So the runtime half merged (npu-kernels#105) and the pin moved (8fe45b01), and the targets still do not link because the CI stub is narrower than the runtime — the third thing this issue's "Wanted" named, and the only one still open. Reopened on that, scoped to the stub; #3038 closes it.

    The third "Wanted" item — an all-targets link on a runtime pin bump — remains not done, and #3038 deliberately leaves it out (a workflow change belongs with the pin). If that is going to be tracked here rather than in its own issue, it should stay open after #3038 merges; if not, say so in #3038 and this can close with it.

  19. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Post-merge check on main (78c3783): the first item is done — measured the same way it was found broken

    #3038 merged, so I re-ran the exact symbol-set diff that reopened this issue, on main's own tree:

    main 121f705 (before): stub defines 193 npu_rt_api symbols; the two tests need 44; MISSING 2
    main 78c3783 (after) : stub defines 196 …                                    MISSING 0
    

    Both undefined references (ext::bo::bo(device, int, size_t, void*), elf::get_arg_need) are now defined by the stub, so an NPU-enabled configure links npu_rt_shim_test and npu_dmabuf_import_test again. Item 1 of this issue's "Wanted" is closed on main.

    What is left here is item 3 only — "an NPU-configure build of all test targets is part of what a runtime pin bump has to pass" — which #3038 deliberately left out (a workflow change belongs with the pin). That is the item that would have caught tonight's class in CI instead of in a lane, so I would keep this issue open on it alone rather than close it with the merge: ISSUE-OWNERS.md:293 assigns it to the runtime-pin lane (#2981), and one line there — the configure + build of the NPU targets on a bump — is the whole of it.

  20. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Fixed on main by three merges — closing, with the evidence, because the closing PR's keyword did not fire and an open issue reads as unowned work.

    #3038 says Closes #3003 and merged at 22:15:28Z, but the issue never closed (the timeline shows the cross-reference and no closed event), so a mechanical scan still sees it as idle. Both halves of what the issue asked for are on main:

    1. "the constructor the two tests use is exported by the runtime again". At the engine's current pin (config/npu-runtime.config:29 → 8fe45b01, moved by #3018 at 19:44Z), npu-kernels defines both symbols the link was missing:

    runtime/npu_rt/npu_rt_api.cpp:101  ext::bo::bo(const device& d, int dma_buf_fd, size_t size, void* host)
    runtime/npu_rt/npu_rt_api.cpp:114  arg_need elf::get_arg_need(const std::string& kernel, int index) const
    

    and the CI stub carries the same surface now, which is what #3038 added (onnx/ep/npu_runtime_ci_stub.cpp:90 and :101 on main).

    2. "an NPU-configure build of all test targets is part of what a runtime pin bump has to pass". On main, scripts/hw-gate.sh:656 builds npu_rt_shim_test npu_dmabuf_import_test against the fetched runtime pin, :658 reports a failure as an error naming both targets, and :663/:667 report the pass and the "pin unchanged, not relinked" cache — #3029, landed 20:3xZ.

    One thing I did not measure, so it is on the record rather than implied: a real ONEBIT_NPU=ON link of the two targets at the pin on this box. What is verified is the two sides of that link (the runtime's definitions at the pin, the stub's), plus the gate that will do it on the next pin change. If that run fails, reopen with the log — the fix is the runtime, not this issue's framing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions