Repository navigation
npu: ship the GGUF repack script, and find it beside 1bit instead of ../src - #543
Conversation
88fad4c to
c691902
Compare
PR Reviewer Guide 🔍(Review updated until commit 57a802c)Here are some key observations to aid the review process:
|
|
Persistent review updated to latest commit c691902 |
…../src A packed install could not serve a GGUF on the NPU: 'Q4NX repack script not found: ../src/scripts/repack_gguf.py', a build-machine relative path (CMake writes scripts/ paths relative to the build dir, and the package cannot mirror ../src). Measured from the rc-2026-10-23 tarball on a clean prefix. - app/built_path.h: packaged_path(rel, baked) -- a helper script beside the executable wins (the package layout), the baked build-relative path is the fallback (a build tree), and the fallback resolves against the executable's directory, not the caller's working directory. - app/serve.cpp: use it for the GGUF repack (scripts/repack_gguf.py) and the lane packer (tools/gguf_to_q4nx.py). - scripts/package-linux.sh: with the NPU lane, pack scripts/repack_gguf.py, scripts/check_repack_config.py (the declared-scale guard, resolved as the repack's sibling) and tools/gguf_to_q4nx.py. - scripts/weekly.sh package_checks: the three public helpers are the stated exception to the tarball's no-source rule (they are Apache-2.0 and already public; what must never ship is a private component's source), and a tarball carrying the NPU kernels must carry all three. - tests/npu_repack_path.sh (+ ctest): beside 1bit wins, ONEBIT_Q4NX_REPACK overrides, neither names the path and the override. No NPU needed -- the repack runs before the device -- and a build without the NPU lane skips (77, SKIP_RETURN_CODE) instead of failing, which is what public CI is. - docs/npu.md, docs/releases.md: say what ships and what a GGUF on the NPU needs (python3 with numpy and gguf, the Q4NX converter, which is not vendored).
c691902 to
57a802c
Compare
|
Persistent review updated to latest commit 57a802c |
…op testing nothing (#1588) The helper ran every arm as env REPACK_MARKER=... ONEBIT_Q4NX_CACHE=... "$@" \ # --port 0: ... timeout 60 "$dir/1bit" serve ... and a `\` continuation followed by a comment line does not put the comment "in the middle" of the command: the backslash is consumed, the `#` starts a comment at the start of a word, and the command becomes `env VAR=... # ...`. Every assignment is dropped and `timeout 60 ...` runs on the next line as a separate, bare command. #1588 added that comment when it switched the port to `0`; before it the continuation went straight to `timeout`, which is why the test passed when it landed in #543 and has failed since. Consequence on main: the two arms that name behaviour were red on every run — the packaged `scripts/repack_gguf.py` precedence and the `ONEBIT_Q4NX_REPACK` override — while the arms that only grep 1bit's own message passed, because with no script and no override the not-found path is exactly what a bare binary takes anyway. The test's own log line carried the proof and nobody read it: it printed `(exit SHELL=/bin/bash` and a screen of environment variables, because `$rc` held the output of `env` with no command to run. Fixed by hoisting the comment above the command, and the reason is in the comment so the next edit to this helper does not put it back. Before (two arms fail, and the third arm's detail is `env`'s own dump): FAIL a package's scripts/repack_gguf.py beside 1bit is the one that runs ok (the run stops at the stand-in: exit 1, GGUF repack failed) FAIL ONEBIT_Q4NX_REPACK overrides the path ok with no script anywhere, serve says so (exit SHELL=/bin/bash ok and it did not claim a build-machine path exists After (5/5, and the third arm now reports its real exit code): ok a package's scripts/repack_gguf.py beside 1bit is the one that runs ok (the run stops at the stand-in: exit 1, GGUF repack failed) ok ONEBIT_Q4NX_REPACK overrides the path ok with no script anywhere, serve says so (exit 1) ok and it did not claim a build-machine path exists The implementation is untouched: `packaged_path()` already tried `here/scripts/repack_gguf.py` before the build-tree fallback, so the arm's layout was right and only the delivery was broken. Test-only change. Refs #1770 (found while running the suite for it).
…e test whose env #1588 dropped (engine#1770) (#1772) * WIP: owner 11-09 snapshot - pending work in zc-1770 (3 paths), committed unmodified so the snapshot relays it * tests: npu_repack_path delivers its environment again, so its arms stop testing nothing (#1588) The helper ran every arm as env REPACK_MARKER=... ONEBIT_Q4NX_CACHE=... "$@" \ # --port 0: ... timeout 60 "$dir/1bit" serve ... and a `\` continuation followed by a comment line does not put the comment "in the middle" of the command: the backslash is consumed, the `#` starts a comment at the start of a word, and the command becomes `env VAR=... # ...`. Every assignment is dropped and `timeout 60 ...` runs on the next line as a separate, bare command. #1588 added that comment when it switched the port to `0`; before it the continuation went straight to `timeout`, which is why the test passed when it landed in #543 and has failed since. Consequence on main: the two arms that name behaviour were red on every run — the packaged `scripts/repack_gguf.py` precedence and the `ONEBIT_Q4NX_REPACK` override — while the arms that only grep 1bit's own message passed, because with no script and no override the not-found path is exactly what a bare binary takes anyway. The test's own log line carried the proof and nobody read it: it printed `(exit SHELL=/bin/bash` and a screen of environment variables, because `$rc` held the output of `env` with no command to run. Fixed by hoisting the comment above the command, and the reason is in the comment so the next edit to this helper does not put it back. Before (two arms fail, and the third arm's detail is `env`'s own dump): FAIL a package's scripts/repack_gguf.py beside 1bit is the one that runs ok (the run stops at the stand-in: exit 1, GGUF repack failed) FAIL ONEBIT_Q4NX_REPACK overrides the path ok with no script anywhere, serve says so (exit SHELL=/bin/bash ok and it did not claim a build-machine path exists After (5/5, and the third arm now reports its real exit code): ok a package's scripts/repack_gguf.py beside 1bit is the one that runs ok (the run stops at the stand-in: exit 1, GGUF repack failed) ok ONEBIT_Q4NX_REPACK overrides the path ok with no script anywhere, serve says so (exit 1) ok and it did not claim a build-machine path exists The implementation is untouched: `packaged_path()` already tried `here/scripts/repack_gguf.py` before the build-tree fallback, so the arm's layout was right and only the delivery was broken. Test-only change. Refs #1770 (found while running the suite for it). --------- Co-authored-by: bong-water-water-bong <[email protected]> Co-authored-by: t <[email protected]>
npu: ship the GGUF repack script with the engine, and find it beside
1bit(not../src)A packed install could not serve a GGUF on the NPU. From the
rc-2026-10-23package on a clean prefix(
wt/release-rc/evidence/clean-prefix.log):Two causes, both fixed here:
scripts/repack_gguf.pywas not in the tarball, and the path baked into1bitwas the builder's layout (
file(RELATIVE_PATH)from the build dir).scripts/lives outside the builddir, so the baked path escapes it and no install layout can mirror it.
What changed
app/built_path.h:packaged_path(rel, baked)— a helper script beside the executable wins (thepackage layout, the same rule the backends already follow), and the CMake-written build-relative path is
the fallback, so a build tree keeps working unchanged. The fallback resolves against the executable's
directory too: left relative,
fs::exists()tested it against the caller's working directory, so thesame binary found its tools from one directory and not from another.
app/serve.cpp: the GGUF repack (scripts/repack_gguf.py) and the lane packer(
tools/gguf_to_q4nx.py) resolve through it.ONEBIT_Q4NX_REPACK/ONEBIT_Q4NX_LANE_PACKstill win.scripts/package-linux.sh: with the NPU lane, packscripts/repack_gguf.py,scripts/check_repack_config.py(the declared-scale guard, which serve resolves as the repack's sibling)and
tools/gguf_to_q4nx.py.scripts/weekly.shpackage_checks: those three are the stated exception to the tarball'sno-source rule — the engine's own Apache-2.0 source, already published here, and a packed install cannot
run the GGUF-on-NPU path without them; what must never ship is a private component's source. New positive
check: a tarball that carries the NPU kernels must carry all three, so this cannot regress.
docs/releases.mdsays both things now.tests/npu_repack_path.sh(+ctest npu_repack_path, no NPU needed — the repack runs before anythingtouches the device): the copy beside
1bitis the one that runs,ONEBIT_Q4NX_REPACKoverrides it, andwith neither the error names the path and the override. It runs from a clean working directory, because a
relative fallback must not be decided by the caller's cwd. A build without the NPU lane (public CI)
has no repack code at all and refuses a
.ggufon--device npubefore it, so the test probes first andexits 77 (
SKIP_RETURN_CODE) with a one-line reason instead of failing — the first push of this PRfailed CI exactly there, on the test, not on the engine.
docs/npu.md: what a GGUF on the NPU needs — the packed script,python3withnumpyandgguf,and FastFlowLM's Q4NX converter, which is not vendored (
ONEBIT_Q4NX_CONVERTER, or~/np-model-generic).The package README says the same.
Proven from the packed tarball on a clean prefix (Strix Halo, one 14-minute claim)
Built from this branch with the release flags (
scripts/weekly.sh's cmake line), packaged byscripts/package-linux.sh, unpacked into an empty directory — no build tree, no private checkout in play:ctest -R npu_repack_path: Passed (0.38 s).1bit-rc-2026-10-23-npu-repack-linux-x86_64.tar.zst, 28 MB, sha25694ca7371865dbf33…:3 of 3 helpers packed (
scripts/repack_gguf.py,scripts/check_repack_config.py,tools/gguf_to_q4nx.py) and the 3 sealed NPU sets as before.1bit --helpfrom the clean prefix: exit 0.1bit serve -m Qwen3-0.6B-Q4_K_M.gguf --device npu, cwd/tmp:1bit serve: repacking /home/bcloud/models/Qwen3-0.6B-Q4_K_M.gguf -> …/cache/Qwen3-0.6B-Q4_K_M, the converter ran,repack complete, 652 MBmodel.q4nxwith
config.json,tokenizer.jsonandrepack-stamp.txtbeside it;finish_reason: stop:"Okay, the user is asking for the capital of France in one short sentence…";1bitcannot see../src/scripts/…from there, so the script it ran is the packed one.dmesgsince the hold: 0amdxdna/aie2lines.Caveat, stated rather than smoothed over: this proves the script ships and resolves, and the path answers.
The decode used
ONEBIT_NPU_KERNELSpointed at this box's development full-ELF directory, because theper-op GGUF forward loads
full_i8_*.elfdesigns and the release'snpu/kernelssets are the fused layerkernels — a different artifact. A release that wants GGUFs on the NPU out of the box needs those designs
shipped too; that is a separate decision and is not attempted here. Until then the release note stands:
the NPU path is a model directory.
Not in this PR
The binary drop does not need the script: a drop user builds the engine from this repository, where
scripts/repack_gguf.pyis already present, so the drop keeps carrying binaries only.Docs + packaging + a C++ path helper + one test.
tools/copyright.py --checkpasses. Not for auto-merge.