advanced24 min studyLesson 538 in Engineering

Make retries visible as training occurrences

Distinguish fetched, delivered, and optimizer-consumed work when workers fail, while preserving intended sampling multiplicities and explicit error policies.

On this page

What you’ll understand

  • Separate a source identity from an intended training occurrence and a delivery attempt.
  • Explain how retry and cursor choices can cause repetition or omission.
  • Audit failure handling without claiming universal exactly-once training semantics.

A decoder worker dies after producing a batch but before the coordinator records its completion. Retrying may deliver the batch again; advancing its cursor may instead lose work that never reached training. The correct recovery decision depends on which boundary was committed and on the intended visitation policy. Input delivery, batch receipt, and optimizer updates are different events. An application must define how they relate rather than assume a loader retry alone provides exactly-once effects on model state.

Name the unit that is allowed to repeat

A source record can legitimately appear in several epochs or in multiple draws of replacement sampling. Deduplicating solely by source identity would incorrectly remove those intended occurrences. Define an occurrence identity using snapshot, epoch or traversal identifier, sampler position, and any required augmentation view. A delivery attempt is another identity attached to an occurrence; retrying the same occurrence should not masquerade as a new independent draw. Preserve these distinctions in diagnostics so a repeated source can be explained as deliberate sampling, retry, or accidental overlap between workers.

Workers may fetch and transform ahead of the trainer. A completed read does not prove a batch was delivered, and a delivered batch does not prove its gradients contributed to a committed optimizer step. Failure after any of those boundaries leaves different uncertainty. Acknowledgments should have a specified meaning, and recovery must use state consistent with that meaning. A durable source offset that advances before the relevant consumer state is saved can create omission after restart. Conversely, replaying uncommitted input is not necessarily a duplicate model update if the model is restored to the matching earlier state.

A=U+E,U>0A=U+E,\qquad U>0
For a finite observed set of delivery attempts, U is the count of distinct intended occurrence identities and E the excess attempts beyond their first appearances, so A is total attempts. This count does not say which attempts affected optimizer state.↔ Scroll wide equations horizontally.

Choose failure behavior without silently changing the population

Corrupt records, temporary read failures, and worker process failures are different causes. A bounded retry may be sensible for a transient read, while repeatedly decoding a permanently corrupt record may never succeed. Skipping that record can be an authorized policy, but it changes observed coverage and may bias training if errors correlate with source or class. Record skipped identities and reasons, enforce the declared tolerance, and expose exhausted retries. A loader that simply returns fewer samples can otherwise appear faster while silently changing the experiment.

Replacement workers must recover the correct ownership and random state rather than restart every iterator at its first record. Map-style and iterable pipelines expose different control points, and framework versions offer different restart support. PyTorch 2.9 documents iterable-replica duplication hazards; TorchData 0.11.0 describes explicit loader state hooks and worker-state aggregation, with its stated topology limitations. Neither fact permits assuming arbitrary external side effects or optimizer updates are exactly once. If a transform writes shared state, its replay safety needs its own design beyond reproducing a tensor.

excess attempt fraction⁡=A−UA,A>0\operatorname{excess\ attempt\ fraction}=\frac{A-U}{A},\qquad A>0
A counts delivery attempts and U distinct occurrence identities in the same window, with 0≤U≤A. The dimensionless fraction measures repeated attempts, not necessarily repeated training updates; an empty window needs an empty outcome.↔ Scroll wide equations horizontally.

Test failures at the ambiguous boundaries

Inject controlled failures before fetch, after transformation, after delivery, and around a checkpoint in a small identifiable experiment. Compare the intended occurrence stream, delivered attempts, and model-consumption record. Include worker replacement and topology changes, because a local cursor may not describe the same shard under a new world size. Preserve a reproducible diagnostic setup while recognizing that nondeterministic scheduling changes where the failure lands. Define what the experiment guarantees: perhaps exact replay under a fixed topology, or an explicitly bounded repetition policy, rather than an unsupported universal visitation claim.

The probability lab models only hypothetical retry frequency. Reset, set both p=0.1 and n=10, predict the zero-event bar, then inspect. Under ten independent equal-probability retry indicators, the chance of at least one is 1−0.9¹⁰≈0.65132. Actual worker failures can share storage or host causes and need not be independent. The instrument does not crash workers, determine delivery status, or deduplicate model updates. Use the conditional calculation to motivate observing retries, then use actual occurrence identities and commit-boundary evidence to diagnose their effects.

Count repeated deliveries without inventing optimizer history

A fictional observation records twelve batch delivery attempts carrying ten distinct intended occurrence identities. Two occurrences each appear twice and the other eight appear once. The log does not record whether each delivered attempt contributed to an optimizer step.

  1. Distinct intended occurrences total ten, while delivery attempts total twelve. Excess attempts are 12−10=2.

  2. The excess-attempt fraction is 2/12≈16.67%. Relative to ten distinct occurrences, the delivery overhead is 2/10=20%; these denominators answer different questions.

  3. The log alone cannot establish that two duplicate optimizer updates occurred. Inspect consumer and checkpoint boundaries before deciding whether attempts were discarded, replayed after rollback, or actually applied twice.

The result

There are two excess delivery attempts and 16.67% of attempts are excess. Their effects on model state remain unknown from the supplied log.

Explore the model

Interactive lab

Interactive lab · probability

Inspect an explicitly independent retry model

Reset, set both p=0.1 and n=10, predict the zero-event bar, then inspect. Its complement is 1−0.9¹⁰≈0.65132. These exact binomial bars assume independent equal-probability indicators and do not simulate worker failures or model updates.

Inspect an explicitly independent retry modelThese are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. Current readings: Mean · np: 5; Variance · np(1−p): 2.5; Total probability: 1. All parameters are adjustable with the labeled controls below.03581000.070.150.220.3Successes kP(X = k)k = 0 · P = 9.77e-4
Exact probabilityHighlighted outcomeMean np
Mean · np
5
Variance · np(1−p)
2.5
Total probability
1
t = 0 s

These are exact binomial probabilities for independent trials with one fixed success probability. Playback tours the distribution; it does not resample outcomes. 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 forShared causes can correlate failures. Determine real repetition and omission from occurrence identities and the committed consumer boundary.

Check your understanding

Why is deduplicating all visits by source-record ID unsafe for a multi-epoch experiment?

Try it yourself

A log has fifteen delivery attempts for thirteen distinct intended occurrences. Compute excess attempts and their fraction of attempts. Can these numbers alone prove duplicate optimizer updates?

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

Give me a hint

Count excess attempts, then identify what the log does not observe.

Compare with the solution

There are 15−13=2 excess attempts, a fraction 2/15≈13.33%. The figures do not reveal whether a consumer discarded, replayed after rollback, or applied those attempts. Optimizer-effect claims require corresponding model and checkpoint evidence.

Take it with you

  • Distinguish source records, intended occurrences, delivery attempts, and model effects.
  • Retries and skips need explicit policies and observable identities.
  • Recovery guarantees depend on the committed boundary and supported state restoration.

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.