Skip to content

1bit serve: forward llama-server's other routes (Lemonade checklist #3) - #69

Merged
bong-water-water-bong merged 2 commits into
mainfrom
serve-llama-routes
Sep 25, 2026
Merged

bong-water-water-bong merged 2 commits into
mainfrom
serve-llama-routes

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

Fixes item 3 of the Lemonade embedding checklist (#68).

The gap: Lemonade's llamacpp backend, which the onebit recipe inherits, forwards /v1/responses, /tokenize and /slots to the backend, and 1bit serve answered 404.

The fix: on vulkan, hrx and rocm, 1bit serve now forwards these to the llama-server behind the model:

  • /v1/responses, streamed or not;
  • /tokenize, /detokenize, /apply-template;
  • GET /slots, POST /slots/<id>?action=… (query string kept), GET /props, GET /metrics.

On npu, zinc and mlx these routes answer 501 with a clear message. docs/serve.md lists them.

Measured on Strix Halo, Lemonade's test/server_llm.py --wrapped-server onebit on the pinned fork:

device before after
Vulkan 19 / 31 23 / 31
HRX 19 / 31 23 / 31

The four newly passing tests: Responses API, Responses API streaming, slots, tokenize. Direct checks: /tokenize returns token ids, /slots lists the slots, /props returns 200. A slot action returns llama-server's own 501 ("start it with --slot-save-path").

🤖 Generated with Claude Code

… slots, props)

Lemonade's llamacpp backend, which the onebit recipe inherits, forwards /v1/responses,
/tokenize and /slots to the backend; 1bit serve answered 404. On vulkan, hrx and rocm they
now go to the llama-server behind the model; npu, zinc and mlx answer 501.
Lemonade's LLM suite through onebit on Strix Halo: Vulkan 19 -> 23/31, HRX 19 -> 23/31.

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 631c08c

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

PR Reviewer Guide 🔍

(Review updated until commit 631c08c)

Here are some key observations to aid the review process:

🎫 Ticket compliance analysis 🔶

68 - Partially compliant

Compliant requirements:

  • Fix the gap for /v1/responses, /tokenize, /detokenize, /apply-template, /slots, /props, /metrics routes
  • Implement forwarding logic for vulkan, hrx, rocm devices
  • Implement 501 responses for npu, zinc, mlx devices
  • Update docs/serve.md with the new routes and their behavior
  • PR description includes measured results showing improvement from 19/31 to 23/31 tests passing

Non-compliant requirements:

  • None

Requires further human verification:

  • Verification that the measured performance improvements (19/31 to 23/31) are accurate on Strix Halo hardware
  • Confirmation that the new routes work correctly with the actual Lemonade integration
⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Potential Query String Encoding Issue

The query string encoding logic in the relay function may not properly handle all special characters in query parameters. Specifically, the use of httplib::encode_query_component might not cover all edge cases that could occur in real-world query strings, potentially leading to malformed requests being forwarded to the backend.

if (!req.params.empty()) {
    std::string query;
    for (const auto& [k, v] : req.params)
        query += (query.empty() ? "?" : "&") + httplib::encode_query_component(k) + "=" + httplib::encode_query_component(v);
    path += query;
}
Possible Race Condition in Model Loading

The first and first_json handlers check ready status before forwarding requests, but there's a potential race condition where the model could become ready between the check and the actual relay. This could lead to inconsistent behavior when the model is loading.

if (!ready) {
    r.status = 503;
    r.set_content(R"({"error":{"message":"model is loading"}})", "application/json");
    return;
}
relay(backends[0].port, q, r);
Incomplete Device Support Check

The device support check in line 532 uses device == "vulkan+rocm" which might not correctly identify all devices that should support these routes. This could lead to incorrect behavior if the device string is formatted differently.

const bool llama = device == "vulkan" || device == "hrx" || device == "rocm" || device == "vulkan+rocm";

@github-actions

Copy link
Copy Markdown

Persistent review updated to latest commit 631c08c

@bong-water-water-bong
bong-water-water-bong merged commit 57e03ea into main Sep 25, 2026
5 checks passed
@bong-water-water-bong
bong-water-water-bong deleted the serve-llama-routes branch September 25, 2026 10:32
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