Repository navigation
refactor(dynamo): move native token response handling to Gym - #3763
jthomson04 wants to merge 6 commits into
Conversation
|
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. |
|
/ok to test 05a5360 |
05a5360 to
245575e
Compare
|
/ok to test 245575e |
jthomson04
left a comment
There was a problem hiding this comment.
Team review of the Dynamo→Gym response-handling move: 6 agents (RL expert, Gym submodule expert, bug finder, design reviewer, test agent, devil's advocate), 18 findings raised, 7 surviving after an adversarial pass.
The refactor itself is a clear win and worth saying so. Gym's replacement isn't just a relocation of _validate_engine_data — it cross-checks the Dynamo bundle against message-level metadata and against vLLM's own response token IDs, neither of which the wrapper ever did. Concrete payoff: adding routed_experts to the native bundle used to mean editing two repos; now it's one entry in _DYNAMO_ENGINE_DATA_FIELD_MAPPING.
The one item I'd genuinely act on before merge is the test-discrimination gap — the suite currently passes with the deleted derivation restored. Everything else is low-severity or documentation.
pre-commit run --all-files is clean. Two items were deliberately not filed here: the missing-engine_data fallback belongs on NeMo-Gym PR 1784, and the "replace the overloaded engine_data flag with a named derive_required_prefix_token_ids boolean" idea belongs in a tracking issue against Gym.
Three findings were dropped by the adversarial pass and are worth naming so they don't get re-raised later: an assert on the hardcoded vllm_model key (the fix would break grpo_nanov3.yaml, and vllm_model_for_training.yaml pins both names anyway), a comment about OmegaConf list replacement (unreachable), and routed_experts not being stripped (router replay is rejected outright on the Dynamo backend).
Generated by Claude Code
245575e to
d3a007e
Compare
|
/ok to test d3a007e |
d3a007e to
34cf872
Compare
|
/ok to test 34cf872 |
Signed-off-by: jthomson04 <[email protected]>
Main renamed dtensor_cfg to automodel_cfg and removed _v2, so the outdated-config check rejected grpo_dynamo_gym_smoke.yaml at startup. Main's setup_nemo_gym_config backend test also built a config without env, which the Dynamo branch now writes to. Signed-off-by: jthomson04 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Gym PR 1784 now stacks on Gym PR 2836. Gym derives required_prefix_token_ids only when derive_prefix_token_ids_from_messages is set, and only from the newest assistant message. - Pin Gym to 2a80b8dfefd1e40a32a6fc55cad19199bb64daf4 and relock. - Set derive_prefix_token_ids_from_messages for the Dynamo backend next to the engine_data request. - Make the token wrapper read only the newest assistant message, so it agrees with Gym about when a prefix must be present. - Name the Gym flag in the missing-prefix error. Signed-off-by: jthomson04 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
grpo_dynamo_gym.sh repeats the Dynamo and vLLM version and backport assertions from grpo_dynamo.sh, so a Dynamo upgrade must update both. Signed-off-by: jthomson04 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
34cf872 to
4ea2d1d
Compare
|
/ok to test 4ea2d1d |
The Dynamo setup built the policy_model overlay with a setdefault chain, so `policy_model: null` (or `nemo_gym: null`) raised AttributeError, and a sharded job without a top-level policy_model got an overlay that no shard claimed, which parse_shard_plan rejects. Build the overlay with _gym_policy_model_overlay, which treats null levels as empty, rejects non-mapping levels, and writes to common_overrides for an unclaimed sharded job so every shard gets it. Signed-off-by: jthomson04 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sibling PRs add their own keys to the same Gym vllm_model overlay, so whole-overlay equality checks would break when they land. Assert the keys this change owns, the preserved user keys, and that other servers stay unchanged. The vLLM-backend test no longer assumes the overlay is untouched; it checks that no Dynamo extra_body was added. Signed-off-by: jthomson04 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
/ok to test 3001240 |
Move the shard-aware lookup of the Gym policy model's vllm_model overlay into _gym_policy_model_overlay, byte-identical to the copy that NVIDIA-NeMo#3856 and NVIDIA-NeMo#3763 add, so the three PRs merge onto one helper. _enable_gym_prefix_derivation now only decides the flag. The helper treats a null overlay level as empty and rejects a non-mapping one with a ValueError. Before, an unsharded policy_model: null (or a null nested level) failed with an AttributeError. Signed-off-by: jthomson04 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The dynamo case asserted that setup_nemo_gym_config leaves env.nemo_gym untouched. The Dynamo setup in NVIDIA-NeMo#3856 and NVIDIA-NeMo#3763 writes its own policy model overlay there, and NVIDIA-NeMo#3763 sets derive_prefix_token_ids_from_messages for Dynamo too, so neither that assertion nor a narrower one on the flag would survive those PRs. Pin only megatron, whose Gym overlay nothing touches. Signed-off-by: jthomson04 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Move the shard-aware lookup of the Gym policy model's vllm_model overlay into _gym_policy_model_overlay, byte-identical to the copy that NVIDIA-NeMo#3856 and NVIDIA-NeMo#3763 add, so the three PRs merge onto one helper. _enable_gym_prefix_derivation now only decides the flag. The helper treats a null overlay level as empty and rejects a non-mapping one with a ValueError. Before, an unsharded policy_model: null (or a null nested level) failed with an AttributeError. Signed-off-by: jthomson04 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
The dynamo case asserted that setup_nemo_gym_config leaves env.nemo_gym untouched. The Dynamo setup in NVIDIA-NeMo#3856 and NVIDIA-NeMo#3763 writes its own policy model overlay there, and NVIDIA-NeMo#3763 sets derive_prefix_token_ids_from_messages for Dynamo too, so neither that assertion nor a narrower one on the flag would survive those PRs. Pin only megatron, whose Gym overlay nothing touches. Signed-off-by: jthomson04 <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
Move native Dynamo response-token interpretation from the NeMo-RL token wrapper into NeMo-Gym.
nvext.engine_dataand setderive_prefix_token_ids_from_messages: true.extra_body,nvextandextra_fieldsvalues are kept, and the request field is added once.extra_bodyornvextis treated as empty. A non-mapping or non-list value raises at setup.nvext.token_datarequest preparation.required_prefix_token_idsinstead of deriving its own.nvext.engine_dataandchoice.logprobs.tests/functional/grpo_dynamo_gym.sh, is added toL1_Functional_Tests_Dynamo.sh.Dependency
This PR depends on NeMo-Gym PR 1784, which stacks on NeMo-Gym PR 2836. The Gym submodule is pinned to PR 1784's exact head,
2a80b8dfefd1e40a32a6fc55cad19199bb64daf4, so CI tests both sides together. That head is based on Gymmainat75bb53e6.Before this PR merges, the submodule must move to the exact Gym
maincommit that contains both PR 2836 and PR 1784.Gym contract
required_prefix_token_idsonly whenderive_prefix_token_ids_from_messagesis true, and this PR sets it forbackend: dynamo. Gym config validation requiresreturn_token_id_information: trueand rejects the flag together withsupply_prefix_token_idsoruse_completions_api.engine_dataand the response lacks it, Gym raises instead of falling back to/tokenize. Message-level token metadata is cross-checked against the engine data, including log probabilities.Compatibility
nvext.token_dataandnvext.extra_fields=["engine_data"].uv.lockchanges because of the Gym bump:>=3.14.4) and 3.14.3 (kept for sglang).Validation
NEMO_RL_PY_EXECUTABLES_SYSTEM=1 .venv/bin/python -m pytest tests/unit/models/generation/test_dynamo_token_wrapper.py tests/unit/models/generation/test_swe1_dynamo_config.py tests/unit/environments/test_nemo_gym.py tests/unit/environments/test_nemo_gym_utils.py -k "dynamo or setup_nemo_gym_config"(33 passed)NEMO_RL_PY_EXECUTABLES_SYSTEM=1 .venv/bin/python -m pytest tests/unit/test_config_validation.py tests/unit/utils/test_outdated_config_checks.py(1161 passed, 350 skipped)NEMO_RL_PY_EXECUTABLES_SYSTEM=1 .venv/bin/python -m pytest tests/unit/environments/test_nemo_gym_token_capture.py tests/unit/environments/test_nemo_gym.py tests/unit/environments/test_nemo_gym_utils.py -m nemo_gym(28 passed).test_nemo_gym_sanityandtest_vllm_http_logprobs_contractneed GPUs and were not run locally.pre-commit run --filespasses on all touched files.The managed Dynamo + Gym round trip is covered by
tests/functional/grpo_dynamo_gym.shinL1_Functional_Tests_Dynamo. It runs in full mode (L1) and is skipped underFAST=1(Lfast).🤖 Generated with Claude Code