Skip to content

fix(vllm_model): apply output-token limits under each endpoint's name - #5462

Merged
zyzhou5 merged 2 commits into
NVIDIA-NeMo:mainfrom
zyzhou5:fix-vllm-token-limit-aliases
Nov 11, 2026
Merged

zyzhou5 merged 2 commits into
NVIDIA-NeMo:mainfrom
zyzhou5:fix-vllm-token-limit-aliases

Conversation

@zyzhou5

@zyzhou5 zyzhou5 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

The output-token limit has a different name on each vLLM endpoint:

  • Chat Completions accepts max_tokens and max_completion_tokens, and reads max_completion_tokens first when both are sent.
  • /v1/completions reads only max_tokens.
  • Responses reads only max_output_tokens.

vllm_model merged limits from the request, extra_body and sampling_overrides without accounting for this. A limit under one name could lose to a limit under another name, or be ignored:

Setup Before After
sampling_overrides: {max_tokens: 100}; the request sends max_completion_tokens: 500 (Chat path) 500: vLLM reads max_completion_tokens 100
sampling_overrides: {max_tokens: 100}, is_responses_native: true; the request sends max_output_tokens: 500 500: the Responses endpoint ignores max_tokens 100
extra_body: {max_completion_tokens: 4096}; a /v1/responses request sends max_output_tokens: 11 (Chat-backed path) 4096: the conversion sends max_tokens: 11 beside the default, and vLLM reads max_completion_tokens 11
extra_body: {max_completion_tokens: 1024}, use_completions_api: true; the request sets no limit 16: /v1/completions ignores max_completion_tokens and uses its own default 1024

After this PR:

  • A sampling_overrides limit replaces the request's limit under every name. It is sent under the name the endpoint reads; on the Chat path the pinned name is kept.
  • A limit in the request body wins over an extra_body limit under either name.
  • On use_completions_api: true, an extra_body max_completion_tokens is sent as max_tokens, unless extra_body also sets max_tokens. A request limit still wins.

These fixes were split out of #4867 at review request (Ananth's comment, Responses-native gap). Yu's review caught a regression in an earlier version of the completions rename, where an extra_body default overwrote a smaller request limit. This version renames the default before the request is merged over it, and a regression test covers that case. The PR is independent of the sampling work that replaces #4867, so it has no linked issue of its own.

Validation

  • pytest responses_api_models/vllm_model/tests/: 906 passed.
  • Eight new tests in TestSamplingOverrides cover the cases above. Six fail on main. The other two pass on main and guard what must not change: a request limit still wins over the default, and the default still applies when the request sets none.
  • pre-commit run --files on the two changed files: passed.

Rollouts

N/A. This changes only how vllm_model builds the request body. The tests check the body passed to the engine client; no model was run.

🤖 Generated with Claude Code

@copy-pr-bot

copy-pr-bot Bot commented Nov 2, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@zyzhou5
zyzhou5 marked this pull request as ready for review November 3, 2026 00:01
@zyzhou5 zyzhou5 added the needs-review PR is ready for code review and waiting on a reviewer label Nov 3, 2026
@zyzhou5

zyzhou5 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 1fc32cc

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHIP

LGTM — no concerns found. I inspected both changed files and traced token-limit normalization, request/default precedence, and endpoint dispatch through the shared converters and outbound client. The regression tests assert concrete outbound limits and preserve request precedence over defaults.

This was a static review; I didn't execute tests.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

@zyzhou5

zyzhou5 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 5156ab2

@zyzhou5
zyzhou5 requested a review from ananthsub November 3, 2026 19:02
@github-actions github-actions Bot added the sla:review-overdue Review response is over the one-business-day SLA label Nov 4, 2026
@zyzhou5
zyzhou5 force-pushed the fix-vllm-token-limit-aliases branch from 5156ab2 to 9cf97e2 Compare November 4, 2026 19:41
@zyzhou5

zyzhou5 commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 9cf97e2

@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 4, 2026 19:45
@svcnvidia-nemo-ci svcnvidia-nemo-ci added bug Something isn't working area:model Model servers, inference providers, and model adapters labels Nov 7, 2026
@zyzhou5

zyzhou5 commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 8cce3bb

zyzhou5 and others added 2 commits November 10, 2026 23:24
The output-token limit has three names: max_tokens and max_completion_tokens on Chat
Completions (vLLM reads max_completion_tokens first), max_tokens on /v1/completions, and
max_output_tokens on Responses. A limit set under one name could lose to a limit under
another name, or be ignored:

- A sampling_overrides pin lost to a request limit under the other Chat name, and a pin
  under a Chat name did nothing on the Responses-native path.
- On the Chat path, an extra_body max_completion_tokens default overrode a smaller request
  limit sent as max_tokens, which is how the Responses-to-Chat conversion sends it.
- On /v1/completions, an extra_body max_completion_tokens default was ignored, so generation
  stopped at vLLM's default of 16 tokens.

A pin now replaces the request's limit under every name and is sent under the name the
endpoint reads. A request limit wins over an extra_body limit under either name, and the
completions path renames a Chat-spelled extra_body default to max_tokens.

Signed-off-by: Zeyu Zhou <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ions path

With both limits in extra_body, the completions path keeps extra_body's own
max_tokens instead of the renamed max_completion_tokens. Nothing tested this:
replacing setdefault with assignment kept every vllm_model test green.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Zeyu Zhou <[email protected]>
@zyzhou5
zyzhou5 force-pushed the fix-vllm-token-limit-aliases branch from 8cce3bb to 7c180b9 Compare November 10, 2026 23:26
@zyzhou5

zyzhou5 commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 7c180b9

@zyzhou5
zyzhou5 added this pull request to the merge queue Nov 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42929222703

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42929372778

@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42929796411

Merged via the queue into NVIDIA-NeMo:main with commit 7748640 Nov 11, 2026
71 of 75 checks passed
@zyzhou5
zyzhou5 deleted the fix-vllm-token-limit-aliases branch November 11, 2026 00:26
zyzhou5 added a commit to zyzhou5/RL that referenced this pull request Nov 11, 2026
… task

NeMo RL wrote policy.generation's temperature, top_p and max_new_tokens into
each Gym row's responses_create_params. Harness agents reject those fields, CLI
harnesses do not send them on every call, and multi-agent tasks have no single
responses_create_params to write into (review item C4). RL's vLLM check also
rejected every call that matched neither the train nor the validation values,
including an untrained judge's call on the policy model.

Rows now carry the values for the rollout's phase beside the unchanged task, as
_ng_model_sampling, and Gym applies them to every model call of the trained
agent. Gym's model server keeps a smaller output limit the call asks for, as
the min() here did.

- The NeMo-Gym actor sets Gym's model_call_sampling block, so a call that
  lost the values fails on policy_model, on servers that _copy it and on any
  the recipe lists, and it refuses sampling_overrides on policy_model.
- The vLLM HTTP server skips its train/val check for calls that Gym marks with
  x-ng-sampling: null, which come from agents NeMo RL does not train.

Bumps the Gym submodule to 77486408c, which has NVIDIA-NeMo/Gym#5462 and
NVIDIA-NeMo/Gym#5463. uv.lock is regenerated with uv 0.13.6, the Dockerfile's
version: the only resolution change is openai 2.44.0 -> 2.45.0, and the rest
is uv's lock format moving to revision 5.

Only calls Gym does not mark null are held to top_k and the policy's sampling.
_spinup imports Gym's model_call_sampling block name, so a stale Gym fails at
spinup; a test checks the names RL copies (row key, header, null) against Gym's.
A spinup test checks that score centering's logprobs/top_logprobs pin on the
required policy_model is accepted by Gym's VLLMModel.

Signed-off-by: Zeyu Zhou <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
zyzhou5 added a commit to zyzhou5/RL that referenced this pull request Nov 12, 2026
… task

NeMo RL wrote policy.generation's temperature, top_p and max_new_tokens into
each Gym row's responses_create_params. Harness agents reject those fields, CLI
harnesses do not send them on every call, and multi-agent tasks have no single
responses_create_params to write into (review item C4). RL's vLLM check also
rejected every call that matched neither the train nor the validation values,
including an untrained judge's call on the policy model.

Rows now carry the values for the rollout's phase beside the unchanged task, as
_ng_model_sampling, and Gym applies them to every model call of the trained
agent. Gym's model server keeps a smaller output limit the call asks for, as
the min() here did.

- The NeMo-Gym actor sets Gym's model_call_sampling block, so a call that
  lost the values fails on policy_model, on servers that _copy it and on any
  the recipe lists, and it refuses sampling_overrides on policy_model.
- The vLLM HTTP server skips its train/val check for calls that Gym marks with
  x-ng-sampling: null, which come from agents NeMo RL does not train.

Bumps the Gym submodule to 77486408c, which has NVIDIA-NeMo/Gym#5462 and
NVIDIA-NeMo/Gym#5463. uv.lock is updated with uv 0.11.28, which keeps main's
lock format: openai 2.44.0 -> 2.45.0 and nemo-gym's own requirements from the
new Gym. uv 0.13.6, the Dockerfile's version, accepts the file unchanged.

Only calls Gym does not mark null are held to top_k and the policy's sampling.
_spinup imports Gym's model_call_sampling block name, so a stale Gym fails at
spinup; a test checks the names RL copies (row key, header, null) against Gym's.
A spinup test checks that score centering's logprobs/top_logprobs pin on the
required policy_model is accepted by Gym's VLLMModel.

Signed-off-by: Zeyu Zhou <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
ADharaUTEXAS123007 added a commit that referenced this pull request Nov 13, 2026
Merge main at fb91374, preserving both secrets-baseline entries. Align the replay budget override with the model-server output-token normalization from #5462 so the intended 8192-token cap is retained. No new features.

Signed-off-by: Arnab Dhara <[email protected]>

This branch had an error being deployed

1 failed deployment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:model Model servers, inference providers, and model adapters bug Something isn't working needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants