-
Notifications
You must be signed in to change notification settings - Fork 550
feat(mopd): add Super Omni multimodal distillation #3430
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
12 commits
Select commit
Hold shift + click to select a range
1f58f5d
fix(mopd): support image-aware async teacher refits
nvilia 940f40c
feat(mopd): add Super Omni image distillation recipe
nvilia 441229e
fix(mopd): target Gym service virtual environments
nvilia 4430840
fix(mopd): add tools/launch config blocks to the mopd test-suite drivers
yfw fba1095
fix(vllm): document and guard reset_encoder_cache_after_weight_update
yfw c23e481
test(opd): cover mixed media and text-only rows within one teacher group
yfw 3b9fe6d
docs(mopd): link the Super Omni MOPD guide from the Nemotron model index
yfw b56ac06
chore(mopd): use the full copyright header and drop dead default_teac…
yfw 684e4bc
build(gym): prefetch circle_click and circle_count venvs for omni images
yfw 870aa0d
Merge branch 'main' into ikarmanov/f9-mopd-super-multimodal
yfw eec4023
ci: add circle-count data prep script to pyrefly project-includes
yfw ec99431
fix(vllm): tolerate partial configs in the encoder-cache transport guard
yfw 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
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,68 @@ | ||
| # Nemotron 3 Super Omni Image MOPD | ||
|
|
||
| This recipe distills a non-colocated Nemotron 3 Super Omni teacher into a | ||
| Super Omni policy over multimodal NeMo Gym trajectories. It extends the | ||
| MTP-disabled Super Omni GRPO recipe with OPD advantages, teacher resources, | ||
| and image-aware teacher log-probability computation. | ||
|
|
||
| ## Data | ||
|
|
||
| Generate deterministic circle-count examples from the pinned NeMo Gym | ||
| submodule: | ||
|
|
||
| ```bash | ||
| uv run python \ | ||
| examples/nemo_gym/nemotron-3-super-omni/prepare_circle_count_mopd_data.py \ | ||
| --out /shared/data/circle_count_train.jsonl \ | ||
| --num-samples 512 | ||
| ``` | ||
|
|
||
| Each row contains one structured `input_image` data URL and an `agent_ref` | ||
| routing it to `circle_count_simple_agent`. The verifier metadata remains | ||
| outside `responses_create_params` and is not included in the model prompt. | ||
|
|
||
| ## Launch | ||
|
|
||
| The production recipe uses ten nodes with eight GPUs per node: | ||
|
|
||
| - one vLLM generation node; | ||
| - one non-colocated teacher node; | ||
| - eight Megatron policy nodes using TP8, EP16, and CP2. | ||
|
|
||
| Set the paths and Slurm values required by the shared Super Omni launcher: | ||
|
|
||
| ```bash | ||
| MODEL_PATH=/shared/models/super-omni-hf \ | ||
| TEACHER_MODEL_PATH=/shared/models/super-omni-teacher-hf \ | ||
| TRAIN_PATH=/shared/data/circle_count_train.jsonl \ | ||
| CONTAINER=/shared/containers/nemo-rl.sqsh \ | ||
| SANDBOX_CONTAINER=/shared/containers/nemo-skills-sandbox.sqsh \ | ||
| PERSISTENT_CACHE=/shared/cache/nemo-rl-super-omni \ | ||
| EXTRA_MOUNTS=/shared:/shared \ | ||
| SLURM_ACCOUNT=<account> \ | ||
| SLURM_PARTITION=<partition> \ | ||
| WANDB_API_KEY=<key> \ | ||
| examples/nemo_gym/nemotron-3-super-omni/run_mopd_circle_count.sh | ||
| ``` | ||
|
|
||
| `TEACHER_MODEL_PATH` is optional. When omitted, the recipe uses | ||
| `MODEL_PATH` for self-distillation. A self-distillation run should have a | ||
| near-zero mean OPD advantage while retaining non-zero token-level spread. | ||
|
|
||
| The recipe disables in-flight weight updates and enables vLLM encoder-cache | ||
| invalidation. This orders each encoder-cache reset after refit and before the | ||
| next image request when the vision tower is trainable. | ||
|
|
||
| ## Three-step smoke | ||
|
|
||
| Use the four-node smoke before a production run: | ||
|
|
||
| ```bash | ||
| CONFIG_PATH=examples/configs/recipes/vlm/mopd-nemotron-super-omni-120ba12b-4n8g-smoke.v1.yaml \ | ||
| EXP_NAME=mopd-super-omni-circle-count-smoke \ | ||
| examples/nemo_gym/nemotron-3-super-omni/run_mopd_circle_count.sh | ||
| ``` | ||
|
|
||
| The smoke runs three optimizer/refit steps. With one-step asynchronous | ||
| trajectory staleness, the third step uses trajectories generated after the | ||
| first weight update. |
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
78 changes: 78 additions & 0 deletions
78
...recipes/vlm/mopd-nemotron-super-omni-120ba12b-10n8g-megatron-tp8ep16cp2-async-gym.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,78 @@ | ||
| # Super Omni image MOPD: 1 generation, 1 teacher, and 8 policy nodes. | ||
| # The default mapping is self-distillation; override it for a stronger teacher. | ||
| defaults: vlm_grpo-nemotron-super-omni-120ba12b-16n8g-megatron-tp8ep16cp2-async-gym.v1.yaml | ||
| checkpointing: | ||
| checkpoint_dir: results/mopd-nemotron-super-omni-circle-count | ||
| keep_top_k: 1 | ||
| cluster: | ||
| num_nodes: 10 | ||
| grpo: | ||
| num_prompts_per_step: 8 | ||
| num_generations_per_prompt: 8 | ||
| max_num_epochs: 5 | ||
| max_num_steps: 200 | ||
| async_grpo: | ||
| in_flight_weight_updates: false | ||
| adv_estimator: | ||
| name: opd | ||
| loss_fn: | ||
| disable_ppo_ratio: true | ||
| truncated_importance_sampling_type: icepop | ||
| truncated_importance_sampling_ratio: 5.0 | ||
| truncated_importance_sampling_ratio_min: 0.2 | ||
| force_on_policy_ratio: false | ||
| use_kl_in_reward: false | ||
| policy: | ||
| train_global_batch_size: 64 | ||
| tokenizer: | ||
| chat_template_kwargs: | ||
| enable_thinking: true | ||
| truncate_history_thinking: false | ||
| generation: | ||
| max_new_tokens: 4096 | ||
| colocated: | ||
| resources: | ||
| num_nodes: 1 | ||
| vllm_cfg: | ||
| gpu_memory_utilization: 0.5 | ||
| enforce_eager: true | ||
| reset_encoder_cache_after_weight_update: true | ||
| data: | ||
| train: | ||
| data_path: /path/to/circle_count_train.jsonl | ||
| validation: | ||
| data_path: /path/to/circle_count_train.jsonl | ||
| env: | ||
| nemo_gym: | ||
| uv_pip_set_python: true | ||
| config_paths: | ||
| - responses_api_models/vllm_model/configs/vllm_model_for_training.yaml | ||
| - resources_servers/circle_count/configs/circle_count.yaml | ||
|
yfw marked this conversation as resolved.
|
||
| policy_model: | ||
| responses_api_models: | ||
| vllm_model: | ||
| max_input_tokens: ${policy.max_total_sequence_length} | ||
| on_policy_distillation: | ||
| enabled: true | ||
| teacher_model_by_agent_name: | ||
| circle_count_simple_agent: ${policy.model_name} | ||
| strict_agent_name_match: true | ||
| deduplicate_shared_teacher_checkpoints: true | ||
| non_colocated_teachers: | ||
| enabled: true | ||
| default_teacher_cfg: | ||
| tensor_model_parallel_size: 8 | ||
| pipeline_model_parallel_size: 1 | ||
| expert_model_parallel_size: 8 | ||
| context_parallel_size: 1 | ||
| num_nodes: 1 | ||
| gpus_per_node: 8 | ||
| precision: bf16 | ||
| micro_batch_size: 1 | ||
| moe_shared_expert_overlap: false | ||
| logger: | ||
| log_dir: logs/mopd-nemotron-super-omni-circle-count | ||
| wandb: | ||
| project: mopd-nemotron-super-omni | ||
| name: mopd-nemotron-super-omni-circle-count | ||
| log_nemo_gym_full_result_tables: true | ||
20 changes: 20 additions & 0 deletions
20
examples/configs/recipes/vlm/mopd-nemotron-super-omni-120ba12b-4n8g-smoke.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,20 @@ | ||
| # Three steps ensure at least one batch was generated after a weight refit. | ||
| defaults: mopd-nemotron-super-omni-120ba12b-10n8g-megatron-tp8ep16cp2-async-gym.v1.yaml | ||
| checkpointing: | ||
| enabled: false | ||
| cluster: | ||
| num_nodes: 4 | ||
| grpo: | ||
| num_prompts_per_step: 2 | ||
| num_generations_per_prompt: 2 | ||
| max_num_epochs: 1 | ||
| max_num_steps: 3 | ||
| policy: | ||
| train_global_batch_size: 4 | ||
| max_total_sequence_length: 4096 | ||
| generation: | ||
| max_new_tokens: 256 | ||
| logger: | ||
| log_dir: logs/mopd-nemotron-super-omni-circle-count-smoke | ||
| wandb: | ||
| name: mopd-nemotron-super-omni-circle-count-smoke |
122 changes: 122 additions & 0 deletions
122
examples/nemo_gym/nemotron-3-super-omni/prepare_circle_count_mopd_data.py
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,122 @@ | ||
| #!/usr/bin/env python3 | ||
| # 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. | ||
|
|
||
| """Generate deterministic NeMo Gym circle-count rows for image MOPD.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import argparse | ||
| import importlib.util | ||
| import json | ||
| from pathlib import Path | ||
| from types import ModuleType | ||
| from typing import Any | ||
|
|
||
| AGENT_REF = { | ||
|
yfw marked this conversation as resolved.
|
||
| "type": "responses_api_agents", | ||
| "name": "circle_count_simple_agent", | ||
| } | ||
|
|
||
|
|
||
| def _load_circle_count_generator() -> ModuleType: | ||
| repo_root = Path(__file__).resolve().parents[3] | ||
| generator_path = ( | ||
| repo_root | ||
| / "3rdparty" | ||
| / "Gym-workspace" | ||
| / "Gym" | ||
| / "resources_servers" | ||
| / "circle_count" | ||
| / "generate_data.py" | ||
| ) | ||
| spec = importlib.util.spec_from_file_location( | ||
| "_nemo_gym_circle_count_generate_data", generator_path | ||
| ) | ||
| if spec is None or spec.loader is None: | ||
| raise RuntimeError(f"Could not load circle-count generator: {generator_path}") | ||
| module = importlib.util.module_from_spec(spec) | ||
| spec.loader.exec_module(module) | ||
| return module | ||
|
|
||
|
|
||
| def _validate_example(example: dict[str, Any]) -> None: | ||
| if example.get("agent_ref") != AGENT_REF: | ||
| raise ValueError("circle-count MOPD row has an invalid agent_ref") | ||
|
|
||
| responses_create_params = example.get("responses_create_params") | ||
| if not isinstance(responses_create_params, dict): | ||
| raise ValueError("row is missing responses_create_params") | ||
|
|
||
| image_urls: list[str] = [] | ||
| for message in responses_create_params.get("input", []): | ||
| content = message.get("content", []) if isinstance(message, dict) else [] | ||
| if not isinstance(content, list): | ||
| continue | ||
| for item in content: | ||
| if isinstance(item, dict) and item.get("type") == "input_image": | ||
| image_urls.append(str(item.get("image_url", ""))) | ||
|
|
||
| if len(image_urls) != 1 or not image_urls[0].startswith("data:image/"): | ||
| raise ValueError( | ||
| "each circle-count MOPD row must contain exactly one data-URL input_image" | ||
| ) | ||
|
|
||
| request_text = json.dumps(responses_create_params) | ||
| if '"circles"' in request_text or '"target_color"' in request_text: | ||
| raise ValueError("answer metadata leaked into responses_create_params") | ||
|
|
||
|
|
||
| def main() -> None: | ||
| parser = argparse.ArgumentParser( | ||
| description="Generate image MOPD data routed to circle_count_simple_agent." | ||
| ) | ||
| parser.add_argument("--out", type=Path, required=True) | ||
| parser.add_argument("--num-samples", type=int, default=512) | ||
| parser.add_argument("--seed-offset", type=int, default=0) | ||
| parser.add_argument("--image-size", type=int, default=1000) | ||
| parser.add_argument("--radius-min", type=int, default=30) | ||
| parser.add_argument("--radius-max", type=int, default=60) | ||
| parser.add_argument("--num-circles-min", type=int, default=5) | ||
| parser.add_argument("--num-circles-max", type=int, default=20) | ||
| parser.add_argument("--num-colors-min", type=int, default=2) | ||
| parser.add_argument("--num-colors-max", type=int, default=4) | ||
| args = parser.parse_args() | ||
|
|
||
| if args.num_samples <= 0: | ||
| raise ValueError("--num-samples must be positive") | ||
|
|
||
| generator = _load_circle_count_generator() | ||
| args.out.parent.mkdir(parents=True, exist_ok=True) | ||
| with args.out.open("w") as output: | ||
| for index in range(args.num_samples): | ||
| example = generator.make_example( | ||
| args.seed_offset + index, | ||
| img_size_range=(args.image_size, args.image_size), | ||
| circle_radius_range=(args.radius_min, args.radius_max), | ||
| num_circles_range=( | ||
| args.num_circles_min, | ||
| args.num_circles_max, | ||
| ), | ||
| num_colors_range=(args.num_colors_min, args.num_colors_max), | ||
| ) | ||
| example["agent_ref"] = dict(AGENT_REF) | ||
| _validate_example(example) | ||
| output.write(json.dumps(example) + "\n") | ||
|
|
||
| print(f"Generated {args.num_samples} image-MOPD rows: {args.out}") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
22 changes: 22 additions & 0 deletions
22
examples/nemo_gym/nemotron-3-super-omni/run_mopd_circle_count.sh
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,22 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # Thin MOPD wrapper around the shared Super Omni launcher. The launcher | ||
| # validates MODEL_PATH, TRAIN_PATH, CONTAINER, SANDBOX_CONTAINER, | ||
| # PERSISTENT_CACHE, SLURM_ACCOUNT, and WANDB_API_KEY (for online logging). | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
|
|
||
| export EXP_NAME="${EXP_NAME:-mopd-super-omni-circle-count}" | ||
| export CONFIG_PATH="${CONFIG_PATH:-examples/configs/recipes/vlm/mopd-nemotron-super-omni-120ba12b-10n8g-megatron-tp8ep16cp2-async-gym.v1.yaml}" | ||
| export WANDB_PROJ="${WANDB_PROJ:-mopd-nemotron-super-omni}" | ||
|
|
||
| if [[ -n "${TEACHER_MODEL_PATH:-}" ]]; then | ||
| while [[ "${TEACHER_MODEL_PATH}" == */ && "${TEACHER_MODEL_PATH}" != "/" ]]; do | ||
| TEACHER_MODEL_PATH="${TEACHER_MODEL_PATH%/}" | ||
| done | ||
| teacher_override="on_policy_distillation.teacher_model_by_agent_name.circle_count_simple_agent=${TEACHER_MODEL_PATH}" | ||
| export EXTRA_HYDRA_ARGS="${EXTRA_HYDRA_ARGS:+${EXTRA_HYDRA_ARGS} }${teacher_override}" | ||
| fi | ||
|
|
||
| exec "${SCRIPT_DIR}/super_omni_launch.sh" |
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.