mixle.models.train_search module¶
Design-of-experiments helpers for language-model training recipes.
Training a language model is an expensive-objective, low-fidelity-proxy
setting: a short run over fewer steps or a data subset is a noisy estimate of
the full run’s loss. tune_training() wraps
mixle.doe.multi_fidelity_minimize so the search uses low-budget runs to
locate promising recipes and reserves full-budget runs to refine them.
The objective is a caller-supplied training callback
train(recipe, budget) -> held-out loss where budget in (0, 1] is the
fraction of full training. lm_train_fn() provides a callback for
LM, and
extrapolate_learning_curve() predicts full-budget loss from a partial
run’s curve for early stopping.
- class TrainingSpace(d_model_choices=(64, 128, 256, 512), n_layer_range=(2, 12), log10_lr_range=(-4.0, -2.0), batch_choices=(16, 32, 64, 128))[source]
Bases:
objectThe tunable axes of an LM training recipe and how a unit-cube point decodes into concrete knobs.
- Parameters:
- bounds()[source]
Return unit-cube bounds for the DOE optimizer.
- class TrainingSearchResult(recipe, loss, history=None)[source]
Bases:
objectThe outcome of a multi-fidelity training search: the best recipe, its full-budget loss, and the history.
- tune_training(train, space=None, *, fidelities=(0.25, 1.0), costs=None, max_cost=20.0, n_init=None, seed=0)[source]
Run multi-fidelity BO over a training recipe.
train(recipe, budget)returns held-out loss, where lower is better.fidelitiesare the training-budget fractions the search may run at. Returns the recipe with the best full-budget loss and the full BO history.
- lm_train_fn(token_ids, val_ids, *, vocab, block=64, max_epochs=3, device='cpu')[source]
Return a training callback
(recipe, budget) -> held-out nats/tokenforLM.budget in (0, 1]scales the number of epochs. A larger pretraining loop can use the same convention to scale steps or token subsets.
- extrapolate_learning_curve(steps, losses, *, at)[source]
Predict the loss at budget/step
atfrom a partial run’s(steps, losses)via a power-law fit.Fits
loss(t) = a + b * t^(-c)and evaluates it atatso a partial run can estimate the full-budget loss for early stopping. Falls back to the last observed loss if the fit fails.