advanced28 min studyLesson 945 in Engineering

Training cost: define useful token contributions

Separate raw processed positions from accepted objective contributions and charge replay, padding, and evaluation consistently.

On this page

What you’ll understand

  • Define useful training contributions with an explicit progress boundary.
  • Account for padding, masking, replay, and failed work without overlap.
  • Compare cost per useful token under held-constant learning requirements.

Tokens processed by a device are not automatically useful training progress. Padding can execute kernels, masked targets can have no loss contribution, and a failed interval can be recomputed before any durable accepted update survives. All prices here are explicitly fictional stable teaching inputs in fictional credits, FC. We define useful tokens as accepted objective contributions in a specified training run, with progress counted once under a chosen durable boundary. This operational denominator does not prove learning quality, data value, or equivalence between different objectives and training recipes.

Define useful contributions instead of raw sequence positions

Specify what the objective actually weights. An input position can be necessary context without being a supervised target, and a zero-loss mask can still require attention computation. For our accounting example, useful tokens are target contributions accepted into the intended optimizer history and retained across recovery. Intentional later epochs can contribute again because the planned objective revisits data; useful token count is not the number of unique corpus strings. Document the loss, masking, weighting, and progress definition before publishing a token-efficiency ratio.

Classify excluded positions with disjoint categories when subtracting them from a processed count. A padding position already included in the padding category must not also be subtracted as masked. Failed or replayed contributions need lineage so work is charged every time it executes but credited once to accepted progress. A checkpoint boundary is one defensible accounting convention, not proof that every update before a crash is invalid for all purposes. State which state is recoverable and how the measured numerator and denominator close over the same run segment.

Nuseful=Nprocessed−Npad−Nmasked−NdiscardedN_{\rm useful}=N_{\rm processed}-N_{\rm pad}-N_{\rm masked}-N_{\rm discarded}
All terms count token positions in the specified cohort. The excluded categories must be disjoint and exhaustive for this definition; accepted intentional repeat epochs remain useful. This arithmetic is not a model of learning quality.↔ Scroll wide equations horizontally.

Charge the run beyond its accepted token counter

Resource-time includes initialization, data stalls, evaluation, checkpoint writes, recovery, and idle allocations within the selected boundary. Add separately priced storage or transfer operations only if they are not already included in another total. Failed intervals can increase this numerator while adding no accepted useful tokens. A throughput optimization that merely moves evaluation or checkpointing outside the reported window can look cheaper without changing the full run. Preserve the complete experiment lifecycle and state which shared infrastructure allocations are included.

Global token normalization also matters to the comparison. Unequal worker token counts do not justify averaging worker means as though each represented equal objective weight. A cheaper recipe with changed gradient weighting is a different training experiment unless that change is intended and evaluated. Hold quality targets, optimizer behavior, and recovery semantics appropriately constant when comparing implementations. Report both raw throughput and useful contribution throughput, alongside final evaluation; none of those alone establishes that two training runs deliver equivalent models.

cmillion=106CrunNuseful(Nuseful>0)c_{\rm million}=10^6\frac{C_{\rm run}}{N_{\rm useful}}\quad(N_{\rm useful}>0)
C_run is the included fictional FC for the complete defined run; the ratio is FC per million accepted token contributions. If useful progress is zero the ratio is undefined, and quality is a separate constraint.↔ Scroll wide equations horizontally.

Measure the discarded work and its uncertainty

Track padding by batch shape, loss masks by objective, and discarded work by failed attempt and recovery lineage. Validate aggregate counts against a small trace where every position and optimizer update can be inspected. Average valid fraction can hide a workload class whose long sequences pad poorly, or a failure pattern that repeatedly loses expensive late-stage work. When estimating from samples, define the sampling unit and dependencies; adjacent tokens in one packed sequence or one failed worker are usually not independent observations.

The sampling lab illustrates an intentionally independent valid-position model. Reset, explicitly set p=0.8 and n=20, predict, then Play or Step. Repeat from a fresh Reset with p=0.8 and n=80 explicitly set. For independent Bernoulli positions, the displayed sample-proportion variances are 0.008 and 0.002. Its mean p is a known input, and playback highlights a fixed exact distribution rather than collecting a real trace. It models no optimizer, masking logic, checkpoint loss, token correlation, cost, or model quality; use a sampling design suitable for the actual run.

