Skip to content

fix(vlm): align training media with rollout placeholders - #4188

Merged
yfw merged 5 commits into
super-v3.5-posttrainingfrom
ehsan/super35-video-media-alignment
Sep 18, 2026
Merged

yfw merged 5 commits into
super-v3.5-posttrainingfrom
ehsan/super35-video-media-alignment

Conversation

@ehosseiniasl

@ehosseiniasl ehosseiniasl commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Stacked PR 1 of 3. #4187 is merged and is now the base of this PR.
The old unsplit PR #4180 and experiment-only PR #4190 are superseded.

Scope of this PR

Rollout/media alignment only:

  • derive image-tile counts from rollout placeholder runs
  • track explicit repaired-media provenance during reattachment
  • never infer a 2-D preprocessing grid from a token count; fail softly and loss-mask an ambiguous sample
  • preserve rollout-matched media across aliased prompt/completion message-log views
  • validate static-video placeholder/tensor alignment with actionable diagnostics
  • add regression coverage for ambiguous geometry and aliased reattachment

The two later Pulkit correctness follow-ups are included: 632e2f2 and 84fe6df. Their behavior activates only on problematic image-tiling paths; normal SA-V video and CapRL rows are unchanged.

Remaining review stack

  1. fix(vlm): align training media with rollout placeholders #4188 — rollout/media alignment (this PR)
  2. fix(video): load frozen vision weights and disable unused MTP #4189 — frozen-vision loading and the optional MTP-off guard
  3. fix(vlm): add joint MOPD video #4199 — joint MOPD media compatibility and optional-MTP Bridge support

Please review and merge in that order. This PR deliberately excludes dataset ingestion, Gym changes, and experiment configuration.

@ehosseiniasl
ehosseiniasl requested review from a team as code owners September 17, 2026 23:46
@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.

@ehosseiniasl
ehosseiniasl force-pushed the ehsan/super35-video-media-alignment branch from 38854a9 to 06249b6 Compare September 17, 2026 23:52
Base automatically changed from ehsan/super35-video-data-support to super-v3.5-posttraining September 18, 2026 07:04
@yfw
yfw requested a review from a team as a code owner September 18, 2026 07:04
@ehosseiniasl
ehosseiniasl force-pushed the ehsan/super35-video-media-alignment branch from 06249b6 to a37eb43 Compare September 18, 2026 16:28
Pulkit Kumar and others added 5 commits September 18, 2026 09:41
…er runs

Async GRPO VLM training crashed mid-run with "Expanded-sequence media
alignment failed: found 32160 valid placeholders for 40800 projected
features". The generation engine sizes image tiles per request (shrinking
them as prompts approach max_model_len); the training-side attach path
re-processed the original images under the processor's static config
budget, so budget-bound rows (e.g. 16 frames at 2400x1080 in a near-32k
prompt) produced more projected vision features than the rollout's
placeholder tokens, and the model forward raised on every rank.

Derive the truth from the rollout itself instead of mirroring the engine's
budget arithmetic:

- multimodal_utils: parse per-image <img><image>*N</img> placeholder runs
  out of the rollout token ids; verify the processor's native output
  against them and, on mismatch, re-process each image pinned to the exact
  run length (budget pin via the image processor's max_model_len clamp,
  with a deterministic exact-grid resize fallback). Raise rather than
  attach misaligned media.
