TensorTonic
Study Plans
Study Plan
Estimate Critical Batch Size
Scaling LawsLanguage Models
Easy

Estimate critical batch size from a training sweep. For each reached target, let BiB_iBi​ be batch size, SiS_iSi​ the steps taken, and EiE_iEi​ the number of examples consumed at sweep index iii:

Ei=BiSi.E_i=B_iS_i.Ei​=Bi​Si​.

Let Smin⁡S_{\min}Smin​ be the smallest step count and Emin⁡E_{\min}Emin​ the smallest example count among reached targets. These minima may come from different sweep points. The critical-batch estimate is:

Bcrit=Emin⁡Smin⁡.B_{\mathrm{crit}}=\frac{E_{\min}}{S_{\min}}.Bcrit​=Smin​Emin​​.

Ignore unreached points when calculating the minima. Return a Python dictionary with examples, an input-aligned list of Python floats with None at unreached positions, and min_steps, min_examples, critical_batch_size, each a Python float.

Loading visualization...

Examples

Input: batch_sizes = [8,16,32], steps_to_target = [100,60,50], reached_mask = [true,true,true]

Output: {"examples":[800,960,1600],"min_steps":50,"min_examples":800,"critical_batch_size":16}

Explanation: The minimum examples and minimum steps occur at different sweep points, and their ratio is 16.

Input: batch_sizes = [4,8,16], steps_to_target = [120,80,60], reached_mask = [true,true,true]

Output: {"examples":[480,640,960],"min_steps":60,"min_examples":480,"critical_batch_size":8}

Input: batch_sizes = [2,4,8,16], steps_to_target = [200,130,90,85], reached_mask = [true,true,true,true]

Output: {"examples":[400,520,720,1360],"min_steps":85,"min_examples":400,"critical_batch_size":4.705882}

Hint 1

Boolean tensor indexing selects only marked entries.

Hint 2

Tensor.min returns the smallest selected value.

Hint 3

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

Requirements

  • Use PyTorch and preserve sweep order.
  • Exclude unreached entries from numerical results while retaining their None placeholders.
  • Do not modify input tensors.

Constraints

  • batch_sizes and steps_to_target are aligned one-dimensional int64 PyTorch tensors.
  • reached_mask is an aligned Boolean PyTorch tensor on the same device.
  • Batch sizes are unique and positive.
  • Reached entries have positive steps; at least one entry is reached.
  • All inputs share a device and may be noncontiguous.
Try Similar Problems
Recover an IsoFLOP Compute-Optimal FrontierHardFit a Data Power Law with a Noise FloorHardExtrapolate Data-Mixture Scaling CurvesHardDiagnose muP Width InvariantsMediumFit Learning-Rate and Batch-Size ScalingHardOrthogonalize a Muon Momentum UpdateEasyPerform Stable Exact DeduplicationEasyPatchify a Batch of ImagesEasyMasked Language ModelingEasyNext Sentence PredictionEasyImplement Prefix Cache Matching and ReuseMediumN-gram Language ModelMedium

Accepts: array

Accepts: array

Accepts: array

You must run your code first.

Estimate Critical Batch Size

Scaling LawsLanguage Models
Easy

Estimate critical batch size from a training sweep. For each reached target, let BiB_iBi​ be batch size, SiS_iSi​ the steps taken, and EiE_iEi​ the number of examples consumed at sweep index iii:

Ei=BiSi.E_i=B_iS_i.Ei​=Bi​Si​.

Let Smin⁡S_{\min}Smin​ be the smallest step count and Emin⁡E_{\min}Emin​ the smallest example count among reached targets. These minima may come from different sweep points. The critical-batch estimate is:

Bcrit=Emin⁡Smin⁡.B_{\mathrm{crit}}=\frac{E_{\min}}{S_{\min}}.Bcrit​=Smin​Emin​​.

Ignore unreached points when calculating the minima. Return a Python dictionary with examples, an input-aligned list of Python floats with None at unreached positions, and min_steps, min_examples, critical_batch_size, each a Python float.

Loading visualization...

Examples

Input: batch_sizes = [8,16,32], steps_to_target = [100,60,50], reached_mask = [true,true,true]

Output: {"examples":[800,960,1600],"min_steps":50,"min_examples":800,"critical_batch_size":16}

Explanation: The minimum examples and minimum steps occur at different sweep points, and their ratio is 16.

Input: batch_sizes = [4,8,16], steps_to_target = [120,80,60], reached_mask = [true,true,true]

Output: {"examples":[480,640,960],"min_steps":60,"min_examples":480,"critical_batch_size":8}

Input: batch_sizes = [2,4,8,16], steps_to_target = [200,130,90,85], reached_mask = [true,true,true,true]

Output: {"examples":[400,520,720,1360],"min_steps":85,"min_examples":400,"critical_batch_size":4.705882}

Hint 1

Boolean tensor indexing selects only marked entries.

Hint 2

Tensor.min returns the smallest selected value.

Hint 3

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

Requirements

  • Use PyTorch and preserve sweep order.
  • Exclude unreached entries from numerical results while retaining their None placeholders.
  • Do not modify input tensors.

Constraints

  • batch_sizes and steps_to_target are aligned one-dimensional int64 PyTorch tensors.
  • reached_mask is an aligned Boolean PyTorch tensor on the same device.
  • Batch sizes are unique and positive.
  • Reached entries have positive steps; at least one entry is reached.
  • All inputs share a device and may be noncontiguous.
Try Similar Problems
Recover an IsoFLOP Compute-Optimal FrontierHardFit a Data Power Law with a Noise FloorHardExtrapolate Data-Mixture Scaling CurvesHardDiagnose muP Width InvariantsMediumFit Learning-Rate and Batch-Size ScalingHardOrthogonalize a Muon Momentum UpdateEasyPerform Stable Exact DeduplicationEasyPatchify a Batch of ImagesEasyMasked Language ModelingEasyNext Sentence PredictionEasyImplement Prefix Cache Matching and ReuseMediumN-gram Language ModelMedium

Accepts: array

Accepts: array

Accepts: array

You must run your code first.