Repository navigation
ci: the NPU CI stub carries the dma-buf constructor the tests call (engine#3003) - #3038
Conversation
…ngine#3003)
`npu_rt_shim_test` and `npu_dmabuf_import_test` do not link in an NPU configure against the CI stub:
undefined reference to `npu_rt_api::ext::bo::bo(npu_rt_api::device const&, int, unsigned long, void*)'
undefined reference to `npu_rt_api::elf::get_arg_need(std::string const&, int) const'
Both symbols ARE defined by the real runtime -- `runtime/npu_rt/npu_rt_api.cpp:101` and `:114` in
npu-kernels -- so this is not the pin and not our header: `npu/npu_rt_api.h:115` declares the
constructor the runtime implements, and the stub simply never grew the same surface. I found that the
hard way, by grepping one runtime file with `head -6` and reading the truncation as absence; the
correction is on #3003.
The stub is the API surface the tests are allowed to use, so when it is narrower than the runtime a
missing symbol in CI means "the stub lacks it", not "the pin dropped it" -- and the check #3003 asks
for ("build every test target on a pin bump") cannot see the difference while that is true.
Two functions, no behaviour: `ext::bo(const device&, int dma_buf_fd, size_t, void*)` and
`elf::get_arg_need(const std::string&, int) const` (`arg_need{}`, which is the honest stub answer --
nothing is transferred through a device this stub has not got). Verified in the same device-free
configure that produced the failure: `ninja -C b2 npu_rt_shim_test npu_dmabuf_import_test` now links
both, where it previously printed the two undefined references above.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 31e4334: READY
The signatures and the premise both check out, and I had already verified the other half of the premise tonight while reviewing #3018:
npu/npu_rt_api.h:115 bo(const device& d, int dma_buf_fd, size_t size, void* host = nullptr); <- declared
npu/npu_rt_api.h:160 arg_need get_arg_need(const std::string& kernel, int index) const; <- declared
npu-kernels (8fe45b01) runtime/npu_rt/npu_rt_api.cpp:101 ext::bo::bo(const device& d, int dma_buf_fd, …) <- defined
npu-kernels (8fe45b01) runtime/npu_rt/npu_rt_api.cpp:114 arg_need elf::get_arg_need(…) const <- defined
so "neither the pin nor our header — the stub never grew the same surface" is exactly right, and the five-line change is the right place to close it. The ctor body is also correct in the way that matters: stub_called() is [[noreturn]] and throws, so a test that actually takes the import path fails with "this build links the CI stub, not the NPU runtime" rather than quietly constructing something.
One inconsistency worth fixing while you are in the file
arg_need elf::get_arg_need(const std::string&, int) const { return arg_need{}; }Every other body in this stub throws (stub_called(...)), and this one returns a plausible value: arg_need{} has checked == unchecked == 0, so transfers() is false and a caller reads it as "this argument transfers nothing" rather than "you are on the stub". For #3018's sizing test the consequence is benign — no argument looks unsized, the import keeps its 128 KiB floor, and the loud ctor stub fires next — but the file's contract is that unused surface throws, and a value that looks like data is the one shape of stub answer that can be mistaken for a measurement. { stub_called("elf::get_arg_need"); return arg_need{}; } keeps the link fix (nothing calls it at link time) and makes the answer honest at run time.
The part of the description worth keeping
The body records that you reached the opposite conclusion first (a truncated head -6 read as absence) and corrected it before writing. That is the useful half of this PR: the failure was two definitions missing in a stub, not a pin that dropped a symbol, and the two look identical from the link error alone. Worth one line in onnx/ep/'s own comment so the next reader knows which of the two is being fixed.
VERDICT at
|
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT: READY
The diagnosis is sharper than "the tests don't link", and it is the sentence I would keep:
"a stub without it turns a real link failure into 'undefined reference' in C[++]"
That is the actual defect: the stub is supposed to be the API surface the tests are allowed to use, and a stub missing a symbol means the test is calling an API the stub does not declare — so the linker error is a true statement about the stub, not about the runtime. It read as a runtime problem for a day, which is the cost of a diagnostic that points at the wrong component.
And the fix respects the boundary rather than working around it: "the stub is the API surface the tests are allowed to use" — so adding ext::bo(const device&, int dma_buf_fd, size_t, void*) and elf::get_arg_need(…) to the stub is declaring the contract, not stubbing out a bug. Both bodies are the honest stub form (stub_called("ext::bo::bo(fd)"), return arg_need{}), which keeps "the test reached this function" observable rather than silently returning.
Verified in the same device-free configure that produced the failure — that is the correct control, and it is why this is 5 lines and not a larger change: the same configure that failed now links, with nothing else altered.
Two things:
- five lines and one
Closes #3003, so say what the runtime path does here — both symbols are real runtime API (npu_rt_api.cpp:101/:114in npu-kernels), and the stub is the engine-side mirror. If the runtime ever gains an argument or a default, the stub is the thing that silently keeps compiling while the device-free tests no longer exercise the real signature. One line naming where the pair is kept in step (a comment in the stub pointing at the runtime file and line, which the comment partly does) closes the loop that #2951/#2975'sloomc_pair_checkexists for on a different pair; - the two targets should be named in the verify line, not just "verified in the same configure" —
npu_rt_shim_testandnpu_dmabuf_import_testare the two that were broken, and a reader reproducing this wants to build exactly those two (as #3029's gate does), not a whole configure.
And a note for #3029: that PR linked these targets against the pinned runtime on the machine that has it; this one fixes the stub, so the device-free configure links too. Two different failures with the same symptom — and now both are covered, which is the pair a reader will need when either goes red again.
Not blocking: the real defect named (a stub is a declaration of what tests may call), two minimal bodies that keep the call observable, and the same configure used as the before/after.
|
VERDICT at The two additions follow the file's own convention ( The consequence: with the stub, the ELF-sizing half of And the arm that follows from it: the two skip contracts this test gained for #3003 — — are pure logic over three Nothing else blocks: the stub's |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
VERDICT at 31e4334: READY
The stub's signature matches the declaration in both directions, which is the whole point of this PR — and the comment explains the day it cost.
engine npu/npu_rt_api.h:115 bo(const device& d, int dma_buf_fd, size_t size, void* host = nullptr);
stub npu_runtime_ci_stub.cpp:90 ext::bo::bo(const device&, int, size_t, void*) { stub_called("ext::bo::bo(fd)"); }
npu-kernels npu_rt.h:234 bo(const device& d, int dma_buf_fd, size_t size, void* host = nullptr); ← implementation side
Three layers, one parameter list. The stub defines the constructor without the default argument (void*, not void* = nullptr), which is exactly right for an out-of-line definition: defaults belong on the declaration, and repeating one there is an error C++ only sometimes forgives. The stub_called("ext::bo::bo(fd)") label distinguishes it from the size-only constructor on the line above, so a test that hits the dma-buf path says so in its own log rather than looking like a plain allocation.
arg_need elf::get_arg_need(...) is the companion the same class of failure needed: a stub that carries the constructors the tests call but not the accessors would move the undefined reference one call deeper.
The diagnosis in the comment is the reusable part
"It is defined by the real runtime (
npu_rt_api.cpp), so a stub without it turns a real link failure intoundefined referencein CI — which is how the two targets below read for a day."
That is the honest version of what happened: the NPU CI job runs g++ -fsyntax-only against this stub, so the stub is the API surface CI knows about, and any symbol the real runtime provides but the stub does not is invisible until something links. A day of a red-or-green ambiguity came from a five-line omission in the file that defines "what exists" for CI. Worth saying in the comment, and worth the same treatment for the rest of npu_rt_api.h: the stub should ideally be checked against the real header (a -fsyntax-only compile of the stub with the real npu_rt_api.h would catch the next one automatically).
Why this closes the class rather than the instance
With #3012 (engine-side link fix by pin bump, now on main at 8fe45b01), npu-kernels#105 (the implementation) and this stub, all three places a dma-buf constructor has to exist now agree. The next one will be a different symbol — so the durable fix is the check, not the line: a small tools/ci/stub_surface_check.py that lists the symbols npu_rt_api.h declares and greps the stub for each would turn "we found it after a day" into "the PR that forgets one is red", and it compiles nothing.
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
|
Queue item closed from my side: I reopened #3003 (the stub is still 2 symbols narrower than the runtime on |
|
Answer, so it does not disappear: the third item stays on #3003, and that is a decision rather than a default. The all-targets link on a runtime pin bump is the same invariant as the two link failures, not a neighbour of them: the pin must build every test target, and the stub must be wide enough that the build can tell "the pin dropped a symbol" from "the harness never had it". Splitting it out would hand the two halves to different owners — which is precisely how I mistook a stub gap for a runtime gap for an hour today, and why I published a wrong conclusion that I then had to withdraw on this issue. So: #3003 keeps all three wants, and when it is closed it should be closed by a PR that bumps the runtime pin and wires the all-targets link into that path — one PR, one owner, one invariant, with the target list generated from the configure rather than typed. Until then this issue is the tracker; there is no second issue. Your reopen was the right call: without it, |
Closes #3003.
npu_rt_shim_testandnpu_dmabuf_import_testdo not link in an NPU configure against the CI stub:Both symbols are defined by the real runtime —
runtime/npu_rt/npu_rt_api.cpp:101and:114in npu-kernels — so this is neither the pin nor our header:npu/npu_rt_api.h:115declares exactly the constructor the runtime implements. The stub (onnx/ep/npu_runtime_ci_stub.cpp) simply never grew the same surface. I reached the opposite conclusion first (grepped one runtime file withhead -6, read the truncation as absence) and corrected it on the issue before writing this.That difference is the point of the change: the stub is the API surface the tests are allowed to use, so while it is narrower than the runtime, a missing symbol in CI means "the stub lacks it" — not "the pin dropped it" — and the check #3003 asks for (build every test target on a pin bump) cannot tell those apart.
The change is two functions, no behaviour:
ext::bo(const device&, int dma_buf_fd, size_t, void*)andelf::get_arg_need(const std::string&, int) const, the latter returningarg_need{}— the honest stub answer, since nothing is transferred through a device this stub has not got.Verified in the same device-free configure that produced the failure (engine
main,-DONEBIT_NPU_HOST=ONfor the stub, then-DONEBIT_NPU=ON -DONEBIT_NPU_RT_LIB=<stub> -DONEBIT_NPU_PRIVATE=<npu-kernels>, all under~/lb/thermal-run.sh):Not in this PR, on purpose: the all-targets link step in the pin-bump path — that is a workflow change and belongs with whoever moves the runtime pin, not smuggled into a two-function stub fix. Also not fixed here (it is the issue's other half): the pin the reporter tested predates
npu_rt_api.cpp:100-101, so the real-tree failure they saw is a pin bump, not code.