Repository navigation
fix(token-capture): preserve explicit vLLM top logprobs requests - #4930
Conversation
|
/ok to test 1051d4d |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
SHIP
LGTM — no reliability concerns.
Reviewed all four changed files and traced request preparation through HTTP forwarding and capture-response cleanup. The vLLM capture handler preserves explicit counts, and final preprocessing normalizes missing/null counts after overrides and capture controls. Legacy token-echo capture and Megatron retain their existing zero-count behavior.
Validation was static only; I did not execute tests or the paired real-vLLM staging/stripping rollout.
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.
There was a problem hiding this comment.
Thanks for the fix! removing the forced top_logprobs=0 from the vLLM capture handler lets the count from sampling_overrides survive, and the single normalization at the end of request preparation covers the null case for both capture and ordinary requests.
What I checked:
- vLLM 0.29.0 (the version Gym pins, spot-checked on 0.30.0): a null count with logprobs on means no logprobs, and an omitted count defaults to 0, so sending an explicit 0 is equivalent. A count above 0 still requires
logprobs=true, which the normalization never violates. - NeMo RL worker (NVIDIA-NeMo/RL#4818): the count K reaches the worker through
sampling_overrides, and the worker requireslogprobs=trueandtop_logprobs == Kon the resolved request. That is exactly what the old overwrite broke. The worker also pops the top-k arrays before serialization and checksmax_logprobs >= Kat setup. - Tests: the new cases pass on the PR head, and the null-count cases fail on the previous code.
i've added some small inline comments added for defense in depth, but these are not blocking
| @@ -339,7 +339,6 @@ def _prepare_admitted_request( | |||
| request_payload[NG_CAPTURE_FIELD] = admission.model_dump(mode="json") | |||
| request_payload.update( | |||
| logprobs=True, | |||
There was a problem hiding this comment.
The new sampler_topk_token_ids and sampler_topk_logprobs message fields are not in the list that _strip_capture_transport_fields removes (TOKEN_FIELDS plus the Megatron transport fields). The companion NeMo RL worker pops them before serialization, so nothing leaks today. Consider adding both names to the strip as defense in depth, since a leaked tensor costs 8*T*K bytes per row on the agent hop.
| @@ -339,7 +339,6 @@ def _prepare_admitted_request( | |||
| request_payload[NG_CAPTURE_FIELD] = admission.model_dump(mode="json") | |||
| request_payload.update( | |||
| logprobs=True, | |||
There was a problem hiding this comment.
With top_logprobs=0 removed here, this handler no longer guarantees a logprob count on its own. The Megatron handler still sets it at line 374, while the vLLM path now relies on the final normalization in vllm_model. That works because only vllm_model builds this handler, but a sentence in the VLLMWorkerCaptureHandler docstring would record the dependency for the next caller.
| else: | ||
| body_dict = self._apply_prefix_supply(body_dict) | ||
|
|
||
| # Normalize after all request overrides and capture controls. vLLM treats |
There was a problem hiding this comment.
Checked against vLLM 0.29.0: a null count with logprobs on resolves to no logprobs (chat_completion/protocol.py:724), and an omitted count defaults to 0, so normalizing to an explicit 0 is correct. One thing to be aware of: 0.29 added logprob_token_ids, and when a request sets it vLLM ignores top_logprobs entirely. Nothing in Gym or NeMo RL sets it today, but it would bypass the worker's top_logprobs == K check if a harness ever forwarded it.
| assert "ng_capture" not in payload | ||
| assert payload["logprobs"] is True | ||
| assert payload["top_logprobs"] == 0 | ||
| if metadata_field is None: |
There was a problem hiding this comment.
metadata_field is None is standing in for "this is the vLLM backend" here. Consider parametrizing on the backend by name so the intent is explicit and the branch does not silently flip if the metadata field changes.
Signed-off-by: Guyue Huang <[email protected]>
Signed-off-by: Guyue Huang <[email protected]>
Signed-off-by: Guyue Huang <[email protected]>
1051d4d to
bbf3cff
Compare
|
/ok to test bbf3cff |
|
/ok to test bbf3cff |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/40244245557 |
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/40244331503 |
Captured vLLM requests currently overwrite an explicit
top_logprobs=Kwith zero after sampling overrides are applied. The capture handler now leaves that field unchanged. Final model request preprocessing normalizes missing/null counts to zero when logprobs are enabled, after request overrides and capture controls, while preserving explicit counts. With logprobs disabled, a missing/null count remains omitted. Ordinary enabled-logprobs requests now send an explicit zero instead of relying on vLLM's default.This lets NeMo-RL request the same K over HTTP that vLLM collects, stage the arrays inside the worker, and strip them before HTTP response serialization. This is a companion dependency of NVIDIA-NeMo/RL#4818. No separate issue is needed for this narrowly scoped request-contract fix. Megatron capture behavior is unchanged. The serving worker must implement staging/stripping for auxiliary top-k arrays; this change does not itself implement that storage contract.
Validation:
extra_body, and sampling overrides with capture on and off, plus existing null-logprob and token-capture regressions.pre-commit run --all-filespasses; the guardwords hook reports its private catalog unavailable and skips its scan.Preserves the worker-staging-before-acknowledgement contract introduced in #2823 and the null-logprob safety behavior from #1612. Based on the Gym revision pinned by the companion RL branch.