Skip to content

Commit e1acf92

Browse files
weizhoubluermccorm4dmitry-tokarev-nv
authored
fix: ensure max_thinking_tokens is respected in OpenAI text mode (#9604)
Signed-off-by: weizhoublue <weizhou.lan@daocloud.io> Co-authored-by: Ryan McCormick <rmccormick@nvidia.com> Co-authored-by: Dmitry Tokarev <dtokarev@nvidia.com>
1 parent 338a898 commit e1acf92

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

components/src/dynamo/vllm/handlers.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -875,6 +875,12 @@ def build_sampling_params_openai(
875875
if "min_tokens" in request and request["min_tokens"] is not None:
876876
sampling_params.min_tokens = request["min_tokens"]
877877

878+
nvext_max_thinking_tokens = (request.get("nvext") or {}).get("max_thinking_tokens")
879+
if nvext_max_thinking_tokens is not None and hasattr(
880+
sampling_params, "thinking_token_budget"
881+
):
882+
sampling_params.thinking_token_budget = nvext_max_thinking_tokens
883+
878884
return sampling_params
879885

880886

components/src/dynamo/vllm/tests/test_vllm_unit.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,3 +1215,16 @@ def test_rejects_multimodal_combo(self, mock_vllm_cli):
12151215
ValueError, match="--embedding-worker cannot be combined with multimodal"
12161216
):
12171217
parse_args()
1218+
1219+
1220+
def test_build_sampling_params_openai_maps_max_thinking_tokens():
1221+
from dynamo.vllm.handlers import build_sampling_params_openai
1222+
1223+
request = {
1224+
"model": "test-model",
1225+
"prompt": "Solve: 1+1.",
1226+
"max_tokens": 32,
1227+
"nvext": {"max_thinking_tokens": 1024},
1228+
}
1229+
sp = build_sampling_params_openai(request, default_sampling_params={})
1230+
assert sp.thinking_token_budget == 1024

0 commit comments

Comments
 (0)