TensorTonic
Study Plans
Study Plan
Fit a Data Power Law with a Noise Floor
Scaling LawsLanguage ModelsProbability and Statistics
Hard

Fit a data scaling law to observed data sizes and losses, using the supplied candidate loss floors:

L(D)=E+AD−α.L(D)=E+AD^{-\alpha}.L(D)=E+AD−α.

Here, DDD is a data size, L(D)L(D)L(D) is its predicted loss, EEE is the irreducible-loss floor, AAA is a positive coefficient, and α\alphaα is a positive decay exponent. For observation iii, DiD_iDi​ and LiL_iLi​ are its data size and loss. A candidate floor is eligible only when it is below every observed loss. Its unweighted least-squares fit is defined in natural-log space by:

log⁡(Li−E)=a+blog⁡Di.\log(L_i-E)=a+b\log D_i.log(Li​−E)=a+blogDi​.

The intercept is a=log⁡Aa=\log Aa=logA and the slope is b=−αb=-\alphab=−α. Consider only fits with positive, finite coefficient and exponent. Select the fit with the smallest root mean squared error (RMSE) on the original loss scale, preserving candidate order on exact ties:

RMSE=1n∑i=0n−1(L(Di)−Li)2.\mathrm{RMSE}=\sqrt{\frac{1}{n}\sum_{i=0}^{n-1}\left(L(D_i)-L_i\right)^2}.RMSE=n1​i=0∑n−1​(L(Di​)−Li​)2​.

Here, nnn is the number of observations. Return a Python dictionary with floor, coefficient, exponent, and rmse as Python floats, plus predictions as a float64 PyTorch tensor matching target_sizes in shape, order, and device.

Loading visualization...

Examples

Input: data_sizes = [1,4,16], losses = [5,3,2], target_sizes = [64], floor_candidates = [0,1]

Output: {"floor":1,"coefficient":4,"exponent":0.5,"predictions":[1.5],"rmse":0}

Explanation: Subtracting floor 1 leaves the exact curve 4D^(-0.5), so its raw-loss error is zero.

Input: data_sizes = [1,2,4], losses = [3,2,1.5], target_sizes = [8], floor_candidates = [1]

Output: {"floor":1,"coefficient":2,"exponent":1,"predictions":[1.25],"rmse":0}

Input: data_sizes = [1,2,4], losses = [2.5,1.5,1], target_sizes = [8,16], floor_candidates = [0,0.5]

Output: {"floor":0.5,"coefficient":2,"exponent":1,"predictions":[0.75,0.625],"rmse":0}

Hint 1

torch.log computes natural logarithms elementwise.

Hint 2

torch.linalg.lstsq solves a least-squares system.

Hint 3

Tensor.square and Tensor.mean help measure errors on the original scale.

Requirements

  • Use PyTorch with float64 fitting and prediction arithmetic.
  • Follow the stated eligibility, least-squares, and fit-selection rules.
  • Do not modify any input tensor.

Constraints

  • data_sizes and losses are aligned one-dimensional float64 PyTorch tensors with at least three entries.
  • target_sizes and floor_candidates are nonempty one-dimensional float64 PyTorch tensors on the same device.
  • Observed and target sizes are positive; observed sizes are unique.
  • At least one floor yields a fit with positive finite coefficient and exponent.
  • All inputs are finite, share a device, and may be noncontiguous.
Try Similar Problems
Extrapolate Data-Mixture Scaling CurvesHardRecover an IsoFLOP Compute-Optimal FrontierHardEstimate Critical Batch SizeEasyFit Learning-Rate and Batch-Size ScalingHardDiagnose muP Width InvariantsMediumDecode Attention with a KV CacheHardTop-k MoE Router with Load StatisticsHardFit Elo Ratings from Pairwise VotesHardN-gram Language ModelMediumText Generation SamplingMediumLanguage ModelingMediumImplement Temperature, Top-k, and Top-p SamplingMedium

Accepts: array

Accepts: array

Accepts: array

Accepts: array

You must run your code first.

Fit a Data Power Law with a Noise Floor

Scaling LawsLanguage ModelsProbability and Statistics
Hard

Fit a data scaling law to observed data sizes and losses, using the supplied candidate loss floors:

L(D)=E+AD−α.L(D)=E+AD^{-\alpha}.L(D)=E+AD−α.

Here, DDD is a data size, L(D)L(D)L(D) is its predicted loss, EEE is the irreducible-loss floor, AAA is a positive coefficient, and α\alphaα is a positive decay exponent. For observation iii, DiD_iDi​ and LiL_iLi​ are its data size and loss. A candidate floor is eligible only when it is below every observed loss. Its unweighted least-squares fit is defined in natural-log space by:

log⁡(Li−E)=a+blog⁡Di.\log(L_i-E)=a+b\log D_i.log(Li​−E)=a+blogDi​.

The intercept is a=log⁡Aa=\log Aa=logA and the slope is b=−αb=-\alphab=−α. Consider only fits with positive, finite coefficient and exponent. Select the fit with the smallest root mean squared error (RMSE) on the original loss scale, preserving candidate order on exact ties:

RMSE=1n∑i=0n−1(L(Di)−Li)2.\mathrm{RMSE}=\sqrt{\frac{1}{n}\sum_{i=0}^{n-1}\left(L(D_i)-L_i\right)^2}.RMSE=n1​i=0∑n−1​(L(Di​)−Li​)2​.

Here, nnn is the number of observations. Return a Python dictionary with floor, coefficient, exponent, and rmse as Python floats, plus predictions as a float64 PyTorch tensor matching target_sizes in shape, order, and device.

Loading visualization...

Examples

Input: data_sizes = [1,4,16], losses = [5,3,2], target_sizes = [64], floor_candidates = [0,1]

Output: {"floor":1,"coefficient":4,"exponent":0.5,"predictions":[1.5],"rmse":0}

Explanation: Subtracting floor 1 leaves the exact curve 4D^(-0.5), so its raw-loss error is zero.

Input: data_sizes = [1,2,4], losses = [3,2,1.5], target_sizes = [8], floor_candidates = [1]

Output: {"floor":1,"coefficient":2,"exponent":1,"predictions":[1.25],"rmse":0}

Input: data_sizes = [1,2,4], losses = [2.5,1.5,1], target_sizes = [8,16], floor_candidates = [0,0.5]

Output: {"floor":0.5,"coefficient":2,"exponent":1,"predictions":[0.75,0.625],"rmse":0}

Hint 1

torch.log computes natural logarithms elementwise.

Hint 2

torch.linalg.lstsq solves a least-squares system.

Hint 3

Tensor.square and Tensor.mean help measure errors on the original scale.

Requirements

  • Use PyTorch with float64 fitting and prediction arithmetic.
  • Follow the stated eligibility, least-squares, and fit-selection rules.
  • Do not modify any input tensor.

Constraints

  • data_sizes and losses are aligned one-dimensional float64 PyTorch tensors with at least three entries.
  • target_sizes and floor_candidates are nonempty one-dimensional float64 PyTorch tensors on the same device.
  • Observed and target sizes are positive; observed sizes are unique.
  • At least one floor yields a fit with positive finite coefficient and exponent.
  • All inputs are finite, share a device, and may be noncontiguous.
Try Similar Problems
Extrapolate Data-Mixture Scaling CurvesHardRecover an IsoFLOP Compute-Optimal FrontierHardEstimate Critical Batch SizeEasyFit Learning-Rate and Batch-Size ScalingHardDiagnose muP Width InvariantsMediumDecode Attention with a KV CacheHardTop-k MoE Router with Load StatisticsHardFit Elo Ratings from Pairwise VotesHardN-gram Language ModelMediumText Generation SamplingMediumLanguage ModelingMediumImplement Temperature, Top-k, and Top-p SamplingMedium

Accepts: array

Accepts: array

Accepts: array

Accepts: array

You must run your code first.