[data] fix: isolate and unify Nemotron Omni collation - #4776
Conversation
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
|
more refactor coming to unify the hf and energon paths for nemotron omni. i'll absorb this fix to that refactor |
145286e to
65589d4
Compare
da244e6 to
e208a27
Compare
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
e208a27 to
1737416
Compare
|
/claude review |
|
Light review - Nemotron-3 Omni collation/inference refactor Overall this is a solid, well-tested refactor. It removes the configurable dynamic_resolution flag (pinning Nemotron Omni to dynamic_resolution=True), consolidates the Energon and Direct-HF paths onto a single shared nemotron_omni_collate_fn, adds post-vision-merge-aware in-batch packing (with total_tokens plumbed through so MCore resets Mamba/SSM state at packed-row boundaries), and reworks inference next-token selection to skip PP padding. Test coverage is thorough, including an HF-vs-Energon parity test for image+video+audio packing and a randomized reference test for adjust_image_tokens. No blocking correctness issues found. A few observations:
Boundaries respected: no 3rdparty/Megatron-LM/ edits, no new dependencies, copyright headers present on new source files. Suggested test cases
No perf tests impacted (no scripts/performance/configs/ files touched). |
| @@ -104,7 +112,7 @@ def _patchify_frame( | |||
| ) -> torch.Tensor: | |||
| """Resize + normalize a PIL frame and pack into [num_patches, 3*P*P] patches. | |||
|
|
|||
There was a problem hiding this comment.
Minor doc-accuracy: this docstring now says it "Mirrors the shared nemotron_omni_collate_fn patchification exactly," but the two implementations diverge. The shared collator (_patchify_frame in collate_fn.py) resizes via torch.nn.functional.interpolate(mode="bicubic", align_corners=False, antialias=True) on a float32 tensor, while this inference helper resizes with PIL.Image.resize(...) + transforms.ToTensor(). Those produce subtly different pixels (PIL resize is not antialiased bicubic and rounds on uint8), so tensors are close but not identical. Consider softening "exactly" to avoid implying bit-parity. Same wording appears in valor32k_avqa_inference.py.
Signed-off-by: Chen Cui <chcui@nvidia.com>
…llate-batch-isolation Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
Signed-off-by: Chen Cui <chcui@nvidia.com>
Summary
This PR has five goals:
adjust_image_tokensnow adjusts each row and image independently using the correctnum_patches, without flattening the batch or misaligning labels and loss masks. Nemotron Omni also distinguishesnum_framestemporal grouping fromnum_image_tileslanguage-model replacement counts and preserves the tokenizer's real pad ID.pixel_valuesvisual input.Full-data HF/Energon parity
Slurm job
13975195trained on the complete MedPix splits (17,420 train / 3,080 validation) for 2,000 packed optimizer steps per path on the same 8xH100 node and source revision. The experiment matched sample and DP order to isolate data-pipeline behavior.0.99977; the worst validation-loss gap was0.065%. Sequence load-balancing correlation was0.99383, with zero skipped or NaN iterations.Compatibility and scope
--dataset vlm-hf,--dataset vlm-energon, anddataset.path=...remain valid.dynamic_resolutionprovider field is retained for serialized/config compatibility, but Nemotron Omni validates that it isTrue; legacy fixed-tile processors fail explicitly.visual_keyssetting is retained for configuration compatibility and must be("pixel_values",). Previously ignored alternatives now fail explicitly.NemotronOmniTaskSampleconstructors must now provide the shared pre-collationexample; batchvisual_tensorsandtokenscompatibility adapters remain available.