Skip to content

Build against a prebuilt binary drop when the private parts are not available - #469

Merged
bong-water-water-bong merged 7 commits into
mainfrom
1bit/binary-drop
Oct 20, 2026
Merged

bong-water-water-bong merged 7 commits into
mainfrom
1bit/binary-drop

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Outside the org, a source build stops at scripts/fetch-private.sh because the HIP kernels and the NPU runtime are closed. This adds the other route: a per-pin binary drop under the 1bit Binary License.

  • scripts/make-binary-drop.sh packs a drop from a release build: hrx/llama (llama-server + libggml-hrx.so with our HIP kernels), npu/ (libnpu_rt_api.a + include/npu_rt_api.h), LICENSE-BINARY, NOTICE-BINARY and a MANIFEST (pins, toolchain, sha256 of every file). It copies an allowlist and refuses source files or private-named files.
  • cmake/binary_drop.cmake: -DONEBIT_BINARY_DROP=. A URL is downloaded with the sha256 pinned in config/binary-drop.config (or -DONEBIT_BINARY_DROP_SHA256); every MANIFEST entry is hashed and a mismatch, a missing MANIFEST or a drop built for another engine commit stops the configure.
  • config/binary-drop.config carries no drop= line yet; the first one is added when a drop is published. Nothing is published by this PR.
  • npu/npu_rt_api.h is the public header for the closed NPU runtime library.

Tested on ryzen (CPU only): drop made from a rehearsal build; a fresh clone with no private access (no token, no submodules) configures and builds against the local drop, ctest 35/35; bad sha, wrong engine commit and tampered file are refused; the packer refuses source in the build dir.

Review notes:

🤖 Generated with Claude Code

bong-water-water-bong and others added 5 commits October 19, 2026 23:15
The engine now reaches the private NPU runtime only through
npu/npu_rt_api.h: the calls its NPU code (and the private route add-ons)
make, each class an opaque handle (device, bo, ext::bo, elf, hw_context,
ext::kernel, run, runlist), plus ert_cmd_state and the two sync
directions. npu/rt.h includes it and aliases xrt = npu_rt_api; the
private npu_rt.h is no longer on the engine's include path.

CMake: ONEBIT_NPU=ON takes exactly one runtime:
- ONEBIT_NPU_RT_LIB: a prebuilt static library implementing the header
  (libnpu_rt_api.a, built in the private repository); no private source
  or header needed.
- ONEBIT_NPU_RT_DIR: the private sources (npu_rt.h, npu_rt.cpp and now
  npu_rt_api.cpp), with the directory on onebit_npu_rt's own include
  path only.

The runtime pin moves to the private commit that adds npu_rt_api.cpp
(npu_rt.cpp and npu_rt.h are unchanged from the old pin).
npu_runtime_option covers the new refusals; npu_rt_shim now links every
call of the header.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A source build that is not on the release machine has no private HIP kernels and no
private NPU runtime sources, so it cannot compile those parts and stops at
scripts/fetch-private.sh. This adds a way to use them already compiled, under the 1bit
Binary License the packages already carry.

scripts/make-binary-drop.sh <engine checkout> <out dir> packs one engine pin as a tarball
plus SHA256SUMS: hrx/llama/bin (the release package's llama-server, llama-bench and the
libraries beside them, libggml-hrx.so with the private kernels compiled in),
npu/libnpu_rt_api.a behind the engine's public npu/npu_rt_api.h, npu/include, both binary
licenses and a MANIFEST with every pin, the build host, the compilers and the sha256 of
every file. It takes the HRX tree from a release build or an already packed release, and
the NPU library prebuilt or built from the pinned private sources, then runs the weekly
package's checks: XRT-free, the kernels really are compiled in, no source files, nothing
named like the private sources, both licenses present. It publishes nothing.

