syne_tune.optimizer.schedulers.searchers.bayesopt.models.cost.cost_model module
- class syne_tune.optimizer.schedulers.searchers.bayesopt.models.cost.cost_model.CostValue(c0, c1)[source]
Bases:
object
Represents cost value \((c_0(x), c_1(x))\):
\(c_0(x)\): Startup cost for evaluation at config \(x\)
\(c_1(x)\): Cost per unit of resource \(r\) at config \(x\)
Our assumption is that, under the model, an evaluation at \(x\) until resource level \(r = 1, 2, 3, \dots\) costs \(c(x, r) = c_0(x) + r c_1(x)\)
-
c0:
float
-
c1:
float
- class syne_tune.optimizer.schedulers.searchers.bayesopt.models.cost.cost_model.CostModel[source]
Bases:
object
Interface for (temporal) cost model in the context of multi-fidelity HPO. We assume there are configurations \(x\) and resource levels \(r\) (for example, number of epochs). Here, \(r\) is a positive int. Can be seen as simplified version of surrogate model, which is mainly used in order to draw (jointly dependent) values from the posterior over cost values \((c_0(x), c_1(x))\).
Note: The model may be random (in which case joint samples are drawn from the posterior) or deterministic (in which case the model is fitted to data, and then cost values returned are deterministic.
A cost model has an inner state, which is set by calling
update()
passing a dataset. This inner state is then used whensample_joint()
is called.- property cost_metric_name: str
- Returns:
Name of metric in
TrialEvaluations
of cases inTuningJobState
- update(state)[source]
Update inner representation in order to be ready to return cost value samples.
Note: The metric :attr``cost_metric_name`` must be dict-valued in
state
, with keys being resource values \(r\). In order to support a proper estimation of \(c_0\) and \(c_1\), there should (ideally) be entries with the same \(x\) and different resource levels \(r\). The likelihood function takes into account that \(c(x, r) = c_0(x) + r c_1(x)\).- Parameters:
state (
TuningJobState
) – Current dataset (onlytrials_evaluations
is used)
- resample()[source]
For a random cost model, the state is resampled, such that calls of joint_sample before and after are conditionally independent. Normally, successive calls of sample_joint are jointly dependent. For example, for a linear model, the state resampled here would be the weight vector, which is then used in
sample_joint()
.For a deterministic cost model, this method does nothing.
- sample_joint(candidates)[source]
Draws cost values \((c_0(x), c_1(x))\) for candidates (non-extended).
If the model is random, the sampling is done jointly. Also, if
sample_joint()
is called multiple times, the posterior is to be updated after each call, such that the sample over the union of candidates over all calls is drawn jointly (but seeresample()
). Also, if measurement noise is allowed in update, this noise is not added here. A sample from \(c(x, r)\) is obtained as \(c_0(x) + r c_1(x)\). If the model is deterministic, the model determined inupdate()
is just evaluated.- Parameters:
candidates (
List
[Dict
[str
,Union
[int
,float
,str
]]]) – Non-extended configs- Return type:
List
[CostValue
]- Returns:
List of \((c_0(x), c_1(x))\)
- static event_time(start_time, level, next_milestone, cost)[source]
If a task reported its last recent value at
start_time
at levellevel
, return time of reaching levelnext_milestone
, given costcost
.- Parameters:
start_time (
float
) – See abovelevel (
int
) – See abovenext_milestone (
int
) – See abovecost (
CostValue
) – See above
- Return type:
float
- Returns:
Time of reaching
next_milestone
under cost model
- predict_times(candidates, resources, cost_values, start_time=0)[source]
Given configs \(x\), resource values \(r\) and cost values returned by
sample_joint()
, compute time predictions for when each config \(x\) reaches its resource level \(r\) if started atstart_time
.- Parameters:
candidates (
List
[Dict
[str
,Union
[int
,float
,str
]]]) – Configsresources (
List
[int
]) – Resource levelscost_values (
List
[CostValue
]) – Cost values fromsample_joint()
start_time (
float
) – See above
- Return type:
List
[float
]- Returns:
Predicted times