syne_tune.optimizer.schedulers.hyperband_stopping module
- class syne_tune.optimizer.schedulers.hyperband_stopping.RungEntry(trial_id, metric_val)[source]
Bases:
object
Represents entry in a rung. This class is extended by rung level systems which need to maintain more information per entry.
- Parameters:
trial_id (
str
) – ID of trialmetric_val (
float
) – Metric value
- class syne_tune.optimizer.schedulers.hyperband_stopping.Rung(level, prom_quant, mode, data=None)[source]
Bases:
object
- Parameters:
level (
int
) – Rung level \(r_j\)prom_quant (
float
) – promotion quantile \(q_j\)data (
Optional
[List
[RungEntry
]]) – Data of all previous jobs reaching the level. This list is kept sorted w.r.t.metric_val
, so that best values come first
- quantile()[source]
Returns same value as
numpy.quantile(metric_vals, q)
, wheremetric_vals
are the metric values indata
, andq = prom_quant
ifmode == "min"
,q = ``1 - prom_quant
otherwise. Iflen(data) < 2
, we returnNone
.See here. The default for
numpy.quantile
ismethod="linear"
.- Return type:
Optional
[float
]- Returns:
See above
- class syne_tune.optimizer.schedulers.hyperband_stopping.RungSystem(rung_levels, promote_quantiles, metric, mode, resource_attr, max_t)[source]
Bases:
object
Terminology: Trials emit results at certain resource levels (e.g., epoch numbers). Some resource levels are rung levels, this is where scheduling decisions (stop, continue or pause, resume) are taken. For a running trial, the next rung level (or
max_t
) it will reach is called its next milestone.Note that
rung_levels
,promote_quantiles
can be empty. All entries ofrung_levels
are smaller thanmax_t
.- Parameters:
rung_levels (
List
[int
]) – List of rung levels (positive int, increasing)promote_quantiles (
List
[float
]) – List of promotion quantiles at each rung levelmetric (
str
) – Name of metric to optimizemode (
str
) – “min” or “max”resource_attr (
str
) – Name of resource attributemax_t (
int
) – Largest resource level
- on_task_schedule(new_trial_id)[source]
Called when new task is to be scheduled.
For a promotion-based rung system, check whether any trial can be promoted. If so, return dict with keys “trial_id”, “resume_from” (rung level where trial is paused), “milestone” (next rung level the trial will reach, or None).
If no trial can be promoted, or if the rung system is not promotion-based, the returned dictionary must not contain the “trial_id” key. It is nevertheless passed back via
extra_kwargs
inon_task_schedule()
. The default is to return an empty dictionary, but some special subclasses can use this to return information in case a trial is not promoted.If no trial can be promoted, or if the rung system is not promotion-based, the returned dictionary must not contain the “trial_id” key. It is nevertheless passed back via
extra_kwargs
inon_task_schedule()
. The default is to return an empty dictionary, but some special subclasses can use this to return information in case a trial is not promoted.- Parameters:
new_trial_id (
str
) – ID for new trial as passed to_suggest()
. Only needed by specific subclasses- Return type:
Dict
[str
,Any
]- Returns:
See above
- on_task_add(trial_id, skip_rungs, **kwargs)[source]
Called when new task is started.
- Parameters:
trial_id (
str
) – ID of trial to be startedskip_rungs (
int
) – This number of the smallest rung levels are not considered milestones for this taskkwargs – Additional arguments
- on_task_report(trial_id, result, skip_rungs)[source]
Called when a trial reports metric results.
Returns dict with keys “milestone_reached” (trial reaches its milestone), “task_continues” (trial should continue; otherwise it is stopped or paused), “next_milestone” (next milestone it will reach, or None). For certain subclasses, there may be additional entries.
- Parameters:
trial_id (
str
) – ID of trial which reported resultsresult (
Dict
[str
,Any
]) – Reported metricsskip_rungs (
int
) – This number of the smallest rung levels are not considered milestones for this task
- Return type:
Dict
[str
,Any
]- Returns:
See above
- on_task_remove(trial_id)[source]
Called when task is removed.
- Parameters:
trial_id (
str
) – ID of trial which is to be removed
- get_first_milestone(skip_rungs)[source]
- Parameters:
skip_rungs (
int
) – This number of the smallest rung levels are not considered milestones for this task- Return type:
int
- Returns:
First milestone to be considered
- get_milestones(skip_rungs)[source]
- Parameters:
skip_rungs (
int
) – This number of the smallest rung levels are not considered milestones for this task- Return type:
List
[int
]- Returns:
All milestones to be considered, in decreasing order; does not include
max_t
- snapshot_rungs(skip_rungs)[source]
A snapshot is a list of rung levels with entries
(level, data)
, ordered from top to bottom (largest rung first).- Parameters:
skip_rungs (
int
) – This number of the smallest rung levels are not considered milestones for this task- Return type:
List
[Tuple
[int
,List
[RungEntry
]]]- Returns:
Snapshot (see above)
- static does_pause_resume()[source]
- Return type:
bool
- Returns:
Is this variant doing pause and resume scheduling, in the sense that trials can be paused and resumed later?
- support_early_checkpoint_removal()[source]
- Return type:
bool
- Returns:
Do we support early checkpoint removal via
paused_trials()
?
- paused_trials(resource=None)[source]
Only for pause and resume schedulers (
does_pause_resume()
returnsTrue
), where trials can be paused at certain rung levels only. Ifresource
is not given, returns list of all paused trials(trial_id, rank, metric_val, level)
, wherelevel
is the rung level, andrank
is the rank of the trial in the rung (0 for the best metric value). Ifresource
is given, only the paused trials in the rung of this level are returned. Ifresource
is not a rung level, the returned list is empty.- Parameters:
resource (
Optional
[int
]) – If given, paused trials of only this rung level are returned. Otherwise, all paused trials are returned- Return type:
List
[Tuple
[str
,int
,float
,int
]]- Returns:
See above
- class syne_tune.optimizer.schedulers.hyperband_stopping.StoppingRungSystem(rung_levels, promote_quantiles, metric, mode, resource_attr, max_t)[source]
Bases:
RungSystem
The decision on whether a trial \(\mathbf{x}\) continues or is stopped at a rung level \(r\), is taken in
on_task_report()
. To this end, the metric value \(f(\mathbf{x}, r)\) is inserted into \(r.data\). Then:\[\mathrm{continues}(\mathbf{x}, r)\; \Leftrightarrow\; f(\mathbf{x}, r) \le \mathrm{np.quantile}(r.data, r.prom\_quant)\]in case
mode == "min"
. See also_task_continues()
.- on_task_schedule(new_trial_id)[source]
Called when new task is to be scheduled.
For a promotion-based rung system, check whether any trial can be promoted. If so, return dict with keys “trial_id”, “resume_from” (rung level where trial is paused), “milestone” (next rung level the trial will reach, or None).
If no trial can be promoted, or if the rung system is not promotion-based, the returned dictionary must not contain the “trial_id” key. It is nevertheless passed back via
extra_kwargs
inon_task_schedule()
. The default is to return an empty dictionary, but some special subclasses can use this to return information in case a trial is not promoted.If no trial can be promoted, or if the rung system is not promotion-based, the returned dictionary must not contain the “trial_id” key. It is nevertheless passed back via
extra_kwargs
inon_task_schedule()
. The default is to return an empty dictionary, but some special subclasses can use this to return information in case a trial is not promoted.- Parameters:
new_trial_id (
str
) – ID for new trial as passed to_suggest()
. Only needed by specific subclasses- Return type:
Dict
[str
,Any
]- Returns:
See above
- on_task_report(trial_id, result, skip_rungs)[source]
Called when a trial reports metric results.
Returns dict with keys “milestone_reached” (trial reaches its milestone), “task_continues” (trial should continue; otherwise it is stopped or paused), “next_milestone” (next milestone it will reach, or None). For certain subclasses, there may be additional entries.
- Parameters:
trial_id (
str
) – ID of trial which reported resultsresult (
Dict
[str
,Any
]) – Reported metricsskip_rungs (
int
) – This number of the smallest rung levels are not considered milestones for this task
- Return type:
Dict
[str
,Any
]- Returns:
See above