Raw throughput hides discarded contributions

A fictional run holds eight devices for ten hours at two FC/device-hour. Add ten FC for data operations, six for checkpoints, and four for evaluation, with no overlapping charges. Of 120 million processed positions, twenty million are padding, ten million other masked positions, and ten million discarded contributions; these categories are disjoint.

  1. Device cost is 8×10×2=160 FC. The separately included operations add twenty FC, giving a complete chosen run cost of 180 FC. No failed computation is removed from that numerator.

  2. Useful progress is 120−20−10−10=80 million contributions under the specified definition. The categories do not double-subtract masked padding or replayed contributions already counted as discarded.

  3. Cost is 180/80=2.25 FC per million useful contributions. Dividing by raw processed positions gives 1.5 FC per million instead, a different metric that rewards work excluded from accepted progress.

The result

The fictional useful-contribution cost is 2.25 FC per million, subject to the stated objective, progress, and whole-run accounting boundaries.

Explore the model

Interactive lab

Interactive lab · sampling

A valid-fraction model assumes independent observations

Use independent Reset → explicitly set BOTH p and n → predict → Play/Step runs for (0.8,20) and (0.8,80). Exact sample-proportion variance falls from 0.008 to 0.002. The fixed distribution has no training trace, optimizer, failure recovery, or learning-quality model.

A valid-fraction model assumes independent observationsExact binomial masses for the mean of n independent Bernoulli trials, compared with normal mass between adjacent half-count boundaries; normal tails outside the finite support remain outside the bars. Playback highlights outcomes, not random samples. The Berry–Esseen bound applies to standardized CDFs, not individual bars or continuity-corrected errors. At p = 0 or 1, normal comparison and that bound are disabled. Normal-CDF evaluation uses a numerical approximation with absolute error below 7.5×10⁻⁸ (at most 1.5×10⁻⁷ per interval, before rounding). Current readings: Mean sample proportion: 0.5; Sample-mean variance: 0.0125; Uniform CDF error bound: ≤ 0.1062. All parameters are adjustable with the labeled controls below.Exact distribution of the mean of 20 independent Bernoulli variables with success probability 0.5; playback highlights outcome 0.00.250.50.75100.0580.1150.1730.23Sample mean · k / nProbability massNormal bin masses are an approximationk = 0 · exact probability = 9.54e-7
Exact binomial massNormal interval massHighlighted outcome / mean
Mean sample proportion
0.5
Sample-mean variance
0.0125
Uniform CDF error bound
≤ 0.1062
t = 0 s

Exact binomial masses for the mean of n independent Bernoulli trials, compared with normal mass between adjacent half-count boundaries; normal tails outside the finite support remain outside the bars. Playback highlights outcomes, not random samples. The Berry–Esseen bound applies to standardized CDFs, not individual bars or continuity-corrected errors. At p = 0 or 1, normal comparison and that bound are disabled. Normal-CDF evaluation uses a numerical approximation with absolute error below 7.5×10⁻⁸ (at most 1.5×10⁻⁷ per interval, before rounding). Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forAudit contribution lineage and sampling dependence before trusting a useful-token ratio.

Check your understanding

Which change makes a useful-token comparison invalid without additional objective-equivalence evaluation?

Try it yourself

A fictional run uses four devices for five hours at three FC/device-hour plus twelve FC of nonoverlapping other charges. Sixty million processed positions include ten million padding, five million other masked, and five million discarded contributions. Compute total and useful-token unit cost.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Subtract the three disjoint excluded categories, and preserve all included resource costs.

Compare with the solution

Compute cost is 4×5×3=60 FC and total cost is 72 FC. Useful progress is 60−10−5−5=40 million contributions. The useful-token cost is 72/40=1.8 FC per million, compared with 1.2 FC per million raw positions. These ratios describe the specified accounting and objective boundary. Confirm that an alternative preserves accepted gradient weighting, recovery behavior, and required evaluation quality before treating a smaller ratio as a better training system.

Take it with you

  • Define useful contributions through the objective and recovery boundary.
  • Subtract disjoint excluded categories and charge replay execution.
  • Compare token efficiency together with model quality and objective equivalence.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.