Repository navigation
refactor(distributed): migrate ClusterConfig from TypedDict to BaseModel - #3916
Merged
Merged
Conversation
Contributor
Author
|
/ok to test e3980a1 |
lonexreb
force-pushed
the
refactor/config-v2-cluster
branch
from
September 10, 2026 04:37
e3980a1 to
982f295
Compare
Contributor
Author
|
/ok to test 982f295 |
Contributor
|
/ok to test 982f295 |
lonexreb
force-pushed
the
refactor/config-v2-cluster
branch
from
September 16, 2026 03:54
982f295 to
a2aa92d
Compare
Contributor
Author
|
/ok to test a2aa92d |
Contributor
Author
|
Thanks for the review @yuki-97! Fixed both issues:
Also rebased onto today's |
2 of 3 tasks
Contributor
|
/ok to test a2aa92d |
yuki-97
reviewed
Sep 17, 2026
yuki-97
force-pushed
the
refactor/config-v2-cluster
branch
from
September 17, 2026 09:02
06073d8 to
a88005e
Compare
Contributor
|
/ok to test a88005e |
Part of the config v1 -> v2 migration (pattern established in NVIDIA-NeMo#2518; runs alongside NVIDIA-NeMo#3197 for policy configs and NVIDIA-NeMo#3289 for generation configs). First PR in a utils-layer series: ClusterConfig now, CheckpointingConfig and LoggerConfig to follow. - ClusterConfig(TypedDict) -> ClusterConfig(BaseModel, extra="allow"); NotRequired fields become Optional[...] = None. No new non-None defaults, so tests/unit/test_config_v2.py and the reference configs are unaffected. - All call sites move from key access (cluster_config["gpus_per_node"], cluster_config.get("segment_size")) to attribute access across grpo, grpo_sync, ppo, sft, dpo, rm, distillation, xtoken, single-controller setup, utils, and eval. - Test fixtures built via MasterConfig.model_construct bypass pydantic validation and would keep cluster as a plain dict, so their cluster values are wrapped in ClusterConfig.model_validate(...). Fixtures that never touch cluster (empty {} placeholders) are left as-is. - Verified: py_compile on all touched files; standalone pydantic check of the migrated class (required fields enforced, extra keys allowed, optional defaults, model_dump round-trip); ruff format + check clean. Signed-off-by: Shubhankar Tripathy <[email protected]>
Signed-off-by: Yuki Huang <[email protected]>
… reference configs Applies all six findings from the NVIDIA-NeMo#3916 review: - single_controller_utils/setup.py: convert the last getattr(master_config, "cluster", {}).get("segment_size") to attribute access (would have raised AttributeError on every SC run). - reference configs: Optional fields are always emitted by model_dump() where NotRequired keys were omitted, so add master_port_range_low/high: null to dpo/rm/sft.yaml and all three optional keys to eval.yaml. Verified all seven reference cluster blocks now cover exactly the keys ClusterConfig emits. - research/template_project/single_update.py (4 reads) and research/flow_grpo/run_flow_grpo.py (4 reads, found by a residual sweep): subscripts on a validated ClusterConfig -> attributes. - test_grpo/test_ppo/test_mpo/test_grpo_checkpoint_engine: item assignments and subscript asserts on the now-real ClusterConfig -> attribute access. - test_setup/test_ppo_setup: plain dicts assigned over the validated cluster field -> ClusterConfig.model_validate({...}) so missed call sites can no longer hide behind a dict that still answers .get. - test_mpo _cluster_config helper returns ClusterConfig(...) instead of an annotated dict. Signed-off-by: Shubhankar Tripathy <[email protected]>
Signed-off-by: Yuki Huang <[email protected]>
Signed-off-by: Yuki Huang <[email protected]>
yuki-97
force-pushed
the
refactor/config-v2-cluster
branch
from
September 30, 2026 15:32
0610acc to
5dc4b4a
Compare
auto-merge was automatically disabled
September 30, 2026 15:32
Head branch was pushed to by a user without write access
Contributor
|
/ok to test 5dc4b4a |
yuki-97
enabled auto-merge (squash)
September 30, 2026 15:33
yuki-97
approved these changes
Sep 30, 2026
lonexreb
added a commit
to lonexreb/RL
that referenced
this pull request
Oct 1, 2026
Third PR in the utils-layer config v1 -> v2 series (NVIDIA-NeMo#3916 ClusterConfig, NVIDIA-NeMo#4152 checkpointing configs; pattern from NVIDIA-NeMo#2518). Schema: WandbConfig, SwanlabConfig, TensorboardConfig, MLflowConfig, GPUMonitoringConfig, and LoggerConfig move from TypedDict to BaseModel(extra="allow"); NotRequired fields become Optional[...] = None. GpuMetricSnapshot stays TypedDict (internal data container, not YAML-loaded config). Behavior-preserving details: - WandbLogger/SwanlabLogger passed dict(cfg) / **cfg straight into wandb.init / swanlab.init; they now pass model_dump(exclude_none=True) so unset Optional fields do not reach the backends as explicit Nones, while extra= passthrough keys survive. - Logger.__init__ raises a named ValueError when a backend is enabled but its sub-config block is absent (previously a KeyError). - MLflowLogger keeps its cfg-or-env fallbacks, now via attributes. Call sites (~22 across algorithms, sync_rollout_actor, trajectory_collector, SC setup, all example run scripts, flow_grpo) move to attribute access. Reference configs: always-emitted Optional keys are added with their default values at both the logger level and inside the nested wandb/tensorboard/mlflow blocks (deep-verified: each reference logger block now matches LoggerConfig.model_dump exactly). Test fixtures wrap logger dict literals in LoggerConfig.model_construct and move subscripts to attribute access. Signed-off-by: Shubhankar Tripathy <[email protected]>
yuki-97
pushed a commit
to lonexreb/RL
that referenced
this pull request
Oct 2, 2026
Third PR in the utils-layer config v1 -> v2 series (NVIDIA-NeMo#3916 ClusterConfig, Schema: WandbConfig, SwanlabConfig, TensorboardConfig, MLflowConfig, GPUMonitoringConfig, and LoggerConfig move from TypedDict to BaseModel(extra="allow"); NotRequired fields become Optional[...] = None. GpuMetricSnapshot stays TypedDict (internal data container, not YAML-loaded config). Behavior-preserving details: - WandbLogger/SwanlabLogger passed dict(cfg) / **cfg straight into wandb.init / swanlab.init; they now pass model_dump(exclude_none=True) so unset Optional fields do not reach the backends as explicit Nones, while extra= passthrough keys survive. - Logger.__init__ raises a named ValueError when a backend is enabled but its sub-config block is absent (previously a KeyError). - MLflowLogger keeps its cfg-or-env fallbacks, now via attributes. Call sites (~22 across algorithms, sync_rollout_actor, trajectory_collector, SC setup, all example run scripts, flow_grpo) move to attribute access. Reference configs: always-emitted Optional keys are added with their default values at both the logger level and inside the nested wandb/tensorboard/mlflow blocks (deep-verified: each reference logger block now matches LoggerConfig.model_dump exactly). Test fixtures wrap logger dict literals in LoggerConfig.model_construct and move subscripts to attribute access. Signed-off-by: Shubhankar Tripathy <[email protected]>
lonexreb
added a commit
to lonexreb/RL
that referenced
this pull request
Oct 5, 2026
…Config to BaseModel Second PR in the utils-layer config v1 -> v2 series (NVIDIA-NeMo#3916 migrated ClusterConfig; pattern from NVIDIA-NeMo#2518, alongside NVIDIA-NeMo#3197/NVIDIA-NeMo#3289). Schema: - Both classes become BaseModel(extra="allow"); NotRequired fields become Optional[...] = None. - Hidden call-site defaults are centralized on the class exactly as they behave today: save_optimizer=True, save_data_plane=False, save_consolidated=False, model_cache_dir="", model_repo_id="", is_peft=False, is_async=False. - model_save_format stays Optional[str] = None on purpose: the DTensor v1 worker rejects any non-None value, and the automodel layers apply their own "safetensors" fallback (CheckpointManager keeps that resolution, now explicit instead of a .get default). - load_replay_buffer stays tri-state (Optional[bool] = None): the async-GRPO restore path only opts out on an explicit False. Call sites (~85 across all algorithms, SC utils, lm_policy) move from key access / .get() to attribute access. Two deliberate dict boundaries are preserved with model_dump(): - policy_config["pretrained_checkpoint"] hand-off (PolicyConfig is still TypedDict-shaped; Megatron setup consumes dict keys), and - checkpointing_cfg forwarded to save_checkpoint workers (the automodel checkpoint layer consumes .items()/.get()). Tests: fixtures built via model_construct bypass validation, so checkpointing dict literals are wrapped in CheckpointingConfig.model_construct(**{...}) (missing required fields now raise AttributeError where they raised KeyError before); CheckpointManager unit tests validate their full config dicts via model_validate. No exemplar YAML or reference-config changes; class defaults mirror the documented/exemplar values, so tests/unit/test_config_v2.py is unaffected. Verified: py_compile on all touched files; standalone pydantic semantics checks (exemplar blocks round-trip, sft.yaml block keeps model_save_format=None, nested pretrained_checkpoint coerces and dumps back, extra keys preserved, model_construct default-fill); ruff format + check clean. Signed-off-by: Shubhankar Tripathy <[email protected]>
lonexreb
added a commit
to lonexreb/RL
that referenced
this pull request
Oct 5, 2026
…e configs and residual call sites Rebase over main's removal of the automodel-only fields from CheckpointingConfig (moved under policy.dtensor_cfg) — the schema now carries only the algorithm-level fields, and the new _AUTOMODEL_ONLY_CHECKPOINT_FIELDS rejection guard is kept, adapted to read config.model_extra since legacy keys now arrive via extra="allow" rather than the field set. The model_dump() worker boundary in lm_policy/lm_value is dropped along with the checkpointing_cfg parameter main removed. Also applies the two failure classes from the NVIDIA-NeMo#3916 review pre-emptively: - Reference configs: Optional fields are always emitted by model_dump() where NotRequired keys were omitted, so the always- emitted checkpointing keys are added with their default values to all six reference blocks; verified each block now covers exactly the keys the model emits. - Residual dict-style sites: converted subscripts/get on the validated checkpointing field in the example run scripts, single_controller, SC setup, flow_grpo, and test files; wrapped dict-over-field assignments (test_ppo, test_sft_v2) in CheckpointingConfig.model_construct so missed call sites cannot hide behind a dict that still answers .get. Signed-off-by: Shubhankar Tripathy <[email protected]>
lonexreb
added a commit
to lonexreb/RL
that referenced
this pull request
Oct 10, 2026
…Config to BaseModel Second PR in the utils-layer config v1 -> v2 series (NVIDIA-NeMo#3916 migrated ClusterConfig; pattern from NVIDIA-NeMo#2518, alongside NVIDIA-NeMo#3197/NVIDIA-NeMo#3289). Schema: - Both classes become BaseModel(extra="allow"); NotRequired fields become Optional[...] = None. - Hidden call-site defaults are centralized on the class exactly as they behave today: save_optimizer=True, save_data_plane=False, save_consolidated=False, model_cache_dir="", model_repo_id="", is_peft=False, is_async=False. - model_save_format stays Optional[str] = None on purpose: the DTensor v1 worker rejects any non-None value, and the automodel layers apply their own "safetensors" fallback (CheckpointManager keeps that resolution, now explicit instead of a .get default). - load_replay_buffer stays tri-state (Optional[bool] = None): the async-GRPO restore path only opts out on an explicit False. Call sites (~85 across all algorithms, SC utils, lm_policy) move from key access / .get() to attribute access. Two deliberate dict boundaries are preserved with model_dump(): - policy_config["pretrained_checkpoint"] hand-off (PolicyConfig is still TypedDict-shaped; Megatron setup consumes dict keys), and - checkpointing_cfg forwarded to save_checkpoint workers (the automodel checkpoint layer consumes .items()/.get()). Tests: fixtures built via model_construct bypass validation, so checkpointing dict literals are wrapped in CheckpointingConfig.model_construct(**{...}) (missing required fields now raise AttributeError where they raised KeyError before); CheckpointManager unit tests validate their full config dicts via model_validate. No exemplar YAML or reference-config changes; class defaults mirror the documented/exemplar values, so tests/unit/test_config_v2.py is unaffected. Verified: py_compile on all touched files; standalone pydantic semantics checks (exemplar blocks round-trip, sft.yaml block keeps model_save_format=None, nested pretrained_checkpoint coerces and dumps back, extra keys preserved, model_construct default-fill); ruff format + check clean. Signed-off-by: Shubhankar Tripathy <[email protected]>
lonexreb
added a commit
to lonexreb/RL
that referenced
this pull request
Oct 10, 2026
…e configs and residual call sites Rebase over main's removal of the automodel-only fields from CheckpointingConfig (moved under policy.dtensor_cfg) — the schema now carries only the algorithm-level fields, and the new _AUTOMODEL_ONLY_CHECKPOINT_FIELDS rejection guard is kept, adapted to read config.model_extra since legacy keys now arrive via extra="allow" rather than the field set. The model_dump() worker boundary in lm_policy/lm_value is dropped along with the checkpointing_cfg parameter main removed. Also applies the two failure classes from the NVIDIA-NeMo#3916 review pre-emptively: - Reference configs: Optional fields are always emitted by model_dump() where NotRequired keys were omitted, so the always- emitted checkpointing keys are added with their default values to all six reference blocks; verified each block now covers exactly the keys the model emits. - Residual dict-style sites: converted subscripts/get on the validated checkpointing field in the example run scripts, single_controller, SC setup, flow_grpo, and test files; wrapped dict-over-field assignments (test_ppo, test_sft_v2) in CheckpointingConfig.model_construct so missed call sites cannot hide behind a dict that still answers .get. Signed-off-by: Shubhankar Tripathy <[email protected]>
lonexreb
added a commit
to lonexreb/RL
that referenced
this pull request
Oct 18, 2026
…Config to BaseModel Second PR in the utils-layer config v1 -> v2 series (NVIDIA-NeMo#3916 migrated ClusterConfig; pattern from NVIDIA-NeMo#2518, alongside NVIDIA-NeMo#3197/NVIDIA-NeMo#3289). Schema: - Both classes become BaseModel(extra="allow"); NotRequired fields become Optional[...] = None. - Hidden call-site defaults are centralized on the class exactly as they behave today: save_optimizer=True, save_data_plane=False, save_consolidated=False, model_cache_dir="", model_repo_id="", is_peft=False, is_async=False. - model_save_format stays Optional[str] = None on purpose: the DTensor v1 worker rejects any non-None value, and the automodel layers apply their own "safetensors" fallback (CheckpointManager keeps that resolution, now explicit instead of a .get default). - load_replay_buffer stays tri-state (Optional[bool] = None): the async-GRPO restore path only opts out on an explicit False. Call sites (~85 across all algorithms, SC utils, lm_policy) move from key access / .get() to attribute access. Two deliberate dict boundaries are preserved with model_dump(): - policy_config["pretrained_checkpoint"] hand-off (PolicyConfig is still TypedDict-shaped; Megatron setup consumes dict keys), and - checkpointing_cfg forwarded to save_checkpoint workers (the automodel checkpoint layer consumes .items()/.get()). Tests: fixtures built via model_construct bypass validation, so checkpointing dict literals are wrapped in CheckpointingConfig.model_construct(**{...}) (missing required fields now raise AttributeError where they raised KeyError before); CheckpointManager unit tests validate their full config dicts via model_validate. No exemplar YAML or reference-config changes; class defaults mirror the documented/exemplar values, so tests/unit/test_config_v2.py is unaffected. Verified: py_compile on all touched files; standalone pydantic semantics checks (exemplar blocks round-trip, sft.yaml block keeps model_save_format=None, nested pretrained_checkpoint coerces and dumps back, extra keys preserved, model_construct default-fill); ruff format + check clean. Signed-off-by: Shubhankar Tripathy <[email protected]>
lonexreb
added a commit
to lonexreb/RL
that referenced
this pull request
Oct 18, 2026
…e configs and residual call sites Rebase over main's removal of the automodel-only fields from CheckpointingConfig (moved under policy.dtensor_cfg) — the schema now carries only the algorithm-level fields, and the new _AUTOMODEL_ONLY_CHECKPOINT_FIELDS rejection guard is kept, adapted to read config.model_extra since legacy keys now arrive via extra="allow" rather than the field set. The model_dump() worker boundary in lm_policy/lm_value is dropped along with the checkpointing_cfg parameter main removed. Also applies the two failure classes from the NVIDIA-NeMo#3916 review pre-emptively: - Reference configs: Optional fields are always emitted by model_dump() where NotRequired keys were omitted, so the always- emitted checkpointing keys are added with their default values to all six reference blocks; verified each block now covers exactly the keys the model emits. - Residual dict-style sites: converted subscripts/get on the validated checkpointing field in the example run scripts, single_controller, SC setup, flow_grpo, and test files; wrapped dict-over-field assignments (test_ppo, test_sft_v2) in CheckpointingConfig.model_construct so missed call sites cannot hide behind a dict that still answers .get. Signed-off-by: Shubhankar Tripathy <[email protected]>
lonexreb
added a commit
to lonexreb/RL
that referenced
this pull request
Oct 24, 2026
…Config to BaseModel Second PR in the utils-layer config v1 -> v2 series (NVIDIA-NeMo#3916 migrated ClusterConfig; pattern from NVIDIA-NeMo#2518, alongside NVIDIA-NeMo#3197/NVIDIA-NeMo#3289). Schema: - Both classes become BaseModel(extra="allow"); NotRequired fields become Optional[...] = None. - Hidden call-site defaults are centralized on the class exactly as they behave today: save_optimizer=True, save_data_plane=False, save_consolidated=False, model_cache_dir="", model_repo_id="", is_peft=False, is_async=False. - model_save_format stays Optional[str] = None on purpose: the DTensor v1 worker rejects any non-None value, and the automodel layers apply their own "safetensors" fallback (CheckpointManager keeps that resolution, now explicit instead of a .get default). - load_replay_buffer stays tri-state (Optional[bool] = None): the async-GRPO restore path only opts out on an explicit False. Call sites (~85 across all algorithms, SC utils, lm_policy) move from key access / .get() to attribute access. Two deliberate dict boundaries are preserved with model_dump(): - policy_config["pretrained_checkpoint"] hand-off (PolicyConfig is still TypedDict-shaped; Megatron setup consumes dict keys), and - checkpointing_cfg forwarded to save_checkpoint workers (the automodel checkpoint layer consumes .items()/.get()). Tests: fixtures built via model_construct bypass validation, so checkpointing dict literals are wrapped in CheckpointingConfig.model_construct(**{...}) (missing required fields now raise AttributeError where they raised KeyError before); CheckpointManager unit tests validate their full config dicts via model_validate. No exemplar YAML or reference-config changes; class defaults mirror the documented/exemplar values, so tests/unit/test_config_v2.py is unaffected. Verified: py_compile on all touched files; standalone pydantic semantics checks (exemplar blocks round-trip, sft.yaml block keeps model_save_format=None, nested pretrained_checkpoint coerces and dumps back, extra keys preserved, model_construct default-fill); ruff format + check clean. Signed-off-by: Shubhankar Tripathy <[email protected]>
lonexreb
added a commit
to lonexreb/RL
that referenced
this pull request
Oct 24, 2026
…e configs and residual call sites Rebase over main's removal of the automodel-only fields from CheckpointingConfig (moved under policy.dtensor_cfg) — the schema now carries only the algorithm-level fields, and the new _AUTOMODEL_ONLY_CHECKPOINT_FIELDS rejection guard is kept, adapted to read config.model_extra since legacy keys now arrive via extra="allow" rather than the field set. The model_dump() worker boundary in lm_policy/lm_value is dropped along with the checkpointing_cfg parameter main removed. Also applies the two failure classes from the NVIDIA-NeMo#3916 review pre-emptively: - Reference configs: Optional fields are always emitted by model_dump() where NotRequired keys were omitted, so the always- emitted checkpointing keys are added with their default values to all six reference blocks; verified each block now covers exactly the keys the model emits. - Residual dict-style sites: converted subscripts/get on the validated checkpointing field in the example run scripts, single_controller, SC setup, flow_grpo, and test files; wrapped dict-over-field assignments (test_ppo, test_sft_v2) in CheckpointingConfig.model_construct so missed call sites cannot hide behind a dict that still answers .get. Signed-off-by: Shubhankar Tripathy <[email protected]>
1 task
lonexreb
added a commit
to lonexreb/RL
that referenced
this pull request
Oct 28, 2026
…Config to BaseModel Second PR in the utils-layer config v1 -> v2 series (NVIDIA-NeMo#3916 migrated ClusterConfig; pattern from NVIDIA-NeMo#2518, alongside NVIDIA-NeMo#3197/NVIDIA-NeMo#3289). Schema: - Both classes become BaseModel(extra="allow"); NotRequired fields become Optional[...] = None. - Hidden call-site defaults are centralized on the class exactly as they behave today: save_optimizer=True, save_data_plane=False, save_consolidated=False, model_cache_dir="", model_repo_id="", is_peft=False, is_async=False. - model_save_format stays Optional[str] = None on purpose: the DTensor v1 worker rejects any non-None value, and the automodel layers apply their own "safetensors" fallback (CheckpointManager keeps that resolution, now explicit instead of a .get default). - load_replay_buffer stays tri-state (Optional[bool] = None): the async-GRPO restore path only opts out on an explicit False. Call sites (~85 across all algorithms, SC utils, lm_policy) move from key access / .get() to attribute access. Two deliberate dict boundaries are preserved with model_dump(): - policy_config["pretrained_checkpoint"] hand-off (PolicyConfig is still TypedDict-shaped; Megatron setup consumes dict keys), and - checkpointing_cfg forwarded to save_checkpoint workers (the automodel checkpoint layer consumes .items()/.get()). Tests: fixtures built via model_construct bypass validation, so checkpointing dict literals are wrapped in CheckpointingConfig.model_construct(**{...}) (missing required fields now raise AttributeError where they raised KeyError before); CheckpointManager unit tests validate their full config dicts via model_validate. No exemplar YAML or reference-config changes; class defaults mirror the documented/exemplar values, so tests/unit/test_config_v2.py is unaffected. Verified: py_compile on all touched files; standalone pydantic semantics checks (exemplar blocks round-trip, sft.yaml block keeps model_save_format=None, nested pretrained_checkpoint coerces and dumps back, extra keys preserved, model_construct default-fill); ruff format + check clean. Signed-off-by: Shubhankar Tripathy <[email protected]>
lonexreb
added a commit
to lonexreb/RL
that referenced
this pull request
Oct 28, 2026
…e configs and residual call sites Rebase over main's removal of the automodel-only fields from CheckpointingConfig (moved under policy.dtensor_cfg) — the schema now carries only the algorithm-level fields, and the new _AUTOMODEL_ONLY_CHECKPOINT_FIELDS rejection guard is kept, adapted to read config.model_extra since legacy keys now arrive via extra="allow" rather than the field set. The model_dump() worker boundary in lm_policy/lm_value is dropped along with the checkpointing_cfg parameter main removed. Also applies the two failure classes from the NVIDIA-NeMo#3916 review pre-emptively: - Reference configs: Optional fields are always emitted by model_dump() where NotRequired keys were omitted, so the always- emitted checkpointing keys are added with their default values to all six reference blocks; verified each block now covers exactly the keys the model emits. - Residual dict-style sites: converted subscripts/get on the validated checkpointing field in the example run scripts, single_controller, SC setup, flow_grpo, and test files; wrapped dict-over-field assignments (test_ppo, test_sft_v2) in CheckpointingConfig.model_construct so missed call sites cannot hide behind a dict that still answers .get. Signed-off-by: Shubhankar Tripathy <[email protected]>
lonexreb
added a commit
to lonexreb/RL
that referenced
this pull request
Oct 31, 2026
…Config to BaseModel Second PR in the utils-layer config v1 -> v2 series (NVIDIA-NeMo#3916 migrated ClusterConfig; pattern from NVIDIA-NeMo#2518, alongside NVIDIA-NeMo#3197/NVIDIA-NeMo#3289). Schema: - Both classes become BaseModel(extra="allow"); NotRequired fields become Optional[...] = None. - Hidden call-site defaults are centralized on the class exactly as they behave today: save_optimizer=True, save_data_plane=False, save_consolidated=False, model_cache_dir="", model_repo_id="", is_peft=False, is_async=False. - model_save_format stays Optional[str] = None on purpose: the DTensor v1 worker rejects any non-None value, and the automodel layers apply their own "safetensors" fallback (CheckpointManager keeps that resolution, now explicit instead of a .get default). - load_replay_buffer stays tri-state (Optional[bool] = None): the async-GRPO restore path only opts out on an explicit False. Call sites (~85 across all algorithms, SC utils, lm_policy) move from key access / .get() to attribute access. Two deliberate dict boundaries are preserved with model_dump(): - policy_config["pretrained_checkpoint"] hand-off (PolicyConfig is still TypedDict-shaped; Megatron setup consumes dict keys), and - checkpointing_cfg forwarded to save_checkpoint workers (the automodel checkpoint layer consumes .items()/.get()). Tests: fixtures built via model_construct bypass validation, so checkpointing dict literals are wrapped in CheckpointingConfig.model_construct(**{...}) (missing required fields now raise AttributeError where they raised KeyError before); CheckpointManager unit tests validate their full config dicts via model_validate. No exemplar YAML or reference-config changes; class defaults mirror the documented/exemplar values, so tests/unit/test_config_v2.py is unaffected. Verified: py_compile on all touched files; standalone pydantic semantics checks (exemplar blocks round-trip, sft.yaml block keeps model_save_format=None, nested pretrained_checkpoint coerces and dumps back, extra keys preserved, model_construct default-fill); ruff format + check clean. Signed-off-by: Shubhankar Tripathy <[email protected]>
lonexreb
added a commit
to lonexreb/RL
that referenced
this pull request
Oct 31, 2026
…e configs and residual call sites Rebase over main's removal of the automodel-only fields from CheckpointingConfig (moved under policy.dtensor_cfg) — the schema now carries only the algorithm-level fields, and the new _AUTOMODEL_ONLY_CHECKPOINT_FIELDS rejection guard is kept, adapted to read config.model_extra since legacy keys now arrive via extra="allow" rather than the field set. The model_dump() worker boundary in lm_policy/lm_value is dropped along with the checkpointing_cfg parameter main removed. Also applies the two failure classes from the NVIDIA-NeMo#3916 review pre-emptively: - Reference configs: Optional fields are always emitted by model_dump() where NotRequired keys were omitted, so the always- emitted checkpointing keys are added with their default values to all six reference blocks; verified each block now covers exactly the keys the model emits. - Residual dict-style sites: converted subscripts/get on the validated checkpointing field in the example run scripts, single_controller, SC setup, flow_grpo, and test files; wrapped dict-over-field assignments (test_ppo, test_sft_v2) in CheckpointingConfig.model_construct so missed call sites cannot hide behind a dict that still answers .get. Signed-off-by: Shubhankar Tripathy <[email protected]>
This was referenced Nov 14, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do ?
Migrates
ClusterConfig(nemo_rl/distributed/virtual_cluster.py) fromTypedDictto pydanticBaseModel(extra="allow"), following the pattern established in #2518. This is the first PR in a utils-layer migration series (ClusterConfig→CheckpointingConfig/PretrainedCheckpointConfig→LoggerConfig), complementing the in-flight policy-config series (#3197, @NolenLiang) and the generation-config migration (#3289, @shuyixiong) — happy to coordinate scope if either of those plans to absorb these classes.Changes:
NotRequiredfields (master_port_range_low/high,segment_size) becomeOptional[...] = None. No new non-None defaults, sotests/unit/test_config_v2.pyandtests/unit/reference_configs/are unaffected..get("segment_size")→.segment_size(identical None semantics).MasterConfig.model_construct(...)bypass validation and would leaveclusteras a plain dict, so their cluster values are wrapped inClusterConfig.model_validate({...}). Empty{}placeholders that no exercised path touches are left as plain dicts.Issues
Part of the TypedDict → BaseModel config migration (v2) tracked by
tests/unit/test_config_v2.py; related discussion in #1675 / #2102.Usage
No user-facing YAML change. Unknown/legacy keys under
cluster:continue to load (extra="allow"); missinggpus_per_node/num_nodesnow fail at config validation time with a clear pydantic error instead of a KeyError mid-setup.Before your PR is "Ready for review"
model_dumpround-trip)ruff format+ruff checkclean (ruff 0.9.9, repo pin);py_compileon all touched files