Skip to content

fix(python): commit streaming worker checkpoints on consumption - #4023

Merged
Xuanwo merged 10 commits into
mainfrom
gatekeeper/fix-3967-1
Aug 24, 2026
Merged

Xuanwo merged 10 commits into
mainfrom
gatekeeper/fix-3967-1

Conversation

@lancedb-gatefixer

Copy link
Copy Markdown
Contributor

Summary

  • add StreamingDataLoader, which transports worker snapshots with prefetched batches and commits them to the parent dataset only when the trainer receives each batch
  • preserve exact non-uniform per-split progress and resume lagging splits without replaying already-consumed rows
  • reject stale parent checkpoints after a standard multi-process DataLoader has started, with guidance to use the consumer-aware loader
  • document the new public loader and merge non-uniform state across ranks

Root cause

PyTorch runs StreamingDataset.__iter__ in private worker-process copies, while callers invoke state_dict() on the parent dataset. Sharing producer counters would still be incorrect because DataLoader prefetch can advance workers beyond batches returned to the trainer.

Validation

  • uv run --extra tests pytest python/tests/test_elastic_dataloader.py -q (154 passed)
  • focused non-uniform merge regression (1 passed)
  • uv run --project python --extra tests --extra dev ruff format .
  • uv run --project python --extra tests --extra dev ruff check .
  • cd docs && PYTHONPATH=. ../python/.venv/bin/mkdocs build

Fixes #3967

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@github-actions github-actions Bot added bug Something isn't working Python Python SDK labels Aug 21, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Aug 21, 2026
@lancedb-gatefixer

Copy link
Copy Markdown
Contributor Author

Addressed in 921e71e. The revision enforces scheduling-safe multi-worker checkpoints, rejects persistent worker reuse, fails checkpointing closed after unreturned batches, preserves complete-cycle skip behavior, and scopes transport authorization to the checkpoint-aware iterator.

@lancedb-gatekeeper lancedb-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Aug 21, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Aug 21, 2026
@lancedb-gatefixer

Copy link
Copy Markdown
Contributor Author

Addressed in abe6916. The revision makes scheduling-boundary checks rank-local, turns collate-originated StopIteration into an invalidating batch failure, and preserves subclass iteration through an identity-scoped transport context.

@lancedb-gatekeeper lancedb-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Aug 21, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Aug 21, 2026
@lancedb-gatefixer

Copy link
Copy Markdown
Contributor Author

Addressed in 6cd8ba7. The revision removes ambient transport authorization, rejects custom iteration that cannot produce exact snapshots, and invalidates checkpointing for every non-exhaustion BaseException.

@lancedb-gatekeeper lancedb-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Aug 21, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Aug 21, 2026
@lancedb-gatefixer

lancedb-gatefixer Bot commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor Author

Addressed in 282a8a4. The consumer iterator now invalidates checkpointing when validation, parent commit, or the final return path fails after a fetched batch, with a regression covering interruption after commit.

@lancedb-gatekeeper lancedb-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Aug 22, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Aug 22, 2026
# Conflicts:
#	python/python/lancedb/streaming.py
@lancedb-gatekeeper lancedb-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Aug 24, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Aug 24, 2026
@lancedb-gatekeeper lancedb-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Aug 24, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Aug 24, 2026
@lancedb-gatekeeper lancedb-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Aug 24, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added the K-changes Latest Gatekeeper recommendation requests changes. label Aug 24, 2026
@lancedb-gatekeeper lancedb-gatekeeper Bot removed the K-changes Latest Gatekeeper recommendation requests changes. label Aug 24, 2026
lancedb-gatekeeper[bot]

This comment was marked as outdated.

@lancedb-gatekeeper lancedb-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Aug 24, 2026
@lancedb-gatekeeper lancedb-gatekeeper Bot removed the K-approved Latest Gatekeeper recommendation permits acceptance. label Aug 24, 2026

@lancedb-gatekeeper lancedb-gatekeeper Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Gate recommendation: approve.

The merge from main leaves the reviewed pull-request patch unchanged. Consumer-committed checkpointing and the atomic iterator lease therefore retain the previously verified delivery, shutdown, and interruption semantics.

@lancedb-gatekeeper lancedb-gatekeeper Bot added the K-approved Latest Gatekeeper recommendation permits acceptance. label Aug 24, 2026
@Xuanwo
Xuanwo merged commit 105fd73 into main Aug 24, 2026
17 checks passed
@Xuanwo
Xuanwo deleted the gatekeeper/fix-3967-1 branch August 24, 2026 20:22
@mintlify

mintlify Bot commented Aug 24, 2026

Copy link
Copy Markdown

Docs PR opened: https://github.com/lancedb/docs/pull/336

Documented the new StreamingDataLoader for safe multi-worker checkpointing and merge_state_dicts for resuming training across changed world sizes.

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

Labels

bug Something isn't working K-approved Latest Gatekeeper recommendation permits acceptance. Python Python SDK

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(python): StreamingDataset state_dict is stale with multi-process DataLoader workers

1 participant