tensorflow / tensorflow/datasets
Support ReadConfig(input_context=) when number of shard is small
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.6k
- Forks
- 1.6k
- Avg merge
- 3h 54m
- Merged PRs (30d)
- 1
Description
Currently in distributed setting, user can use tfds.ReadConfig(input_context=) as described in
https://www.tensorflow.org/datasets/performances#auto-shard_your_data_across_workers. This make sure that each worker read a different slice of the data.
However this only works when the number of shards is bigger than the number of workers. Otherwise, user is required to use the subsplit API:
def make_ds(input_context: tf.distribute.InputContext):
split = tfds.even_splits('train', n=input_context.num_input_pipelines)[input_context.input_pipeline_id]
ds = tfds.load('cifar10', split=split)
return ds
ds = strategy.distribute_datasets_from_function(make_ds)
It would be nice that the input_context automatically apply the subsplit API if info.splits[split].num_shards < read_config.input_context.num_input_pipelines, so the code in https://www.tensorflow.org/datasets/performances#auto-shard_your_data_across_workers would works for all datasets.
We might want to wait for the new TFDS file format before doing this.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the ReadConfig(input_context=) auto-sharding behavior described in the TensorFlow Datasets performance documentation, then compare it with the even_splits example for datasets with too few shards. Done means the input_context path applies equivalent subsplitting when the shard count is smaller than the worker count, while preserving the existing behavior otherwise.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, tensorflow
- Domain
- data, distributed-systems
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100