Repository navigation
refactor(examples): build MasterConfig with model_validate - #5306
Conversation
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
LGTM. I found no actionable issues across the 19 changed files and directly affected config and test contracts.
One child report was unavailable, so I inspected its assigned entrypoints directly. This was a static source review. I did not run tests or lint/type checks, and I could not independently verify CI.
Generated by Codex
Note: formal approval is not available for this request, so this review is posted as a comment only.
Review generated by codex. This was a full review. Request a full review with /review reset=true.
915c8ab to
350a77f
Compare
741a817 to
a48fc3a
Compare
|
/ok to test 350a77f |
The example entry points constructed their config with MasterConfig(**config), where config is the untyped dict returned by OmegaConf.to_container. Pyrefly reports one missing-argument error per required field at each such call. Use MasterConfig.model_validate(config), as run_sft_v2.py and run_vlm_mpo.py already do, and prune the 114 baseline entries this resolves. Five tests that fake MasterConfig on an example module follow the new call. Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: Robin Nabel <[email protected]>
350a77f to
0e4657c
Compare
6e805bc to
13d40e8
Compare
|
/ok to test 0e4657c |
terrykong
left a comment
There was a problem hiding this comment.
LGTM, thanks for clearing these out of the baseline. For a dict config, MasterConfig.model_validate(config) does the same thing as MasterConfig(**config). Every MasterConfig is a plain pydantic BaseModel: no custom __init__, no before or wrap validators, no aliases, and no validation context. The only validator on a MasterConfig is a mode="after" validator, and it runs the same way for both calls.
The 5 updated test fakes are needed. If run_ppo, run_grpo, run_vlm_grpo, run_grpo_single_controller and run_distillation_nemo_gym go back to MasterConfig(**config), all 5 changed test files fail. The changed tests plus the entry-point and outdated-config suites pass on CPU (119 passed, 1 skipped on purpose). The ordering check in _call_lines already matches MasterConfig.model_validate(...), so it still checks that check_outdated_config runs before the config is built in all 13 scripts. The baseline drops exactly 114 entries and adds none.
Optional, not blocking: research/template_project/single_update.py still uses MasterConfig(**config). Its README tells people to copy that folder to start new projects, so switching it too would stop the old form from spreading. It's fine to leave that for a later PR.
Generated by Claude Code
What does this PR do ?
Builds the top-level config in the example entry points with
MasterConfig.model_validate(config)instead ofMasterConfig(**config), which removes 114 errors from the Pyrefly baseline.Issues
None. Stacked on #5298.
Usage
Before your PR is "Ready for review"
Pre checks:
Additional Information
Why
configis the untyped dict returned byOmegaConf.to_container. Unpacking it into the constructor makes Pyrefly report onemissing-argumenterror per required field, plus abad-unpackingerror, at every call.model_validatetakes the data as a value, so nothing is reported.examples/run_sft_v2.pyandexamples/run_vlm_mpo.pyalready construct their config this way.Changes
examples/, the same one-line change in each.MasterConfigon an example module with a fake now give the fake amodel_validate.pyrefly-baseline.jsonpruned: 1,610 entries become 1,496 (101missing-argument, 13bad-unpacking). None are added.Behaviour
For a dict input the two forms are equivalent. This was checked by running each script's real
main()up to config construction with its default YAML, building the config both ways, and comparingmodel_dump(), extra keys and the fields set:run_grpo_nemo_gym.py, fails validation with the same error both ways, so that predates this PR: its default YAML lackspolicy.megatron_cfg.moe_per_layer_logging.ValidationErrorboth ways.Two inputs that already fail now fail with a different exception type: a top-level non-string key, and a non-mapping config. Both were
TypeErrorand are now pydanticValidationError.Testing
Run in a Linux container with the locked environment, CPU only:
pyrefly checkat 1.4.0 with the baseline: 0 errors before pruning and after.run_grpo_single_controller.main()end to end, so that box is left unchecked.🤖 Generated with Claude Code