You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit cbadf8b
Browse filesBrowse the repository at this point in the historyBrowse files
fix(train): raise on invalid constructor hyperparameters (#6306)
* fix(train): apply constructor hyperparameters in fine-tuning trainers
Passing hyperparameters={...} when constructing a fine-tuning trainer
(SFT, DPO, RLVR, RLAIF, MultiTurnRL) was silently ignored: BaseTrainer
stored the dict, but each trainer then unconditionally replaced
self.hyperparameters with a fresh FineTuningOptions built from the
model's Hub spec, discarding the user's values. The only way to set
values was post-construction via trainer.hyperparameters.<name> = value.
Capture the constructor-supplied hyperparameters in BaseTrainer and add a
shared _apply_user_hyperparameters helper that re-applies them onto the
rebuilt FineTuningOptions through its validating __setattr__. Each
fine-tuning trainer calls it after building options, so a dict passed at
construction is honored and validated against the model spec. Invalid
option names or out-of-spec values raise (consistent with the direct
attribute-assignment path) instead of being dropped.
Add unit tests for the helper (valid apply, invalid name, out-of-spec
value, empty/None no-op, non-FineTuningOptions no-op) and end-to-end
SFTTrainer tests covering the construction path.
* fix(train): only apply overridable constructor hyperparameters, warn on rest
Refine _apply_user_hyperparameters to apply a constructor-supplied
hyperparameter only when its name is overridable for the model (present
in the FineTuningOptions _specs). Non-overridable names are ignored
rather than raising, and a single warning lists them so the user knows
those values will not take effect. Overridable names are still applied
through __setattr__, so an out-of-spec value for an overridable name
still raises.
Update tests: a non-overridable name is now skipped with a warning
(instead of raising); out-of-spec value for an overridable name still
raises.
* fix(train): raise on invalid constructor hyperparameters
Change _apply_user_hyperparameters to route every constructor-supplied
hyperparameter through FineTuningOptions.__setattr__ instead of skipping
names that are not in the recipe spec. A dict passed at construction now
behaves exactly like the trainer.hyperparameters.<name> = value path:
- an unknown option name raises AttributeError
- an out-of-spec or off-enum value raises ValueError
Previously non-overridable names were ignored with a warning, which is
inconsistent with the direct-assignment path and can still let a job run
on a configuration the caller believed they set. Raising surfaces the
mistake immediately.
Update the helper and end-to-end SFT tests to assert the raise behavior.
* test(train): add constructor-hyperparameter wiring tests for DPO/RLVR/RLAIF
Each fine-tuning trainer calls _apply_user_hyperparameters at its own
call-site, so add a focused end-to-end test per trainer asserting a
constructor-supplied hyperparameter is applied onto the resolved
FineTuningOptions (value set + tracked in _user_set). This guards each
trainer's wiring against regressions; the apply/raise logic itself
remains covered centrally in test_apply_user_hyperparameters.py.
---------
Co-authored-by: Roja Reddy Sareddy <rsareddy@amazon.com>
0 commit comments