feat(data): add PackedTensor preprocessing modes - #4106
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. |
|
Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
931969f to
e347801
Compare
e347801 to
977f0f3
Compare
977f0f3 to
3b6df1a
Compare
terrykong
left a comment
There was a problem hiding this comment.
This PR moves Nemotron Omni pixel_values from pad-to-max-shape to patchify, so each image is cut into vision patches at its native resolution and packed into one sequence instead of being padded up to the largest image in the batch. It adds preprocess_mode / preprocess_kwargs to PackedTensor, a _patchify_segments helper, and a get_preprocess policy function that picks the mode per processor and per field.
The patchify layout is not invented here — it's what Bridge's own Nemotron Omni SFT collate produces (collate_fn.py L342-L346), and the per-frame kernel does the same reshape/permute (nemotron_omni_utils.py L63-L67). Three lanes checked independently that _patchify_segments is bit-for-bit identical to Bridge's _patchify_dynamic_images on mixed-resolution input. _preprocess_spec is also a genuinely good call: it replaces what would otherwise be ten hand-written copies of the same keyword pair across every copy/slice/concat path, and an audit of all of them found none missed.
The one blocking problem is that get_preprocess decides patchify from the processor alone, with no idea which backend will read the result. Megatron takes pre-patchified input by design; the AutoModel/DTensor forward takes 4-D only, so two nightly VLM lanes now hit an unpack error raised inside HuggingFace code — details in the inline comment on get_preprocess.
One note on the description: it says a self-review on the previous PR (#4082) "was addressed in this PR", but the change this PR contributes is identical to #4082's — every added and removed line matches across all 10 files, with only hunk offsets moved by the rebase — so no code changed as a result. If that review happened somewhere off GitHub, could you link it? A pending review would be invisible to us, so I can't tell from here whether one exists.
FYI, for a later PR and not this one: the next PR up the stack calls PackedTensor(..., pad_to_max_shape=True) in nemo_rl/data/energon/multimodal/task_encoders/nemotron_multimodal.py while carrying this PR's __init__, which takes no such keyword and no **kwargs — that'll raise TypeError once this lands.
Reviewed by a team of agents.
Generated by Claude Code
3b6df1a to
5fbf187
Compare
5fbf187 to
2fc6596
Compare
|
Validated end to end: uv run examples/run_vlm_grpo.py --config examples/configs/recipes/vlm/vlm_grpo-nemotron-omni-30ba3b-clevr-1n8g-megatron-tp8ep8.v1.yaml
uv run examples/run_vlm_grpo.py --config examples/configs/recipes/vlm/vlm_grpo-nemotron-omni-30ba3b-clevr-1n8g-automodel-ep8.v2.yaml |
|
/ok to test 2fc6596 |
2fc6596 to
972e9f4
Compare
|
/ok to test 972e9f4 |
972e9f4 to
1cba512
Compare
|
/ok to test 1cba512 |
Signed-off-by: rohitrango <rohit.rango@gmail.com>
Signed-off-by: rohitrango <rohit.rango@gmail.com>
Signed-off-by: rohitrango <rohit.rango@gmail.com>
Signed-off-by: rohitrango <rohit.rango@gmail.com>
1cba512 to
30821cc
Compare
|
/ok to test 30821cc |
What does this PR do ?
Adds configurable PackedTensor preprocessing and patchifies Nemotron Omni pixels before materialization.
Issues
None.
Usage
Before your PR is "Ready for review"
18281365(Ruff lint, import sorting, Ruff format, Pyrefly, and config checks).18281365: 90 passed, 1 skipped (megatron.bridgeunavailable).18281365.Additional Information
rohit/sft_v2_stage2base branch. Retarget this PR tomainafter feat: add Energon-owned SFT sequence packing #4105 merges.Scripts validated
uv run examples/run_vlm_grpo.py --config examples/configs/recipes/vlm/vlm_grpo-nemotron-omni-30ba3b-clevr-2n8g-megatron-tp8ep8.v1-tq_mooncake.yaml logger.wandb.name=grpo-nemotron-with-patches logger.wandb_enabled=true logger.wandb.project=sft-dev cluster.num_nodes=1(brown: baseline, green: with patches)

Previous PR and self-review
Previous PR: #4082. A self-review was performed on the previous PR, and the resulting feedback was addressed in this PR.