Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(iterable): ensure MappedExamplesIterable supports state_dict for resume #7656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ArjunJagdale wants to merge 1 commit into huggingface:main
base: main
Choose a base branch
Loading
from ArjunJagdale:patch-18

Conversation

Copy link
Contributor

@ArjunJagdale ArjunJagdale commented Jun 29, 2025

Fixes #7630

Problem

When calling .map() on an IterableDataset, resuming from a checkpoint skips a large number of samples. This is because MappedExamplesIterable did not implement state_dict() or load_state_dict(), so checkpointing was not properly delegated to the underlying iterable.

What This PR Does

This patch adds:

def state_dict(self):
 return self.ex_iterable.state_dict()
def load_state_dict(self, state):
 self.ex_iterable.load_state_dict(state)

to MappedExamplesIterable, so the wrapped base iterable's state can be saved and restored as expected.

Result
Using .map() no longer causes sample skipping after checkpoint resume.

Let me know if a dedicated test case is required — happy to add one!

...resume
Fixes huggingface#7630
### Problem
When calling `.map()` on an `IterableDataset`, resuming from a checkpoint skips a large number of samples. This is because `MappedExamplesIterable` did not implement `state_dict()` or `load_state_dict()`, so checkpointing was not properly delegated to the underlying iterable.
### What This PR Does
This patch adds:
```python
def state_dict(self):
 return self.ex_iterable.state_dict()
def load_state_dict(self, state):
 self.ex_iterable.load_state_dict(state)
to MappedExamplesIterable, so the wrapped base iterable's state can be saved and restored as expected.
Result
Using .map() no longer causes sample skipping after checkpoint resume.
Tested manually using the reproducer script in huggingface#7630. The resumed iterator now yields the correct samples.
Let me know if a dedicated test case is required — happy to add one!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

[bug] resume from ckpt skips samples if .map is applied
1 participant

AltStyle によって変換されたページ (->オリジナル) /