- nemo_gym actor: pass each turn's placeholder runs into the attach; with
  deduplicate_multimodal_data on, keep the omission only when the
  statically-budgeted pre-attached tensors provably match the rollout's
  first-turn runs (predicted via the processor's own grid math), else
  attach rollout-matched tensors actor-side.
- rollouts: the driver-side static reattach never overwrites media the
  actor already attached; video rows are unaffected (their tensors attach
  at datum time and their turns carry no extracted images).

Verified offline against the checkpoint processor (exact-count repair
across a 7-size x 7-budget sweep; the crash row now yields exactly
matching feature counts; non-binding rows byte-match the previous fast
path) and in production: the failing run resumed through the previously
fatal batch and trained to completion with no alignment errors.

Signed-off-by: Pulkit Kumar <[email protected]>
Signed-off-by: ehosseiniasl <[email protected]>
…s relocated

- Replace the key-presence reattach guard with an explicit provenance
  marker (ROLLOUT_MATCHED_MEDIA_KEY): the attach sets it only on turns it
  actually REPAIRED to the rollout's placeholder runs, and the driver-side
  static reattach skips (and consumes) exactly those turns. Unmarked
  values — including placeholder or stale payloads — are replaced as
  before, restoring the documented behavior of
  test_reattach_original_multimodal_payloads_is_media_only_and_turn_aligned,
  and unrepaired turns keep the shared-tensor restore across a prompt
  group's repeated rows.
- Move the Nemotron-specific parity logic (placeholder-run parsing, static
  budget prediction, exact-count re-processing and grid math) out of
  multimodal_utils into the existing Nemotron helper module
  (nemo_rl/environments/nemotron_utils.py). The generic attach keeps only
  the verification contract and delegates the repair via a local import;
  processors without the placeholder grammar degrade gracefully as before.
- Add a regression test: a marked turn keeps its rollout-matched tensors
  and the marker is consumed, while unmarked representations are still
  restored from the static source.

Signed-off-by: Pulkit Kumar <[email protected]>
Signed-off-by: ehosseiniasl <[email protected]>
…ambiguity

A placeholder-run length does not uniquely identify the rollout engine's
preprocessing grid (several grids share one product), so the closest-aspect
fallback could pass count validation while training against different pixels
and spatial feature ordering than generated the rollout. Remove the grid
inference: when re-running the processor under the rollout's own budget does
not reproduce the count, raise RolloutGeometryUnderdetermined.

The Gym actor converts that into a per-sample fail-soft instead of a run
failure: strip all media from the sample (partial media would leave the
model with fewer projected features than placeholder tokens; the per-row
media validity mask then treats its placeholder ids as ordinary tokens),
mark every user turn rollout-matched so the driver-side static reattach does
not restore misaligned tensors, and flag the sample for loss masking.
…log views

NemoGym returns input_message_log as a slice of message_log, so both views
alias the same message dictionaries. Reattachment popped the marker while
processing the first view and then overwrote the rollout-matched media when
it met the same dictionary, markerless, via the second view. Thread one
processed-id set through the reattach call sites (including the prompt log
and completion logs in the rollout manager, which can alias the same turns)
so each unique message is handled exactly once. Regression test places the
exact same marked object in both views.
…attach

Video rows attach statically-preprocessed tensors (one <img><image>*k</img>
run per tubelet) to vLLM-authored rollout tokens. When vLLM's own expansion
disagrees (different per-frame grid or tubelet count), training crashed deep
in Megatron with an unattributable 'Expanded-sequence media alignment failed'.

Compare the placeholder-run structure of the rollout tokens against the
static source tokens before the attach and raise a diagnostic that names the
mismatch: run counts, per-run lengths, first mismatching run, num_frames and
frame size. Plumbed the tokenizer through attach_static_multimodal_payload's
two live call paths (RolloutWorker.run_rollout, run_async_nemo_gym_rollout);
verification is a no-op for image-only turns or when no tokenizer is passed.

Signed-off-by: ehosseiniasl <[email protected]>
@ehosseiniasl
ehosseiniasl force-pushed the ehsan/super35-video-media-alignment branch from a37eb43 to 49669fa Compare September 18, 2026 16:44
@yfw
yfw merged commit f871add into super-v3.5-posttraining Sep 18, 2026
11 of 12 checks passed
@yfw
yfw deleted the ehsan/super35-video-media-alignment branch September 18, 2026 22:18
arendu added a commit that referenced this pull request Oct 7, 2026
Port of the backend-independent parts of super-v3.5-posttraining
2ad27a6 (#4187), 501709c (#4189) and a6951c0 (#4199):

- Register NemotronH_Omni_Reasoning_V3Processor and
  NemotronH_Super_Omni_Reasoning_V3Processor as placeholder-style image
  processors and as Nemotron video processors.
- Mixed Gym manifests: only rows that actually carry video media
  (cached frames or native video parts) take the static-video path; still
  image rows in the same manifest fall through to the regular Gym
  placeholder instead of raising. The placeholder token_ids are int64 so
  mixed batches collate.
- data.image_max_num_tiles: logical tile cap kept on the row for Megatron
  postprocessing and forwarded to vLLM as mm_processor_kwargs.max_num_tiles
  through the existing _inject_vllm_mm_processor_kwargs helper.
- configure_generation_config respects an explicit vllm_cfg.load_format
  (VLM training needs "auto": the frozen vision tower is never refitted).
- _apply_mtp_config: mtp_num_layers=0 also strips mtp_hybrid_override_pattern,
  mtp_use_repeated_layer and the "/M" MTP suffix of hybrid layer patterns so
  HybridProvider.finalize() does not re-add an MTP section.
- resolve_vllm_video_config rejects the legacy vllm_cfg.video_loader key.
- Gym image extraction treats only inline data:image URLs in tool outputs as
  images and skips unresolvable sources instead of crashing postprocessing.

Not ported: f871add (#4188, rollout/train media re-processing at rollout
placeholder budgets) and the NanoVLV2 fixed-tile imgs_sizes guard. Main
addresses rollout/train media alignment through vLLM media capture
(nemo_rl/data/captured_media.py, _capture_request_media) and has
restructured the imgs_sizes backfill, so those changes do not apply as
written; see the PR description.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit 1312127)
arendu added a commit that referenced this pull request Oct 7, 2026
Port of the backend-independent parts of super-v3.5-posttraining
2ad27a6 (#4187), 501709c (#4189) and a6951c0 (#4199):

- Register NemotronH_Omni_Reasoning_V3Processor and
  NemotronH_Super_Omni_Reasoning_V3Processor as placeholder-style image
  processors and as Nemotron video processors.
- Mixed Gym manifests: only rows that actually carry video media
  (cached frames or native video parts) take the static-video path; still
  image rows in the same manifest fall through to the regular Gym
  placeholder instead of raising. The placeholder token_ids are int64 so
  mixed batches collate.
- data.image_max_num_tiles: logical tile cap kept on the row for Megatron
  postprocessing and forwarded to vLLM as mm_processor_kwargs.max_num_tiles
  through the existing _inject_vllm_mm_processor_kwargs helper.
- configure_generation_config respects an explicit vllm_cfg.load_format
  (VLM training needs "auto": the frozen vision tower is never refitted).
- _apply_mtp_config: mtp_num_layers=0 also strips mtp_hybrid_override_pattern,
  mtp_use_repeated_layer and the "/M" MTP suffix of hybrid layer patterns so
  HybridProvider.finalize() does not re-add an MTP section.
- resolve_vllm_video_config rejects the legacy vllm_cfg.video_loader key.
- Gym image extraction treats only inline data:image URLs in tool outputs as
  images and skips unresolvable sources instead of crashing postprocessing.

Not ported: f871add (#4188, rollout/train media re-processing at rollout
placeholder budgets) and the NanoVLV2 fixed-tile imgs_sizes guard. Main
addresses rollout/train media alignment through vLLM media capture
(nemo_rl/data/captured_media.py, _capture_request_media) and has
restructured the imgs_sizes backfill, so those changes do not apply as
written; see the PR description.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit 1312127)
arendu added a commit that referenced this pull request Oct 7, 2026
Port of the backend-independent parts of super-v3.5-posttraining
2ad27a6 (#4187), 501709c (#4189) and a6951c0 (#4199):

- Register NemotronH_Omni_Reasoning_V3Processor and
  NemotronH_Super_Omni_Reasoning_V3Processor as placeholder-style image
  processors and as Nemotron video processors.
- Mixed Gym manifests: only rows that actually carry video media
  (cached frames or native video parts) take the static-video path; still
  image rows in the same manifest fall through to the regular Gym
  placeholder instead of raising. The placeholder token_ids are int64 so
  mixed batches collate.
- data.image_max_num_tiles: logical tile cap kept on the row for Megatron
  postprocessing and forwarded to vLLM as mm_processor_kwargs.max_num_tiles
  through the existing _inject_vllm_mm_processor_kwargs helper.
- configure_generation_config respects an explicit vllm_cfg.load_format
  (VLM training needs "auto": the frozen vision tower is never refitted).
- _apply_mtp_config: mtp_num_layers=0 also strips mtp_hybrid_override_pattern,
  mtp_use_repeated_layer and the "/M" MTP suffix of hybrid layer patterns so
  HybridProvider.finalize() does not re-add an MTP section.
- resolve_vllm_video_config rejects the legacy vllm_cfg.video_loader key.
- Gym image extraction treats only inline data:image URLs in tool outputs as
  images and skips unresolvable sources instead of crashing postprocessing.

Not ported: f871add (#4188, rollout/train media re-processing at rollout
placeholder budgets) and the NanoVLV2 fixed-tile imgs_sizes guard. Main
addresses rollout/train media alignment through vLLM media capture
(nemo_rl/data/captured_media.py, _capture_request_media) and has
restructured the imgs_sizes backfill, so those changes do not apply as
written; see the PR description.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit 1312127)
Signed-off-by: adithyare <[email protected]>
arendu added a commit that referenced this pull request Oct 7, 2026
Port of the backend-independent parts of super-v3.5-posttraining
2ad27a6 (#4187), 501709c (#4189) and a6951c0 (#4199):

- Register NemotronH_Omni_Reasoning_V3Processor and
  NemotronH_Super_Omni_Reasoning_V3Processor as placeholder-style image
  processors and as Nemotron video processors.
- Mixed Gym manifests: only rows that actually carry video media
  (cached frames or native video parts) take the static-video path; still
  image rows in the same manifest fall through to the regular Gym
  placeholder instead of raising. The placeholder token_ids are int64 so
  mixed batches collate.
- data.image_max_num_tiles: logical tile cap kept on the row for Megatron
  postprocessing and forwarded to vLLM as mm_processor_kwargs.max_num_tiles
  through the existing _inject_vllm_mm_processor_kwargs helper.
- configure_generation_config respects an explicit vllm_cfg.load_format
  (VLM training needs "auto": the frozen vision tower is never refitted).
- _apply_mtp_config: mtp_num_layers=0 also strips mtp_hybrid_override_pattern,
  mtp_use_repeated_layer and the "/M" MTP suffix of hybrid layer patterns so
  HybridProvider.finalize() does not re-add an MTP section.
- resolve_vllm_video_config rejects the legacy vllm_cfg.video_loader key.
- Gym image extraction treats only inline data:image URLs in tool outputs as
  images and skips unresolvable sources instead of crashing postprocessing.

Not ported: f871add (#4188, rollout/train media re-processing at rollout
placeholder budgets) and the NanoVLV2 fixed-tile imgs_sizes guard. Main
addresses rollout/train media alignment through vLLM media capture
(nemo_rl/data/captured_media.py, _capture_request_media) and has
restructured the imgs_sizes backfill, so those changes do not apply as
written; see the PR description.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit 1312127)
Signed-off-by: adithyare <[email protected]>
arendu added a commit that referenced this pull request Oct 7, 2026
Port of the backend-independent parts of super-v3.5-posttraining
2ad27a6 (#4187), 501709c (#4189) and a6951c0 (#4199):

- Register NemotronH_Omni_Reasoning_V3Processor and
  NemotronH_Super_Omni_Reasoning_V3Processor as placeholder-style image
  processors and as Nemotron video processors.
- Mixed Gym manifests: only rows that actually carry video media
  (cached frames or native video parts) take the static-video path; still
  image rows in the same manifest fall through to the regular Gym
  placeholder instead of raising. The placeholder token_ids are int64 so
  mixed batches collate.
- data.image_max_num_tiles: logical tile cap kept on the row for Megatron
  postprocessing and forwarded to vLLM as mm_processor_kwargs.max_num_tiles
  through the existing _inject_vllm_mm_processor_kwargs helper.
- configure_generation_config respects an explicit vllm_cfg.load_format
  (VLM training needs "auto": the frozen vision tower is never refitted).
- _apply_mtp_config: mtp_num_layers=0 also strips mtp_hybrid_override_pattern,
  mtp_use_repeated_layer and the "/M" MTP suffix of hybrid layer patterns so
  HybridProvider.finalize() does not re-add an MTP section.
- resolve_vllm_video_config rejects the legacy vllm_cfg.video_loader key.
- Gym image extraction treats only inline data:image URLs in tool outputs as
  images and skips unresolvable sources instead of crashing postprocessing.

Not ported: f871add (#4188, rollout/train media re-processing at rollout
placeholder budgets) and the NanoVLV2 fixed-tile imgs_sizes guard. Main
addresses rollout/train media alignment through vLLM media capture
(nemo_rl/data/captured_media.py, _capture_request_media) and has
restructured the imgs_sizes backfill, so those changes do not apply as
written; see the PR description.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit 1312127)
Signed-off-by: adithyare <[email protected]>
aroshanghias-nvd pushed a commit that referenced this pull request Oct 17, 2026
Port of the backend-independent parts of super-v3.5-posttraining
2ad27a6 (#4187), 501709c (#4189) and a6951c0 (#4199):

- Register NemotronH_Omni_Reasoning_V3Processor and
  NemotronH_Super_Omni_Reasoning_V3Processor as placeholder-style image
  processors and as Nemotron video processors.
- Mixed Gym manifests: only rows that actually carry video media
  (cached frames or native video parts) take the static-video path; still
  image rows in the same manifest fall through to the regular Gym
  placeholder instead of raising. The placeholder token_ids are int64 so
  mixed batches collate.
- data.image_max_num_tiles: logical tile cap kept on the row for Megatron
  postprocessing and forwarded to vLLM as mm_processor_kwargs.max_num_tiles
  through the existing _inject_vllm_mm_processor_kwargs helper.
- configure_generation_config respects an explicit vllm_cfg.load_format
  (VLM training needs "auto": the frozen vision tower is never refitted).
- _apply_mtp_config: mtp_num_layers=0 also strips mtp_hybrid_override_pattern,
  mtp_use_repeated_layer and the "/M" MTP suffix of hybrid layer patterns so
  HybridProvider.finalize() does not re-add an MTP section.
- resolve_vllm_video_config rejects the legacy vllm_cfg.video_loader key.
- Gym image extraction treats only inline data:image URLs in tool outputs as
  images and skips unresolvable sources instead of crashing postprocessing.

Not ported: f871add (#4188, rollout/train media re-processing at rollout
placeholder budgets) and the NanoVLV2 fixed-tile imgs_sizes guard. Main
addresses rollout/train media alignment through vLLM media capture
(nemo_rl/data/captured_media.py, _capture_request_media) and has
restructured the imgs_sizes backfill, so those changes do not apply as
written; see the PR description.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit 1312127)
Signed-off-by: adithyare <[email protected]>
(cherry picked from commit 13d0a9d)
aroshanghias-nvd pushed a commit that referenced this pull request Oct 22, 2026
Port of the backend-independent parts of super-v3.5-posttraining
2ad27a6 (#4187), 501709c (#4189) and a6951c0 (#4199):

- Register NemotronH_Omni_Reasoning_V3Processor and
  NemotronH_Super_Omni_Reasoning_V3Processor as placeholder-style image
  processors and as Nemotron video processors.
- Mixed Gym manifests: only rows that actually carry video media
  (cached frames or native video parts) take the static-video path; still
  image rows in the same manifest fall through to the regular Gym
  placeholder instead of raising. The placeholder token_ids are int64 so
  mixed batches collate.
- data.image_max_num_tiles: logical tile cap kept on the row for Megatron
  postprocessing and forwarded to vLLM as mm_processor_kwargs.max_num_tiles
  through the existing _inject_vllm_mm_processor_kwargs helper.
- configure_generation_config respects an explicit vllm_cfg.load_format
  (VLM training needs "auto": the frozen vision tower is never refitted).
- _apply_mtp_config: mtp_num_layers=0 also strips mtp_hybrid_override_pattern,
  mtp_use_repeated_layer and the "/M" MTP suffix of hybrid layer patterns so
  HybridProvider.finalize() does not re-add an MTP section.
- resolve_vllm_video_config rejects the legacy vllm_cfg.video_loader key.
- Gym image extraction treats only inline data:image URLs in tool outputs as
  images and skips unresolvable sources instead of crashing postprocessing.

Not ported: f871add (#4188, rollout/train media re-processing at rollout
placeholder budgets) and the NanoVLV2 fixed-tile imgs_sizes guard. Main
addresses rollout/train media alignment through vLLM media capture
(nemo_rl/data/captured_media.py, _capture_request_media) and has
restructured the imgs_sizes backfill, so those changes do not apply as
written; see the PR description.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
(cherry picked from commit 1312127)
Signed-off-by: adithyare <[email protected]>
(cherry picked from commit 13d0a9d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants