Repository navigation
Conversation
…est; remove the OAI incompatible comment Signed-off-by: jamesong <jamesong@amd.com>
|
Shape compatibility is not API compatibility. The contract a client depends on is that logprobs cover the generated tokens. The repo already encodes that invariant explicitly: test_logprobs_stream asserts assert aggregated_text == output_text i.e. concatenating logprobs.content[].token across the stream reproduces the completion. That assertion is the compatibility test. The new test drops it and substitutes assert seen_logprobs — "at least one entry appeared anywhere." That weakening is the tell: the stricter assertion would fail, because of the empty-deltas drop we traced. A client summing logprobs to score a tool call gets a sum over an unknown subset, with no gap marker. So on the goal as stated: the request is now accepted (good), the shape is right (was already), and the payload is incomplete in exactly the configuration the PR enables. One thing that makes this cheap to fix. send_final_response already populates probs_output with the complete token vector even in stream mode (server-context.cpp:2140-2143) — and to_json_oaicompat_chat_stream never reads it (verified: no reference to probs_output or logprobs anywhere in that function, server-task.cpp:462-526). The full data is being assembled and thrown away. Emitting it on the final chunk, or synthesizing a logprobs-only chunk when deltas is empty, closes the gap without new plumbing. Separate pre-existing compat gap, worth noting but not this PR's job: top_logprobs has no range validation (server-common.cpp:1409 — json_value(body, "top_logprobs", 20) passes straight through). OpenAI rejects values outside 0-20 with a 400; here top_logprobs: 100 is silently accepted. Pre-existing, but if the goal is auditing OpenAI compatibility it belongs on the list. |
…tly dropped when a chat-msg diff is empty Signed-off-by: jamesong <jamesong@amd.com>
Signed-off-by: jamesong <jamesong@amd.com>
Updates according to the review:
|
|
Please add the following tests
Each candidate must include an integer token id. An actual tool call means checking the function name, valid assembled JSON arguments, and finish_reason: "tool_calls". |
…ool calls Signed-off-by: jamesong <jamesong@amd.com>
Requested tests are added. Replaced the old streaming-only The tests are locally verified and all pass. |
|
A couple of things:
Using the PR's Llama-3.2-1B-Instruct Q4_K_M model with logprobs: true and top_logprobs: 5:
Both streaming and non-streaming return correct tool arguments and finish_reason: "tool_calls". The problem is the logprob payload: some generated tokens have no entry, and the completing token's probability is attached to the merged character rather than its individual byte piece. A client therefore cannot reliably score the complete generated tool call. This is a pre-existing issue that also affects the streaming-tool configuration newly enabled by this PR. The current ASCII-only test arguments do not exercise it. The expected behavior is complete, correctly attributed per-token logprobs even when a character spans multiple tokens.
Consequently, missing or malformed candidate bytes would still pass all four tests. The requested valid-schema coverage should include that field. |
Signed-off-by: jamesong <jamesong@amd.com>
Signed-off-by: jamesong <jamesong@amd.com>
Applied two fixes as requested:
|
Overview
This pr targets llama-server's chat functionality: removes the throw when stream + tool + logprobs is requested and add a unit test. Also replaces the stale OAI-incompatible comment.
The chat logprobs response is already OAI compatible, so no change is made to the response format.
The streaming path now mirrors the existing non-streaming behavior — it emits per-token logprobs for all tokens, including tool-call tokens.
Additional information
N/A
Requirements