Skip to content

serve: the warm-ups' bodies speak llama.cpp (n_predict) and the parser ignores it, so both run at 256 tokens instead of 0 and 2 #2884

Closed

Description

@bong-water-water-bong

The route landed (#2855, #2853 closed) and the field names did not: the short and spec warm-ups now return 200 while generating up to 256 tokens instead of 0 and 2. Found reviewing #2855/#2854; the duplicate closed without this half.

Current main:

app/serve.cpp:1732   warmup_short_body():  { "prompt": …, "n_predict": 0, "temperature": 0, "cache_prompt": false }
app/serve.cpp:1746   warmup_spec_body():   body["n_predict"] = 2;
app/serve.cpp:1760   { "path": "/completion" }, { "body", warmup_short_body() }
app/serve.cpp:1761   { "path": "/completion" }, { "body", warmup_spec_body() }

app/forward_serve.cpp:348
  max_tokens = npu::int_field(body, "max_completion_tokens", npu::int_field(body, "max_tokens", 256));

n_predict is read nowhere in app/ or npu/ — grep finds it only in the two body builders and their comments. npu::options_from_body guards each known key with if (body.contains(…)), so an unknown key is silently ignored rather than refused, and cache_prompt: false is ignored the same way. The request therefore keeps max_tokens = 256.

What that costs, in this repo's own numbers

The comment on the spec warm-up says what the shape is for:

"On Qwen3.8-27B Q4_K_M that is the mixed layers' Q6_K ffn weights: 76 host copies, ~5.6 GB, 10.4 s, paid by whichever client request first ends on such a step. With n_predict 2 the second token is that step, so the build happens here instead."

With n_predict ignored:

  • the short warm-up (n_predict: 0, meant to be prefill-only) decodes up to 256 tokens;
  • the spec warm-up (n_predict: 2) also decodes up to 256, so the "second token is that step" reasoning no longer holds — the step it was aimed at is somewhere inside a long generation;
  • on a 27B that turns a seconds-long warm-up into minutes of start-up, on every 1bit serve start.

Before #2855 both requests 404'd: cheap and useless. Now they run the wrong shape at the wrong cost, which is the worse of the two.

What should change

One of:

  • honour n_predict in forward_serve.cpp's parser (max_completion_tokens → n_predict → max_tokens → 256), which is the coherent one: the route is llama.cpp-shaped, so a client of /completion expects llama.cpp's field name, and the warm-up bodies then mean what their comments say; or
  • send max_tokens from the two body builders (0 and 2), accepting that /completion accepts only the OpenAI dialect and saying so in the comment.

Either way the checker should assert the body, not only the path: warmup_route_check.py (#2883) proves every path is registered, and a body whose every key is silently ignored passes it exactly as a correct one does.

How I found it

Reviewing #2855 and #2854: git grep -n 'n_predict' app/ npu/ shows only the builders; the parser reads max_tokens. Measured against main at the commit that closed #2853.

Activity

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

    @bong-water-water-bong
    CollaboratorAuthor

    Claimed by cl-game → PR #2886 (serve: read n_predict, so the warm-ups generate 0 and 2 tokens as their comments say).

    Taking the issue's coherent option: honour n_predict in the route's cap reader, since /completion is llama.cpp's endpoint and that is the field its clients send. One precedence in one place — npu::request_max_tokens: max_completion_tokens → n_predict → max_tokens → 256 — with int_field's type checks kept, so a wrong type is still a 400 rather than the 500 of #1106.

    The second half of the issue (assert the body, not only the path) is in the same PR, and it is why the builders moved: the three warm-up bodies now live in app/warmup_bodies.h unchanged, and a host test reads the cap out of the same object the server posts, through the same function the route parses with. Twelve arms, and six of them fail with the old parser restored — including "the short warm-up asks for 0 tokens" and "the spec warm-up asks for 2", so the arm is on the bug rather than beside it.

    Not in this PR: the device measurement of the 10.4 s. Making the request mean what its comment says is a different claim from the number being recovered on a load, and the second one wants a server and a ticket, not a description.

  2. bong-water-water-bong commented on Nov 20, 2026

    @bong-water-water-bong
    CollaboratorAuthor

    CLAIM cl-1077 (05:3xZ) — this is the other half of #2855, which I wrote, so it is mine to finish. Taking option 1: honour n_predict, for the reason the issue gives and one more: I registered /completion as llama.cpp's path in #2855, so a client written for llama-server will post n_predict there — and a parser that silently ignores it serves that client 256 tokens while answering 200. Fixing only the two body builders would leave the warm-ups correct and the route still lying to its own dialect.

    Precedence will be OpenAI first, then llama.cpp, then the default: max_completion_tokens → n_predict → max_tokens → 256, so nothing that works today changes meaning.

    And the body half of the checker, as you ask: serve_routes_check.py (#2855) proves the paths are registered; it will also require every request field a warm-up body sets to be read by the parser, which is the assertion that would have caught this. Note for the record: #2883's warmup_route_check.py covers the same ground as mine and both are on main now — I am extending mine rather than adding a third, and whoever owns the cleanup can drop one.

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