Skip to content

fix: restore unexpanded Nemotron prompts for vLLM - #4182

Merged
yfw merged 4 commits into
mainfrom
fix/omni-vllm-image-expansion
Oct 1, 2026
Merged

yfw merged 4 commits into
mainfrom
fix/omni-vllm-image-expansion

Conversation

@aroshanghias-nvd

@aroshanghias-nvd aroshanghias-nvd commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do ?

Restore unexpanded Nemotron image prompts at the native vLLM handoff and reject rollouts generated from a different prompt than the learner's.

#3920 set vllm_content to None for placeholder-style image processors. That sends learner-expanded token IDs alongside raw images to vLLM, which expands them again. A 342-token prompt becomes 599 tokens while the learner retains the original 342.

Restore vllm_content = string_formatted_dialog. Before constructing a training trace, both native vLLM workers require the returned prompt IDs to match the learner's IDs exactly.

Issues

Fixes the native image-prompt regression introduced by #3920.

Usage

No configuration changes. The learner's expanded IDs and Megatron Inference inputs are preserved.

Before your PR is "Ready for review"

  • Followed contributor guidelines and signed off the commit.
  • Added regression coverage for the processor-to-vLLM handoff and prompt mismatch rejection in both workers.
  • Focused validation completed.

Additional Information

Validation: 26 focused CPU tests passed in the pinned vLLM environment (12.14 seconds), covering the MMPR processor/formatter handoff, exact/mismatched/missing prompt IDs, both native workers, and the existing sampled-logprob test. Ruff lint, import ordering, formatting, and diff checks pass. No model weights or new training runs were used.

The PR contains no vLLM source patch, compactor, tokenizer setup changes, or native multi-turn extension. Prompt equality is checked after generation; this does not validate vLLM's internal embedding placement. The separate numerical TMPE investigation is outside this PR.

Native multimodal multi-turn limitation: if an environment continues beyond the first response, later native turns send updated token IDs with the original media. vLLM may re-expand image placeholders, and the new guard rejects the resulting prompt mismatch. This PR does not fix that existing path. The shipped VLM environment terminates after the first response, so increasing max_rollout_turns alone does not exercise it. NeMo-Gym manages its own multi-turn rollout path.

@aroshanghias-nvd aroshanghias-nvd added the CI:L1 Run doctests, unit tests, and functional tests label Sep 17, 2026
@aroshanghias-nvd
aroshanghias-nvd requested review from a team as code owners September 17, 2026 22:33
@copy-pr-bot

copy-pr-bot Bot commented Sep 17, 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.

@aroshanghias-nvd
aroshanghias-nvd marked this pull request as draft September 17, 2026 22:41
@aroshanghias-nvd
aroshanghias-nvd force-pushed the fix/omni-vllm-image-expansion branch from eb2ba4c to e1b5162 Compare September 17, 2026 23:04
@aroshanghias-nvd aroshanghias-nvd changed the title fix: preserve Nemotron image prompts across vLLM rollouts fix: restore unexpanded Nemotron prompts for vLLM Sep 17, 2026
@aroshanghias-nvd
aroshanghias-nvd force-pushed the fix/omni-vllm-image-expansion branch from e1b5162 to 5c33fe5 Compare September 17, 2026 23:16
@aroshanghias-nvd
aroshanghias-nvd marked this pull request as ready for review September 17, 2026 23:17

@aroshanghias-nvd aroshanghias-nvd left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Team review of PR #4182 (5 agents: rl-expert, test-agent, design-reviewer, devil-advocate, leader; the bug-finder agent hung and its checks were re-done by the leader).

The fix is substantive and correct: with a string prompt vLLM 0.25.1 only finds placeholders (_apply_hf_processor_text_mm returns is_update_applied=True), so learner and rollout ids agree by construction, and the new guard turns the silent 342 → 599 mismatch into a hard error. Two inline comments below.

Verified clean (no action): learner/vLLM BOS handling agrees for Nemotron (add_bos_token: false; vLLM add_special_tokens=False), Gemma4 (override) and Qwen (no BOS); RequestOutput.prompt_token_ids is always list[int] | None (outputs.py); the new test needs no @pytest.mark.vllm (base shard of L0_Unit_Tests_Vllm_*.sh, no top-level vllm imports in the workers); stubbed workers provide every attribute the real generate paths read; Megatron inference does not consume vllm_content. Pinned ruff 0.9.9 check/isort/format pass on all 7 files (pyrefly not run locally; utils.py is already in pyrefly.toml).

Context — no action (non-blocking):

  • It would be helpful to include one short Nemotron clevr run on this branch showing no ValueError and the restored 342-token prompt, since the new assert is unconditional and the CPU tests cannot exercise vLLM's real expansion.
  • Known adjacent case: a Gemma-3 VLM (none shipped) would double-BOS on the vLLM string path (vLLM default add_special_tokens=True, no override in gemma3_mm.py) while the learner has a single BOS; the new guard will surface that as a ValueError. Worth a line in the PR description.

Generated by Claude Code

Comment thread nemo_rl/data/processors.py Resolved
@aroshanghias-nvd
aroshanghias-nvd requested a review from a team as a code owner September 18, 2026 20:29
Comment thread nemo_rl/data/processors.py Resolved
Comment thread nemo_rl/models/generation/vllm/utils.py Resolved
@yfw yfw added CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) and removed CI:L1 Run doctests, unit tests, and functional tests labels Oct 1, 2026
@aroshanghias-nvd

Copy link
Copy Markdown
Contributor Author

/ok to test 3347a74

@aroshanghias-nvd

Copy link
Copy Markdown
Contributor Author

/ok to test 741973f

@yfw
yfw merged commit 1a6828e into main Oct 1, 2026
95 checks passed
@yfw
yfw deleted the fix/omni-vllm-image-expansion branch October 1, 2026 23:54
yuki-97 pushed a commit that referenced this pull request Oct 2, 2026
Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Yuki Huang <[email protected]>
yuki-97 added a commit that referenced this pull request Oct 2, 2026
…vLLM (#4412)

Signed-off-by: Ali Roshan Ghias <[email protected]>
Signed-off-by: Yuki Huang <[email protected]>
Co-authored-by: aroshanghias-nvd <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants