Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/transformers/integrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/transformers/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 4 additions & 1 deletion src/transformers/trainer_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`):
Expand All @@ -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:
Expand Down