Skip to content

Commit

Permalink
polina's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lhoestq committed Dec 15, 2022
1 parent 11a2158 commit 00958f2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/source/use_with_pytorch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ Like `torch.utils.data.Dataset` objects, a [`Dataset`] can be passed directly to
### Optimize data loading

There are several ways you can increase the speed your data is loaded which can save you time, especially if you are working with large datasets.
PyTorch offers parallelized data loading, retrieving batches of indices instead of individually, and streaming to progressively download datasets.
PyTorch offers parallelized data loading, retrieving batches of indices instead of individually, and streaming to iterate over the dataset without downloading it on disk.

#### Use multiple Workers

Expand Down Expand Up @@ -200,7 +200,7 @@ You must use a `BatchSampler` if you want the transform to be given full batches

### Stream data

Loading a dataset in streaming mode is useful to progressively download the data you need while iterating over the dataset.
Loading a dataset in streaming mode allows one to iterate over the dataset without downloading it on disk.
An iterable dataset from `datasets` inherits from `torch.utils.data.IterableDataset` so you can pass it to a `DataLoader`:

```py
Expand Down
2 changes: 1 addition & 1 deletion src/datasets/iterable_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ class ShufflingConfig:


def _maybe_add_torch_iterable_dataset_parent_class(cls):
"""Add torch.utils.data.IterableDataset as a parent class if 'torch' is imported"""
"""Add torch.utils.data.IterableDataset as a parent class if 'torch' is available"""
if config.TORCH_AVAILABLE:
import torch.utils.data

Expand Down

1 comment on commit 00958f2

@github-actions
Copy link

Choose a reason for hiding this comment

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

Show benchmarks

PyArrow==6.0.0

Show updated benchmarks!

Benchmark: benchmark_array_xd.json

metric read_batch_formatted_as_numpy after write_array2d read_batch_formatted_as_numpy after write_flattened_sequence read_batch_formatted_as_numpy after write_nested_sequence read_batch_unformated after write_array2d read_batch_unformated after write_flattened_sequence read_batch_unformated after write_nested_sequence read_col_formatted_as_numpy after write_array2d read_col_formatted_as_numpy after write_flattened_sequence read_col_formatted_as_numpy after write_nested_sequence read_col_unformated after write_array2d read_col_unformated after write_flattened_sequence read_col_unformated after write_nested_sequence read_formatted_as_numpy after write_array2d read_formatted_as_numpy after write_flattened_sequence read_formatted_as_numpy after write_nested_sequence read_unformated after write_array2d read_unformated after write_flattened_sequence read_unformated after write_nested_sequence write_array2d write_flattened_sequence write_nested_sequence
new / old (diff) 0.008882 / 0.011353 (-0.002470) 0.004647 / 0.011008 (-0.006362) 0.099099 / 0.038508 (0.060591) 0.030366 / 0.023109 (0.007257) 0.307384 / 0.275898 (0.031486) 0.369358 / 0.323480 (0.045878) 0.007300 / 0.007986 (-0.000686) 0.003449 / 0.004328 (-0.000879) 0.076692 / 0.004250 (0.072442) 0.039693 / 0.037052 (0.002640) 0.317538 / 0.258489 (0.059049) 0.355393 / 0.293841 (0.061552) 0.037181 / 0.128546 (-0.091365) 0.014583 / 0.075646 (-0.061063) 0.322733 / 0.419271 (-0.096538) 0.044902 / 0.043533 (0.001369) 0.310262 / 0.255139 (0.055123) 0.334901 / 0.283200 (0.051702) 0.090299 / 0.141683 (-0.051384) 1.518017 / 1.452155 (0.065862) 1.590732 / 1.492716 (0.098016)

Benchmark: benchmark_getitem_100B.json

metric get_batch_of_1024_random_rows get_batch_of_1024_rows get_first_row get_last_row
new / old (diff) 0.188587 / 0.018006 (0.170581) 0.441303 / 0.000490 (0.440813) 0.004253 / 0.000200 (0.004053) 0.000080 / 0.000054 (0.000026)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.023756 / 0.037411 (-0.013655) 0.102764 / 0.014526 (0.088238) 0.108762 / 0.176557 (-0.067795) 0.149315 / 0.737135 (-0.587820) 0.112067 / 0.296338 (-0.184272)

Benchmark: benchmark_iterating.json

metric read 5000 read 50000 read_batch 50000 10 read_batch 50000 100 read_batch 50000 1000 read_formatted numpy 5000 read_formatted pandas 5000 read_formatted tensorflow 5000 read_formatted torch 5000 read_formatted_batch numpy 5000 10 read_formatted_batch numpy 5000 1000 shuffled read 5000 shuffled read 50000 shuffled read_batch 50000 10 shuffled read_batch 50000 100 shuffled read_batch 50000 1000 shuffled read_formatted numpy 5000 shuffled read_formatted_batch numpy 5000 10 shuffled read_formatted_batch numpy 5000 1000
new / old (diff) 0.417797 / 0.215209 (0.202588) 4.153960 / 2.077655 (2.076306) 1.866286 / 1.504120 (0.362166) 1.678268 / 1.541195 (0.137073) 1.743169 / 1.468490 (0.274679) 0.681870 / 4.584777 (-3.902907) 3.438170 / 3.745712 (-0.307542) 1.915468 / 5.269862 (-3.354393) 1.142060 / 4.565676 (-3.423617) 0.080394 / 0.424275 (-0.343881) 0.011549 / 0.007607 (0.003942) 0.532110 / 0.226044 (0.306066) 5.291640 / 2.268929 (3.022712) 2.305734 / 55.444624 (-53.138890) 1.991033 / 6.876477 (-4.885443) 2.093581 / 2.142072 (-0.048491) 0.797582 / 4.805227 (-4.007645) 0.146524 / 6.500664 (-6.354140) 0.063466 / 0.075469 (-0.012003)

Benchmark: benchmark_map_filter.json

metric filter map fast-tokenizer batched map identity map identity batched map no-op batched map no-op batched numpy map no-op batched pandas map no-op batched pytorch map no-op batched tensorflow
new / old (diff) 1.230888 / 1.841788 (-0.610900) 14.269624 / 8.074308 (6.195316) 27.293163 / 10.191392 (17.101771) 0.142943 / 0.680424 (-0.537481) 0.029410 / 0.534201 (-0.504791) 0.396113 / 0.579283 (-0.183170) 0.411725 / 0.434364 (-0.022639) 0.461078 / 0.540337 (-0.079259) 0.550347 / 1.386936 (-0.836589)
PyArrow==latest
Show updated benchmarks!

Benchmark: benchmark_array_xd.json

metric read_batch_formatted_as_numpy after write_array2d read_batch_formatted_as_numpy after write_flattened_sequence read_batch_formatted_as_numpy after write_nested_sequence read_batch_unformated after write_array2d read_batch_unformated after write_flattened_sequence read_batch_unformated after write_nested_sequence read_col_formatted_as_numpy after write_array2d read_col_formatted_as_numpy after write_flattened_sequence read_col_formatted_as_numpy after write_nested_sequence read_col_unformated after write_array2d read_col_unformated after write_flattened_sequence read_col_unformated after write_nested_sequence read_formatted_as_numpy after write_array2d read_formatted_as_numpy after write_flattened_sequence read_formatted_as_numpy after write_nested_sequence read_unformated after write_array2d read_unformated after write_flattened_sequence read_unformated after write_nested_sequence write_array2d write_flattened_sequence write_nested_sequence
new / old (diff) 0.006893 / 0.011353 (-0.004460) 0.004640 / 0.011008 (-0.006368) 0.097995 / 0.038508 (0.059487) 0.027569 / 0.023109 (0.004460) 0.347634 / 0.275898 (0.071736) 0.382798 / 0.323480 (0.059318) 0.006330 / 0.007986 (-0.001656) 0.003557 / 0.004328 (-0.000772) 0.074885 / 0.004250 (0.070635) 0.043330 / 0.037052 (0.006278) 0.347300 / 0.258489 (0.088811) 0.394674 / 0.293841 (0.100833) 0.031674 / 0.128546 (-0.096872) 0.011636 / 0.075646 (-0.064010) 0.320286 / 0.419271 (-0.098986) 0.047741 / 0.043533 (0.004208) 0.342711 / 0.255139 (0.087573) 0.370077 / 0.283200 (0.086878) 0.093895 / 0.141683 (-0.047788) 1.595624 / 1.452155 (0.143469) 1.647167 / 1.492716 (0.154451)

Benchmark: benchmark_getitem_100B.json

metric get_batch_of_1024_random_rows get_batch_of_1024_rows get_first_row get_last_row
new / old (diff) 0.231451 / 0.018006 (0.213445) 0.436395 / 0.000490 (0.435906) 0.004034 / 0.000200 (0.003834) 0.000083 / 0.000054 (0.000029)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.024455 / 0.037411 (-0.012957) 0.100140 / 0.014526 (0.085614) 0.109041 / 0.176557 (-0.067515) 0.143050 / 0.737135 (-0.594085) 0.112252 / 0.296338 (-0.184087)

Benchmark: benchmark_iterating.json

metric read 5000 read 50000 read_batch 50000 10 read_batch 50000 100 read_batch 50000 1000 read_formatted numpy 5000 read_formatted pandas 5000 read_formatted tensorflow 5000 read_formatted torch 5000 read_formatted_batch numpy 5000 10 read_formatted_batch numpy 5000 1000 shuffled read 5000 shuffled read 50000 shuffled read_batch 50000 10 shuffled read_batch 50000 100 shuffled read_batch 50000 1000 shuffled read_formatted numpy 5000 shuffled read_formatted_batch numpy 5000 10 shuffled read_formatted_batch numpy 5000 1000
new / old (diff) 0.471743 / 0.215209 (0.256534) 4.691079 / 2.077655 (2.613424) 2.402774 / 1.504120 (0.898655) 2.211550 / 1.541195 (0.670356) 2.274591 / 1.468490 (0.806101) 0.689532 / 4.584777 (-3.895245) 3.443125 / 3.745712 (-0.302587) 2.840348 / 5.269862 (-2.429513) 1.316001 / 4.565676 (-3.249676) 0.081179 / 0.424275 (-0.343096) 0.011756 / 0.007607 (0.004149) 0.575494 / 0.226044 (0.349450) 5.750582 / 2.268929 (3.481654) 2.868124 / 55.444624 (-52.576500) 2.531727 / 6.876477 (-4.344750) 2.641658 / 2.142072 (0.499586) 0.801981 / 4.805227 (-4.003246) 0.149585 / 6.500664 (-6.351079) 0.066462 / 0.075469 (-0.009007)

Benchmark: benchmark_map_filter.json

metric filter map fast-tokenizer batched map identity map identity batched map no-op batched map no-op batched numpy map no-op batched pandas map no-op batched pytorch map no-op batched tensorflow
new / old (diff) 1.313081 / 1.841788 (-0.528706) 14.404363 / 8.074308 (6.330055) 13.451770 / 10.191392 (3.260378) 0.127887 / 0.680424 (-0.552537) 0.016803 / 0.534201 (-0.517398) 0.379080 / 0.579283 (-0.200204) 0.391291 / 0.434364 (-0.043073) 0.440901 / 0.540337 (-0.099436) 0.524694 / 1.386936 (-0.862243)

Please sign in to comment.