Skip to content

1bit serve --embedding / --reranking (Lemonade checklist #4) - #70

Merged
bong-water-water-bong merged 1 commit into
mainfrom
serve-roles
Sep 25, 2026
Merged

bong-water-water-bong merged 1 commit into
mainfrom
serve-roles

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Engine half of item 4 on the Lemonade checklist. Lemonade loads embedding and reranking models as models of their own, but 1bit serve only served them as companions of a chat model (--embed, --rerank).

The change: --embedding and --reranking serve the model itself in that role. llama-server runs on the device asked for (vulkan, hrx, rocm) with that flag, and 1bit serve exposes /v1/embeddings (+ /embeddings) or /v1/rerank (+ /rerank, /v1/reranking, /reranking).

Measured on Strix Halo:

  • Direct: embeddings work on Vulkan and HRX (768-dimension vectors). Rerank works on Vulkan: "Paris is the capital of France." scores 0.20 against 0.0016 for the other document.
  • Rerank on HRX fails: HRX's JIT can't link the fp32 matmul-with-bias kernel jina-reranker-v1-tiny needs. docs/serve.md documents this.
  • With the fork's matching recipe change (1bit-MONSTER/lemonade, branch onebit-embed), Lemonade's LLM suite through onebit:
    • Vulkan: 29 of 29 run tests pass, with 2 skipped (echo and generation parameters, which Lemonade's llamacpp recipe doesn't declare either);
    • HRX: 26 of 29 pass; the 3 reranking tests fail on the HRX JIT bug.

🤖 Generated with Claude Code

…role

Lemonade loads embedding and reranking models as models of their own; 1bit serve only
served them as companions of a chat model (--embed, --rerank). The role runs llama-server
on the device asked for (vulkan, hrx, rocm) with --embedding / --reranking and serves
/v1/embeddings or /v1/rerank. Strix Halo: embeddings on Vulkan and HRX, rerank on Vulkan;
rerank on HRX hits an HRX JIT link failure (fp32 mul_mat+bias), documented.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@context7

context7 Bot commented Sep 25, 2026

Copy link
Copy Markdown

Docs7 for 1bit-monster/engine

Result Status Action
Deployment ➖ Not used —
Content review ➖ Did not run. This site has no agent runs available this month. Wait for the monthly reset or check your Docs7 plan. —

Commit 92c522a

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Incorrect Role Handling for Reranking

The code introduces a new --reranking flag that sets o.role to "reranking", but the logic in serve_child and the HTTP handler only checks for o.role == "embedding" to set up the appropriate endpoints. This means that when --reranking is used, the HTTP server will not correctly register the /v1/rerank and related endpoints, as the condition o.role == "embedding" will be false. This could lead to the reranking model not being accessible via the expected API endpoints.

if (o.role == "embedding")
    for (const char* path : {"/v1/embeddings", "/embeddings"}) srv.Post(path, h);
else
    for (const char* path : {"/v1/rerank", "/rerank", "/v1/reranking", "/reranking"}) srv.Post(path, h);
Potential Incorrect Device Validation

The validation logic for the device in the --role branch checks if dev is one of "vulkan", "hrx", or "rocm". However, it does not ensure that the device matches the role being served. For example, if a user specifies --reranking --device rocm, it should be valid, but the current check might not properly enforce that the device is appropriate for the specific role being served. This could lead to incorrect behavior or runtime errors.

if (dev != "vulkan" && dev != "hrx" && dev != "rocm")
    throw std::runtime_error("--" + o.role + " runs on llama-server devices (vulkan, hrx, rocm), not " + dev);
if (o.adaptive || !o.mtp.empty() || !o.prefill_device.empty())
    throw std::runtime_error("--" + o.role + " does not combine with --adaptive, --mtp or --prefill-device");

@bong-water-water-bong
bong-water-water-bong merged commit 9b70369 into main Sep 25, 2026
5 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the serve-roles branch September 25, 2026 10:38
bong-water-water-bong pushed a commit that referenced this pull request Oct 2, 2026
…512 tokens, deterministic flash attention

llama.cpp fork since cebcd70 (balanced mode, figures from each PR):
- #66 MUL_MAT_ID at multiples of 32 plus a decode-loader stride fix; #67 ADD_ID and SWIGLU_OAI on HRX;
  #73 a placement guard for the CPU/HRX split bug (engine #286). gpt-oss-20b MXFP4: pp512 25.8 -> ~1000,
  tg128 12.6 -> ~35 tok/s, text correct, KLD vs CPU 0.029.
- #69 TQ1_0/TQ2_0 on HRX: Ternary-Bonsai-1.7B KLD vs CPU 0.000523; pp512/tg128 3542/113 and 4100/156.
- #70 MLA V transpose: GLM-4.7-Flash prompts of 512+ tokens gave garbage (PPL 315,664), now 5.916 (CPU 5.959).
- #71 llama-hadamard folds qwen3next's ssm_ba and refuses unfoldable stamped files.
- #72 masked flash-attention keys reach P*V as V = +0: identical requests now give identical logits
  (Qwen3-0.6B and Qwen3.8-27B bit-identical repeats); pp512 -4.7% on Qwen3-0.6B.

Docs: docs/hrx.md "Our patches". Registry regenerated (no mapping changes).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
bong-water-water-bong added a commit that referenced this pull request Oct 2, 2026
…tic FA, attention sinks) (#295)

* Pin llama.cpp 2bd7f58: gpt-oss on HRX, TQ1_0/TQ2_0, MLA prompts past 512 tokens, deterministic flash attention

llama.cpp fork since cebcd70 (balanced mode, figures from each PR):
- #66 MUL_MAT_ID at multiples of 32 plus a decode-loader stride fix; #67 ADD_ID and SWIGLU_OAI on HRX;
  #73 a placement guard for the CPU/HRX split bug (engine #286). gpt-oss-20b MXFP4: pp512 25.8 -> ~1000,
  tg128 12.6 -> ~35 tok/s, text correct, KLD vs CPU 0.029.
- #69 TQ1_0/TQ2_0 on HRX: Ternary-Bonsai-1.7B KLD vs CPU 0.000523; pp512/tg128 3542/113 and 4100/156.
- #70 MLA V transpose: GLM-4.7-Flash prompts of 512+ tokens gave garbage (PPL 315,664), now 5.916 (CPU 5.959).
- #71 llama-hadamard folds qwen3next's ssm_ba and refuses unfoldable stamped files.
- #72 masked flash-attention keys reach P*V as V = +0: identical requests now give identical logits
  (Qwen3-0.6B and Qwen3.8-27B bit-identical repeats); pp512 -4.7% on Qwen3-0.6B.

Docs: docs/hrx.md "Our patches". Registry regenerated (no mapping changes).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Pin llama.cpp 4485916: attention sinks on HRX (gpt-oss)

#68 runs gpt-oss's sink logits on HRX as an exact post-correction of the flash-attention output.
Docs: docs/hrx.md "Our patches". Registry pin updated.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Pin llama.cpp f5b7f4a: PrismML tile bytes (PQ2_0 small-model decode)

#74: the low-token SwiGLU read every PQ2_0 / PTQ1_0 row from row 0; Ternary-Bonsai-1.7B PQ2_0 now
matches the CPU. Found by the release format matrix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: bong-water-water-bong <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
bong-water-water-bong pushed a commit that referenced this pull request Nov 13, 2026
…2293) and the QSA/mask work behind them

Two commits past the previous bump, and both are the ones the issue threads are waiting on:

  #68  aa25474  the prefill GEMM keeps activations inside the f16 range (2^-6 prescale, undone before the epilogue)
  #70  dccd024  dense prefill and small-batch K-quant activations finite above the f16 range (engine #2293)

#70 is #2293's part 2 -- the 12 dense magnitude rows that had no fix when the issue was filed. Its comment in
hrx_dense_prefill.hip names the issue and the rows: "an activation above 65504 became inf in the narrowing and the result
NaN (engine #2293: test-backend-ops MUL_MAT magnitude=91000 on q8_0 / iq4_xs / q5_K / q6_K)". #68's comment in
hrx_prefill_gemm.hip names #2159's failure the same way.

Verified by fetching the pin with this branch's config (1.4 s, shallow sparse checkout) and reading the two files, not by
trusting the PR titles: both carry kXs = 0.015625f / kXsInv = 64.0f with those comments.

The range is TEN commits, not the three the previous body named -- the full inventory is in the PR body, because the review
at bd8fe4b was right that a count of three understated what a reader is being asked to accept.
bong-water-water-bong added a commit that referenced this pull request Nov 13, 2026
…uted GEMM fit (#572) and the registration guard (#2316)

* gpu-kernels: pin eb0f3839, which carries the 2^-6 prefill prescale (#2159), the routed GEMM fit (#572) and the
registration guard

Upstream merged three kernel fixes today and the engine still pinned the commit before them:

  gpu-kernels main   eb0f383972039bb2292f0d9f740b1020fcd3a1e1
  gpu-kernels#68     the prefill GEMM keeps activations inside the f16 range (2^-6 prescale, the llama.cpp #285/#288 shape)
  gpu-kernels#67     the routed-expert prefill GEMM fitted to Qwen3.8-Flash-Next
  gpu-kernels#66     registration fails when a HipKernel has no launch
  engine pin was     fd69590c6c471507f6d804751f38473261436350

So the engine now builds the kernels that carry them. The sha is advertised by the remote (checked with `git ls-remote`, not
assumed) and the config's format is unchanged: `scripts/fetch-private.sh` checks out exactly this commit at build time.

This changes the compiled kernels in every HRX build, which is the point and also the risk: the code objects the release
ships come from this checkout, so the first HRX build after this PR is the one that proves the bump. #2159's fix was measured
by the kernel lane on these kernels (the MUL_MAT_ID rows and the 12 dense magnitude rows in #2293), so the prescale is not a
guess.

One doc line had to change with it: docs/hetero-prefill.md said "`origin/main`'s `config/gpu-kernels.config` pins fd69590c…",
which stops being true the moment this lands. It now says "at the time of this capture pinned", which keeps the argument
(the pin carried the fix then; the capture's runtime was stale) without asserting anything about today's pin.

* gpu-kernels: pin b0ed206, which carries both f16-range fixes (#2159, #2293) and the QSA/mask work behind them

Two commits past the previous bump, and both are the ones the issue threads are waiting on:

  #68  aa25474  the prefill GEMM keeps activations inside the f16 range (2^-6 prescale, undone before the epilogue)
  #70  dccd024  dense prefill and small-batch K-quant activations finite above the f16 range (engine #2293)

#70 is #2293's part 2 -- the 12 dense magnitude rows that had no fix when the issue was filed. Its comment in
hrx_dense_prefill.hip names the issue and the rows: "an activation above 65504 became inf in the narrowing and the result
NaN (engine #2293: test-backend-ops MUL_MAT magnitude=91000 on q8_0 / iq4_xs / q5_K / q6_K)". #68's comment in
hrx_prefill_gemm.hip names #2159's failure the same way.

Verified by fetching the pin with this branch's config (1.4 s, shallow sparse checkout) and reading the two files, not by
trusting the PR titles: both carry kXs = 0.015625f / kXsInv = 64.0f with those comments.

The range is TEN commits, not the three the previous body named -- the full inventory is in the PR body, because the review
at bd8fe4b was right that a count of three understated what a reader is being asked to accept.

---------

Co-authored-by: bong-water-water-bong <[email protected]>
bong-water-water-bong pushed a commit that referenced this pull request Nov 14, 2026
Found while reading my own PRs with `--state` (which #2400 added): it reported npu-kernels#70
as held by a CHANGES at 14:51Z. That "verdict" was **my own reconciliation comment**, which
quotes the verdict it disagrees with:

    `VERDICT: NEEDS-CHANGE` at `8a27d70c5` measured:

`VERDICT_LINE` allows markdown decoration before VERDICT (bold, list bullets), and a backtick is
decoration too - so a quotation of someone else's verdict at the head read as a verdict by the
author. The same applies to a comment that quotes the *format* (`Write it as \`VERDICT: READY at
<head>\``).

A verdict does not begin inside an inline code span:

    VERDICT_LINE  ^(?![^A-Za-z0-9]*`[^`]*VERDICT)[^A-Za-z0-9]*VERDICT\b
    VERDICT_KIND  same exclusion -- `--state` classifies through it

Measured on the real comment: `verdict_kind` -> None, `reviewed_at` -> False; and it is not a
one-way narrowing - the house forms still read (bold `**VERDICT: READY at \`abc1234\`**`, bare,
list-decorated). After the fix `--state --repos npu-kernels` reports #70 as `newest=READY
2026-11-13T06:40:19Z`, the reviewer's actual verdict.

Two arms added (quoted verdict, quoted format); removing the exclusion fails **4** arms.
bong-water-water-bong added a commit that referenced this pull request Nov 14, 2026
…the queue crashed at 07:13Z) (#2408)

* pr_review_queue: a non-list page is an error, not a list of strings

The queue crashed outright at 07:13Z:

    body = r.get('body') or ''
    AttributeError: 'str' object has no attribute 'get'

`gh()` paginated does `out.extend(json.loads(chunk))`. A list endpoint answers with a
list, but an error object (`{"message":"API rate limit exceeded"}`, a 404, a renamed repo)
is a **dict**, and `extend(dict)` extends with the dict's **keys** - strings - which then
explode in `reviewed_at`. So one transient API error took out the whole queue.

Now a non-list page raises, naming the endpoint and the message, and `main` returns 2:

    pr_review_queue: gh api repos/OWNER/REPO/pulls?state=open did not answer with a list: Not Found
    rc=2

Reported rather than skipped, because a failed read must not come out as "every open PR has
a verdict" - that is the same false negative this tool exists to prevent (a verdict that
exists read as absent).

Arm drives the real `gh` path through a stub that answers an error object; disabling the
guard fails it (1 FAIL). Verified end to end against a repository that does not exist:
rc 2 with the message above.

* pr_review_queue: a QUOTED verdict is not a verdict

Found while reading my own PRs with `--state` (which #2400 added): it reported npu-kernels#70
as held by a CHANGES at 14:51Z. That "verdict" was **my own reconciliation comment**, which
quotes the verdict it disagrees with:

    `VERDICT: NEEDS-CHANGE` at `8a27d70c5` measured:

`VERDICT_LINE` allows markdown decoration before VERDICT (bold, list bullets), and a backtick is
decoration too - so a quotation of someone else's verdict at the head read as a verdict by the
author. The same applies to a comment that quotes the *format* (`Write it as \`VERDICT: READY at
<head>\``).

A verdict does not begin inside an inline code span:

    VERDICT_LINE  ^(?![^A-Za-z0-9]*`[^`]*VERDICT)[^A-Za-z0-9]*VERDICT\b
    VERDICT_KIND  same exclusion -- `--state` classifies through it

Measured on the real comment: `verdict_kind` -> None, `reviewed_at` -> False; and it is not a
one-way narrowing - the house forms still read (bold `**VERDICT: READY at \`abc1234\`**`, bare,
list-decorated). After the fix `--state --repos npu-kernels` reports #70 as `newest=READY
2026-11-13T06:40:19Z`, the reviewer's actual verdict.

Two arms added (quoted verdict, quoted format); removing the exclusion fails **4** arms.

---------

Co-authored-by: bong-water-water-bong <[email protected]>
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