Skip to content

Conversation

@lhoestq
Copy link
Member

@lhoestq lhoestq commented Jan 10, 2024

requests.get(..., streaming=True) is faster than using HTTP range requests when streaming large TAR files

it can be enabled using block_size=0 in fsspec

cc @rwightman

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@lhoestq lhoestq force-pushed the faster-webdataset-streaming branch from b78c955 to 0d1e704 Compare January 10, 2024 18:30
@lhoestq
Copy link
Member Author

lhoestq commented Jan 11, 2024

I added faster streaming support using streaming Requests instances in huggingface_hub and will be available in 0.21.

This PR can be used with huggingface/huggingface_hub#1967 to get fast WebDataset streaming

@lhoestq lhoestq requested a review from mariosasko January 30, 2024 15:49
@lhoestq lhoestq merged commit 9849523 into main Jan 30, 2024
@lhoestq lhoestq deleted the faster-webdataset-streaming branch January 30, 2024 18:39
@github-actions
Copy link

Show benchmarks

PyArrow==8.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.004941 / 0.011353 (-0.006412) 0.003431 / 0.011008 (-0.007577) 0.062768 / 0.038508 (0.024260) 0.029212 / 0.023109 (0.006103) 0.253053 / 0.275898 (-0.022845) 0.273061 / 0.323480 (-0.050419) 0.004114 / 0.007986 (-0.003871) 0.002713 / 0.004328 (-0.001616) 0.048481 / 0.004250 (0.044231) 0.040001 / 0.037052 (0.002949) 0.268461 / 0.258489 (0.009971) 0.287767 / 0.293841 (-0.006074) 0.027885 / 0.128546 (-0.100661) 0.010474 / 0.075646 (-0.065172) 0.207989 / 0.419271 (-0.211282) 0.035893 / 0.043533 (-0.007640) 0.256833 / 0.255139 (0.001694) 0.274197 / 0.283200 (-0.009003) 0.017283 / 0.141683 (-0.124400) 1.133597 / 1.452155 (-0.318558) 1.206661 / 1.492716 (-0.286055)

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.089610 / 0.018006 (0.071604) 0.306051 / 0.000490 (0.305562) 0.000217 / 0.000200 (0.000017) 0.000042 / 0.000054 (-0.000012)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.018686 / 0.037411 (-0.018725) 0.061253 / 0.014526 (0.046727) 0.073654 / 0.176557 (-0.102903) 0.120499 / 0.737135 (-0.616637) 0.074827 / 0.296338 (-0.221511)

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.293756 / 0.215209 (0.078547) 2.897755 / 2.077655 (0.820100) 1.558146 / 1.504120 (0.054026) 1.458020 / 1.541195 (-0.083174) 1.453489 / 1.468490 (-0.015001) 0.576666 / 4.584777 (-4.008111) 2.423441 / 3.745712 (-1.322271) 2.727760 / 5.269862 (-2.542102) 1.750287 / 4.565676 (-2.815390) 0.062094 / 0.424275 (-0.362181) 0.004940 / 0.007607 (-0.002667) 0.338815 / 0.226044 (0.112770) 3.342677 / 2.268929 (1.073748) 1.928335 / 55.444624 (-53.516290) 1.629965 / 6.876477 (-5.246511) 1.651836 / 2.142072 (-0.490236) 0.644354 / 4.805227 (-4.160874) 0.117890 / 6.500664 (-6.382774) 0.041907 / 0.075469 (-0.033562)

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) 0.984399 / 1.841788 (-0.857389) 11.516572 / 8.074308 (3.442264) 10.326922 / 10.191392 (0.135530) 0.130821 / 0.680424 (-0.549603) 0.014084 / 0.534201 (-0.520117) 0.287078 / 0.579283 (-0.292205) 0.263466 / 0.434364 (-0.170898) 0.326867 / 0.540337 (-0.213470) 0.425313 / 1.386936 (-0.961623)
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.005305 / 0.011353 (-0.006048) 0.003646 / 0.011008 (-0.007362) 0.049402 / 0.038508 (0.010894) 0.031719 / 0.023109 (0.008610) 0.272579 / 0.275898 (-0.003319) 0.295241 / 0.323480 (-0.028239) 0.004309 / 0.007986 (-0.003677) 0.002781 / 0.004328 (-0.001548) 0.048134 / 0.004250 (0.043883) 0.044702 / 0.037052 (0.007650) 0.288201 / 0.258489 (0.029712) 0.320351 / 0.293841 (0.026510) 0.051327 / 0.128546 (-0.077219) 0.011019 / 0.075646 (-0.064628) 0.057983 / 0.419271 (-0.361288) 0.034211 / 0.043533 (-0.009322) 0.272856 / 0.255139 (0.017717) 0.290007 / 0.283200 (0.006807) 0.018656 / 0.141683 (-0.123027) 1.135017 / 1.452155 (-0.317138) 1.183904 / 1.492716 (-0.308813)

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.090854 / 0.018006 (0.072847) 0.299654 / 0.000490 (0.299165) 0.000224 / 0.000200 (0.000024) 0.000063 / 0.000054 (0.000009)

Benchmark: benchmark_indices_mapping.json

metric select shard shuffle sort train_test_split
new / old (diff) 0.021882 / 0.037411 (-0.015529) 0.075297 / 0.014526 (0.060771) 0.086620 / 0.176557 (-0.089937) 0.127125 / 0.737135 (-0.610011) 0.088622 / 0.296338 (-0.207717)

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.287104 / 0.215209 (0.071895) 2.802723 / 2.077655 (0.725068) 1.570137 / 1.504120 (0.066017) 1.452234 / 1.541195 (-0.088961) 1.465457 / 1.468490 (-0.003033) 0.564965 / 4.584777 (-4.019812) 2.416724 / 3.745712 (-1.328988) 2.645057 / 5.269862 (-2.624805) 1.727599 / 4.565676 (-2.838078) 0.063338 / 0.424275 (-0.360937) 0.005018 / 0.007607 (-0.002589) 0.345280 / 0.226044 (0.119235) 3.384323 / 2.268929 (1.115395) 1.957227 / 55.444624 (-53.487397) 1.667620 / 6.876477 (-5.208856) 1.795339 / 2.142072 (-0.346733) 0.642049 / 4.805227 (-4.163178) 0.114853 / 6.500664 (-6.385811) 0.040459 / 0.075469 (-0.035010)

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.023640 / 1.841788 (-0.818147) 11.998130 / 8.074308 (3.923822) 10.858137 / 10.191392 (0.666744) 0.130235 / 0.680424 (-0.550189) 0.016201 / 0.534201 (-0.518000) 0.289743 / 0.579283 (-0.289540) 0.275100 / 0.434364 (-0.159264) 0.329299 / 0.540337 (-0.211039) 0.418632 / 1.386936 (-0.968304)

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.

4 participants