Repository navigation
refactor(evals): migrate EvalConfig from TypedDict to BaseModel - #4909
Conversation
Fourth PR in the utils-layer config v1->v2 series (NVIDIA-NeMo#3916, NVIDIA-NeMo#4278, NVIDIA-NeMo#4152). EvalConfig is now a pydantic BaseModel with extra="allow". The five fields carry the exemplar defaults from examples/configs/evals/eval.yaml, and the metric / k_value / num_tests_per_prompt checks that setup() used to assert at runtime now run in a model_validator so a bad eval block fails at config load. The cross-config temperature/top_k check stays in setup(). All eval_config["k"] / .get("k") / master_config.eval["k"] call sites in nemo_rl/evals/eval.py use attribute access. The _run_env_eval_impl test fixture builds a real EvalConfig instead of a dict so missed call sites cannot hide behind a dict's .get. New tests cover the defaults, the three validator rejections, and extra-key passthrough. _PassThroughEnvConfig stays a TypedDict until MathEnvConfig/VLMEnvConfig are migrated with the environment configs. Co-Authored-By: Claude Fable 5.1 <[email protected]> Signed-off-by: Shubhankar Tripathy <[email protected]>
|
/ok to test 40ba2b3 |
yuki-97
left a comment
There was a problem hiding this comment.
@RayenTian could you also help review this?
|
/ok to test 40ba2b3 |
RayenTian
left a comment
There was a problem hiding this comment.
Reviewed the EvalConfig TypedDict→BaseModel migration (4th in the config v1→v2 series). Verified end-to-end: the three former setup() asserts map exactly to the new model_validator (no flipped/off-by-one conditions), the validator actually fires at load via examples/run_eval.py → MasterConfig(**config) (no model_construct bypass), every call site in eval.py was converted to attribute access, no other module references EvalConfig, and the 5 class defaults match eval.yaml exactly. Moving validation to config-load time is a nice improvement. tests/unit/evals/test_eval.py passes 17/17 locally. One minor, non-blocking test suggestion inline.
Generated by Claude Code
Signed-off-by: Shubhankar Tripathy <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Shubhankar Tripathy <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@yuki-97 merged main again (was 16 behind, no conflicts; eval/config tests pass locally). Could you |
yuki-97
left a comment
There was a problem hiding this comment.
Merge blockers — please rebase on main; the PR is 29 commits behind and the "Check if PR branch is up to date" job allows at most 10.
Thanks for migrating EvalConfig to a BaseModel. Moving the three eval checks into its validator means a bad eval block now fails at config load, in MasterConfig(**config) (run_eval.py:105), instead of after the cluster is up.
Scope: the EvalConfig TypedDict-to-BaseModel migration in nemo_rl/evals/eval.py and its tests, at ec5537e
Checked:
- Validator vs removed asserts: the three moved conditions are identical to the removed
setup()asserts, and the cross-section temperature/top_k check rightly stays insetup()(eval.py:126-129) - Consumers: a repo-wide sweep finds no dict-style access to
EvalConfigleft; onlyeval.pyand its test use it - Defaults: all 5 class defaults match
examples/configs/evals/eval.yaml,mmau.yamland the reference config, sotest_config_v2sees no new keys (eval.yaml:2-7) - Coverage: the validator runs on every shipped eval config, through
run_eval.pyandtest_config_validation.py(test_config_validation.py:199-201)
Remaining comments are on:
- Dropping the two
EvalConfigtests that only assert class defaults and pydantic'sextra="allow"handling
nit
- Unused
metric/k_valuelocals and a comment about where the checks moved, insetup() - Declaring
metricandk_valueon the fields withLiteralandPositiveIntinstead of checking them by hand
Generated by Claude Code (#4999 version)
… fields Use Literal and PositiveInt so pydantic rejects bad values; the validator keeps only the cross-field num_tests_per_prompt >= k_value check. Drop the now-unused setup() locals and the tests that only pinned defaults and pydantic's extra="allow" handling. Co-Authored-By: Claude Fable 5.2 <[email protected]> Signed-off-by: Shubhankar Tripathy <[email protected]>
yuki-97
left a comment
There was a problem hiding this comment.
Thanks for resolving the previous round's comments.
Scope: fix commit b71c138, checked against the open threads from the previous review, plus a scan of the changed files for new issues.
Checked:
Literal/PositiveInton the fields reject the same inputs the removed hand-written checks did, and every shipped eval config and test-suite override (eval.num_tests_per_prompt=16) still validates (eval.py:46-61)setup()keeps only the temperature/top_k cross-check, and no dict-styleEvalConfigaccess remains anywhere in the repo- The remaining
test_eval_config_rejects_fewer_tests_than_kexercises the project's own after-validator, so it stays within the testing rule (test_eval.py:294-299)
LGTM — no remaining findings from this re-review.
Generated by Claude Code
|
/ok to test b71c138 |
|
@yuki-97 |
…kind-advantages Brings in 8 commits, including the BaseModel environment configs (#5234), the BaseModel EvalConfig (#4909), the pipelined prefix writer (#5176) and the self-review status check (#5348). No conflicts. The two GRPO configs pick up main's new math verifier_type key next to this PR's masked_reward_policy comments. Main's ledger schema is still 8, so failure_kind stays in schema 9. The Gym pin is the same on both sides (9e2e5d0ad0). Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
What and why
Part of the config v2 series (#3916 ClusterConfig, #4278 LoggerConfig, #5239 CheckpointingConfig).
EvalConfigwas still aTypedDict, and its checks ran as asserts insetup(), after the cluster was already up.EvalConfigis aBaseModel(extra="allow")(nemo_rl/evals/eval.py). The five fields carry the defaults fromexamples/configs/evals/eval.yaml:metric="pass@k",num_tests_per_prompt=1,seed=42,k_value=1,save_path=None.metricisLiteral["pass@k", "cons@k"]andk_valueisPositiveInt. Amodel_validator(mode="after")checksnum_tests_per_prompt >= k_value. A badeval:block now fails atMasterConfig(**config)with apydantic.ValidationErrorinstead of anAssertionErrorinsetup(). Thetemperature > 0 and top_k != 1check spans eval and generation, so it stays insetup().eval_config["k"],eval_config.get("save_path")andmaster_config.eval["k"]ineval.pyuses attribute access. No other module readsEvalConfig(checkednemo_rl/,examples/,research/,docs/)._run_env_eval_implfixture intests/unit/evals/test_eval.pybuilds a realEvalConfiginstead of a dict, andtest_eval_config_rejects_fewer_tests_than_kcovers the validator.No YAML or reference-config changes: every
EvalConfigkey is already inexamples/configs/evals/*.yamlandtests/unit/reference_configs/eval.yaml, somodel_dump()adds no keys. Valid configs behave as before.Not in this PR:
_PassThroughEnvConfigstays aTypedDict; the env configs it nests are migrated in #5234.Issues
None.
Convergence / perf / functionality proof
N/A: no change to eval scoring, generation or dependencies; only where the config is declared and validated moves.
Run locally on CPU:
tests/unit/evals/test_eval.py,tests/unit/test_config_v2.pyandtests/unit/test_config_validation.py(471 passed, 0 failed).ruff0.9.9 (including--select Iandformat) is clean. No GPU eval run was done.Needs upstream changes
None.
PR commands and CI
CI:Lfast: the default for most PRs. Runs a fast test subset.CI:L1: dependency or container changes (pyproject.toml,uv.lock,Dockerfile) or broad core changes. Builds a new image and runs unit and functional tests.CI:docs: docs-only changes. Runs doc tests only./ok to test <full-commit-sha>: start CI for that commit. Post again after each push./review: automated review comments. Addmode=strictfor a stricter review,reset=truefor a fresh full review./resolve-conflict: Autobot mergesmaininto this PR and resolves the conflicts. PRs from forks must allow edits by maintainers./review-pr-team <pr-number>for a team review before you ask for human review.🤖 Generated with Claude Code