﻿# Mosaic Streaming: resume the data position with the model checkpoint

Connect MDS dataset identity, StreamingDataLoader state and elastic-determinism constraints when resuming distributed training.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/data-guide-mosaic-mds-shard-replay/
Language: en

## Stored shards and iteration state differ

Mosaic Streaming supports serialized dataset formats including MDS, the Mosaic Data Shard format. Its data representation and loader state solve different problems: the shards hold examples, while iteration state describes progress through the selected dataset.

If a training process restarts with model weights alone, it can begin reading from a different point or repeat already consumed examples. For a controlled continuation, record the dataset identity and the progress associated with the model checkpoint rather than inferring it from a directory of cached shards.

## Use the documented stateful loader

The resumption documentation instructs users to save StreamingDataLoader state with the checkpoint and restore it when restarting. This loader works with StreamingDataset to track the data position. A generic loader should not be assumed to provide the same resumption contract merely because it can read the same files.

Keep the loader configuration with the saved state. An epoch number alone is too coarse when a run stops midway through an epoch. Conversely, a count of downloaded examples can include prefetched material that has not contributed to an optimizer update.

## Coordinate state at a completed boundary

A checkpoint should associate model state, optimizer state and data position consistently. Consider a failure after data has been prefetched but before the current update completes. Resuming from the prefetched position could skip examples the restored model has not actually learned from.

A proposed validation interrupts a short controlled run, restores the saved checkpoint and compares subsequent example identifiers with an uninterrupted reference. This checks the application's checkpoint integration, not merely whether the loader accepts a state dictionary.

## Elastic determinism has requirements

The project documents deterministic resumption across changes in GPU count under stated conditions, including a constant global batch size divisible by the participating GPU counts. These conditions belong in the experiment configuration. Changing local batch size or topology without considering the global contract can alter the effective sequence of updates.

Data-order reproducibility also does not prove bitwise deterministic model computation. Kernels, reduction order and other execution settings can matter. Report the data-order check separately from any comparison of losses or resulting model parameters.

## Keep shard content stable during replay

A saved position has meaning relative to the dataset it indexes. Replacing shard content or rebuilding an index under the same path can invalidate that interpretation. Preserve the selected dataset release and the relevant stream configuration alongside loader state.

When investigating a failed restart, distinguish inaccessible shards, incompatible saved state and mismatched model/data boundaries. This separation turns a broad claim that training resumed into an inspectable account of which examples and updates were actually continued.

## Primary references

[Mosaic Streaming dataset format](https://docs.mosaicml.com/projects/streaming/en/stable/preparing_datasets/dataset_format.html).

[Mosaic Streaming fast resumption](https://docs.mosaicml.com/projects/streaming/en/stable/distributed_training/fast_resumption.html).

[Mosaic Streaming elastic determinism](https://docs.mosaicml.com/projects/streaming/en/stable/distributed_training/elastic_determinism.html).

Related explanations: [Paired image and text learning](/journal/clip-image-text-contrastive-space/); [Provenance of derived samples](/journal/document-markdown-json-provenance/).
