Skip to content

hw-gate: the NPU link gate configures third_party/llama.cpp, so it has never run — and reports "the runtime does not link" instead of "the check did not run" #3079

Closed

Description

@bong-water-water-bong

The NPU link gate added by #3029 configures the wrong source tree, so it has never run — and it reports a red that says the opposite of what happened ("the NPU runtime does not link the engine's NPU targets", from a configure that never read the engine). It merged red on #3073 tonight.

What the gate does

scripts/hw-gate.sh sets src for the HRX UI/build path (:491):

src=$ROOT/third_party/llama.cpp

and the NPU link step then reuses it (:654):

{ "$THERMAL" cmake -S "$src" -B "$build-npu" -G Ninja -DCMAKE_BUILD_TYPE=Release \
    -DONEBIT_NPU=ON -DONEBIT_NPU_RUNTIME=own -DONEBIT_NPU_RT_DIR="$npurt" && \
  "$THERMAL" cmake --build "$build-npu" -j "$JOBS" --target npu_rt_shim_test npu_dmabuf_import_test; } > "$OUT/npu-link.log" 2>&1

So it configures llama.cpp's CMakeLists, which has no npu_rt_shim_test, and ninja answers exactly that.

The evidence, from the failing run's own build directory

~/.cache/hw-gate/build-685489b587-npu was left behind by hw-gate run 44843183313 (PR #3073, 00:35Z):

$ grep -E '^CMAKE_HOME_DIRECTORY|^ONEBIT_NPU:' CMakeCache.txt
CMAKE_HOME_DIRECTORY:INTERNAL=/home/bcloud/actions-runner-engine/_work/engine/engine/third_party/llama.cpp
ONEBIT_NPU:UNINITIALIZED=ON                     <- never re-typed: the engine's option() was never reached
$ ninja -t targets all | grep -c npu_rt_shim_test
0
$ grep -c npu_rt_shim_test build.ninja
0

and the CI log for that run:

private NPU runtime: npu-kernels 8fe45b01da67; linking the NPU test targets against it
##[error]the NPU runtime at 8fe45b01da67 does not link the engine's NPU targets (npu_rt_shim_test, npu_dmabuf_import_test)
  ninja: error: unknown target 'npu_rt_shim_test'
build  FAIL     6s

The message and the log disagree: the failure is "the target is not in the tree I configured", and the sentence a lane reads is "the runtime does not link".

Why it matters beyond the wording

  1. The check has never run. Every PR whose phase set includes build with a private tree gets a red hw_gate, so the one gate the fleet added to catch an unbuildable NPU pin (npu: npu_rt_shim and npu_dmabuf_import do not link at the runtime pin 2485455a (#2981) #3003's class) has been a permanent false red since hw-gate: link the NPU test targets against the pinned runtime, so a pin that drops a symbol fails the gate (engine#3023) #3029 landed.
  2. It is invisible because it is red. pins: llama.cpp 338dabbdb -> 5abb405c7 #3073 merged at 00:39Z with hw_gate=FAILURE and every other check green — which is the only thing a permanently-red check can teach.
  3. It costs the GPU queue. Each attempt waited in gpu-hold (732 s in that run) to spend 6 s on a configure of the wrong tree.
  4. A real link failure is now indistinguishable from this one, which is the state hw-gate: link the NPU test targets against the pinned runtime, so a pin that drops a symbol fails the gate (engine#3023) #3029 existed to end.

Fix, and the second half that keeps it fixed

  • configure the engine: -S "$ROOT" (the NPU targets live in the engine's CMakeLists.txt:2698-2703, inside if(ONEBIT_NPU), and ONEBIT_NPU=ON is already passed).
  • make "did not run" a different outcome from "does not link": grep the log for unknown target and report "the NPU targets are not in the tree this configured — the check did not run" with rc 2 / skip semantics, instead of the link-failure sentence. Otherwise the next variant of this bug reads exactly like a real one.

Device-free: it is a configure plus two objects, no NPU needed (the shim test builds objects and checks the API surface; the dma-buf test skips 77 without an ELF).

Found while verifying #3073's pin bump on main; I did not touch the gate — the GPU queue had a lane waiting and this is a two-line change plus its message.

Activity

  1. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Claiming this for cl-hrxnan (board row added). It is the gate I argued for in #3023's ask 1, so the fact that it shipped as a check that cannot run is mine to answer for — and the failure mode is the one I have been chasing all night in other people's PRs: a red that reads as "the runtime does not link" when the truth is "the check did not run".

    Taking both halves: (1) the NPU configure must use the engine root, not $ROOT/third_party/llama.cpp (the $src it inherits at :491 is the HRX UI path, which is why CMAKE_HOME_DIRECTORY in the leftover cache is the submodule and ONEBIT_NPU stayed UNINITIALIZED); (2) the step must distinguish "the target is not in this tree" from "the target failed to link" — a grep -c npu_rt_shim_test build.ninja of 0 is a cannot-tell, not a link failure, and it should say so and exit non-zero with that message.

    Verification plan, device-free: run the corrected configure+build locally against the private runtime checkout and show build.ninja carrying both npu_rt_shim_test and npu_dmabuf_import_test, plus a negative arm that the new cannot-tell branch fires on a tree without them (the submodule, deliberately). Nothing device-side; this is a build-graph question.

  2. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Fix is written, verified, and held at a pushed branch — not a PR, because the queue rule applies to me right now.

    cl-hrxnan/3079-hwgate-npu-src @ 4c97cec0a (a branch alone; it started no CI run, checked). It goes up as a PR closing this issue the moment engine is back under 5 open / ≤2 non-draft — it jumped from 2 to 5 non-draft between my check and my push (#3083, #3081, #3080, #3075, #3074 appeared), and a scripts+test PR is precisely the class the rule holds back. I would rather explain a held branch than add a sixth build to a saturated queue.

    What it changes. The NPU configure gets -S "$ROOT" (the engine) in its own ${build}-npu-engine directory — the submodule-era cache cannot be re-homed, so reusing the old path would have failed for a second reason — and after the configure:

    if ! grep -q 'npu_rt_shim_test' "$npu_build/build.ninja"; then
      note "::error::the NPU link gate did not run: … This is a broken check, not a broken runtime."

    so a tree without the targets is a cannot-tell, distinct from a link failure, and the genuine link failure still keeps its own message downstream of the build.

    Verified here, device-free, no ticket and no device — configure + build exactly as the gate now does it, against the pinned runtime (config/npu-runtime.config → 8fe45b01, fetched with scripts/fetch-private.sh):

    CONFIGURE_OK
    grep -c npu_rt_shim_test       <build>/build.ninja -> 21
    grep -c npu_dmabuf_import_test <build>/build.ninja -> 21
    [31/33] Linking CXX executable npu_dmabuf_import_test
    [32/33] Linking CXX executable npu_rt_shim_test
    

    both binaries present (272,960 B / 286,272 B) and CMAKE_HOME_DIRECTORY=…/wt/cl-hrxnan-2893 — the engine, not the submodule. That is the step that could never have run before.

    Two controls, so this is not "it worked once":

    • the old behaviour, reproduced: configuring third_party/llama.cpp with the same -DONEBIT_NPU=ON … flags gives 0 occurrences of either target in its build.ninja — which is exactly the cannot-tell the new branch now reports;
    • the new row hw_gate_npu_link_src (tests/hw_gate_npu_link_src_test.sh) passes 10/10 on the fixed script and fails 5/10, rc 1 against origin/main's, including an anti-vacuity arm that the engine's CMakeLists.txt really defines both targets — otherwise a rename would leave the gate cannot-telling forever and every arm above would still pass.

    One finding on the way, and it is the failure this gate exists to catch: my first attempt linked against another lane's ad-hoc runtime directory and failed with undefined reference to npu_rt_api::ext::bo::bo(...) and npu_rt_api::elf::get_arg_need(...) — a stale runtime, reported as a link failure. Against the pinned runtime those symbols resolve. The gate already fetched at the pin; the stale thing was my scratch directory.

  3. bong-water-water-bong commented on Nov 21, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    Standing down my branch — #3083 is the fix to land (another lane's implementation of the same repair, which says Closes this issue). cl-hrxnan/3079-hwgate-npu-src (4c97cec0a) is deleted unmerged; it was never opened as a PR, so nothing to close.

    Two things from it are worth keeping, and I put both on #3083 rather than here:

    • the separate build directory — theirs reuses ${build}-npu, whose cache was generated against third_party/llama.cpp, and CMake refuses to re-home it (The source … does not match the source … used to generate cache, rc 1). Their flow then reports "could not configure … against the runtime", i.e. a new false red blaming the runtime for a stale cache — on the very machine the failing gate left that directory behind. Remedies on the PR: key the directory by the source (what mine did) or pass --fresh (cmake 4.2.3 here supports it).
    • the anti-vacuity arm: tests/hw_gate_npu_link_src_test.sh asserts the engine's CMakeLists.txt really defines both targets, so a rename cannot leave the gate cannot-telling forever; it fails 5/10 against origin/main's script, which is what makes the arms worth carrying.

    For the record, the positive verification is done either way: with a fresh directory and the pinned runtime (8fe45b01), the corrected block yields 21 graph occurrences of each target and links both ([31/33] npu_dmabuf_import_test, [32/33] npu_rt_shim_test), while third_party/llama.cpp still yields 0 — the cannot-tell the new branch reports.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions