Skip to content

server: accept null sampling params - #25538

Merged
ngxson merged 2 commits into
ggml-org:masterfrom
ServeurpersoCom:schema/null-sampling-params
Jul 10, 2026
Merged

ngxson merged 2 commits into
ggml-org:masterfrom
ServeurpersoCom:schema/null-sampling-params

Conversation

@ServeurpersoCom

Copy link
Copy Markdown
Contributor

Overview

Follow-up to #24150: treat null as absent in the sampling param schema so nullable fields (temperature, top_p, ...) fall back to the server default instead of returning a 400, matching the OpenAI spec.

Additional information

Testing:

# server
llama-server -m gemma-4-E2B-it-UD-Q8_K_XL.gguf --host 127.0.0.1 --port 7777 -ngl 99 -c 4096
# request
curl -s localhost:7777/v1/chat/completions -H 'Content-Type: application/json' \
  -d '{"messages":[{"role":"user","content":"Hi"}],"temperature":null,"max_tokens":8}'

Before PR

{"error":{"code":400,"message":"Field 'temperature': [json.exception.type_error.302] type must be number, but is null","type":"invalid_request_error"}}

After PR

{"choices":[{"finish_reason":"length","index":0,"message":{"role":"assistant","content":"","reasoning_content":"Thinking Process:\n\n1.  **Analyze the input:** The"}}], ... "usage":{"completion_tokens":8,"prompt_tokens":17,"total_tokens":25}}</parameter>

Fixes #25515

Requirements

Extend the schema validation to treat a null value as absent, so
clients can send null on nullable params (temperature, top_p, ...)
to request the server default. This matches the OpenAI spec and the
json_value convention used elsewhere.

Add has_field() to skip null in the field eval guards.
@ServeurpersoCom
ServeurpersoCom requested a review from a team as a code owner July 10, 2026 19:07
@ngxson
ngxson merged commit 4f37f51 into ggml-org:master Jul 10, 2026
25 checks passed
satindergrewal pushed a commit to satindergrewal/llama.cpp that referenced this pull request Aug 12, 2026
* server: accept null sampling params

Extend the schema validation to treat a null value as absent, so
clients can send null on nullable params (temperature, top_p, ...)
to request the server default. This matches the OpenAI spec and the
json_value convention used elsewhere.

Add has_field() to skip null in the field eval guards.

* has_field -> has_value​
zbrad pushed a commit to zbrad/llama.cpp that referenced this pull request Sep 10, 2026
* server: accept null sampling params

Extend the schema validation to treat a null value as absent, so
clients can send null on nullable params (temperature, top_p, ...)
to request the server default. This matches the OpenAI spec and the
json_value convention used elsewhere.

Add has_field() to skip null in the field eval guards.

* has_field -> has_value​
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Misc. bug: OpenAI-compatible endpoints reject nullable sampling parameters

2 participants