Repository navigation
feat(sft): add SFT v2 stage 1 with the Energon multimodal data path #3917
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
db03f96
SFT v2
rohitrango 8522a4a
packer refactor
rohitrango 8ff1ed3
remove dead code from nemotron cookers
rohitrango ebbc40c
refactor(sft): defer Energon packing and dataset prep to stage 2
rohitrango 7a54112
refactor(sft): strip Energon packing from the stage 1 surface
rohitrango d043777
SFTV2Config existed only to parameterize _run_loader_measurement, a b…
rohitrango 6744f40
config
rohitrango 40b0d3b
removed packing api from stage 1
rohitrango 0395b5f
config compaction
rohitrango a5b7806
export
rohitrango a089e7a
fingerprint
rohitrango 65e313b
fix(sft): log policy metrics from the SFTv2 train step
rohitrango d53e016
feat(data-plane): add checkpoint save/load and list_sample_ids to the…
rohitrango a6ac194
chore(deps): move megatron-energon from the energon extra into mcore
rohitrango 23d9700
fix(sft): address SFTv2 review, unblock CI, and rebuild the processor…
rohitrango d2401bb
chore(deps): relock for megatron-energon[av-decode] in the mcore extra
rohitrango 0a45c45
tests cleanup (patch regressions from stage 2)
rohitrango a8adf5c
add copyright notice
rohitrango 8771080
lint/pyrefly
rohitrango 72b7cdb
remove partition generation
rohitrango d88bf5b
repair config and pyproject.toml
rohitrango c3aca71
remove energon plumbing for v1
rohitrango d9b31b7
end by timeout added
rohitrango 4cb00d5
feat(sft_v2): rank checkpoints on train metrics via checkpointing.met…
rohitrango b260bdb
change topology mapper
rohitrango f47bb28
Update nemo_rl/data_plane/adapters/local.py
rohitrango 215141b
added test
rohitrango 2e370fe
Update tests/unit/data/test_energon_sft.py
rohitrango f9f4f8e
Update tests/test_suites/disabled.txt
rohitrango e32af45
Update nemo_rl/data/energon/sft_dataloader.py
rohitrango cc6fdff
Update tests/unit/data/test_energon_multimodal_registry.py
rohitrango 4a4fc0f
Update nemo_rl/data/energon/topology.py
rohitrango 8c224da
removed fingerprinting
rohitrango d2f43d9
Merge branch 'rohit/sft_v2_stage1' of github.com:rohitrango/NeMo-RL i…
rohitrango dbfa18d
update uv.lock
rohitrango 0928773
fix(data-plane): pair local batches with materialize_local and fix lo…
rohitrango fa7748d
Update nemo_rl/data_plane/adapters/local.py
rohitrango 83c7256
Update tests/unit/data/test_energon_sft.py
rohitrango 89dd231
Update tests/test_suites/disabled.txt
rohitrango d23405f
Update nemo_rl/data/energon/sft_dataloader.py
rohitrango b022619
Update tests/unit/data/test_energon_multimodal_registry.py
rohitrango e5bf0b3
Update nemo_rl/data/energon/topology.py
rohitrango be6b6c2
update uv.lock
rohitrango b85d50c
fix(data-plane): pair local batches with materialize_local and fix lo…
rohitrango 9bc865b
Merge remote-tracking branch 'nv/main' into rohit/sft_v2_stage1
rohitrango b8e2b80
Merge branch 'rohit/sft_v2_stage1' of github.com:rohitrango/NeMo-RL i…
rohitrango 426a1f8
corrected energon regression
rohitrango d65008c
chore: restore Megatron-Bridge pointer to main's b11414c7
rohitrango e4e37c2
Update tests/test_suites/disabled.txt
rohitrango 6ca21f2
Update nemo_rl/data/energon/sft_dataloader.py
rohitrango ad3fba3
Update tests/unit/data/test_energon_sft.py
rohitrango 0714271
Merge branch 'main' into rohit/sft_v2_stage1
rohitrango ef3ba97
lint check
rohitrango bb83579
configg_cli fix for _override_ subdicts
rohitrango 7b2ae92
Merge branch 'main' into rohit/sft_v2_stage1
rohitrango 0147b60
ci: drop nemo_rl/modelopt/utils.py from pyrefly project-includes
rohitrango 98c8dc9
fix energon tests and match energon <> HF parity
rohitrango a9b7ea8
Merge branch 'main' into rohit/sft_v2_stage1
rohitrango 0273d5e
support for model_slices_context_parallel_inputs is there now, changing
rohitrango 36374eb
Merge branch 'main' into rohit/sft_v2_stage1
rohitrango 11f9526
Merge branch 'main' of github.com:NVIDIA-NeMo/RL into rohit/sft_v2_st…
rohitrango 3b41b28
Merge branch 'rohit/sft_v2_stage1' of github.com:rohitrango/NeMo-RL i…
rohitrango 41f59d1
fix(sft): unblock multimodal split training
rohitrango 975c576
Merge branch 'main' into rohit/sft_v2_stage1
rohitrango 3d45816
chore(data-plane): remove internal broadcast comments
rohitrango df685d7
test(sft): address Energon SFTv2 review feedback
rohitrango c916435
fix(lint): satisfy pre-commit checks
rohitrango c1ea6e3
Merge branch 'main' into rohit/sft_v2_stage1
rohitrango 6110d9a
test(nemo-gym): normalize optional generation flags
rohitrango bfe3f3c
Merge branch 'main' of github.com:NVIDIA-NeMo/RL into rohit/sft_v2_st…
rohitrango a0d0826
Merge branch 'main' into rohit/sft_v2_stage1
rohitrango b8c8b63
Merge branch 'main' of github.com:NVIDIA-NeMo/RL into rohit/sft_v2_st…
rohitrango File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
...nfigs/recipes/vlm/vlm_sft-nemotron-omni-30ba3b-clevr-1n8g-megatron-tp8ep8-energon.v1.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| defaults: vlm_sft-qwen2.5-vl-3b-instruct-clevr-1n2g-megatrontp1-energon.v1.yaml | ||
| sft: | ||
| max_num_steps: 100 | ||
| policy: | ||
| model_name: /data/models/Nemotron-3-Nano-Omni-30B-A3B-Reasoning-BF16 | ||
| megatron_cfg: | ||
| empty_unused_memory_level: 2 | ||
| activation_checkpointing: true | ||
| bias_activation_fusion: false | ||
| tensor_model_parallel_size: 8 | ||
| expert_model_parallel_size: 8 | ||
| sequence_parallel: true | ||
| freeze_vision_model: true | ||
| freeze_vision_projection: false | ||
| freeze_sound_encoder: true | ||
| freeze_sound_projection: true | ||
| moe_router_dtype: fp32 | ||
| moe_router_load_balancing_type: none | ||
| moe_aux_loss_coeff: 0.0 | ||
| moe_router_enable_expert_bias: true | ||
| defer_fp32_logits: true | ||
| radio_force_cpe_eval_mode: true | ||
| optimizer: | ||
| optimizer_cpu_offload: true | ||
| optimizer_offload_fraction: 1.0 | ||
| distributed_data_parallel_config: | ||
| overlap_param_gather: false | ||
| checkpointing: | ||
| enabled: false | ||
| data: | ||
| add_bos: false | ||
| add_eos: false | ||
| energon: | ||
| model_family: nemotron | ||
| logger: | ||
| wandb_enabled: false | ||
| log_dir: logs/sft-nemotron-omni-30b-clevr-energon-tp4etp4-v2 | ||
| wandb: | ||
| name: sft-nemotron-omni-30b-clevr-energon-tp4etp4-v2 | ||
| tensorboard: | ||
| log_dir: tb_logs-sft-nemotron-omni-30b-clevr-energon-tp4etp4-v2 | ||
| swanlab: | ||
| name: sft-nemotron-omni-30b-clevr-energon-tp4etp4-v2 | ||
| mlflow: | ||
| run_name: sft-nemotron-omni-30b-clevr-energon-tp4etp4-v2 | ||
| cluster: | ||
| gpus_per_node: 8 |
60 changes: 60 additions & 0 deletions
60
...configs/recipes/vlm/vlm_sft-qwen2.5-vl-3b-instruct-clevr-1n2g-megatrontp1-energon.v1.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| defaults: ../../sft_vlm_3B.yaml | ||
|
terrykong marked this conversation as resolved.
Resolved
|
||
| sft: | ||
| max_num_steps: 1000 | ||
| val_period: 0 | ||
| val_batches: 0 | ||
| val_at_start: false | ||
| policy: | ||
| dtensor_cfg: | ||
| enabled: false | ||
| megatron_cfg: | ||
| enabled: true | ||
| apply_rope_fusion: false | ||
| distributed_data_parallel_config: | ||
| overlap_grad_reduce: false | ||
| make_sequence_length_divisible_by: ${policy.megatron_cfg.tensor_model_parallel_size} | ||
| optimizer: null | ||
| checkpointing: | ||
| checkpoint_dir: results/sft_${policy.model_name}_clevr_energon_v2 | ||
| metric_name: null | ||
| data: | ||
| _override_: true | ||
|
rohitrango marked this conversation as resolved.
Resolved
|
||
| backend: energon | ||
| max_input_seq_length: ${policy.max_total_sequence_length} | ||
| add_bos: true | ||
| add_eos: true | ||
| add_generation_prompt: false | ||
| shuffle: true | ||
| num_workers: 0 | ||
| energon: | ||
| model_family: qwen | ||
| num_workers: 8 | ||
| shuffle_buffer_size: 1000 | ||
| processor_adapter: hf_multimodal | ||
| topology_mapper: default | ||
| task_encoder: | ||
| name: generic_sft | ||
| options: {} | ||
| cookers: | ||
| - name: generic_conversation | ||
| options: {} | ||
| train: | ||
| path: /data/nemorl-datasets/clevr | ||
| split: train | ||
| virtual_epoch_length: 4375 | ||
| validation: null | ||
| data_plane: | ||
| enabled: true | ||
| impl: local | ||
| max_partitions: 2 | ||
| logger: | ||
| wandb_enabled: true | ||
| log_dir: logs/sft-qwen2.5-vl-3b-clevr-energon-v2 | ||
| wandb: | ||
| name: sft-qwen2.5-vl-3b-clevr-energon-v2 | ||
| tensorboard: | ||
| log_dir: tb_logs-sft-qwen2.5-vl-3b-clevr-energon-v2 | ||
| swanlab: | ||
| name: sft-qwen2.5-vl-3b-clevr-energon-v2 | ||
| mlflow: | ||
| run_name: sft-qwen2.5-vl-3b-clevr-energon-v2 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| # Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Run single-controller SFT with colocated Energon loaders.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import argparse | ||
| import os | ||
| import pprint | ||
| import warnings | ||
|
|
||
| import ray | ||
| from omegaconf import OmegaConf | ||
|
|
||
| from nemo_rl.algorithms.sft_v2 import ( | ||
| MasterConfig, | ||
| SFTSingleControllerActor, | ||
| setup_sft_v2, | ||
| ) | ||
| from nemo_rl.algorithms.utils import get_tokenizer | ||
| from nemo_rl.distributed.virtual_cluster import init_ray | ||
| from nemo_rl.telemetry.setup import init_telemetry_driver, shutdown_telemetry | ||
| from nemo_rl.utils.config import ( | ||
| load_config, | ||
| parse_hydra_overrides, | ||
| register_omegaconf_resolvers, | ||
| ) | ||
| from nemo_rl.utils.logger import get_next_experiment_dir | ||
|
|
||
|
|
||
| def parse_args() -> tuple[argparse.Namespace, list[str]]: | ||
| """Parse the config path and Hydra-style overrides.""" | ||
| parser = argparse.ArgumentParser(description="Run SFTv2 training") | ||
| parser.add_argument( | ||
| "--config", | ||
| type=str, | ||
| default=os.path.join( | ||
| os.path.dirname(__file__), | ||
| "configs", | ||
| "recipes", | ||
| "vlm", | ||
| "vlm_sft-qwen2.5-vl-3b-instruct-clevr-1n2g-megatrontp1-energon.v1.yaml", | ||
| ), | ||
| ) | ||
| return parser.parse_known_args() | ||
|
|
||
|
|
||
| def main() -> None: | ||
| """Load configuration and start the SFT single controller.""" | ||
| register_omegaconf_resolvers() | ||
| args, overrides = parse_args() | ||
| config = load_config(args.config) | ||
| if overrides: | ||
| config = parse_hydra_overrides(config, overrides) | ||
| resolved = OmegaConf.to_container(config, resolve=True) | ||
| master_config = MasterConfig.model_validate(resolved) | ||
| master_config.logger["log_dir"] = get_next_experiment_dir( | ||
| master_config.logger["log_dir"] | ||
| ) | ||
| pprint.pprint(master_config.model_dump()) | ||
|
|
||
|
rohitrango marked this conversation as resolved.
Resolved
|
||
| # NEMO_RL_OTEL_* env is snapshotted into the Ray runtime_env and inherited | ||
| # by every worker, so this has to run before init_ray(). | ||
| init_telemetry_driver(master_config, algorithm="sft_v2") | ||
|
|
||
| init_ray() | ||
| processor = get_tokenizer(master_config.policy["tokenizer"], get_processor=True) | ||
| actor_args = setup_sft_v2(master_config, processor) | ||
| controller = SFTSingleControllerActor.remote(master_config, actor_args) | ||
| try: | ||
| result = ray.get(controller.run.remote()) | ||
| pprint.pprint(result) | ||
| finally: | ||
| try: | ||
| actor_args.trainer.shutdown() | ||
| except Exception as error: # teardown must preserve the controller failure | ||
| warnings.warn(f"SFTv2 trainer shutdown failed: {error}", stacklevel=2) | ||
| shutdown_telemetry() | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.