Skip to content

Bug: StreamingDataset checkpointing doesn't work when num_workers > 0 #3751

Open

Description

@westonpace

SDK

Python

Description

The samples consumed counters are process-local and so state_dict and load_state_dict do not function correctly

Activity

  1. added
    enhancement
    on Jul 31, 2026
  2. KushalChunduru commented on Aug 11, 2026

    @KushalChunduru

    Started digging into this (context: reviewing the fault-tolerance PR, #3763, surfaced the same underlying gap). Confirmed root cause: state_dict() reads self.resume_offset/self.resume_positions, which are plain instance attributes updated inside iter. With a real DataLoader(num_workers>0), each worker gets its own pickled copy of the dataset (per getstate/setstate), so those attributes only ever get updated on the worker-local copies — the parent object that state_dict() is actually called on never iterates and stays at its initial state. This is distinct from the observability counters (bytes_loaded, rows_skipped, etc.), which already cross the process boundary correctly via the RawArray-backed _worker_stats.

    Also worth flagging: none of the existing "multi-worker" tests in test_elastic_dataloader.py actually exercise a real DataLoader(num_workers=N) — they all simulate workers via worker_info_override on separate in-process instances, which never crosses a pickle/subprocess boundary. So this bug is currently untestable by the existing suite; I'll add a real-DataLoader regression test as part of the fix.

    Proposed fix, before I write it, want to confirm the approach:

    Step 1: Add a second RawArray(ctypes.c_int64, num_splits) alongside _worker_stats, written per-split by whichever worker owns that split (same pattern as the existing stats array).

    Step 2: state_dict() reads positions_consumed_per_split from that array instead of _resume_positions whenever it's been written.

    Step 3: For samples_consumed_per_split (the uniform "global step" value): since sibling DataLoader workers aren't synchronized in real time, I don't think the parent can just read a single scalar. I think it needs to be the min across the shared per-split array (the slowest split defines the last fully-completed global step boundary). Does that match your intent, or were you thinking of a different mechanism (e.g. an explicit cross-worker sync point)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions