diff --git a/src/transformers/integrations.py b/src/transformers/integrations.py index a2effeac6361..14857f830831 100644 --- a/src/transformers/integrations.py +++ b/src/transformers/integrations.py @@ -346,7 +346,7 @@ def dynamic_modules_import_trainable(*args, **kwargs): **kwargs, ) best_trial = analysis.get_best_trial(metric="objective", mode=direction[:3], scope=trainer.args.ray_scope) - best_run = BestRun(best_trial.trial_id, best_trial.last_result["objective"], best_trial.config) + best_run = BestRun(best_trial.trial_id, best_trial.last_result["objective"], best_trial.config, analysis) if _tb_writer is not None: trainer.add_callback(_tb_writer) return best_run diff --git a/src/transformers/trainer.py b/src/transformers/trainer.py index 518e58342afe..344523842343 100755 --- a/src/transformers/trainer.py +++ b/src/transformers/trainer.py @@ -2492,7 +2492,8 @@ def hyperparameter_search( - the documentation of [sigopt](https://app.sigopt.com/docs/endpoints/experiments/create) Returns: - [`trainer_utils.BestRun`]: All the information about the best run. + [`trainer_utils.BestRun`]: All the information about the best run. Experiment summary can be found in + `run_summary` attribute for Ray backend. """ if backend is None: backend = default_hp_search_backend() diff --git a/src/transformers/trainer_utils.py b/src/transformers/trainer_utils.py index 9f273ab1ed6c..a213e4b1f447 100644 --- a/src/transformers/trainer_utils.py +++ b/src/transformers/trainer_utils.py @@ -192,7 +192,7 @@ class HubStrategy(ExplicitEnum): class BestRun(NamedTuple): """ - The best run found by an hyperparameter search (see [`~Trainer.hyperparameter_search`]). + The best run found by a hyperparameter search (see [`~Trainer.hyperparameter_search`]). Parameters: run_id (`str`): @@ -202,11 +202,14 @@ class BestRun(NamedTuple): The objective that was obtained for this run. hyperparameters (`Dict[str, Any]`): The hyperparameters picked to get this run. + run_summary (`Optional[Any]`): + A summary of tuning experiments. `ray.tune.ExperimentAnalysis` object for Ray backend. """ run_id: str objective: float hyperparameters: Dict[str, Any] + run_summary: Optional[Any] = None def default_compute_objective(metrics: Dict[str, float]) -> float: