feat: allow warm-start helper methods to set new hyperparameter_ranges (#1816) - #6352
mohamedzeidan2021 wants to merge 1 commit into
Conversation
|
Claude finished @mohamedzeidan2021's task in 1m 15s —— View job PR Review — warm-start helper
|
lucasjia-aws
left a comment
There was a problem hiding this comment.
Automated review: 1 non-blocking suggestion. See inline comment.
|
|
||
| def transfer_learning_tuner(self, additional_parents=None, model_trainer=None): | ||
| def transfer_learning_tuner( | ||
| self, additional_parents=None, model_trainer=None, hyperparameter_ranges=None |
There was a problem hiding this comment.
[suggestion] correctness
The new hyperparameter_ranges parameter is overloaded to carry two incompatible shapes depending on internal state the caller does not directly control: dict[str, ParameterRange] in the single-model_trainer branch, but dict[str, dict[str, ParameterRange]] in the .create()-based branch. It is forwarded without a shape check — as hyperparameter_ranges in one branch and hyperparameter_ranges_dict in the other — so passing the flat form to a dict-based parent tuner is silently accepted here and only fails later inside HyperparameterTuner/create with an error that does not point back to this argument. Validate the shape against the active branch and raise a ValueError naming the parameter and the expected shape, so misuse fails fast at this public API boundary.
Problem
The v3 warm-start helpers
HyperparameterTuner.transfer_learning_tunerand_create_warm_start_tuneralways reused the parent tuner's ranges (self._hyperparameter_ranges/self._hyperparameter_ranges_dict) with no way to override them. Users who wanted the warm-started child tuner to explore a different search space had to monkeypatch the private_hyperparameter_rangesattribute.Fix
Added an optional, backward-compatible
hyperparameter_ranges=Noneparameter totransfer_learning_tuner(forwarded to_create_warm_start_tuner). When provided it overrides the parent's ranges — used ashyperparameter_rangesin the single-trainer branch and ashyperparameter_ranges_dictin the.create()-based branch. When omitted (None), existing behavior is preserved exactly. Docstrings updated to document both accepted shapes.Testing
Added 4 unit tests in
test_tuner_phase5.pycovering single-trainer override + fallback and dict-based override + fallback. Full tuner unit suites pass (65 tests). Verified the override tests fail when the source is reverted (negative control).black+flake8clean.Fixes #1816