Skip to content

feat(vllm_model): opt-in refit of the output budget to the prompt - #5864

Merged
AdamRajfer merged 1 commit into
NVIDIA-NeMo:mainfrom
AdamRajfer:arajfer/vllm-refit-output-budget-to-prompt
Nov 10, 2026
Merged

AdamRajfer merged 1 commit into
NVIDIA-NeMo:mainfrom
AdamRajfer:arajfer/vllm-refit-output-budget-to-prompt

Conversation

@AdamRajfer

Copy link
Copy Markdown
Contributor

What

Adds refit_output_budget_to_prompt to the vLLM model client. It is off by default, so no existing config changes behaviour.

Why

refit_output_budget_to_window only acts when the requested output budget by itself exceeds the context window. It deliberately leaves the other length refusal alone: the budget fits the window, but prompt plus budget do not. That keeps the context_length_exceeded refusal as a cue for harnesses that compact their history.

That choice is wrong for a harness that does not compact. Take a 262144-token window and a benchmark that asks for 131072 output tokens. Once the prompt passes 131072 tokens, the engine refuses every request while half the window is still empty. The call returns an empty length completion, an agent that reads that as the end of its episode stops, and the world state is scored as it stands. In a 2400-rollout run of such a benchmark, 105 rollouts (4.4%) ended this way, with prompts of 126k to 177k tokens. The failure is in the evaluation setup, not in the model's answer, and shrinking the benchmark's output budget would change the benchmark. The client should send what the window leaves.

Behaviour

With refit_output_budget_to_prompt: true, a length refusal that names the context window and whose budget fits that window is retried once with the budget set to window - prompt - 16. The margin, the prompt-length source (the refusal text, else one /tokenize call) and the single-retry rule are the ones refit_output_budget_to_window already uses.

  • The refit is recorded in the same capture fields (requested_max_tokens, applied_max_tokens, output_budget_refit), so the run health facts and inspect count it.
  • A prompt that alone fills the window leaves no output token, so it keeps the context_length_exceeded refusal (or propagated error). So does a refusal that names no window.
  • The retry never raises a budget: if the lowered value would not be below the requested one, the refusal stays.
  • Each flag governs its own case. refit_output_budget_to_window covers a budget above the window, refit_output_budget_to_prompt covers a budget within it. They do not depend on each other.
  • Chat and /v1/completions paths are both covered.

Enable it only for a benchmark whose agent does not compact its history. The docs on the vLLM model page say so.

policy_model:
  responses_api_models:
    vllm_model:
      refit_output_budget_to_prompt: true

Tests

New unit tests in responses_api_models/vllm_model/tests/test_app.py, run on chat and completions:

  • prompt plus budget overflow is refit once and recorded in the capture (two refusal message formats, with and without propagation, with the window setting on and off);
  • a prompt that alone is over the window, or within the margin of it, still fails as a context-length failure (finish reason and propagated);
  • the setting off, which is the default, keeps today's refusal;
  • prompt count from /tokenize when the refusal has none;
  • the budget is never raised, and there is no second refit.

25 of these fail without the change. The whole vllm_model test directory, test_public_api_facades.py, the refit gate-facts tests and the docs link test pass, and ruff check and ruff format are clean.

Not verified

No cluster or real-engine run. The refusal texts in the tests are the formats the existing refit tests already use for vLLM. I have not confirmed the behaviour against a live server on a long-context agent benchmark, or that the affected benchmark then completes those rollouts.

A call whose output budget fits the context window but whose prompt and
budget together overflow it was refused for length on every request once
the prompt passed the window minus the budget (for example a 131072-token
budget in a 262144-token window), and an agent that reads the empty
length reply as the end of its episode stopped there.

refit_output_budget_to_prompt (default off) sends such a call once more
with the budget lowered to the window minus the prompt minus the margin
refit_output_budget_to_window uses, and records it in the same
output_budget_refit capture event. A prompt that alone fills the window
leaves no output token and keeps the context_length_exceeded refusal, as
does a refusal that names no window.

Signed-off-by: Adam Rajfer <[email protected]>
@AdamRajfer AdamRajfer added models infra for different models and inference providers; middleware to standardize to OAI responses evaluation labels Nov 9, 2026
@nemo-automation-bot
nemo-automation-bot Bot requested review from a team November 9, 2026 17:50
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

@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 reviewed the refit logic and generation paths, affected refusal and capture handling, the regression tests, and the configuration documentation. I found no qualifying introduced defects.

This was a static review. I didn't execute tests or validate against a live vLLM engine.

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.

@AdamRajfer
AdamRajfer requested a review from wprazuch November 10, 2026 11:56
@AdamRajfer
AdamRajfer added this pull request to the merge queue Nov 10, 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/42853064093

@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/42855502584

Merged via the queue into NVIDIA-NeMo:main with commit af7e67e Nov 10, 2026
66 checks passed
@AdamRajfer
AdamRajfer deleted the arajfer/vllm-refit-output-budget-to-prompt branch November 10, 2026 16:49
osoblanco added a commit to osoblanco/Gym that referenced this pull request Nov 15, 2026
Merge main at 330c461 into the agentic CritPt branch. Where main has
since added its own handling for something this branch also changed,
the merge keeps main's version:

- responses_api_models/vllm_model is identical to main. The exact
  completion fitting is dropped; main's refit_output_budget_to_prompt
  (NVIDIA-NeMo#5864) covers what the agentic recipe needs.
- Stirrup compaction failure uses main's handling (NVIDIA-NeMo#5822) and its
  max_turns stop reason (NVIDIA-NeMo#5937). In finish_tool mode the grader scores
  an agent_invalid_output response zero as candidate_no_answer.
- Context-overflow recovery becomes the opt-in Stirrup option
  context_overflow_recovery (default false). The runner reports the
  model server's own rejection.
- The grader's execution sessions use ResourcesSessionLocks and
  ResourcesSessionFences (NVIDIA-NeMo#5083); agentic_execution refuses several
  workers (NVIDIA-NeMo#4790).
- A semantic validator failure or timeout stays unscorable with
  score_comparator_uncertain_as_incorrect (NVIDIA-NeMo#5416).
- nemo_gym/ is unchanged.

Two fixes found while validating the merge:

- Since NVIDIA-NeMo#5128 the single_agent_turn environment servers and the agents
  that verify through verify_agent_response send failure_report with
  every /verify request. The grader read it as an unknown task field
  and answered task_invalid for every such rollout; it is now a
  framework field.
- tests/test_runner_remote.py built ExecutionPolicy with four arguments
  the policy does not have and expected a 2 GiB address-space limit it
  never set, so nine of its tests failed; both are corrected.

Also included: fixes from a review of the merged diff (session glossary
wording, main's lost-session body on /code_exec, tighter execution
limits, a stopped session releasing its capacity slot, route tests, and
a local end-to-end grade of a semantic-validator task).

Signed-off-by: Erik Arakelyan <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch was previously deployed

1 inactive deployment
public — 3da57ba2 Deployed Nov 9, 2026 by copy-pr-bot[bot] via release / finalize / notify #11081
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

evaluation models infra for different models and inference providers; middleware to standardize to OAI responses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants