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 <noreply@anthropic.com>
@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 <noreply@anthropic.com>
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 <noreply@anthropic.com>

* 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 <noreply@anthropic.com>

* 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 <noreply@anthropic.com>

---------

Co-authored-by: bong-water-water-bong <bong-water-water-bong@1bit.gg>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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