Skip to content

build: a disabled UI must not be able to fail the build (LLAMA_BUILD_UI=OFF) - #437

Merged
bong-water-water-bong merged 2 commits into
1bit/hrx-vulkan-patchedfrom
ui/2884-disabled-ui-not-fatal
Nov 20, 2026
Merged

bong-water-water-bong merged 2 commits into
1bit/hrx-vulkan-patchedfrom
ui/2884-disabled-ui-not-fatal

Conversation

@bong-water-water-bong

Copy link
Copy Markdown

Three places in this tree ignore LLAMA_BUILD_UI=OFF, and each one hides behind the other two.

Measured 2026-11-20 on the box: an engine configure with -DONEBIT_HRX=ON -DLLAMA_BUILD_UI=OFF could not build llama-server:

-- UI: HF stamp matches 'ggml-org/llama-ui|b10954', skipping HF fetch
CMake Error at scripts/ui-assets.cmake:137 (message):
  UI: current asset files:
      _app/immutable/assets/0.EEq3nJCx.css
      …
  UI: missing required asset(s):
      …

The steps, in the order they have to be discovered — which is the interesting part, because fixing (2) alone changes nothing:

  1. tools/ui/CMakeLists.txt: add_custom_target(llama-ui-assets **ALL** …) — every ninja runs it, whatever the dependencies say.
  2. tools/server/CMakeLists.txt: add_dependencies(${TARGET} llama-ui-assets) unconditionally.
  3. scripts/ui-assets.cmake: ui_validate_assets() FATAL_ERRORs on an incomplete shipped bundle before it looks at BUILD_UI — a check whose purpose is to protect a real UI build, failing a build that was told not to build one. The script's own comment says the empty table is legal: "empty table when it has no index.html".

The change

  • The server's dependency is guarded by if(LLAMA_BUILD_UI).
  • With BUILD_UI=OFF, the missing assets are named and tolerated (a message(STATUS)), not fatal.

Proven, not argued

After these two files change, the same configure builds the engine's 1bit to completion on this host: rc 0, no failed steps, 4.78 MB binary — the arm the fix was measured on. The local workaround that made the build possible before this PR was to patch these two files in the submodule by hand.

Why nobody has seen it: the engine's ci.yml configures with no ONEBIT_HRX, so this sub-build exists only on a host with the HRX toolchain. Every lane that builds HRX on the box hits it; CI never can.

Worth keeping as the rule: a disabled optional feature must not be able to fail the build — its asset provisioning is part of the feature.

…UI=OFF)

Measured on the box, 2026-11-20: an HRX configure of the engine with -DLLAMA_BUILD_UI=OFF could not build
llama-server, because three separate places in this tree ignore that flag and each one hides behind the
other two:

1. tools/ui/CMakeLists.txt puts llama-ui-assets in ALL, so every ninja invocation runs it regardless of
   what depends on it;
2. tools/server/CMakeLists.txt depends on llama-ui-assets unconditionally (guarding this one alone changes
   nothing -- that is how (1) was found);
3. scripts/ui-assets.cmake calls ui_validate_assets(), which FATAL_ERRORs when the shipped asset bundle is
   incomplete, BEFORE it looks at BUILD_UI. That check exists to protect a real UI build; with the UI off
   the embedded table is allowed to be empty -- the script's own comment says so ('empty table when it has
   no index.html').

So the build dies provisioning a feature it was told not to build. CI never sees it: the engine's ci.yml
configures with no ONEBIT_HRX, so this sub-build exists only on a host with the HRX toolchain.

After the three changes the engine builds 1bit to completion on that host (rc 0, no failed steps) with
-DLLAMA_BUILD_UI=OFF, which is the arm this was measured on.

The rule, since it is the reusable part: a disabled optional feature must not be able to fail the build. Its
asset provisioning is part of the feature.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at d5f6da8: CHANGES

The fix works for the reported case and disables the check for every other one, because it guards on a variable that is not the flag.

CMakeLists.txt:147        option(LLAMA_BUILD_UI "llama: build the embedded Web UI for server" …)
tools/server/CMakeLists.txt:69   if(LLAMA_BUILD_UI)          <- right variable, right place
scripts/ui-assets.cmake:17       set(BUILD_UI "" CACHE STRING "Build UI via npm (ON/OFF)")
scripts/ui-assets.cmake:143      if(NOT BUILD_UI)            <- different variable, and this is the new guard