cmake/binary_drop.cmake takes ONEBIT_BINARY_DROP as a directory or a URL. A URL is
downloaded with the sha256 config/binary-drop.config pins for that engine commit, and a
body that does not match is refused. A directory is verified against its MANIFEST, every
file's sha256 and the engine commit it was built from, and a mismatch stops the configure.
When a drop is used, cmake/hrx.cmake links its llama-server instead of building llama.cpp
(so neither TheRock nor the llama.cpp and hrx-system submodules are needed) and the NPU
block takes ONEBIT_NPU_RT_LIB from the drop. Without ONEBIT_BINARY_DROP nothing changes.

docs/releases.md documents the layout, how to make one and how to build against one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CMake's regex engine did not honour {64} in the MANIFEST and pin patterns, so the
verification loop matched nothing and every drop was refused as empty. Match on
[0-9a-f]+ and check the length explicitly instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On a machine without TheRock the drop branch found no libhsa-runtime64.so.1 and
list(GET) on the empty result stopped the configure. Guard it; the build proceeds
with an empty ONEBIT_HRX_LIBHSA and says so.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he end

zstd refuses to overwrite, so a second run in the same output directory did all the
work and then stopped. Remove this script's own previous output first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit feb5e1a)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

468 - Partially compliant

Compliant requirements:

  • README: --moe-slots is out of the feature list (app/serve.cpp refuses it unless built with ONEBIT_MOE_STREAMING_HRX, which nothing sets). serve.md keeps the section, retitled "not in this build", and marks the synopsis line.
  • Pins: README and PORTING.md name the current hrx-system 82804197 and llama.cpp 00f2a68de (the 2026-10-18 numbers stay, labelled as measured at the 8d9ce2c1a move). lemonade.md names c5ba797132a4 (was 4812a683) and no longer says the suite passes on Vulkan.
  • "Packages ship every Sunday" is gone: no release is published yet. README and releases.md say the release run is weekly and the first release is not out.
  • config/recipes.json is empty: README and serve.md now say so instead of describing built-in recipes.
  • pm.md examples use Lemonade's default port 13305; serve.md says the --lemonade-url default (8000, in code) is not Lemonade's port and that the onebit recipe passes the real address.
  • Dead links: the 1bit.gg site has not built since 2026-10-05 (315-STATUS.html has 26 <h1> elements), so the live site is stale and links to removed pages. With this branch the site builds (36 pages) and a link check over the built pages and over every tracked .md finds no dead internal link. Three lines starting with #<number> (hrx.md, hw-gate.md, serve.md) also broke the build and are rewrapped; one serve.md anchor that differed between GitHub and the site is fixed. The README's link to 1bit-MONSTER/kernel is a private repo (404 for visitors); left as is for the owner to decide.
  • The HRX: GLM-4.7-Flash intermittent HSA memory fault / NaN logits under varied-length requests (base fork tip too) #315 debugging notes (docs/315-*.md, docs/315-campaign/) move to dev/315/, which the site does not publish; references in KNOWN-ISSUES.md, 315-COORDINATION.md and .pi/agents/hrx315.md follow. They are still in the public repository.
  • npu.md no longer describes how the NPU runtime talks to the driver.
  • NPU in the release: releases.md and README describe the product as HRX with our HIP kernels and the NPU engine, all inside Lemonade. The NPU route is marked in progress: the runtime ships compiled into 1bit, the from-source NPU kernels are not merged yet (npu.md, Step 3d). No code defaults change.
  • hrx-system pin off its branch: 82804197 is on 1bit/e3e6a976-pin-6 and 1bit/315-allow-no-svm (identical), not on 1bit/main. GitHub's compare says 1bit/main (c9656af5) and the pin have diverged: 1bit/main has 6 commits the pin does not (the merges of AMD's 40a1a36c and c0b135a7, and the HRX: hipModuleLoadData segfaults on a truncated code object where ROCm returns an error #409/HRX: libhip_intercept wraps only 331 of 540 HIP symbols (rest silently unobservable) #410/HRX opens the NPU device (/dev/accel/accel0) in GPU-only processes #401/Steps 1-2: embedded Lemonade, and HRX + Vulkan in one llama.cpp build #6 fixes the pin line carries as replayed commits). It is not a fast-forward; moving 1bit/main to the pin would be a force push. hrx.md records this ("The pin is off 1bit/main") and .gitmodules points to it. Nothing was pushed to the fork.
  • weekly.sh preflight: From the 19 Oct rehearsal: before the first stage, weekly.sh checks the HRX toolchain (/opt/rocm-therock or -DONEBIT_HRX_TOOLCHAIN in WEEKLY_CMAKE_ARGS), hipcc for DwarfStar (same search as build-ds4.sh, or ROCM_PATH), patchelf, and a readable kernel image (VMLINUZ or /boot/vmlinuz-$(uname -r)), only for the stages requested. The package stage checks $W/src/third_party/lemonade/LICENSE before packaging. With everything present the run is unchanged. releases.md lists the checks.

