Skip to content

npu: serve -m <model dir> cannot start a model-generic Q4NX container (plan.json + full ELFs), so published containers are invisible to Lemonade's npu backend #1129

Closed

Description

@bong-water-water-bong

What happens

1bit serve -m <model dir> --device npu cannot start a model-generic Q4NX container, i.e. a directory with
model.q4nx + config.json + tokenizer.json + plan.json, even when the NPU kernels for that geometry are on disk. Measured on
the shipped c25 payload binary (~/wt/payload-c25/lemonade-onebit-rc-2026-11-05-c25/1bit/1bit, sha f373dc80…), one npu-hold
ticket per directory:

directory result
~/models/npu/ZR1-1.5B-npu-q4km-q8 (published as 1bit-MONSTER/ZR1-1.5B-GGUF/npu-container-q8, 339 tensors, plan.json, 8 full ELFs built for its geometry) refused: 1bit serve: … is not an NPU model directory (the fast lane needs npu/), nothing ever served
~/models/npu/Qwen3-0.6B accepted — 1bit unified: on the private route dx: dense Qwen3 on the dx kernels, one design per layer (…/npu/kernels/1024x3072x16x8), ready in 641 ms
~/models/npu/bonsai2-27b-NPU refused, same message

The same engine runs the refused container correctly through the per-op forward — `1bit forward-serve -m model.q4nx --kernels

` gives 4/5 byte-identical prompts against llama.cpp on the container's own weights (this lane's route row on merged main) — so the runtime is there; only `serve`'s dispatch cannot reach it. `plan.json`/`full_i8_*` ELFs are exactly what `tools/npu_plan.py` and the ELF path produce, so this is the shape any converter+paker of ours emits.

Why, in the code

app/unified.cpp (npu_model_problem(), npu_model_kind()) accepts exactly two shapes:

  1. a private route — npu/private_route.cpp's known() lists qwen3_5_moe ("Qwen3.6-35B-A3B"), and a build-time addon can
    register more (dx, which is why Qwen3-0.6B is accepted above);
  2. the fast lane — npu/lane.cpp:69-76 reads a fixed kernel set (layer_ctx1.elf, layer_ctx2.elf, layer_ctx17.elf,
    lmhead.elf, layer.pdi) and only serves qwen2/qwen3 on those shape-specific kernels.

A model-generic container satisfies neither, so it is refused before the device is even opened. The GGUF branch of serve
(serve -m <gguf> --device npu) is the only path that ends in run_forward_serve, and a directory has no way to say "this is that
kind of model".

Consequence for the product path: Lemonade's onebit npu backend drives serve -m <dir>, so every model-generic container we
publish — ZR1-1.5B's (this lane's, 16 files) and bonsai2-27b-NPU — is invisible to it, while the hand-built fast-lane and
private-route models are not. That is also why an NPU scoreboard row for such a model reads "N/A": not the hardware, the dispatch.

Fix options

  1. A third kind in npu_model_kind(). If the directory has model.q4nx + config.json + tokenizer.json and NPU kernels
    resolve (from <dir>/npu, ONEBIT_NPU_KERNELS, or a per-request option), run the in-process per-op forward — i.e. exactly what
    the GGUF branch already runs after its repack. Purely additive: nothing that starts today changes behaviour, and it reuses the
    path that npu: a GGUF repacked by the GGUF-on-NPU path is a container the per-op forward cannot consume (every request: 'forward step failed: dequant failed') #1097 just fixed for off-grid intermediate_size.
  2. Require lane kernels in the container (the status quo for FastFlowLM packs). Not general: the lane kernels are
    shape-specific per model family, so a converted model of another geometry can never satisfy them.
  3. Docs-only: say in docs/npu.md that serve -m <dir> is fast-lane/private-route only and that a model-generic container must
    be served with forward-serve (or repacked from a GGUF), and accept that Lemonade's onebit npu backend cannot serve them.

How to verify (no device needed to see the refusal)

cb=$(shopt -s nullglob; ls -d ~/models/npu/*/ | head -3); for d in $cb; do
  ~/wt/payload-c25/lemonade-onebit-rc-2026-11-05-c25/1bit/1bit serve -m "$d" --device npu -p 18190; done

Each is a fast refusal or a load, no ticket needed for the refusal path; a load wants npu-hold. Option 1's acceptance test is the
container above answering /v1/completions with token ids while served as a directory, with text matching the forward-serve
row that already exists.

Activity

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

    @bong-water-water-bong
    CollaboratorAuthor

    Acceptance criterion met, and it was met on a published container rather than a scratch dir: ~/models/npu/ZR1-1.5B-npu-q4km-q8 (339 tensors, 28 layers, the eight full ELFs in ~/models/npu/zr1-elfs), driver 349FDC99, one npu-hold ticket per group, greedy 16 tokens on ids [151646,3639,5767,13228,321].

    • main 55cfaf89: refused — is not an NPU model directory (the fast lane needs npu/); and it is refused the same way when the dir carries an npu/ of the ELFs, so npu/ alone never helped and the dispatch really was the whole gap.
    • serve: a model-generic Q4NX container is served through the per-op forward, not refused #1133 8c53876: accepted, Model loaded: 339 tensors, 28 layers, ready (full ELF) in 2 s (ONEBIT_NPU_KERNELS) / 1 s (<dir>/npu, no env), /v1/completions 200 in both arms.
    • The answers are the per-op forward's own: serve -m <dir> and forward-serve -m model.q4nx --kernels … returned byte-identical text (same 23 s for 16 tokens), in the same ticket. Full table and the two doc consequences are on the PR (comment 6665961608).

    For the NPU column that reads N/A for such a model (pi-supreme's board): the cell becomes servable once #1133 is in, and it needs nothing from the model repo — kernels resolve from <container dir>/npu with no env var. That is why this lane's publish target changed from npu-container-q8/kernels/ to npu-container-q8/npu/ (~/models/npu/zr1-elfs/PUBLISH-READY.md; nothing uploaded, still the owner's word).

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