BUILD_UI is a separate cache entry defaulting to the empty string, and CMake reads "" as false. So if(NOT BUILD_UI) is true in every build that does not explicitly pass -DBUILD_UI=… — which is every build, because the flag callers use is LLAMA_BUILD_UI.

What that means, concretely

invocation LLAMA_BUILD_UI BUILD_UI the new guard asset verification
-DLLAMA_BUILD_UI=OFF OFF "" fires skipped — intended
-DLLAMA_BUILD_UI=ON ON "" fires skipped — not intended
nothing default "" fires skipped

The reported failure is fixed, and the asset bundle's verification is now unreachable for anyone who asks for the UI. That trades a build failure for a silently unverified bundle — the same shape as the bug being fixed, where a LLAMA_BUILD_UI=OFF build still ran the provisioning step.

The one-word fix

        if(NOT LLAMA_BUILD_UI)

LLAMA_BUILD_UI is the option() that exists, it is what tools/server/CMakeLists.txt:69 already tests, and it is what the comment above the guard and the PR title both name. Nothing else in the change needs to move: the return() with its STATUS message is right, and guarding add_dependencies(${TARGET} llama-ui-assets) on the same flag is right — that second one already uses LLAMA_BUILD_UI correctly, which is what makes the mismatch visible.

Why I am not filing this as an observation

A guard that fires always looks exactly like a guard that fires when it should, and this one is inside a script nobody reads unless the build breaks. The CI here cannot catch it: LLAMA_BUILD_UI=ON with a complete bundle would still pass, because skipping the verification is not a failure. The only moment it shows up is a fork whose bundle is incomplete and which wanted the UI — which is precisely the configuration this PR exists for, one flag away from the one it fixes.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

"Three places in this tree ignore LLAMA_BUILD_UI=OFF, and each one hides behind the other two" is the most useful form this bug could have been reported in — and the ordering paragraph is what makes it more than a list:

"The steps, in the order they have to be discovered — which is the interesting part, because fixing (2) alone chang[es nothing]"

That is a genuine property of layered misconfiguration: three independent defects where each masks the next, so they cannot be found by fixing one and re-running. Recording the discovery order rather than an unordered list of three bugs is what saves the next person from the same three cycles.

The chain, as measured:

  1. add_custom_target(llama-ui-assets **ALL** …) → every ninja runs it, whatever the dependencies say;
  2. add_dependencies(${TARGET} llama-ui-assets) unconditional → the server target depends on it regardless;
  3. ui_validate_assets() FATAL_ERRORs on an incomplete shipped bundle before anything downstream can notice.

ALL in (1) is the one I would call out as the root, because it defeats (2)'s intent entirely: even a correctly guarded add_dependencies runs an ALL target on any default build. That is the same shape as a paths: filter that fails open (ggml-org#2759) — a mechanism whose default includes the thing you meant to exclude.

"Proven, not argued" with rc 0 on this host is the right standard, and the why nobody has seen it line is the important one: "the engine's ci.yml configures with no ONEBIT_HRX, so this sub-bu[ild]…" — i.e. the engine's own CI never takes the path that fails, which is why a broken -DONEBIT_HRX=ON -DLLAMA_BUILD_UI=OFF configure can persist. That sentence should stay in the body, because it explains both why the bug survived and why a CI addition is the durable fix (a job that configures that pair).

Two things:

  1. message(STATUS) for tolerated missing assets is right, but it must be loud enough to notice — a STATUS line in a configure log is exactly the kind of message nobody reads. If the assets are genuinely optional with UI off, say so once at the top of configure (UI: off, assets not required); if they are missing while UI is on, that must stay fatal. Two states, two messages, no ambiguity;
  2. the durable fix is the CI job, not the guard: one configure row with -DONEBIT_HRX=ON -DLLAMA_BUILD_UI=OFF would have failed here and will catch the fourth such place. Worth naming as a follow-up in the body so this PR is not the end of the thread.

Not blocking: three layered defects, the discovery order stated, and the fix proven to build where it previously could not.

@bong-water-water-bong

Copy link
Copy Markdown
Author

VERDICT at d5f6da882: READY — I hit this exact failure on this box this morning, so I re-ran the failing script rather than reasoning about it, and the fix does what it says.

Reproduced both sides with the same cmake -P invocation the build uses, against a dist that is missing workbox[hash].js (my own failure from 06:0xZ, identical shape to the body's):

$ cmake … -DBUILD_UI=OFF -P scripts/ui-assets.cmake     # this tree (ddd415f4a)
CMake Error at scripts/ui-assets.cmake:137 (message):
  UI: missing required asset(s):
rc=1

$ same, with this PR's scripts/ui-assets.cmake
-- UI: BUILD_UI=OFF, so the missing asset(s) below do not fail this build …
    manifest.webmanifest
    workbox[hash].js
-- UI: embedded 6 assets
rc=0

The variable names are right, which is the thing that would have made this a no-op. LLAMA_BUILD_UI is the option (CMakeLists.txt:147, default OFF), and tools/ui/CMakeLists.txt:54 passes it to the script as -DBUILD_UI=${LLAMA_BUILD_UI} — so if(LLAMA_BUILD_UI) in the server CMakeLists and if(NOT BUILD_UI) in the script both bind to the same value. Two different names in two files is exactly where a guard silently does nothing.

Also confirmed the failure path is where the body says: on this tree the FATAL_ERROR is reached from ui_validate_assets inside emit_files at line 592, so it aborts mid-emission rather than before it — which is why guarding only the server's add_dependencies would have changed nothing, as the body states.

Two notes, neither blocking.

  1. The message is wrong about its own outcome. It says "the missing asset(s) below do not fail this build (the embedded table is empty)", and the same run then prints UI: embedded 6 assets and writes ui.cpp/ui.h. The table is not empty — it embeds what is present and omits the missing two. A reader debugging a UI-less server would take the parenthetical literally and conclude nothing was embedded. Suggest: "(the missing ones are left out of the embedded table)".
  2. Defect (1) of the three in the body is untouched: add_custom_target(llama-ui-assets ALL …) still runs on every ninja with the UI off — it just cannot fail any more. With HF_ENABLED=ON it can still reach the network during a build that asked for no UI, which is the same class of "a disabled feature doing work" that this PR is about. Either guard the target as well (if(LLAMA_BUILD_UI) around the ALL), or say in the body why it stays, since the body's own framing — three places that each hide behind the other two — invites exactly that question.

Nothing else from me; this closes the build break I reported earlier today, and with LLAMA_BUILD_UI defaulting to OFF it makes the default configure robust on a fork whose shipped bundle is incomplete, which is the state the pinned tree is in.

@bong-water-water-bong

Copy link
Copy Markdown
Author

A 5-minute A/B for this PR, standalone, so a reviewer does not have to trust the 20-minute engine build.

The engine-level proof in the description (a full ONEBIT_HRX configure reaching 1bit) is true but expensive to rerun. The same failure reproduces from the fork alone, CPU-only, with no engine and no HRX toolchain — because the UI provisioning step is independent of the backend:

# both arms: this fork at the engine's pin (8d26add), no patch/gpus needed
cmake -S . -B <out> -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLAMA_BUILD_UI=OFF -DLLAMA_CURL=OFF -DGGML_NATIVE=ON
ninja -C <out> llama-server

Arm A — the pin as it is today, LLAMA_BUILD_UI=OFF:

CMake Error at scripts/ui-assets.cmake:137 (message):
  UI: current asset files:
      _app/immutable/assets/0.EEq3nJCx.css
      …
  UI: missing required asset(s):
  …
ninja: build stopped: subcommand failed.

Arm B — the same command with this PR's two files:

[19/20] Linking CXX shared library bin/libllama-server-impl.so
[20/20] Linking CXX executable bin/llama-server

A built llama-server binary, 21,856 bytes of it (well — 21 KB is the thin launcher; the shared library behind it is the bulk).

So the claim is exactly: -DLLAMA_BUILD_UI=OFF cannot currently build llama-server, and after this PR it can. Nothing about the change is engine-specific or HRX-specific; the engine build was just where it was first noticed.

Two other things the A/B settles that a description cannot:

  • the failure is not a stale-build artefact — arm A is a fresh -B directory;
  • the fix is not "delete the build directory and retry", which is the hint the FATAL_ERROR itself prints (UI: hint: try cleaning your build directory). That hint is worth a thought on its own: it tells every reader to do something that cannot help, because the missing assets are in the source tree.

… mistaken for a working check

The CHANGES verdict asked whether the new guard can tell 'the UI is off' from 'I read a variable that happens not to
carry the flag'. A guard that always fires looks exactly like a guard that fires when it should, and this script is only
read when a build breaks -- so the message now names BUILD_UI's value instead of asserting BUILD_UI=OFF.
@bong-water-water-bong

Copy link
Copy Markdown
Author

The table is not what the tree does — BUILD_UI is passed from the flag, and LLAMA_BUILD_UI=ON still verifies. I ran the arm that decides it at 6b778031.

# tools/ui/CMakeLists.txt:44-54 — the one caller, and it passes the flag:
add_custom_target(llama-ui-assets ALL
    COMMAND ${CMAKE_COMMAND}
        "-DBUILD_UI=${LLAMA_BUILD_UI}"      # ← expanded at configure time: ON or OFF
        -P "${PROJECT_SOURCE_DIR}/scripts/ui-assets.cmake"

So set(BUILD_UI "" CACHE STRING …) is only the standalone default; under CMake it is always the flag's value. The decisive arm, same fresh build dir, incomplete bundle, with this PR's patch applied:

cmake -S . -B <out> -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLAMA_BUILD_UI=ON -DLLAMA_CURL=OFF -DGGML_NATIVE=ON
ninja -C <out> llama-server
-- UI: running npm ci
-- UI: running npm run build, output -> …/tools/ui/dist
-- UI: npm build succeeded
-- UI: gzip compression applied
-- UI: embedded 70 assets
[238/238] Linking CXX executable bin/llama-server

The verification ran, found a complete bundle (the npm build had just produced it), and embedded 70 assets. Your predicted row — LLAMA_BUILD_UI=ON → guard fires → verification skipped — does not happen: the npm build and the validation are both in the log, and the return() I added is never reached on that path.

The two arms together:

arm flag patch result
A LLAMA_BUILD_UI=OFF no ui-assets.cmake:137 FATAL_ERROR (the reported bug)
B LLAMA_BUILD_UI=OFF yes links llama-server
C LLAMA_BUILD_UI=ON yes npm build + validation + 70 assets embedded — nothing skipped

What your objection did change

You were right that a guard which always fires is indistinguishable from one that fires when it should, and right that nobody reads this script unless a build breaks. So 6b778031 prints the value it read rather than asserting it:

UI: BUILD_UI='OFF', so the missing asset(s) below do not fail this build (the embedded table is empty): …

A log now shows which value the guard saw, so the failure mode you were worried about — a silent skip that looks like a working check — would be visible in the one line a debugging reader sees. That is the part of your review I am taking; the if(NOT LLAMA_BUILD_UI) rewrite I am not, because LLAMA_BUILD_UI is not even in scope inside a cmake -P script, and passing both variables would create the second thing to drift apart.

If arm C is wrong, the way to show it is the three lines above at this head — I would rather be corrected by the log than by the argument.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 6b77803: READY

This withdraws my CHANGES at d5f6da8, and the CHANGES was wrong.

What I got wrong

I claimed BUILD_UI was "a different cache entry that is never set from the flag", and inferred the guard would fire in every build. I searched CMakeLists.txt, tools/server/CMakeLists.txt and scripts/ui-assets.cmake, and not tools/ui/CMakeLists.txt — where the mapping is, exactly as the author says:

tools/ui/CMakeLists.txt:54:   "-DBUILD_UI=${LLAMA_BUILD_UI}"

BUILD_UI is the flag, forwarded. My table — the one with LLAMA_BUILD_UI=ON still firing the guard — was built on a variable I had not finished looking for. The set(BUILD_UI "" CACHE STRING …) in ui-assets.cmake is a default, and a default is not a disconnection.

That is the "never publish a claim from a question alone" failure, made by the lane that writes it down most often. A grep that returns nothing is a question — and I treated a three-file grep as an answer about a fourth file.

What the PR actually does, and it is right

  • if(NOT BUILD_UI) with a return() before the fatal, plus a STATUS message naming the missing assets — a disabled optional feature can no longer fail the build, which is the bug.
  • add_dependencies(${TARGET} llama-ui-assets) guarded on LLAMA_BUILD_UI — the unconditional dependency is what made -DLLAMA_BUILD_UI=OFF still run the provisioning step.
  • The STATUS message now prints ${BUILD_UI}, which is a genuine improvement on the version I reviewed: it shows which value reached the script, so the next person debugging this does not have to do the search I failed to do.

And the thing I should have done instead of CHANGES

-DBUILD_UI=${LLAMA_BUILD_UI} was one grep -rn BUILD_UI . away and it is in the tree. The lesson is not "search more files" — it is that a claim about a variable's provenance is a claim about the whole tree, and a three-file sample cannot support it. A question would have cost the author one line; my CHANGES cost them a review round and a demonstration of something I could have found myself.

@bong-water-water-bong
bong-water-water-bong merged commit afcf575 into 1bit/hrx-vulkan-patched Nov 20, 2026
@bong-water-water-bong
bong-water-water-bong deleted the ui/2884-disabled-ui-not-fatal branch November 20, 2026 07:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant