TensorTonic
Study Plans
Study Plan
Diagnose muP Width Invariants
Scaling LawsLanguage Models
Medium

Measure how activations and their one-step changes vary with model width under maximal-update parameterization (muP). activation_rms contains activation root-mean-square values; activation_change_rms contains the RMS change after one update. For each series, fit an unweighted least-squares line using natural logarithms:

log⁡yi=a+blog⁡wi.\log y_i=a+b\log w_i.logyi​=a+blogwi​.

Here, iii identifies a measurement, wiw_iwi​ is its model width, yiy_iyi​ is the supplied RMS value, aaa is the log-space intercept and bbb is the slope. The maximum-to-minimum ratio is:

R=max⁡iyimin⁡iyi.R=\frac{\max_i y_i}{\min_i y_i}.R=mini​yi​maxi​yi​​.

Classify a series as width-invariant when its fitted slope satisfies:

∣b∣≤τ.|b|\le\tau.∣b∣≤τ.

Here, RRR measures the spread of the original values and τ\tauτ is slope_tolerance. Return a Python dictionary with activation_slope, activation_intercept, change_slope, change_intercept, activation_ratio and change_ratio as Python floats, and activation_invariant and change_invariant as Python Booleans.

Loading visualization...

Examples

Input: widths = [128,256,512], activation_rms = [1,1,1], activation_change_rms = [0.5,0.5,0.5], slope_tolerance = 0.05

Output: {"activation_slope":0,"activation_intercept":0,"change_slope":0,"change_intercept":-0.693147,"activation_ratio":1,"change_ratio":1,"activation_invariant":true,"change_invariant":true}

Explanation: Constant RMS values have zero log-log slope and therefore satisfy the tolerance.

Input: widths = [1,2,4], activation_rms = [1,2,4], activation_change_rms = [1,1,1], slope_tolerance = 0.1

Output: {"activation_slope":1,"activation_intercept":0,"change_slope":0,"change_intercept":0,"activation_ratio":4,"change_ratio":1,"activation_invariant":false,"change_invariant":true}

Input: widths = [64,128,256,512], activation_rms = [1,1.01,0.99,1.02], activation_change_rms = [0.2,0.199,0.201,0.2], slope_tolerance = 0.05

Output: {"activation_slope":0.005685,"activation_intercept":-0.02463,"change_slope":0.001443,"change_intercept":-1.616944,"activation_ratio":1.030303,"change_ratio":1.01005,"activation_invariant":true,"change_invariant":true}

Hint 1

torch.log computes natural logarithms elementwise.

Hint 2

torch.linalg.lstsq returns fitted coefficients in design-column order.

Hint 3

Tensor.item converts a one-element tensor to a Python scalar.

Requirements

  • Use PyTorch float64 arithmetic for both fits and ratios.
  • Apply the inclusive tolerance to each series independently.
  • Do not modify input tensors.

Constraints

  • widths, activation_rms and activation_change_rms are aligned one-dimensional float64 PyTorch tensors with at least two entries.
  • Widths are unique and positive; both measurement series are positive.
  • slope_tolerance is a finite nonnegative Python number.
  • Tensor values are finite and inputs may be noncontiguous.
Try Similar Problems
Fit Learning-Rate and Batch-Size ScalingHardGenerate a Warmup-Stable-Decay ScheduleMediumRecover an IsoFLOP Compute-Optimal FrontierHardFit a Data Power Law with a Noise FloorHardExtrapolate Data-Mixture Scaling CurvesHardEstimate Critical Batch SizeEasyOrthogonalize a Muon Momentum UpdateEasyTrain a BPE Tokenizer From Scratch in PythonMediumImplement Prefix Cache Matching and ReuseMediumN-gram Language ModelMediumBeam Search DecodingMediumText Generation SamplingMedium

Accepts: array

Accepts: array

Accepts: array

Accepts: number

You must run your code first.

Diagnose muP Width Invariants

Scaling LawsLanguage Models
Medium

Measure how activations and their one-step changes vary with model width under maximal-update parameterization (muP). activation_rms contains activation root-mean-square values; activation_change_rms contains the RMS change after one update. For each series, fit an unweighted least-squares line using natural logarithms:

log⁡yi=a+blog⁡wi.\log y_i=a+b\log w_i.logyi​=a+blogwi​.

Here, iii identifies a measurement, wiw_iwi​ is its model width, yiy_iyi​ is the supplied RMS value, aaa is the log-space intercept and bbb is the slope. The maximum-to-minimum ratio is:

R=max⁡iyimin⁡iyi.R=\frac{\max_i y_i}{\min_i y_i}.R=mini​yi​maxi​yi​​.

Classify a series as width-invariant when its fitted slope satisfies:

∣b∣≤τ.|b|\le\tau.∣b∣≤τ.

Here, RRR measures the spread of the original values and τ\tauτ is slope_tolerance. Return a Python dictionary with activation_slope, activation_intercept, change_slope, change_intercept, activation_ratio and change_ratio as Python floats, and activation_invariant and change_invariant as Python Booleans.

Loading visualization...

Examples

Input: widths = [128,256,512], activation_rms = [1,1,1], activation_change_rms = [0.5,0.5,0.5], slope_tolerance = 0.05

Output: {"activation_slope":0,"activation_intercept":0,"change_slope":0,"change_intercept":-0.693147,"activation_ratio":1,"change_ratio":1,"activation_invariant":true,"change_invariant":true}

Explanation: Constant RMS values have zero log-log slope and therefore satisfy the tolerance.

Input: widths = [1,2,4], activation_rms = [1,2,4], activation_change_rms = [1,1,1], slope_tolerance = 0.1

Output: {"activation_slope":1,"activation_intercept":0,"change_slope":0,"change_intercept":0,"activation_ratio":4,"change_ratio":1,"activation_invariant":false,"change_invariant":true}

Input: widths = [64,128,256,512], activation_rms = [1,1.01,0.99,1.02], activation_change_rms = [0.2,0.199,0.201,0.2], slope_tolerance = 0.05

Output: {"activation_slope":0.005685,"activation_intercept":-0.02463,"change_slope":0.001443,"change_intercept":-1.616944,"activation_ratio":1.030303,"change_ratio":1.01005,"activation_invariant":true,"change_invariant":true}

Hint 1

torch.log computes natural logarithms elementwise.

Hint 2

torch.linalg.lstsq returns fitted coefficients in design-column order.

Hint 3

Tensor.item converts a one-element tensor to a Python scalar.

Requirements

  • Use PyTorch float64 arithmetic for both fits and ratios.
  • Apply the inclusive tolerance to each series independently.
  • Do not modify input tensors.

Constraints

  • widths, activation_rms and activation_change_rms are aligned one-dimensional float64 PyTorch tensors with at least two entries.
  • Widths are unique and positive; both measurement series are positive.
  • slope_tolerance is a finite nonnegative Python number.
  • Tensor values are finite and inputs may be noncontiguous.
Try Similar Problems
Fit Learning-Rate and Batch-Size ScalingHardGenerate a Warmup-Stable-Decay ScheduleMediumRecover an IsoFLOP Compute-Optimal FrontierHardFit a Data Power Law with a Noise FloorHardExtrapolate Data-Mixture Scaling CurvesHardEstimate Critical Batch SizeEasyOrthogonalize a Muon Momentum UpdateEasyTrain a BPE Tokenizer From Scratch in PythonMediumImplement Prefix Cache Matching and ReuseMediumN-gram Language ModelMediumBeam Search DecodingMediumText Generation SamplingMedium

Accepts: array

Accepts: array

Accepts: array

Accepts: number

You must run your code first.