Repository navigation
feat(gym): add multimodal coding task integration for Megatron - #5122
Conversation
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Enable the existing VLM entrypoint for all coding recipes. The text workplace parent did not select a processor. Verified five resolved SingleController configurations and the real row90 processor on a source image: CPU pixels [1,3,480,576], 270 image tokens; no model weights or optimizer updates. Focused behavior regressions: 33 passed. GPU training and recovery remain pending. Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
…atches Signed-off-by: Fuxiao Liu <[email protected]>
…e-super35 Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
…cies Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
yfw
left a comment
There was a problem hiding this comment.
Thank you, Fuxiao, for narrowing this PR.
The PR is now a task integration for the Megatron learner with vLLM generation. It has a row builder, three recipes that compose onto a base recipe, a configuration and runtime check, and a guide. It also has a train-and-resume helper and one TransferQueue fix.
Several parts are in good shape and are worth keeping:
exportwrites each output once. It writes a temporary file, callsfsyncand then publishes the file withos.link(#L342-L343).select_routeis a pure function.- The check script keeps module discovery (
check_runtime) apart from the configuration checks (check_training_config). - The TransferQueue change is small (
transfer_queue.py#L1405-L1418). Its test runs against a real controller, fails with main's code and passes with the fix. - The input models are strict (
ExperimentTask,SourceGymRow).
The PR cannot merge yet. Three problems stop the recipes at setup or at the first rollout, and one problem turns unit CI red:
- (C24) The training split loads the OpenMathInstruct-2 math set instead of the prepared rows.
- (C17) With the guide's output budget on the test base, Gym refuses every multi and mixed episode at seed.
- (C23) Gym main refuses every single-answer row that carries
problem_id. - (C26) A unit test that loads every example recipe fails, because
mm_coding_single.yamlneedsMM_CODING_BASE_CONFIGwhen it loads.
Main has moved since this review. The PR now conflicts with main in one file, pyrefly.toml. Since #5298, main checks every Python file under examples/, so the two lines that this PR adds there (#L58-L59) are no longer needed.
What to change, in order
- Merge main. Then fix (C24), (C17), (C23) and (C26). These four stop the merge.
- (C27) the resume helper fails when it restores the scheduler. (C16) the fixed output limit in each row. (C29) the environment and the overrides of the runtime check. (C28) the Gym revision in the guide.
- (C30) a test that no CI lane runs. (C32) a TransferQueue assert that passes with no placeholder. (C31) a checkpoint at every step. (C25) the guide index and scope. (C19) the task ID length cap.
Follow-up, not asked in this PR
The builder copies about nine values that Gym owns. Examples are benchmark names, task fields, image limits, answer file names, sandbox paths, and the taskset and agent names. Assume that one of them drifts, for example an answer file name. Then every OpenCode episode of that family scores a 0 that is not masked, and nothing raises. If the builder lives next to TaskData in Gym, like Gym's deepcad/prepare_opencode.py, Gym's own tests can check the rows.
Copied values, with the RL line and the Gym line for each
| Value | RL builder | Gym server |
|---|---|---|
| Benchmark names | prepare_mm_coding.py#L38-L44 |
task_data.py#L11 |
| Task ID limit | prepare_mm_coding.py#L45 |
task_data.py#L19 |
Answer file names (ARTIFACTS, LANGUAGES) |
prepare_mm_coding.py#L132-L138 |
remote_renderer.py#L17-L23 |
Renderer path /opt/mmrl/render.py |
prepare_mm_coding.py#L242 |
session_app.py#L117 |
Reference path /workspace/reference<ext> |
prepare_mm_coding.py#L233-L235 |
session_app.py#L126 |
Agent name mm_coding_training_simple_agent |
prepare_mm_coding.py#L269-L272 |
mm_coding_training.yaml#L30 |
Taskset name mm-coding:opencode |
prepare_mm_coding.py#L251 |
mm_coding_multi.yaml#L13-L14 |
A second follow-up: a general check in test_shipped_config that every split with the Gym processor loads NemoGymDataset can catch the C24 problem in any recipe. Main's circle-click recipe has the same problem (vlm_grpo-nemotron-omni-30ba3b-circle-click-2n8g-megatron-tp2ep8.v1.yaml#L127-L130), so that fix can go in the same change.
Context, not asked in this PR
-
The recipes need a Gym revision that contains Gym #6091. RL's Gym pin does not contain it yet (C28,
mm-coding.md#L40). -
Two notes on TransferQueue:
Log noise from the new schema query, and what the fixed bug does on main
- The new schema query (
transfer_queue.py#L1412-L1415) makes the controller log one WARNING ("Partition ... not found" or "Keys [...] were not found") for eachregister_partitioncall that adds fields. SFT v2 Energon makes one partition per batch per DP rank (sft_worker.py#L161-L163), so expect one such line per batch. Both warnings come from NeMo RL's own patchedkv_retrieve_meta(tq_controller_patch.py#L66-L68,#L80-L83), so a fix can live in NeMo RL. - On main, without this PR's fix, a client that re-registers a partition that still holds rows sends float placeholders for integer and boolean columns. One example is the SingleController driver after a SimpleStorage or NIXL restore: it restores (
setup.py#L2469-L2473) and then re-registers (#L2548-L2549). The Mooncake path already skips the re-registration after a restore (single_controller.py#L479-L483). - The controller then raises on the dtype change (
controller.py#L226-L235), logs an ERROR (dtype mismatch) and stops that placeholder's metadata update partway (#L556-L558). The client then clears the placeholder. In a local CPU run, the existing rows read back unchanged.
- The new schema query (
-
Evidence: this review ran on CPU only, at
04ce237d45and with the PR merged onto main95963d732e. The (C26) test also fails with the PR merged onto main5e2711744e. No CI test job has run on this PR yet.
Thank you again.
Generated by Claude Code
Signed-off-by: Fuxiao Liu <[email protected]>
Signed-off-by: Fuxiao Liu <[email protected]>
yfw
left a comment
There was a problem hiding this comment.
Thank you, Fuxiao, for fixing every comment from the last review in one push.
All 13 comments are done as asked at f3eb843. This review adds a "fixed in" reply to each thread.
One of our asks was wrong, though. (C25) asked you to delete grpo.deduplicate_multimodal_data: false. SingleController setup needs that line when the base turns multimodal dedup on, as the test base does. So the recipes now fail at setup with such a base. (C33) asks you to put the line back. It is the only change left in this review. Sorry for the extra round.
The four blockers from the last review are fixed:
-
(C24) All three recipes now load only the prepared rows. The new test
test_composed_recipe_loads_only_prepared_training_and_validation_rowschecks single, multi and mixed. -
(C17) OpenCode's context window is now the full sequence length (
mm_coding_multi.yaml#L24). -
(C23) Rows no longer carry
problem_id. The Gym-marked testtest_training_reader_and_processor_preserve_materialized_rowspasses against RL's Gym pin. -
(C26) A session fixture sets the recipe variables (
conftest.py#L256-L273). All oftests/unit/utils/test_config.pyandtests/unit/test_config_validation.pypasses. -
Evidence: this check ran on CPU only, at
f3eb8430fe. The PR merges with mainda067f1331without conflicts. The runs weretests/unit/utils/test_mm_coding.py(with its Gym-marked test against the pinned Gym),tests/unit/utils/test_config.py,tests/unit/test_config_validation.py, the TransferQueue registration test and the (C33) setup repro. The save-and-resume helper and GPU training were not run.
Signed-off-by: Fuxiao Liu <[email protected]>
|
/ok to test b39eee3 |
Signed-off-by: Fuxiao Liu <[email protected]>
|
/ok to test 44e3427 |
Signed-off-by: Fuxiao Liu <[email protected]>
|
/ok to test 38038af |
|
/ok to test 38038af |
|
/ok to test 38038af |
|
/ok to test 5900329 |
What and why
Visual-coding tasks need their prepared datasets, private grading metadata and supported Gym routes to reach the existing learner unchanged. This adds a model-neutral adapter and single-answer/OpenCode multi/mixed overlays for a Megatron learner with vLLM generation.
NemoGymDatasetexplicitly for both splits and retain source task identities. Disable multimodal deduplication because captured rows already carry their own media, including when the supplied VLM base enables deduplication.MM_CODING_MAX_NEW_TOKENSoptional and retain native CLI overrides. Bind vLLM and OpenCode context limits to the policy sequence limit; cap output to remaining context. Prepared rows carry no fixed output limit.Issues
Addresses the previous adapter, dataset, context-budget, runtime, test-lane and helper review findings, plus C33. C33 restores
grpo.deduplicate_multimodal_data: falsewith its setup-time reason; all three overlays inherit it. A subsequent independent team review found three helper/preflight issues: an inherited one-epoch cap that shortened the four-step helper run, checkpoint-directory overrides that diverged from the guarded/inspected path, and nonpositive output budgets accepted by preflight. The first follow-up fixed the epoch and numeric bounds and rejected direct checkpoint redirection. Independent follow-up then identified a remaining dependent-path case: phase-specific logging overrides could change an interpolated checkpoint root after the common preflight. The latest helper builds both complete phase argument arrays, checks both against the guarded checkpoint root before either training process starts, and reuses those same arrays at launch. Publication of the separate independent review report is pending author approval.Convergence / perf / functionality proof
Validation by revision:
The following helper/checker results are for predecessor
44e3427b16554e7f9aa74d08e64a02dfe23a5cda:The following broader validation is for predecessor
b39eee391e9313f58b8078762b140997d5e34e4b:041060103fc3fc441eb17142b97c91d4133f34d2: all five task families across both routes pass 20 sibling seed-schema checks. Native sampling middleware applies the default 32,768 output limit. Six native OpenCode cases reach the provider-creation boundary, including default 32,768/65,536 budgets and environment/CLI overrides to 8,192/16,384. These checks make no model calls and create no remote sandboxes.Separately, a real mixed-route visual-model smoke at predecessor
f3eb8430fe25f7015fd83a9078ff7c350f867167completed three native optimizer updates across 16 learner ranks: 48 real scored episodes, 24 per route. Eleven overlong OpenCode rows were masked, leaving 37 gradient-bearing rows. Independent checks verified PPO ratios and clipping, sampling-importance metric normalization, RLOO values, reward/image/sample bindings and actual parameter changes. Maximum absolute PPO-ratio formula error was below1e-6.That smoke used 8,192 output tokens, 16,384 total tokens and separately qualified role environments, including a public Gym source override and a genuine fast-hadamard-transform dependency override. It does not qualify the new default 32,768/65,536 budget, the unchanged default lockfile, checkpoint recovery, long-run stability or convergence. Longer contexts require an appropriately sized model runtime and allocation.
Needs upstream changes
The deployment needs the public environment from Gym #6091, including compatible session/token-capture APIs. RL's Gym pin does not contain it yet. The integration guide gives a public Gym commit and source/dependency/cache provisioning steps. This PR does not bump the Gym pin or lockfile; Gym #6451 is not required.
PR commands and CI