Skip to content
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

Fast dataset iter #5030

Merged
merged 4 commits into from Sep 29, 2022
Merged

Fast dataset iter #5030

merged 4 commits into from Sep 29, 2022

Conversation

mariosasko
Copy link
Contributor

@mariosasko mariosasko commented Sep 27, 2022

Use pa.Table.to_reader to make iteration over examples/batches faster in Dataset.{__iter__, map}

TODO:

  • benchmarking (the only benchmark for now - iterating over (single) examples of bookcorpus (75 mil examples) in Colab is approx. 2.3x faster)
  • check if iterating over bigger chunks + slicing to fetch individual examples in _iter yields better performance

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Sep 27, 2022

The documentation is not available anymore as the PR was closed or merged.

@mariosasko
Copy link
Contributor Author

I ran some benchmarks (focused on the data fetching part of __iter__) and it seems like the combination table.to_reader(batch_size) + RecordBatch.slice performs the best (script with the results). I think we can choose (implicit) batch_size=10 in the final implementation to avoid having problems with fetching large examples.

Copy link
Member

@lhoestq lhoestq left a comment

Choose a reason for hiding this comment

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

Nice thank you ! The benchmarks are super helpful as well, I think you can link to them in comments in the code

src/datasets/arrow_dataset.py Outdated Show resolved Hide resolved
src/datasets/arrow_dataset.py Show resolved Hide resolved
src/datasets/config.py Outdated Show resolved Hide resolved
src/datasets/arrow_dataset.py Show resolved Hide resolved
src/datasets/arrow_dataset.py Show resolved Hide resolved
Co-authored-by: Quentin Lhoest <42851186+lhoestq@users.noreply.github.com>
@mariosasko mariosasko merged commit 1ea4d09 into main Sep 29, 2022
@mariosasko mariosasko deleted the iter-with-reader branch September 29, 2022 15:48
@lhoestq lhoestq mentioned this pull request Oct 14, 2022
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants