Skip to content

Commit

Permalink
Simplify skipping (#5373)
Browse files Browse the repository at this point in the history
Update iterable_dataset.py
  • Loading branch information
Muennighoff authored Dec 18, 2022
1 parent 78da5c3 commit 4403d06
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions src/datasets/iterable_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,10 +608,7 @@ def __init__(self, ex_iterable: _BaseExamplesIterable, n: int):
self.n = n

def __iter__(self):
ex_iterator = iter(self.ex_iterable)
for _ in islice(ex_iterator, self.n):
pass
yield from ex_iterator
yield from islice(self.ex_iterable, self.n, None)

def shuffle_data_sources(self, generator: np.random.Generator) -> "SkipExamplesIterable":
"""Doesn't shuffle the wrapped examples iterable since it would skip examples from other shards instead."""
Expand Down

1 comment on commit 4403d06

@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.008162 / 0.011353 (-0.003191) 0.004430 / 0.011008 (-0.006579) 0.098562 / 0.038508 (0.060054) 0.028888 / 0.023109 (0.005778) 0.298214 / 0.275898 (0.022316) 0.352699 / 0.323480 (0.029220) 0.006580 / 0.007986 (-0.001405) 0.004582 / 0.004328 (0.000254) 0.075293 / 0.004250 (0.071043) 0.035457 / 0.037052 (-0.001595) 0.311284 / 0.258489 (0.052795) 0.344284 / 0.293841 (0.050443) 0.032469 / 0.128546 (-0.096077) 0.011401 / 0.075646 (-0.064245) 0.324450 / 0.419271 (-0.094822) 0.039551 / 0.043533 (-0.003982) 0.308129 / 0.255139 (0.052990) 0.326492 / 0.283200 (0.043293) 0.084769 / 0.141683 (-0.056914) 1.509104 / 1.452155 (0.056950) 1.526458 / 1.492716 (0.033741)

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.178284 / 0.018006 (0.160278) 0.404484 / 0.000490 (0.403994) 0.000825 / 0.000200 (0.000625) 0.000071 / 0.000054 (0.000017)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.022496 / 0.037411 (-0.014916) 0.096837 / 0.014526 (0.082311) 0.101980 / 0.176557 (-0.074576) 0.140596 / 0.737135 (-0.596539) 0.106697 / 0.296338 (-0.189641)

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.417113 / 0.215209 (0.201904) 4.147624 / 2.077655 (2.069969) 1.849007 / 1.504120 (0.344887) 1.652940 / 1.541195 (0.111745) 1.652368 / 1.468490 (0.183878) 0.687975 / 4.584777 (-3.896802) 3.336466 / 3.745712 (-0.409246) 1.867321 / 5.269862 (-3.402541) 1.231045 / 4.565676 (-3.334632) 0.082553 / 0.424275 (-0.341723) 0.011648 / 0.007607 (0.004041) 0.531241 / 0.226044 (0.305196) 5.347145 / 2.268929 (3.078217) 2.270627 / 55.444624 (-53.173997) 1.930035 / 6.876477 (-4.946441) 1.938519 / 2.142072 (-0.203553) 0.803339 / 4.805227 (-4.001889) 0.147231 / 6.500664 (-6.353433) 0.063341 / 0.075469 (-0.012128)

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.204746 / 1.841788 (-0.637042) 13.354329 / 8.074308 (5.280021) 13.582030 / 10.191392 (3.390637) 0.141924 / 0.680424 (-0.538500) 0.027803 / 0.534201 (-0.506398) 0.392507 / 0.579283 (-0.186776) 0.398375 / 0.434364 (-0.035989) 0.457632 / 0.540337 (-0.082705) 0.546223 / 1.386936 (-0.840713)
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.006140 / 0.011353 (-0.005213) 0.004092 / 0.011008 (-0.006916) 0.095992 / 0.038508 (0.057484) 0.026308 / 0.023109 (0.003199) 0.338832 / 0.275898 (0.062934) 0.374640 / 0.323480 (0.051160) 0.004628 / 0.007986 (-0.003358) 0.003230 / 0.004328 (-0.001099) 0.073278 / 0.004250 (0.069027) 0.034531 / 0.037052 (-0.002522) 0.340165 / 0.258489 (0.081676) 0.381714 / 0.293841 (0.087873) 0.030752 / 0.128546 (-0.097795) 0.011394 / 0.075646 (-0.064252) 0.318015 / 0.419271 (-0.101256) 0.040471 / 0.043533 (-0.003062) 0.339571 / 0.255139 (0.084432) 0.367454 / 0.283200 (0.084254) 0.085773 / 0.141683 (-0.055910) 1.491779 / 1.452155 (0.039625) 1.558723 / 1.492716 (0.066006)

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.240424 / 0.018006 (0.222418) 0.398817 / 0.000490 (0.398327) 0.010960 / 0.000200 (0.010760) 0.000085 / 0.000054 (0.000031)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.024617 / 0.037411 (-0.012795) 0.098712 / 0.014526 (0.084186) 0.105515 / 0.176557 (-0.071042) 0.140428 / 0.737135 (-0.596707) 0.109938 / 0.296338 (-0.186401)

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.464991 / 0.215209 (0.249782) 4.627711 / 2.077655 (2.550056) 2.377105 / 1.504120 (0.872985) 2.182985 / 1.541195 (0.641790) 2.186347 / 1.468490 (0.717857) 0.692158 / 4.584777 (-3.892619) 3.368103 / 3.745712 (-0.377609) 1.825597 / 5.269862 (-3.444264) 1.153239 / 4.565676 (-3.412438) 0.081568 / 0.424275 (-0.342707) 0.011745 / 0.007607 (0.004138) 0.594411 / 0.226044 (0.368367) 5.727926 / 2.268929 (3.458997) 2.820096 / 55.444624 (-52.624529) 2.468208 / 6.876477 (-4.408269) 2.515353 / 2.142072 (0.373281) 0.803797 / 4.805227 (-4.001430) 0.150584 / 6.500664 (-6.350080) 0.064920 / 0.075469 (-0.010549)

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.255476 / 1.841788 (-0.586312) 13.725481 / 8.074308 (5.651173) 13.386731 / 10.191392 (3.195339) 0.141092 / 0.680424 (-0.539332) 0.016505 / 0.534201 (-0.517696) 0.382977 / 0.579283 (-0.196306) 0.383946 / 0.434364 (-0.050418) 0.474150 / 0.540337 (-0.066187) 0.568133 / 1.386936 (-0.818803)

Please sign in to comment.