refactor(dpo): migrate DPOConfig, DPOSaveState, DPOValMetrics to Base…#2524
Open
NolenLiang wants to merge 7 commits into
Open
refactor(dpo): migrate DPOConfig, DPOSaveState, DPOValMetrics to Base…#2524NolenLiang wants to merge 7 commits into
NolenLiang wants to merge 7 commits into
Conversation
Contributor
Author
|
/ok to test 3ae126b |
Contributor
Author
|
/ok to test 97a03ea |
…Model Convert 3 TypedDict classes to pydantic BaseModel with extra="allow": - DPOConfig: 14 required fields, used by dpo_train and setup - DPOSaveState: 5 fields with defaults, checkpoint serialization - DPOValMetrics: 9 required fields, validation metrics Update all dict-style access to attribute access in dpo.py. Wrap model_construct dpo dict in test_dpo.py with DPOConfig.model_construct(). Fix BaseModel-incompatible patterns: .items() → .model_dump().items(), "key in obj" → hasattr(obj, key). Signed-off-by: nliang <nliang@nvidia.com>
- DPOLossFn on main expects cfg["key"] (TypedDict). Pass master_config.dpo.model_dump() to maintain compatibility until PR2 (loss BaseModel migration) is merged. - Convert checkpoint dict to DPOSaveState on load (same pattern as GRPO checkpoint fix). Signed-off-by: nliang <nliang@nvidia.com>
logger.log_metrics() calls metrics.items() internally. DPOValMetrics is now BaseModel which lacks .items(). Use .model_dump() to convert. Signed-off-by: nliang <nliang@nvidia.com>
8b20cce to
0e50ce6
Compare
Contributor
Author
|
/ok to test 0e50ce6 |
Contributor
Author
|
/ok to test 0e50ce6 |
Contributor
Author
|
/ok to test e57928a |
4 tasks
NolenLiang
added a commit
that referenced
this pull request
May 19, 2026
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>
NolenLiang
added a commit
that referenced
this pull request
May 20, 2026
… DistillationLossFn guard 1. Revert DraftCrossEntropyLossConfig to TypedDict (unused, not loaded from config) 2. Remove isinstance(cfg, dict) guard from DistillationLossFn.__init__ and update all callers to pass DistillationLossConfig directly 3. Keep DPOLossFn guard for now (dpo.py still passes dict on this branch; will remove after DPO PR #2524 merges) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: nliang <nliang@nvidia.com>
- Convert DPOLossConfig from TypedDict to BaseModel with defaults - DPOLossFn.__init__ uses attribute access directly (no isinstance guard) - dpo.py passes master_config.dpo directly (no .model_dump() roundtrip) - Update test_loss_functions.py to pass DPOLossConfig(...) instead of dict Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: nliang <nliang@nvidia.com>
Contributor
Author
|
/ok to test 71a72f1 |
Missed indirect caller of DPOLossFn in tests/unit/models/policy/. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: nliang <nliang@nvidia.com>
Contributor
Author
|
/ok to test 69658f2 |
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.
…Model
Convert 3 TypedDict classes to pydantic BaseModel with extra="allow":
Update all dict-style access to attribute access in dpo.py. Wrap model_construct dpo dict in test_dpo.py with DPOConfig.model_construct(). Fix BaseModel-incompatible patterns: .items() → .model_dump().items(), "key in obj" → hasattr(obj, key).
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