Non-compliant requirements:

  • None

Requires further human verification:

  • None
⏱️ Estimated effort to review: 4 🔵🔵🔵🔵⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Potential Security Issue

The script make-binary-drop.sh performs checks to ensure that the binary drop does not contain source files or private source names. However, it relies on a names variable that is generated from config/npu-runtime.config and config/gpu-kernels.config to check for private source names. If these config files are not properly maintained or if the logic for generating names is flawed, it could allow private source names to slip into the binary drop, which would be a security issue. This is particularly critical because the binary drop is intended to be distributed under the 1bit Binary License, and any private source code or names should be excluded.

# nothing named like the private sources: the pins' require= names, plus every tracked file name
# when a private checkout happens to be at hand (the same rule weekly.sh applies)
names=$(for pin in npu-runtime gpu-kernels; do
            sed -n 's/^require=//p' "$src/config/$pin.config" | tr ' ' '\n'
        done | grep -v '^$' | xargs -r -n1 basename | LC_ALL=C sort -u)
n=$(find "$stage" -type f -printf '%f\n' | LC_ALL=C sort -u | LC_ALL=C comm -12 - <(echo "$names") | wc -l)
[ "$n" = 0 ] || fail "$n files named like the private sources"
Incorrect Error Message

In cmake/binary_drop.cmake, the error message when a URL is provided but no matching drop is found in config/binary-drop.config is misleading. It states that the pin file has no line for the engine commit, but it should clarify that the pin file does not contain a line for the specific engine commit being built, rather than just stating that the pin file has no line at all.

    message(FATAL_ERROR
        "ONEBIT_BINARY_DROP is a URL but config/binary-drop.config pins no drop for engine commit "
        "'${_drop_engine_sha}'. Add its line (drop=<sha> <version> <sha256>), or pass "
        "-DONEBIT_BINARY_DROP_SHA256=<sha256> (docs/releases.md, \"The public binary drop\").")
endif()
Missing Test Coverage

The test script tests/npu_runtime_option.sh has been updated to include new test cases for missing API files and incorrect library specifications. However, it is missing a test case for when ONEBIT_NPU_RT_LIB is set to a valid library file but ONEBIT_NPU_RT_DIR is also set, which should result in a configuration error. This scenario is important to test to ensure that the build system correctly enforces that only one of these options is set.

expect no_api_dir "ONEBIT_NPU needs the NPU runtime" -DONEBIT_NPU_RT_DIR="$tmp/noapi"
expect missing_lib "is not a library file" -DONEBIT_NPU_RT_LIB="$tmp/none.a"
expect dir_as_lib "is not a library file" -DONEBIT_NPU_RT_LIB="$tmp"
expect lib_and_dir "not both" -DONEBIT_NPU_RT_LIB="$tmp/libnpu_rt_api.a" -DONEBIT_NPU_RT_DIR="$tmp/noapi"
[ $fail -eq 0 ] && echo PASS

# Conflicts:
#	docs/npu.md
#	docs/releases.md
@github-actions

Copy link
Copy Markdown

Preparing review...

@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit feb5e1a

@bong-water-water-bong
bong-water-water-bong merged commit 4e4e3be into main Oct 20, 2026
8 of 9 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the 1bit/binary-drop branch October 20, 2026 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant