Training a language model on one token costs a forward pass and a backward pass through the whole network. For a dense model with parameters, a standard estimate of the total number of operations (additions and multiplications) to train on tokens is
Use it to answer the question the video asks: at a given number of operations per second, how long would training take?
Implement two functions. Use a year of days, and round with 4 significant figures where asked (for example float(f"{x:.4g}")).
training_compute(n_params, n_tokens, ops_per_second) returns a dict:
"flops": the total operations , to 4 significant figures."log10_flops": of the unrounded , rounded to 3 decimals."years": how many years operations take at ops_per_second, to 4 significant figures.tokens_in_budget(n_params, ops_per_second, years) returns how many training tokens a model with n_params parameters can be trained on in years of compute at ops_per_second, to 4 significant figures.
Inputs may be Python ints or floats. Return plain Python floats.