refactor(rm): migrate RMConfig, RMSaveState, RMValMetrics to BaseModel#2526
Open
NolenLiang wants to merge 5 commits into
Open
refactor(rm): migrate RMConfig, RMSaveState, RMValMetrics to BaseModel#2526NolenLiang wants to merge 5 commits into
NolenLiang wants to merge 5 commits into
Conversation
Contributor
Author
|
/ok to test 7cf7f71 |
Contributor
Author
|
/ok to test 2b901ea |
Convert 3 TypedDict classes to pydantic BaseModel with extra="allow": - RMConfig: 9 required fields - RMSaveState: 5 fields with defaults - RMValMetrics: 9 required fields, validation metrics Update all dict-style access to attribute access in rm.py. Fix BaseModel-incompatible patterns: .items() → .model_dump().items(), "key not in obj" → "not hasattr(obj, key)". Wrap model_construct rm dicts in test_rm.py with RMConfig.model_construct(). Signed-off-by: nliang <nliang@nvidia.com>
Signed-off-by: nliang <nliang@nvidia.com>
logger.log_metrics() calls metrics.items() internally. RMValMetrics is now BaseModel which lacks .items(). Use .model_dump() to convert. Signed-off-by: nliang <nliang@nvidia.com>
64125e7 to
4cc1cb3
Compare
Contributor
Author
|
/ok to test 4cc1cb3 |
Add defaults to RMConfig, RMValMetrics fields matching the reference config (rm.yaml). RMSaveState already had defaults. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: nliang <nliang@nvidia.com>
Contributor
Author
|
/ok to test dfde832 |
Contributor
Author
|
/ok to test dfde832 |
1 similar comment
Contributor
Author
|
/ok to test dfde832 |
val_metrics returned by validate() is a plain dict, not RMValMetrics BaseModel, so .model_dump() fails. Same fix as DPO (PR #2524). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: nliang <nliang@nvidia.com>
Contributor
Author
|
/ok to test 1c57dd8 |
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.
Convert 3 TypedDict classes to pydantic BaseModel with extra="allow":
Update all dict-style access to attribute access in rm.py. Fix BaseModel-incompatible patterns: .items() → .model_dump().items(), "key not in obj" → "not hasattr(obj, key)".
Wrap model_construct rm dicts in test_rm.py with RMConfig.model_construct().
What does this PR do ?
Add a one line overview of what this PR aims to accomplish.
Issues
List issues that this PR closes (syntax):
Usage
# Add a code snippet demonstrating how to use thisBefore your PR is "Ready for review"
Pre checks:
Results before / after the changes