physics.scaling
physics.scaling
Scaling-law arithmetic: power-law price lists and compute-optimal allocation.
Functions
| Name | Description |
|---|---|
| calc_allocation_growth | Calculate fractional allocation growth under a compute power law. |
| calc_compute_optimal_allocation | Allocate a compute budget at a fixed tokens-per-parameter ratio. |
| calc_halving_multiple | Find the resource multiple that halves a power-law loss term. |
| calc_loss_reduction_compute_multiple | Find the compute multiple for a fractional power-law loss reduction. |
| calc_power_law_factor | Calculate the remaining fraction of a resource-dependent power-law term. |
calc_allocation_growth
physics.scaling.calc_allocation_growth(compute_multiple, exponent)Calculate fractional allocation growth under a compute power law.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| compute_multiple | float | Positive dimensionless ratio of new to old compute budget. | required |
| exponent | float | Dimensionless exponent relating the allocation to compute. | required |
Returns
| Name | Type | Description |
|---|---|---|
| float | Fractional change in allocation; multiply by 100 only when presenting a percentage. |
Notes
Equation: growth = compute_multiple**exponent - 1.
Assumptions: Allocation follows X_opt = A*C**exponent with fixed A.
Excludes: Fitting the exponent, integer rounding, and changes in optimal regime.
References
Derivation: divide X_new=A*C_new**exponent by X_old=A*C_old**exponent and subtract one.
Examples
>>> calc_allocation_growth(4, 0.5)
1.0calc_compute_optimal_allocation
physics.scaling.calc_compute_optimal_allocation(
budget_flops,
tokens_per_param,
flops_per_param_token,
)Allocate a compute budget at a fixed tokens-per-parameter ratio.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| budget_flops | Quantity or float | Positive training-work budget C, in FLOPs or as a plain number. | required |
| tokens_per_param | float | Positive ratio r of training tokens to model parameters. | required |
| flops_per_param_token | float | Positive accounting coefficient k, FLOPs per parameter per token. | required |
Returns
| Name | Type | Description |
|---|---|---|
| tuple of float | Parameter count N and training-token count D as continuous plain numbers; neither value is rounded to an implementable model shape. |
Notes
Equation: N = sqrt(C/(k*r)); D = r*N, from C=k*N*D.
Assumptions: The supplied ratio is the chosen allocation rule and work is parameter dominated. The function does not estimate the optimal ratio.
Excludes: Attention work, communication, architecture constraints, and fitting a loss model to determine r.
References
Hoffmann et al. (2022), “Training Compute-Optimal Large Language Models.” https://arxiv.org/abs/2203.15556 (bibliography key: hoffmann2022chinchilla). Derivation: substitute the assumed D=r*N into the work budget C=k*N*D.
Examples
>>> calc_compute_optimal_allocation(600, 1, 6)
(10.0, 10.0)calc_halving_multiple
physics.scaling.calc_halving_multiple(exponent)Find the resource multiple that halves a power-law loss term.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| exponent | float | Positive dimensionless power-law exponent alpha. | required |
Returns
| Name | Type | Description |
|---|---|---|
| float | Dimensionless resource multiplier required to halve the modeled term. |
Notes
Equation: multiple = 2**(1/exponent).
Assumptions: The reducible term follows A*R**(-alpha) with fixed A and alpha.
Excludes: Irreducible loss, regime changes, and estimation of the exponent.
References
Derivation: solve (R_new/R_old)**(-alpha) = 1/2 for the resource ratio.
Examples
>>> calc_halving_multiple(0.5)
4.0calc_loss_reduction_compute_multiple
physics.scaling.calc_loss_reduction_compute_multiple(exponent, loss_reduction)Find the compute multiple for a fractional power-law loss reduction.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| exponent | float | Positive dimensionless alpha in L=A*C**(-alpha). | required |
| loss_reduction | float | Desired fractional reduction r in the modeled loss, in (0, 1). | required |
Returns
| Name | Type | Description |
|---|---|---|
| float | Dimensionless new-to-old compute ratio. |
Notes
Equation: multiple = (1/(1-loss_reduction))**(1/exponent).
Assumptions: The entire loss being reduced is the power-law term with fixed coefficient and exponent.
Excludes: Irreducible loss floors, model-size constraints, and fitted uncertainty.
References
Derivation: solve multiple**(-alpha) = 1-r for multiple. Small positive exponents can make modest loss reductions expensive.
Examples
>>> calc_loss_reduction_compute_multiple(0.5, 0.5)
4.0calc_power_law_factor
physics.scaling.calc_power_law_factor(multiple, exponent)Calculate the remaining fraction of a resource-dependent power-law term.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| multiple | float | Positive dimensionless ratio of new to old resource. | required |
| exponent | float | Dimensionless alpha in the assumed law A*R**(-alpha). | required |
Returns
| Name | Type | Description |
|---|---|---|
| float | New term divided by old term, dimensionless; this is the remaining fraction rather than the reduction fraction. |
Notes
Equation: factor = multiple**(-exponent).
Assumptions: The same coefficient and exponent hold before and after the change.
Excludes: Irreducible offsets, empirical fitting, and saturation.
References
Derivation: cancel A in the ratio (A*R_new**(-alpha))/(A*R_old**(-alpha)).
Examples
>>> calc_power_law_factor(4, 0.5)
0.5